about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--locale/programs/locale.c263
2 files changed, 133 insertions, 135 deletions
diff --git a/ChangeLog b/ChangeLog
index 08df92dba4..7f2053b494 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2014-09-12  Roland McGrath  <roland@hack.frob.com>
 
+	* locale/programs/locale.c (show_locale_vars): Inline local function
+	into its sole call site.  Clean up some style nits.
+	(print_item): New function, broken out of ...
+	(show_info): ... local function here.  Clean up style nits.
+
 	* locale/programs/ld-ctype.c (set_one_default): New function, broken
 	out of ...
 	(set_class_defaults): ... local function set_default here.
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)