Skip to content

Commit

Permalink
Revert "git: try to fix non-ASCII problem"
Browse files Browse the repository at this point in the history
As promised...

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Feb 21, 2017
1 parent 5c3940b commit 2c8ab4f
Showing 1 changed file with 2 additions and 48 deletions.
50 changes: 2 additions & 48 deletions mingw-w64-git/git-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,53 +491,7 @@ static void initialize_top_level_path(LPWSTR top_level_path, LPWSTR exepath,
}
}

/*
* Returns 0 if it is not UTF-8, 1 if it is UTF-8, -1 if it is plain ASCII.
* This is purposefully kept simply, i.e. *not* checking for overlong sequences.
*/
static inline int is_utf8(const char *p)
{
while (*p) {
unsigned char c = (unsigned char)*(p++);
int count;

if (c < 0x80) {
if (c < 0x20 && c != 0x09 && c != 0x0a && c != 0x0d)
return 0;
continue;
}

if (c < 0xc0 || c >= 0xf8)
return 0;

if (c < 0xe0)
count = 1;
else if (c < 0xf0)
count = 2;
else
count = 3;
while (count--)
if ((*(p++) & 0xc0) != 0x80)
return 0;
}
return -1;
}

static inline int argv_are_utf8(int argc, const char **argv)
{
int ret = 0, i;

for (i = 0; i < argc; i++)
switch (is_utf8(argv[i])) {
case 0:
return 0;
case 1:
ret = 1;
}
return ret;
}

int main(int argc, const char **argv)
int main(void)
{
int r = 1, wait = 1, prefix_args_len = -1, needs_env_setup = 1,
is_git_command = 1, full_path = 1, skip_arguments = 0,
Expand Down Expand Up @@ -607,7 +561,7 @@ int main(int argc, const char **argv)
}
else if (!wcsicmp(basename, L"git.exe")) {
initialize_top_level_path(top_level_path, exepath, NULL, 1);
needs_lc_all = argv_are_utf8(argc, argv);
needs_lc_all = 1;

/* set the default exe module */
wcscpy(exe, top_level_path);
Expand Down

0 comments on commit 2c8ab4f

Please sign in to comment.