OSDN Git Service

* nlsfuncs.cc (__set_lc_time_from_win): Use LOCALE_SMONTHNAME1
authorcorinna <corinna>
Wed, 26 May 2010 11:36:17 +0000 (11:36 +0000)
committercorinna <corinna>
Wed, 26 May 2010 11:36:17 +0000 (11:36 +0000)
instead of LOCALE_SABBREVMONTHNAME1 in Japanese and Korean
locales to get abbreviated month names.  Explain why.

winsup/cygwin/ChangeLog
winsup/cygwin/nlsfuncs.cc

index cbf2a0e..1e274ff 100644 (file)
@@ -1,4 +1,11 @@
-2010-05-18  Kazuhiro Fujida  <fujieda@acm.org>
+2010-05-26  Kazuhiro Fujieda  <fujieda@acm.org>
+           Corinna Vinschen  <corinna@vinschen.de>
+
+       * nlsfuncs.cc (__set_lc_time_from_win): Use LOCALE_SMONTHNAME1
+       instead of LOCALE_SABBREVMONTHNAME1 in Japanese and Korean
+       locales to get abbreviated month names.  Explain why.
+
+2010-05-18  Kazuhiro Fujieda  <fujieda@acm.org>
 
        * environ.cc (regopt): Change the first argument to wide char string.
        (environ_init): Accommodate change to the first argument of regopt.
index b4afa23..e678147 100644 (file)
@@ -551,10 +551,20 @@ __set_lc_time_from_win (const char *name,
                                            sizeof *lc_era, locale_cmp);
 
       /* mon */
+      /* Windows has a bug in Japanese and Korean locales.  In these
+        locales, strings returned for LOCALE_SABBREVMONTHNAME* are missing
+        the suffix representing a month.  Unfortunately this is not
+        documented in English.  A Japanese article describing the problem
+        is http://msdn.microsoft.com/ja-jp/library/cc422084.aspx
+        The workaround is to use LOCALE_SMONTHNAME* in these locales,
+        even for the abbreviated month name. */
+      const LCTYPE mon_base =
+               lcid == MAKELANGID (LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN)
+               || lcid == MAKELANGID (LANG_KOREAN, SUBLANG_KOREAN)
+               ? LOCALE_SMONTHNAME1 : LOCALE_SABBREVMONTHNAME1;
       for (int i = 0; i < 12; ++i)
        {
-         _time_locale->wmon[i] = getlocaleinfo (time,
-                                                LOCALE_SABBREVMONTHNAME1 + i);
+         _time_locale->wmon[i] = getlocaleinfo (time, mon_base + i);
          _time_locale->mon[i] = charfromwchar (time, wmon[i]);
        }
       /* month and alt_month */