about summary refs log tree commit diff
path: root/locale
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2014-09-12 16:07:23 -0700
committerRoland McGrath <roland@hack.frob.com>2014-09-12 16:07:23 -0700
commita62b3c15de6b48619d9cee17b391c497b4a4cf7a (patch)
tree0cfaf205d73f346bed302c86cfd3e9ce8ab24fb1 /locale
parentd7e49b19d3ba73f02ec4c6e8c81aeb27f52186b2 (diff)
downloadglibc-a62b3c15de6b48619d9cee17b391c497b4a4cf7a.tar.gz
glibc-a62b3c15de6b48619d9cee17b391c497b4a4cf7a.tar.xz
glibc-a62b3c15de6b48619d9cee17b391c497b4a4cf7a.zip
Minor cleanup in locale.c
Diffstat (limited to 'locale')
-rw-r--r--locale/programs/locale.c263
1 files changed, 128 insertions, 135 deletions
diff --git a/locale/programs/locale.c b/locale/programs/locale.c
index 4b3d15a3fd..c9660e94c4 100644
--- a/locale/programs/locale.c
+++ b/locale/programs/locale.c
@@ -792,188 +792,181 @@ print_assignment (const char *name, const char *val, bool dquote)
 static void
 show_locale_vars (void)
 {
-  size_t cat_no;
-  const char *lcall = getenv ("LC_ALL") ? : "";
-  const char *lang = getenv ("LANG") ? : "";
-
-  auto void get_source (const char *name);
-
-  void get_source (const char *name)
-    {
-      char *val = getenv (name);
-
-      if (lcall[0] != '\0' || val == NULL)
-	print_assignment (name, lcall[0] ? lcall : lang[0] ? lang : "POSIX",
-			  true);
-      else
-	print_assignment (name, val, false);
-    }
+  const char *lcall = getenv ("LC_ALL") ?: "";
+  const char *lang = getenv ("LANG") ?: "";
 
   /* LANG has to be the first value.  */
   print_assignment ("LANG", lang, false);
 
   /* Now all categories in an unspecified order.  */
-  for (cat_no = 0; cat_no < NCATEGORIES; ++cat_no)
+  for (size_t cat_no = 0; cat_no < NCATEGORIES; ++cat_no)
     if (cat_no != LC_ALL)
-      get_source (category[cat_no].name);
+      {
+	const char *name = category[cat_no].name;
+	const char *val = getenv (name);
+
+	if (lcall[0] != '\0' || val == NULL)
+	  print_assignment (name,
+			    lcall[0] != '\0' ? lcall
+			    : lang[0] != '\0' ? lang
+			    : "POSIX",
+			    true);
+	else
+	  print_assignment (name, val, false);
+      }
 
   /* The last is the LC_ALL value.  */
   print_assignment ("LC_ALL", lcall, false);
 }
 
 
-/* Show the information request for NAME.  */
+/* Subroutine of show_info, below.  */
 static void
