diff options
author | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-05-29 21:33:35 +0000 |
---|---|---|
committer | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-05-29 21:33:35 +0000 |
commit | 4eb7b61f2c1c20024050339e57a2aee041147ec4 (patch) | |
tree | 96002dd0abd5b477d7d771673ceec8d85c96df7b | |
parent | 360ece753248451ec41e47e4cf6dd0a6ec6d1423 (diff) | |
download | gcc-4eb7b61f2c1c20024050339e57a2aee041147ec4.tar.gz |
PR bootstrap/10169
* mips-tfile.c (main): Use getopt_long instead of getopt.
Add new command line option --version to display version.
Treat --verbose like -v to report a single line version.
(options): New global variable for getopt_long.
* mips-tdump.c (main): Use getopt_long instead of getopt.
New command line options -v, --version and -verbose to display
the program version number (to match mips-tfile's behavior).
(options): New global variable for getopt_long.
* gcov.c (options): Zero-terminate getopt_long array.
* gcov-dump.c (options): Likewise.
* Makefile.in (mips-tdump.o): Add dependency on version.h.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@67230 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 18 | ||||
-rw-r--r-- | gcc/Makefile.in | 2 | ||||
-rw-r--r-- | gcc/gcov-dump.c | 1 | ||||
-rw-r--r-- | gcc/gcov.c | 1 | ||||
-rw-r--r-- | gcc/mips-tdump.c | 48 | ||||
-rw-r--r-- | gcc/mips-tfile.c | 53 |
6 files changed, 106 insertions, 17 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 94633586a47..3c6b7a02ac2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,21 @@ +2003-05-29 Roger Sayle <roger@eyesopen.com> + Kaveh Ghazi <ghazi@caip.rutgers.edu> + + PR bootstrap/10169 + * mips-tfile.c (main): Use getopt_long instead of getopt. + Add new command line option --version to display version. + Treat --verbose like -v to report a single line version. + (options): New global variable for getopt_long. + * mips-tdump.c (main): Use getopt_long instead of getopt. + New command line options -v, --version and -verbose to display + the program version number (to match mips-tfile's behavior). + (options): New global variable for getopt_long. + + * gcov.c (options): Zero-terminate getopt_long array. + * gcov-dump.c (options): Likewise. + + * Makefile.in (mips-tdump.o): Add dependency on version.h. + 2003-05-29 Stan Shebs <shebs@apple.com> Remove OBJC_PROLOGUE everywhere. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 044ec12ee00..708f358fefd 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1793,7 +1793,7 @@ mips-tfile.o : mips-tfile.c $(CONFIG_H) $(RTL_H) $(SYSTEM_H) coretypes.h $(TM_H) mips-tdump: mips-tdump.o version.o $(LIBDEPS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ mips-tdump.o version.o $(LIBS) -mips-tdump.o : mips-tdump.c $(CONFIG_H) $(RTL_H) $(SYSTEM_H) coretypes.h $(TM_H) +mips-tdump.o : mips-tdump.c $(CONFIG_H) $(RTL_H) $(SYSTEM_H) coretypes.h $(TM_H) version.h # # Generate header and source files from the machine description, diff --git a/gcc/gcov-dump.c b/gcc/gcov-dump.c index c7c31ad5454..57a020a3359 100644 --- a/gcc/gcov-dump.c +++ b/gcc/gcov-dump.c @@ -55,6 +55,7 @@ static const struct option options[] = { "version", no_argument, NULL, 'v' }, { "long", no_argument, NULL, 'l' }, { "positions", no_argument, NULL, 'o' }, + { 0, 0, 0, 0 } }; static const tag_format_t tag_table[] = diff --git a/gcc/gcov.c b/gcc/gcov.c index 3a7de61d3f4..4c92170ebbf 100644 --- a/gcc/gcov.c +++ b/gcc/gcov.c @@ -445,6 +445,7 @@ static const struct option options[] = { "object-directory", required_argument, NULL, 'o' }, { "object-file", required_argument, NULL, 'o' }, { "unconditional-branches", no_argument, NULL, 'u' }, + { 0, 0, 0, 0 } }; /* Process args, return index to first non-arg. */ diff --git a/gcc/mips-tdump.c b/gcc/mips-tdump.c index 4c88325f6e6..44486b4e500 100644 --- a/gcc/mips-tdump.c +++ b/gcc/mips-tdump.c @@ -1,5 +1,5 @@ /* Read and manage MIPS symbol tables from object modules. - Copyright (C) 1991, 1994, 1995, 1997, 1998, 1999, 2000, 2001 + Copyright (C) 1991, 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc. Contributed by hartzell@boulder.colorado.edu, Rewritten by meissner@osf.org. @@ -25,6 +25,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "system.h" #include "coretypes.h" #include "tm.h" +#include "version.h" #ifdef index #undef index #endif @@ -34,6 +35,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "mips/a.out.h" #endif /* CROSS_COMPILE */ +/* Include getopt.h for the sake of getopt_long. */ +#include "getopt.h" + #ifndef MIPS_IS_STAB /* Macros for mips-tfile.c to encapsulate stabs in ECOFF, and for and mips-tdump.c to print them out. This is used on the Alpha, @@ -209,6 +213,8 @@ int want_line = 0; /* print line numbers */ int want_rfd = 0; /* print relative file desc's */ int want_scope = 0; /* print scopes for every symbol */ int tfile = 0; /* no global header file */ +int version = 0; /* print version # */ +int verbose = 0; int tfile_fd; /* file descriptor of .T file */ off_t tfile_offset; /* current offset in .T file */ scope_t *cur_scope = 0; /* list of active scopes */ @@ -254,6 +260,14 @@ const struct {const short code; const char string[10];} stab_names[] = { #undef __define_stab }; +/* Command line options for getopt_long. */ + +static const struct option options[] = +{ + { "version", 0, 0, 'V' }, + { "verbose", 0, 0, 'v' }, + { 0, 0, 0, 0 } +}; /* Read some bytes at a specified location, and return a pointer. */ @@ -1434,7 +1448,7 @@ main (argc, argv) /* * Process arguments */ - while ((opt = getopt (argc, argv, "alrst")) != EOF) + while ((opt = getopt_long (argc, argv, "alrsvt", options, NULL)) != -1) switch (opt) { default: errors++; break; @@ -1442,10 +1456,35 @@ main (argc, argv) case 'l': want_line++; break; /* print line numbers */ case 'r': want_rfd++; break; /* print relative fd's */ case 's': want_scope++; break; /* print scope info */ - case 't': tfile++; break; /* this is a tfile (without header), and not a .o */ + case 'v': verbose++; break; /* print version # */ + case 'V': version++; break; /* print version # */ + case 't': tfile++; break; /* this is a tfile (without header), + and not a .o */ } - if (errors || optind != argc - 1) + if (version) + { + printf ("mips-tdump (GCC) %s\n", version_string); + fputs ("Copyright (C) 2003 Free Software Foundation, Inc.\n", stdout); + fputs ("This is free software; see the source for copying conditions. There is NO\n\ +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n", + stdout); + exit (0); + } + + if (optind != argc - 1) + errors++; + + if (verbose || errors) + { + fprintf (stderr, "mips-tdump (GCC) %s", version_string); +#ifdef TARGET_VERSION + TARGET_VERSION; +#endif + fputc ('\n', stderr); + } + + if (errors) { fprintf (stderr, "Calling Sequence:\n"); fprintf (stderr, "\t%s [-alrst] <object-or-T-file>\n", argv[0]); @@ -1456,6 +1495,7 @@ main (argc, argv) fprintf (stderr, "\t-r Print out relative file descriptors.\n"); fprintf (stderr, "\t-s Print out the current scopes for an item.\n"); fprintf (stderr, "\t-t Assume there is no global header (ie, a T-file).\n"); + fprintf (stderr, "\t-v Print program version.\n"); return 1; } diff --git a/gcc/mips-tfile.c b/gcc/mips-tfile.c index 45b8717d933..d5c378f2e05 100644 --- a/gcc/mips-tfile.c +++ b/gcc/mips-tfile.c @@ -611,6 +611,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #define saber_stop() #endif +/* Include getopt.h for the sake of getopt_long. */ +#include "getopt.h" + #ifndef __LINE__ #define __LINE__ 0 #endif @@ -1510,6 +1513,7 @@ static unsigned cur_line_alloc = 0; /* # bytes total in buffer */ static long line_number = 0; /* current input line number */ static int debug = 0; /* trace functions */ static int version = 0; /* print version # */ +static int verbose = 0; static int had_errors = 0; /* != 0 if errors were found */ static int rename_output = 0; /* != 0 if rename output file*/ static int delete_input = 0; /* != 0 if delete input after done */ @@ -1664,6 +1668,15 @@ static const pseudo_ops_t pseudo_ops[] = { }; +/* Command line options for getopt_long. */ + +static const struct option options[] = +{ + { "version", 0, 0, 'V' }, + { "verbose", 0, 0, 'v' }, + { 0, 0, 0, 0 } +}; + /* Add a page to a varray object. */ STATIC void @@ -4809,7 +4822,7 @@ main (argc, argv) void_type_info = type_info_init; void_type_info.basic_type = bt_Void; - while ((option = getopt (argc, argv, "d:i:I:o:v")) != EOF) + while ((option = getopt_long (argc, argv, "d:i:I:o:v", options, NULL)) != -1) switch (option) { default: @@ -4849,10 +4862,24 @@ main (argc, argv) break; case 'v': + verbose++; + break; + + case 'V': version++; break; } + if (version) + { + printf (_("mips-tfile (GCC) %s\n"), version_string); + fputs (_("Copyright (C) 2003 Free Software Foundation, Inc.\n"), stdout); + fputs (_("This is free software; see the source for copying conditions. There is NO\n\ +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"), + stdout); + exit (0); + } + if (obj_in_name == (char *) 0 && optind <= argc - 2) obj_in_name = argv[--argc]; @@ -4868,7 +4895,19 @@ main (argc, argv) delete_input = 1; } - if (object_name == (char *) 0 || had_errors || optind != argc - 1) + if (optind != argc - 1) + had_errors++; + + if (verbose || had_errors) + { + fprintf (stderr, _("mips-tfile (GCC) %s"), version_string); +#ifdef TARGET_VERSION + TARGET_VERSION; +#endif + fputc ('\n', stderr); + } + + if (object_name == (char *) 0 || had_errors) { fprintf (stderr, _("Calling Sequence:\n")); fprintf (stderr, _("\tmips-tfile [-d <num>] [-v] [-i <o-in-file>] -o <o-out-file> <s-file> (or)\n")); @@ -4883,16 +4922,6 @@ main (argc, argv) return 1; } - - if (version) - { - fprintf (stderr, _("mips-tfile version %s"), version_string); -#ifdef TARGET_VERSION - TARGET_VERSION; -#endif - fputc ('\n', stderr); - } - if (obj_in_name == (char *) 0) obj_in_name = object_name; |