summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0cd8f84)
raw | patch | inline | side by side (parent: 0cd8f84)
author | Ozan Çağlayan <ozan@pardus.org.tr> | |
Tue, 19 Apr 2011 05:38:40 +0000 (08:38 +0300) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 3 May 2011 01:38:44 +0000 (21:38 -0400) |
Problem:
On a tr_TR.UTF-8 locale, adding a key binding to tigrc can not be
correctly parsed if the keymap contains 'i' like main, generic, etc.
as they are wrongly converted to upper case.
In languages like Turkish, 'i' is not converted to 'I' as they're
different characters. So one should never use locale-aware conversion
methods which will break things in some locales.
See:
http://www.mattryall.net/blog/2009/02/the-infamous-turkish-locale-bug
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
On a tr_TR.UTF-8 locale, adding a key binding to tigrc can not be
correctly parsed if the keymap contains 'i' like main, generic, etc.
as they are wrongly converted to upper case.
In languages like Turkish, 'i' is not converted to 'I' as they're
different characters. So one should never use locale-aware conversion
methods which will break things in some locales.
See:
http://www.mattryall.net/blog/2009/02/the-infamous-turkish-locale-bug
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
tig.h | patch | blob | history |
index ef298c736a1aea2a922e7f92c91499ad2a653826..7baf8241b53680eeb9ad61a7216b125a081ef95f 100644 (file)
--- a/tig.h
+++ b/tig.h
#define prefixcmp(str1, str2) \
strncmp(str1, str2, STRING_SIZE(str2))
+static inline int
+ascii_toupper(int c)
+{
+ if (c >= 'a' && c <= 'z')
+ c &= ~0x20;
+ return c;
+}
+
+static inline int
+ascii_tolower(int c)
+{
+ if (c >= 'A' && c <= 'Z')
+ c |= 0x20;
+ return c;
+}
+
static inline int
suffixcmp(const char *str, int slen, const char *suffix)
{
/* Diff-Header == DIFF_HEADER */
for (i = 0; i < len; i++) {
- if (toupper(str1[i]) == toupper(str2[i]))
+ if (ascii_toupper(str1[i]) == ascii_toupper(str2[i]))
continue;
if (string_enum_sep(str1[i]) &&
int bufpos;
for (bufpos = 0; bufpos <= namelen; bufpos++) {
- buf[bufpos] = tolower(name[bufpos]);
+ buf[bufpos] = ascii_tolower(name[bufpos]);
if (buf[bufpos] == '_')
buf[bufpos] = '-';
}