Skip to content

Commit

Permalink
git-wrapper: make the interpolation code easier to understand
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dscho authored and Git for Windows Build Agent committed Aug 13, 2016
1 parent 0ada72d commit 6346be8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions compat/win32/git-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6346be8

Please sign in to comment.