From: Bruno Haible Date: Wed, 24 Jun 2026 17:46:12 +0000 (+0200) Subject: Update after gnulib changed. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f2e7d78174250d8509759df32f8d6459c535c52;p=thirdparty%2Fgettext.git Update after gnulib changed. * gettext-runtime/intl/setlocale.c: Reduce scope of local variables. M = Move variable declaration to its initialization. R = Reduce scope. (setlocale_unixlike): MR. (langcmp): R. (libintl_setlocale): MR. --- diff --git a/gettext-runtime/intl/setlocale.c b/gettext-runtime/intl/setlocale.c index 74fe95a96..2d051e1a7 100644 --- a/gettext-runtime/intl/setlocale.c +++ b/gettext-runtime/intl/setlocale.c @@ -670,10 +670,6 @@ static char * setlocale_unixlike (int category, const char *locale) { int is_utf8 = (GetACP () == 65001); - char *result; - char llCC_buf[64]; - char ll_buf[64]; - char CC_buf[64]; /* The native Windows implementation of setlocale understands the special locale name "C", but not "POSIX". Therefore map "POSIX" to "C". */ @@ -690,13 +686,14 @@ setlocale_unixlike (int category, const char *locale) locale = "English_United States.65001"; /* First, try setlocale with the original argument unchanged. */ - result = setlocale (category, locale); + char *result = setlocale (category, locale); if (result != NULL) return result; /* Otherwise, assume the argument is in the form language[_territory][.codeset][@modifier] and try to map it using the tables. */ + char llCC_buf[64]; if (strlen (locale) < sizeof (llCC_buf)) { /* Second try: Remove the codeset part. */ @@ -768,9 +765,11 @@ setlocale_unixlike (int category, const char *locale) if (territory_end == NULL) territory_end = territory_start + strlen (territory_start); + char ll_buf[64]; memcpy (ll_buf, llCC_buf, underscore - llCC_buf); strcpy (ll_buf + (underscore - llCC_buf), territory_end); + char CC_buf[64]; memcpy (CC_buf, territory_start, territory_end - territory_start); CC_buf[territory_end - territory_start] = '\0'; @@ -1114,9 +1113,6 @@ static int langcmp (const char *locale1, const char *locale2) { size_t locale1_len; - size_t locale2_len; - int cmp; - { const char *locale1_end = strchr (locale1, '_'); if (locale1_end != NULL) @@ -1124,6 +1120,7 @@ langcmp (const char *locale1, const char *locale2) else locale1_len = strlen (locale1); } + size_t locale2_len; { const char *locale2_end = strchr (locale2, '_'); if (locale2_end != NULL) @@ -1132,6 +1129,7 @@ langcmp (const char *locale1, const char *locale2) locale2_len = strlen (locale2); } + int cmp; if (locale1_len < locale2_len) { cmp = memcmp (locale1, locale2, locale1_len); @@ -1436,12 +1434,9 @@ libintl_setlocale (int category, const char *locale) LC_MONETARY, LC_MESSAGES }; - char *saved_locale; - const char *base_name; - unsigned int i; /* Back up the old locale, in case one of the steps fails. */ - saved_locale = setlocale (LC_ALL, NULL); + char *saved_locale = setlocale (LC_ALL, NULL); if (saved_locale == NULL) return NULL; saved_locale = strdup (saved_locale); @@ -1451,11 +1446,12 @@ libintl_setlocale (int category, const char *locale) /* Set LC_CTYPE category. Set all other categories (except possibly LC_MESSAGES) to the same value in the same call; this is likely to save calls. */ - base_name = + const char *base_name = gl_locale_name_environ (LC_CTYPE, category_to_name (LC_CTYPE)); if (base_name == NULL) base_name = gl_locale_name_default (); + unsigned int i; if (setlocale_unixlike (LC_ALL, base_name) != NULL) { /* LC_CTYPE category already set. */ @@ -1483,9 +1479,8 @@ libintl_setlocale (int category, const char *locale) for (; i < countof (categories); i++) { int cat = categories[i]; - const char *name; - - name = gl_locale_name_environ (cat, category_to_name (cat)); + const char *name = + gl_locale_name_environ (cat, category_to_name (cat)); if (name == NULL) name = gl_locale_name_default ();