This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit] Use an enum for main.c's option handling


Hello,

Just a simple cleanup. Replace those magic numbers in [captured_]main used by the option parsing code with an enum.

committed,
Andrew
2003-03-01  Andrew Cagney  <cagney at redhat dot com>

	* main.c (captured_main): Replace magic option characters with an
	enum.

Index: main.c
===================================================================
RCS file: /cvs/src/src/gdb/main.c,v
retrieving revision 1.29
diff -u -r1.29 main.c
--- main.c	14 Feb 2003 13:58:06 -0000	1.29
+++ main.c	2 Mar 2003 00:45:53 -0000
@@ -237,12 +237,19 @@
     /* When var field is 0, use flag field to record the equivalent
        short option (or arbitrary numbers starting at 10 for those
        with no equivalent).  */
+    enum {
+      OPT_SE = 10,
+      OPT_CD,
+      OPT_ANNOTATE,
+      OPT_STATISTICS,
+      OPT_TUI
+    };
     static struct option long_options[] =
     {
       {"async", no_argument, &event_loop_p, 1},
       {"noasync", no_argument, &event_loop_p, 0},
 #if defined(TUI)
-      {"tui", no_argument, 0, 14},
+      {"tui", no_argument, 0, OPT_TUI},
 #endif
       {"xdb", no_argument, &xdb_commands, 1},
       {"dbx", no_argument, &dbx_commands, 1},
@@ -264,9 +271,9 @@
       {"fullname", no_argument, 0, 'f'},
       {"f", no_argument, 0, 'f'},
 
-      {"annotate", required_argument, 0, 12},
+      {"annotate", required_argument, 0, OPT_ANNOTATE},
       {"help", no_argument, &print_help, 1},
-      {"se", required_argument, 0, 10},
+      {"se", required_argument, 0, OPT_SE},
       {"symbols", required_argument, 0, 's'},
       {"s", required_argument, 0, 's'},
       {"exec", required_argument, 0, 'e'},
@@ -288,7 +295,7 @@
       {"i", required_argument, 0, 'i'},
       {"directory", required_argument, 0, 'd'},
       {"d", required_argument, 0, 'd'},
-      {"cd", required_argument, 0, 11},
+      {"cd", required_argument, 0, OPT_CD},
       {"tty", required_argument, 0, 't'},
       {"baud", required_argument, 0, 'b'},
       {"b", required_argument, 0, 'b'},
@@ -296,7 +303,7 @@
       {"nowindows", no_argument, &use_windows, 0},
       {"w", no_argument, &use_windows, 1},
       {"windows", no_argument, &use_windows, 1},
-      {"statistics", no_argument, 0, 13},
+      {"statistics", no_argument, 0, OPT_STATISTICS},
       {"write", no_argument, &write_files, 1},
       {"args", no_argument, &set_args, 1},
       {0, no_argument, 0, 0}
@@ -320,23 +327,23 @@
 	  case 0:
 	    /* Long option that just sets a flag.  */
 	    break;
-	  case 10:
+	  case OPT_SE:
 	    symarg = optarg;
 	    execarg = optarg;
 	    break;
-	  case 11:
+	  case OPT_CD:
 	    cdarg = optarg;
 	    break;
-	  case 12:
+	  case OPT_ANNOTATE:
 	    /* FIXME: what if the syntax is wrong (e.g. not digits)?  */
 	    annotation_level = atoi (optarg);
 	    break;
-	  case 13:
+	  case OPT_STATISTICS:
 	    /* Enable the display of both time and space usage.  */
 	    display_time = 1;
 	    display_space = 1;
 	    break;
-	  case 14:
+	  case OPT_TUI:
 	    /* --tui is equivalent to -i=tui.  */
 	    xfree (interpreter_p);
 	    interpreter_p = xstrdup ("tui");

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]