*** empty log message ***
[m17n/m17n-lib.git] / src / locale.c
index 247ce7b..05dbf46 100644 (file)
@@ -1,5 +1,5 @@
 /* locale.c -- locale module.
-   Copyright (C) 2003, 2004
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H15PRO112
 
@@ -17,7 +17,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the m17n library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    02111-1307, USA.  */
 
 /***en
@@ -86,34 +86,24 @@ MLocale *mlocale__messages, *mlocale__time;
 MLocale *mlocale_monetary, *mlocale_numeric, ;
 #endif
 
-/** Parse locale name NAME and return a newly created MLocale object.
-    If the locale is not supported by the system, return NULL.  */
+/** Parse locale name NAME and return a newly created MLocale object.  */
 
 static MLocale *
 make_locale (const char *name)
 {
-  char *current, *new, *str;
+  char *str;
   int len;
   MLocale *locale;
   char c;
 
-  str = setlocale (LC_CTYPE, NULL);
-  len = strlen (str) + 1;
-  current = alloca (len);
-  memcpy (current, str, len); 
-
-  if (! (new = setlocale (LC_CTYPE, name)))
-    return NULL;
-
-
   M17N_OBJECT (locale, NULL, MERROR_LOCALE);
-  locale->name = msymbol (new);
+  locale->name = msymbol (name);
   msymbol_put (locale->name, M_locale, (void *) locale);
   M17N_OBJECT_UNREF (locale);
 
-  len = strlen (new) + 1;
+  len = strlen (name) + 1;
   str = alloca (len);
-  memcpy (str, new, len);
+  memcpy (str, name, len);
 
   c = '\0';
   while (1)
@@ -128,20 +118,20 @@ make_locale (const char *name)
       str[i] = '\0';
       if (c == '\0')
        /* The first field is for language.  */
-       locale->language = msymbol (name);      
+       locale->language = msymbol (str);
       else if (c == '_')
        /* The field following '_' is for territory.  */
-       locale->territory = msymbol (name);
+       locale->territory = msymbol (str);
       else if (c == '.')
        /* The field following '.' is for codeset.  */
-       locale->codeset = msymbol (name);
+       locale->codeset = msymbol (str);
       else
        /* The other field is for modifier.  */
-       locale->modifier = msymbol (name);
+       locale->modifier = msymbol (str);
       if (! c1)
        break;
       c = c1;
-      name += i + 1;
+      str += i + 1;
     }
 
 #ifdef HAVE_NL_LANGINFO
@@ -162,8 +152,6 @@ make_locale (const char *name)
     }
   else
     locale->coding = Mcoding_us_ascii;
-
-  setlocale (LC_CTYPE, current);
   return locale;
 }
 
@@ -344,7 +332,6 @@ MSymbol Mcodeset;
     If the call is successful, mlocale_set () returns an opaque locale
     object that corresponds to the locale.  The name of the locale can
     be acquired by the function mlocale_get_prop ().
-
     Otherwise, it returns NULL.  */
 
 /***ja
@@ -363,7 +350,6 @@ MSymbol Mcodeset;
     ¸Æ¤Ó½Ð¤·¤ËÀ®¸ù¤¹¤ì¤Ð¡¢mlocale_set () ¤Ï¥í¥±¡¼¥ë¤ËÂбþ¤¹¤ë opaque 
     ¥í¥±¡¼¥ë¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤¹¡£¥í¥±¡¼¥ë¤Î̾Á°¤Ï´Ø¿ô
     mlocale_get_prop () ¤Ë¤è¤Ã¤ÆÆÀ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
-
     ¤½¤¦¤Ç¤Ê¤±¤ì¤Ð NULL ¤òÊÖ¤¹¡£
      */
 
@@ -460,7 +446,7 @@ mlocale_get_prop (MLocale *locale, MSymbol key)
     of strftime ().
 
     @seealso
-    strftime ()
+    strftime ().
 */
 /***ja
     @brief ÆüÉդȻþ´Ö¤ò¥Õ¥©¡¼¥Þ¥Ã¥È¤¹¤ë.
@@ -472,7 +458,7 @@ mlocale_get_prop (MLocale *locale, MSymbol key)
     °ú¿ô $TM ¤È $FORMAT ¤Î°ÕÌ£¤Ï strftime () ¤Î¾ì¹ç¤ÈƱ¤¸¡£
 
     @seealso
-    strftime ()
+    strftime ().
 */
 
 int