changeset 17730:71d3ac6d7927

localename: Enforce declarations before statements. * localename.c (gl_locale_name_thread): Declare 'lcid' before the first statement.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 19 Jul 2014 21:22:26 +0900
parents 874a5cc03904
children 6d5945b320ad
files ChangeLog lib/localename.c
diffstat 2 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-07-19  Eli Zaretskii  <eliz@gnu.org>
+
+	localename: Enforce declarations before statements.
+	* localename.c (gl_locale_name_thread): Declare 'lcid' before the
+	first statement.
+
 2014-07-18  Jim Meyering  <meyering@fb.com>
 
 	test-userspec: don't look up numeric user names
--- a/lib/localename.c
+++ b/lib/localename.c
@@ -2730,6 +2730,7 @@
   if (LC_MIN <= category && category <= LC_MAX)
     {
       char *locname = setlocale (category, NULL);
+      LCID lcid = 0;
 
       /* If CATEGORY is LC_ALL, the result might be a semi-colon
         separated list of locales.  We need only one, so we take the
@@ -2738,14 +2739,14 @@
       if (strchr (locname, ';'))
        locname = setlocale (LC_CTYPE, NULL);
 
-    /* Convert locale name to LCID.  We don't want to use
-       LocaleNameToLCID because (a) it is only available since Vista,
-       and (b) it doesn't accept locale names returned by 'setlocale'.  */
-    LCID lcid = get_lcid (locname);
+      /* Convert locale name to LCID.  We don't want to use
+         LocaleNameToLCID because (a) it is only available since Vista,
+         and (b) it doesn't accept locale names returned by 'setlocale'.  */
+      lcid = get_lcid (locname);
 
-    if (lcid > 0)
-      return gl_locale_name_from_win32_LCID (lcid);
-  }
+      if (lcid > 0)
+        return gl_locale_name_from_win32_LCID (lcid);
+    }
 #endif
   return NULL;
 }