Show
Ignore:
Timestamp:
2001-04-26 06:36:33 (8 years ago)
Author:
Thomas Roessler <roessler@…>
Branch:
HEAD
Message:

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'.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • charset.c

    r2368 r2371  
    174174  { "latin9",           "iso-8859-15"   }, /* this is not a bug */ 
    175175   
    176   { "�59-9",    "iso-8859-9"    }, /* work around a problem: 
    177                                             * In iso-8859-9, the lower- 
    178                                             * case version of I is �                * not i. 
    179                                             */ 
    180    
    181176   
    182177  /* 
     
    247242 
    248243  /* catch some common iso-8859-something misspellings */ 
    249   if (!mutt_strncasecmp (name, "8859", 4) && name[4] != '-') 
     244  if (!ascii_strncasecmp (name, "8859", 4) && name[4] != '-') 
    250245    snprintf (scratch, sizeof (scratch), "iso-8859-%s", name +4); 
    251   else if (!mutt_strncasecmp (name, "8859-", 5)) 
     246  else if (!ascii_strncasecmp (name, "8859-", 5)) 
    252247    snprintf (scratch, sizeof (scratch), "iso-8859-%s", name + 5); 
    253   else if (!mutt_strncasecmp (name, "iso8859", 7) && name[7] != '-') 
     248  else if (!ascii_strncasecmp (name, "iso8859", 7) && name[7] != '-') 
    254249    snprintf (scratch, sizeof (scratch), "iso_8859-%s", name + 7); 
    255   else if (!mutt_strncasecmp (name, "iso8859-", 8)) 
     250  else if (!ascii_strncasecmp (name, "iso8859-", 8)) 
    256251    snprintf (scratch, sizeof (scratch), "iso_8859-%s", name + 8); 
    257252  else 
     
    259254 
    260255  for (i = 0; PreferredMIMENames[i].key; i++) 
    261     if (!mutt_strcasecmp (scratch, PreferredMIMENames[i].key)) 
     256    if (!ascii_strcasecmp (scratch, PreferredMIMENames[i].key) || 
     257        !mutt_strcasecmp (scratch, PreferredMIMENames[i].key)) 
    262258    { 
    263259      strfcpy (dest, PreferredMIMENames[i].pref, dlen); 
     
    269265  /* for cosmetics' sake, transform to lowercase. */ 
    270266  for (p = dest; *p; p++) 
    271     if (isupper (*p)) 
    272       *p = tolower (*p); 
     267    *p = ascii_tolower (*p); 
    273268} 
    274269 
     
    280275 
    281276  mutt_canonical_charset (buffer, sizeof (buffer), s); 
    282   return !mutt_strcasecmp (buffer, chs); 
     277  return !ascii_strcasecmp (buffer, chs); 
    283278} 
    284279