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 <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2015-11-01 18:15:30 +01:00
parent 2b21131b81
commit 59ae23d2f5

View File

@@ -239,8 +239,9 @@ static LPWSTR expand_variables(LPWSTR buffer, size_t alloc)
break;
*atat2 = L'\0';
atat2 += 2;
env_len = GetEnvironmentVariable(atat + 2, NULL, 0);
delta = env_len - 1 - (atat2 + 2 - atat);
delta = env_len - 1 - (atat2 - atat);
if (len + delta >= alloc) {
LPWSTR buf2;
alloc = alloc_nr(alloc);
@@ -264,10 +265,10 @@ static LPWSTR expand_variables(LPWSTR buffer, size_t alloc)
atat2 += buf2 - buf;
buf = buf2;
}
if (delta)
memmove(atat2 + 2 + delta, atat2 + 2,
if (delta > 0)
memmove(atat2 + delta, atat2,
sizeof(WCHAR) * (len + 1
- (atat2 + 2 - buf)));
- (atat2 - buf)));
len += delta;
save = atat[env_len - 1];
GetEnvironmentVariable(atat + 2, atat, env_len);