From be2d06821bcddd218a9e9b564ef5f8687f977403 Mon Sep 17 00:00:00 2001 From: handa Date: Mon, 21 May 2007 01:42:48 +0000 Subject: [PATCH] Include (mlanguage__info): Use strncasecmp (not memcmp). (mlanguage_name): Downcase language name for backward compatibility. --- src/language.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/language.c b/src/language.c index 359d0bd..de9f7e0 100644 --- a/src/language.c +++ b/src/language.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "m17n.h" #include "m17n-misc.h" @@ -185,9 +186,9 @@ mlanguage__info (MSymbol language) MText *mt = MPLIST_MTEXT (pl); if (mtext_nbytes (mt) == MSYMBOL_NAMELEN (language) - && memcmp (MTEXT_DATA (MPLIST_MTEXT (pl)), - MSYMBOL_NAME (language), - MSYMBOL_NAMELEN (language)) == 0) + && strncasecmp ((char *) MTEXT_DATA (MPLIST_MTEXT (pl)), + MSYMBOL_NAME (language), + MSYMBOL_NAMELEN (language)) == 0) return MPLIST_PLIST (plist); } } @@ -680,6 +681,7 @@ mlanguage_name (MSymbol language) { MPlist *plist = mlanguage__info (language); MText *mt; + char *str; if (! plist) /* 3-letter code */ return Mnil; @@ -687,15 +689,13 @@ mlanguage_name (MSymbol language) if (MPLIST_TAIL_P (plist)) return Mnil; plist = MPLIST_NEXT (plist); /* english name */ - if (MPLIST_MTEXT_P (plist)) + if (! MPLIST_MTEXT_P (plist)) return Mnil; mt = MPLIST_MTEXT (plist); - if (mtext_nbytes (mt) != MSYMBOL_NAMELEN (language) - || memcmp (MTEXT_DATA (MPLIST_MTEXT (plist)), - MSYMBOL_NAME (language), - MSYMBOL_NAMELEN (language))) - return Mnil; - return language; + str = alloca (mtext_nbytes (mt)); + memcpy (str, MTEXT_DATA (mt), mtext_nbytes (mt)); + str[0] = tolower (str[0]); + return msymbol__with_len (str, mtext_nbytes (mt)); } /*=*/ -- 1.7.10.4