Skip to content

Commit 56740a8

Browse files
committed
git-wrapper: simplify interpolation code
After we found the `@@` marker after the key to interpolate, we pretty much only need the offset *after* the marker. So let's just advance it instead of adding 2 in many places. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 919e1b6 commit 56740a8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

compat/win32/git-wrapper.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,9 @@ static LPWSTR expand_variables(LPWSTR buffer, size_t alloc)
239239
break;
240240

241241
*atat2 = L'\0';
242+
atat2 += 2;
242243
env_len = GetEnvironmentVariable(atat + 2, NULL, 0);
243-
delta = env_len - 1 - (atat2 + 2 - atat);
244+
delta = env_len - 1 - (atat2 - atat);
244245
if (len + delta >= alloc) {
245246
LPWSTR buf2;
246247
alloc = alloc_nr(alloc);
@@ -264,10 +265,10 @@ static LPWSTR expand_variables(LPWSTR buffer, size_t alloc)
264265
atat2 += buf2 - buf;
265266
buf = buf2;
266267
}
267-
if (delta)
268-
memmove(atat2 + 2 + delta, atat2 + 2,
268+
if (delta > 0)
269+
memmove(atat2 + delta, atat2,
269270
sizeof(WCHAR) * (len + 1
270-
- (atat2 + 2 - buf)));
271+
- (atat2 - buf)));
271272
len += delta;
272273
save = atat[env_len - 1];
273274
GetEnvironmentVariable(atat + 2, atat, env_len);

0 commit comments

Comments
 (0)