[2/3] genmatch: clean up showUsage

Message ID 20230508181311.25961-3-amonakov@ispras.ru
State Accepted
Headers
Series Trivial cleanups for genmatch |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Alexander Monakov May 8, 2023, 6:13 p.m. UTC
  Display usage more consistently and get rid of camelCase.

gcc/ChangeLog:

	* genmatch.cc (showUsage): Reimplement as ...
	(usage): ...this.  Adjust all uses.
	(main): Print usage when no arguments.  Add missing 'return 1'.
---
 gcc/genmatch.cc | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
  

Patch

diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
index d5e56e2d68..baf93855a6 100644
--- a/gcc/genmatch.cc
+++ b/gcc/genmatch.cc
@@ -5301,13 +5301,12 @@  round_alloc_size (size_t s)
 /* Construct and display the help menu.  */
 
 static void
-showUsage ()
+usage ()
 {
-  fprintf (stderr, "Usage: genmatch [--gimple] [--generic] "
-		   "[--header=<filename>] [--include=<filename>] [-v[v]] input "
-		   "[<outputfile>...]\n");
-  fprintf (stderr, "\nWhen more then one outputfile is specified --header "
-		   "is required.\n");
+  const char *usage = "Usage:\n"
+    " %s [--gimple|--generic] [-v[v]] <input>\n"
+    " %s [options] [--include=FILE] --header=FILE <input> <output>...\n";
+  fprintf (stderr, usage, progname, progname);
 }
 
 /* Write out the correct include to the match-head fle containing the helper
@@ -5332,9 +5331,6 @@  main (int argc, char **argv)
 
   progname = "genmatch";
 
-  if (argc < 2)
-    return 1;
-
   bool gimple = true;
   char *s_header_file = NULL;
   char *s_include_file = NULL;
@@ -5359,14 +5355,17 @@  main (int argc, char **argv)
 	files.safe_push (argv[i]);
       else
 	{
-	  showUsage ();
+	  usage ();
 	  return 1;
 	}
     }
 
   /* Validate if the combinations are valid.  */
   if ((files.length () > 1 && !s_header_file) || files.is_empty ())
-    showUsage ();
+    {
+      usage ();
+      return 1;
+    }
 
   if (!s_include_file)
     s_include_file = s_header_file;