-show_info (const char *name)
+print_item (struct cat_item *item)
 {
-  size_t cat_no;
-
-  auto void print_item (struct cat_item *item);
-
-  void print_item (struct cat_item *item)
+  switch (item->value_type)
     {
-      switch (item->value_type)
-	{
-	case string:
-	  if (show_keyword_name)
-	    printf ("%s=\"", item->name);
-	  fputs (nl_langinfo (item->item_id) ? : "", stdout);
-	  if (show_keyword_name)
-	    putchar ('"');
-	  putchar ('\n');
-	  break;
-	case stringarray:
-	  {
-	    int cnt;
-	    const char *val;
-
-	    if (show_keyword_name)
-	      printf ("%s=\"", item->name);
+    case string:
+      if (show_keyword_name)
+	printf ("%s=\"", item->name);
+      fputs (nl_langinfo (item->item_id) ? : "", stdout);
+      if (show_keyword_name)
+	putchar ('"');
+      putchar ('\n');
+      break;
+    case stringarray:
+      {
+	const char *val;
+	int cnt;
 
-	    for (cnt = 0; cnt < item->max - 1; ++cnt)
-	      {
-		val = nl_langinfo (item->item_id + cnt);
-		if (val != NULL)
-		  fputs (val, stdout);
-		putchar (';');
-	      }
+	if (show_keyword_name)
+	  printf ("%s=\"", item->name);
 
+	for (cnt = 0; cnt < item->max - 1; ++cnt)
+	  {
 	    val = nl_langinfo (item->item_id + cnt);
 	    if (val != NULL)
 	      fputs (val, stdout);
-
-	    if (show_keyword_name)
-	      putchar ('"');
-	    putchar ('\n');
+	    putchar (';');
 	  }
-	  break;
-	case stringlist:
+
+	val = nl_langinfo (item->item_id + cnt);
+	if (val != NULL)
+	  fputs (val, stdout);
+
+	if (show_keyword_name)
+	  putchar ('"');
+	putchar ('\n');
+      }
+      break;
+    case stringlist:
+      {
+	int first = 1;
+	const char *val = nl_langinfo (item->item_id) ? : "";
+
+	if (show_keyword_name)
+	  printf ("%s=", item->name);
+
+	for (int cnt = 0; cnt < item->max && *val != '\0'; ++cnt)
 	  {
-	    int first = 1;
-	    const char *val = nl_langinfo (item->item_id) ? : "";
-	    int cnt;
-
-	    if (show_keyword_name)
-	      printf ("%s=", item->name);
-
-	    for (cnt = 0; cnt < item->max && *val != '\0'; ++cnt)
-	      {
-		printf ("%s%s%s%s", first ? "" : ";",
-			show_keyword_name ? "\"" : "", val,
-			show_keyword_name ? "\"" : "");
-		val = strchr (val, '\0') + 1;
-		first = 0;
-	      }
-	    putchar ('\n');
+	    printf ("%s%s%s%s", first ? "" : ";",
+		    show_keyword_name ? "\"" : "", val,
+		    show_keyword_name ? "\"" : "");
+	    val = strchr (val, '\0') + 1;
+	    first = 0;
 	  }
-	  break;
-	case byte:
-	  {
-	    const char *val = nl_langinfo (item->item_id);
+	putchar ('\n');
+      }
+      break;
+    case byte:
+      {
+	const char *val = nl_langinfo (item->item_id);
 
-	    if (show_keyword_name)
-	      printf ("%s=", item->name);
+	if (show_keyword_name)
+	  printf ("%s=", item->name);
 
-	    if (val != NULL)
-	      printf ("%d", *val == '\377' ? -1 : *val);
-	    putchar ('\n');
-	  }
-	  break;
-	case bytearray:
+	if (val != NULL)
+	  printf ("%d", *val == '\377' ? -1 : *val);
+	putchar ('\n');
+      }
+      break;
+    case bytearray:
+      {
+	const char *val = nl_langinfo (item->item_id);
+	int cnt = val ? strlen (val) : 0;
+
+	if (show_keyword_name)
+	  printf ("%s=", item->name);
+
+	while (cnt > 1)
 	  {
-	    const char *val = nl_langinfo (item->item_id);
-	    int cnt = val ? strlen (val) : 0;
+	    printf ("%d;", *val == '\177' ? -1 : *val);
+	    --cnt;
+	    ++val;
+	  }
 
-	    if (show_keyword_name)
-	      printf ("%s=", item->name);
+	printf ("%d\n", cnt == 0 || *val == '\177' ? -1 : *val);
+      }
+      break;
+    case word:
+      {
+	union { unsigned int word; char *string; } val;
+	val.string = nl_langinfo (item->item_id);
+	if (show_keyword_name)
+	  printf ("%s=", item->name);
 
-	    while (cnt > 1)
-	      {
-		printf ("%d;", *val == '\177' ? -1 : *val);
-		--cnt;
-		++val;
-	      }
+	printf ("%d\n", val.word);
+      }
+      break;
+    case wordarray:
+      {
+	int first = 1;
+	union { unsigned int *wordarray; char *string; } val;
 
-	    printf ("%d\n", cnt == 0 || *val == '\177' ? -1 : *val);
-	  }
-	  break;
-	case word:
-	  {
-	    union { unsigned int word; char *string; } val;
-	    val.string = nl_langinfo (item->item_id);
-	    if (show_keyword_name)
-	      printf ("%s=", item->name);
+	val.string = nl_langinfo (item->item_id);
+	if (show_keyword_name)
+	  printf ("%s=", item->name);
 
-	    printf ("%d\n", val.word);
-	  }
-	  break;
-	case wordarray:
+	for (int cnt = 0; cnt < item->max; ++cnt)
 	  {
-	    int first = 1;
-	    union { unsigned int *wordarray; char *string; } val;
-	    int cnt;
-
-	    val.string = nl_langinfo (item->item_id);
-	    if (show_keyword_name)
-	      printf ("%s=", item->name);
-
-	    for (cnt = 0; cnt < item->max; ++cnt)
-	      {
-		printf ("%s%d", first ? "" : ";", val.wordarray[cnt]);
-		first = 0;
-	      }
-	    putchar ('\n');
+	    printf ("%s%d", first ? "" : ";", val.wordarray[cnt]);
+	    first = 0;
 	  }
-	  break;
-	case wstring:
-	case wstringarray:
-	case wstringlist:
-	  /* We don't print wide character information since the same
-	     information is available in a multibyte string.  */
-	default:
-	  break;
-
-	}
+	putchar ('\n');
+      }
+      break;
+    case wstring:
+    case wstringarray:
+    case wstringlist:
+      /* We don't print wide character information since the same
+	 information is available in a multibyte string.  */
+    default:
+      break;
     }
+}
 
-  for (cat_no = 0; cat_no < NCATEGORIES; ++cat_no)
+/* Show the information request for NAME.  */
+static void
+show_info (const char *name)
+{
+  for (size_t cat_no = 0; cat_no < NCATEGORIES; ++cat_no)
     if (cat_no != LC_ALL)
       {
-	size_t item_no;
-
 	if (strcmp (name, category[cat_no].name) == 0)
 	  /* Print the whole category.  */
 	  {
 	    if (show_category_name != 0)
 	      puts (category[cat_no].name);
 
-	    for (item_no = 0; item_no < category[cat_no].number; ++item_no)
+	    for (size_t item_no = 0;
+		 item_no < category[cat_no].number;
+		 ++item_no)
 	      print_item (&category[cat_no].item_desc[item_no]);
 
 	    return;
 	  }
 
-	for (item_no = 0; item_no < category[cat_no].number; ++item_no)
+	for (size_t item_no = 0; item_no < category[cat_no].number; ++item_no)
 	  if (strcmp (name, category[cat_no].item_desc[item_no].name) == 0)
 	    {
 	      if (show_category_name != 0)