diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 2001-04-26 13:36:33 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 2001-04-26 13:36:33 +0000 |
commit | c73ebd9aa108d55a09c7eebbf9a81e3453fa0c3b (patch) | |
tree | a35487e7f469b6510dab2172a21c8c7d36265033 /charset.c | |
parent | 3f16589816ab217ec425ecbf026a9a5ade18333f (diff) |
Add ascii_strcasecmp() and ascii_strncasecmp() functions which do
locale-independent and case-insensitive string comparisons. Needed
for mutt to work in iso-8859-9 environments, where tolower('I') !=
'i'.
Diffstat (limited to 'charset.c')
-rw-r--r-- | charset.c | 22 |
1 files changed, 8 insertions, 14 deletions
@@ -173,12 +173,6 @@ PreferredMIMENames[] = { "iso_8859-15", "iso-8859-15" }, { "latin9", "iso-8859-15" }, /* this is not a bug */ - { "ýso-8859-9", "iso-8859-9" }, /* work around a problem: - * In iso-8859-9, the lower- - * case version of I is ý, - * not i. - */ - /* * If you happen to encounter system-specific brain-damage with @@ -247,19 +241,20 @@ void mutt_canonical_charset (char *dest, size_t dlen, const char *name) char scratch[LONG_STRING]; /* catch some common iso-8859-something misspellings */ - if (!mutt_strncasecmp (name, "8859", 4) && name[4] != '-') + if (!ascii_strncasecmp (name, "8859", 4) && name[4] != '-') snprintf (scratch, sizeof (scratch), "iso-8859-%s", name +4); - else if (!mutt_strncasecmp (name, "8859-", 5)) + else if (!ascii_strncasecmp (name, "8859-", 5)) snprintf (scratch, sizeof (scratch), "iso-8859-%s", name + 5); - else if (!mutt_strncasecmp (name, "iso8859", 7) && name[7] != '-') + else if (!ascii_strncasecmp (name, "iso8859", 7) && name[7] != '-') snprintf (scratch, sizeof (scratch), "iso_8859-%s", name + 7); - else if (!mutt_strncasecmp (name, "iso8859-", 8)) + else if (!ascii_strncasecmp (name, "iso8859-", 8)) snprintf (scratch, sizeof (scratch), "iso_8859-%s", name + 8); else strfcpy (scratch, NONULL(name), sizeof (scratch)); for (i = 0; PreferredMIMENames[i].key; i++) - if (!mutt_strcasecmp (scratch, PreferredMIMENames[i].key)) + if (!ascii_strcasecmp (scratch, PreferredMIMENames[i].key) || + !mutt_strcasecmp (scratch, PreferredMIMENames[i].key)) { strfcpy (dest, PreferredMIMENames[i].pref, dlen); return; @@ -269,8 +264,7 @@ void mutt_canonical_charset (char *dest, size_t dlen, const char *name) /* for cosmetics' sake, transform to lowercase. */ for (p = dest; *p; p++) - if (isupper (*p)) - *p = tolower (*p); + *p = ascii_tolower (*p); } int mutt_chscmp (const char *s, const char *chs) @@ -280,7 +274,7 @@ int mutt_chscmp (const char *s, const char *chs) if (!s) return 0; mutt_canonical_charset (buffer, sizeof (buffer), s); - return !mutt_strcasecmp (buffer, chs); + return !ascii_strcasecmp (buffer, chs); } |