git-wrapper: make the interpolation code easier to understand

When moving bytes (because the name and the value of the environment
variable to interpolate differ in length), we introduce a variable to
unclutter the code and make it more obvious what is happening.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2015-11-01 18:26:16 +01:00
parent 59ae23d2f5
commit c885439682

View File

@@ -224,7 +224,7 @@ static void extract_first_arg(LPWSTR command_line, LPWSTR exepath, LPWSTR buf)
static LPWSTR expand_variables(LPWSTR buffer, size_t alloc)
{
LPWSTR buf = buffer;
size_t len = wcslen(buf);
size_t len = wcslen(buf), move_len;
for (;;) {
LPWSTR atat = wcsstr(buf, L"@@"), atat2;
@@ -265,10 +265,9 @@ static LPWSTR expand_variables(LPWSTR buffer, size_t alloc)
atat2 += buf2 - buf;
buf = buf2;
}
move_len = sizeof(WCHAR) * (len + 1 - (atat2 - buf));
if (delta > 0)
memmove(atat2 + delta, atat2,
sizeof(WCHAR) * (len + 1
- (atat2 - buf)));
memmove(atat2 + delta, atat2, move_len);
len += delta;
save = atat[env_len - 1];
GetEnvironmentVariable(atat + 2, atat, env_len);