Closed nonakap closed 1 year ago
Thank you @nonakap. Your proposed correction has the exact opposite effect on macOS, it works without and it doesn't work with, but it certainly goes in the right direction. Could you try the following ?
diff --git a/src/string.c b/src/string.c
index a90fc1bb..4cb0910b 100644
--- a/src/string.c
+++ b/src/string.c
@@ -103,7 +103,7 @@ string_expand(char *dst, size_t dstlen, const char *src, int srclen, int tabsize
expanded = dstlen - size - 1;
memcpy(dst + size, " ", expanded);
size += expanded;
- } else if (isspace((unsigned char)c) || iscntrl((unsigned char)c)) {
+ } else if (iswspace(c) || iswcntrl(c)) {
dst[size++] = ' ';
} else {
dst[size++] = src[pos];
@@ -119,7 +119,7 @@ string_trim_end(char *name)
{
int namelen = strlen(name) - 1;
- while (namelen > 0 && isspace((unsigned char)name[namelen]))
+ while (namelen > 0 && iswspace(name[namelen]))
name[namelen--] = 0;
return name;
@@ -128,7 +128,7 @@ string_trim_end(char *name)
char *
string_trim(char *name)
{
- while (isspace((unsigned char)*name))
+ while (iswspace(*name))
name++;
return string_trim_end(name);
EDIT: actually this is a macOS thing only, we'll handle it with a specific case.
Should cast the argument passed to is*() function in ctype.h to unsigned char.
See https://wiki.sei.cmu.edu/confluence/display/c/STR37-C.+Arguments+to+character-handling+functions+must+be+representable+as+an+unsigned+char.
Should fix https://github.com/jonas/tig/issues/1294.
before: The commit log contains Japanese characters, but they are not displayed correctly.
after: The commit log is displayed correctly.