Fix a bug in w32-get-locale-info.
authorEli Zaretskii <eliz@gnu.org>
Sat, 23 Jun 2012 12:44:42 +0000 (15:44 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 23 Jun 2012 12:44:42 +0000 (15:44 +0300)
 src/w32proc.c (Fw32_get_locale_info): Fix an off-by-one error in
 last argument of make_unibyte_string.

src/ChangeLog
src/w32proc.c

index a01a93f..b23e920 100644 (file)
@@ -1,5 +1,8 @@
 2012-06-23  Eli Zaretskii  <eliz@gnu.org>
 
+       * w32proc.c (Fw32_get_locale_info): Fix an off-by-one error in
+       last argument of make_unibyte_string.
+
        * keyboard.c (kbd_buffer_get_event): Include the codepage and the
        language ID in the event parameters.
 
index 55b9ee1..2f5f39e 100644 (file)
@@ -1949,8 +1949,12 @@ If LCID (a 16-bit number) is not a valid locale, the result is nil.  */)
       got_full = GetLocaleInfo (XINT (lcid),
                                XINT (longform),
                                full_name, sizeof (full_name));
+      /* GetLocaleInfo's return value includes the terminating null
+        character, when the returned information is a string, whereas
+        make_unibyte_string needs the string length without the
+        terminating null.  */
       if (got_full)
-       return make_unibyte_string (full_name, got_full);
+       return make_unibyte_string (full_name, got_full - 1);
     }
 
   return Qnil;