diff options
Diffstat (limited to 'src/core/wee-utf8.c')
-rw-r--r-- | src/core/wee-utf8.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/core/wee-utf8.c b/src/core/wee-utf8.c index 0fc4560ac..c8756a695 100644 --- a/src/core/wee-utf8.c +++ b/src/core/wee-utf8.c @@ -199,28 +199,32 @@ utf8_prev_char (const char *string_start, const char *string) /* UTF-8, at least 2 bytes */ string--; if (string < string_start) - return (char *)string + 1; + return string + 1; if (((unsigned char)(string[0]) & 0xC0) == 0x80) { /* UTF-8, at least 3 bytes */ string--; if (string < string_start) - return (char *)string + 1; + return string + 1; if (((unsigned char)(string[0]) & 0xC0) == 0x80) { /* UTF-8, 4 bytes */ string--; if (string < string_start) - return (char *)string + 1; - return (char *)string; + return string + 1; + return string; } else - return (char *)string; + { + return string; + } } else - return (char *)string; + { + return string; + } } - return (char *)string; + return string; } /* @@ -239,31 +243,31 @@ utf8_next_char (const char *string) if (((unsigned char)(string[0]) & 0xE0) == 0xC0) { if (!string[1]) - return (char *)string + 1; - return (char *)string + 2; + return string + 1; + return string + 2; } /* UTF-8, 3 bytes: 1110vvvv 10vvvvvv 10vvvvvv */ else if (((unsigned char)(string[0]) & 0xF0) == 0xE0) { if (!string[1]) - return (char *)string + 1; + return string + 1; if (!string[2]) - return (char *)string + 2; - return (char *)string + 3; + return string + 2; + return string + 3; } /* UTF-8, 4 bytes: 11110vvv 10vvvvvv 10vvvvvv 10vvvvvv */ else if (((unsigned char)(string[0]) & 0xF8) == 0xF0) { if (!string[1]) - return (char *)string + 1; + return string + 1; if (!string[2]) - return (char *)string + 2; + return string + 2; if (!string[3]) - return (char *)string + 3; - return (char *)string + 4; + return string + 3; + return string + 4; } /* UTF-8, 1 byte: 0vvvvvvv */ - return (char *)string + 1; + return string + 1; } /* |