diff options
-rw-r--r-- | gcc/java/ChangeLog | 26 | ||||
-rw-r--r-- | gcc/java/gjavah.c | 308 | ||||
-rw-r--r-- | gcc/java/jcf-dump.c | 171 | ||||
-rw-r--r-- | gcc/java/jv-scan.c | 117 |
4 files changed, 405 insertions, 217 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 6bec15f..40ac69c 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,29 @@ +2000-02-02 Tom Tromey <tromey@cygnus.com> + + * jv-scan.c: Include version.c, <getopt.h>. + (LONG_OPT, OPT_HELP, OPT_VERSION): New macros. + (options): New array. + (usage): New function. + (version): New function. + (main): Use getopt_long to parse command line. + * jcf-dump.c: Include version.c, <getopt.h>. + (LONG_OPT, OPT_classpath, OPT_CLASSPATH, OPT_HELP, OPT_VERSION, + OPT_JAVAP): New macros. + (options): New array. + (usage): Return `void'. Changed message. + (help): New function. + (version): New function. + (main): Use getopt_long_only to parse command line. + * gjavah.c: Include <getopt.h>. + (LONG_OPT, OPT_classpath, OPT_CLASSPATH, OPT_HELP, OPT_TEMP, + OPT_VERSION, OPT_PREPEND, OPT_FRIEND, OPT_ADD, OPT_APPEND, OPT_M, + OPT_MM, OPT_MG, OPT_MD, OPT_MMD): New macros. + (options): New array. + (java_no_argument): Removed. + (help): Updated with missing options. + (main): Use getopt_long_only to parse command line. + (usage): Changed message. + 2000-01-30 Anthony Green <green@redhat.com> * jcf-write.c (generate_bytecode_insns): Use TYPE_IS_WIDE to diff --git a/gcc/java/gjavah.c b/gcc/java/gjavah.c index 9955fbf..8233c92 100644 --- a/gcc/java/gjavah.c +++ b/gcc/java/gjavah.c @@ -35,6 +35,10 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "version.c" +#include <getopt.h> + + + /* The output file. */ FILE *out = NULL; @@ -134,7 +138,6 @@ static const unsigned char *decode_signature_piece static void print_class_decls PARAMS ((FILE *, JCF *, int)); static void usage PARAMS ((void)) ATTRIBUTE_NORETURN; static void help PARAMS ((void)) ATTRIBUTE_NORETURN; -static void java_no_argument PARAMS ((const char *)) ATTRIBUTE_NORETURN; static void version PARAMS ((void)) ATTRIBUTE_NORETURN; JCF_u2 current_field_name; @@ -161,7 +164,7 @@ static int method_pass; if (out && ! stubs) \ print_field_info (out, jcf, current_field_name, \ current_field_signature, \ - current_field_flags); \ + current_field_flags); \ } \ else \ if (! stubs) add_class_decl (out, jcf, current_field_signature); @@ -901,7 +904,7 @@ DEFUN(print_full_cxx_name, (stream, jcf, name_index, signature_index, is_init, n fputs (")", stream); } } - + static void DEFUN(print_stub, (stream, jcf, name_index, signature_index, is_init, name_override), @@ -1490,10 +1493,51 @@ DEFUN(process_file, (jcf, out), } } + + +/* This is used to mark options with no short value. */ +#define LONG_OPT(Num) ((Num) + 128) + +#define OPT_classpath LONG_OPT (0) +#define OPT_CLASSPATH LONG_OPT (1) +#define OPT_HELP LONG_OPT (2) +#define OPT_TEMP LONG_OPT (3) +#define OPT_VERSION LONG_OPT (4) +#define OPT_PREPEND LONG_OPT (5) +#define OPT_FRIEND LONG_OPT (6) +#define OPT_ADD LONG_OPT (7) +#define OPT_APPEND LONG_OPT (8) +#define OPT_M LONG_OPT (9) +#define OPT_MM LONG_OPT (10) +#define OPT_MG LONG_OPT (11) +#define OPT_MD LONG_OPT (12) +#define OPT_MMD LONG_OPT (13) + +static struct option options[] = +{ + { "classpath", required_argument, NULL, OPT_classpath }, + { "CLASSPATH", required_argument, NULL, OPT_CLASSPATH }, + { "help", no_argument, NULL, OPT_HELP }, + { "stubs", no_argument, &stubs, 1 }, + { "td", required_argument, NULL, OPT_TEMP }, + { "verbose", no_argument, NULL, 'v' }, + { "version", no_argument, NULL, OPT_VERSION }, + { "prepend", required_argument, NULL, OPT_PREPEND }, + { "friend", required_argument, NULL, OPT_FRIEND }, + { "add", required_argument, NULL, OPT_ADD }, + { "append", required_argument, NULL, OPT_APPEND }, + { "M", no_argument, NULL, OPT_M }, + { "MM", no_argument, NULL, OPT_MM }, + { "MG", no_argument, NULL, OPT_MG }, + { "MD", no_argument, NULL, OPT_MD }, + { "MMD", no_argument, NULL, OPT_MMD }, + { NULL, no_argument, NULL, 0 } +}; + static void usage () { - fprintf (stderr, "gcjh: no classes specified\n"); + fprintf (stderr, "Try `gcjh --help' for more information.\n"); exit (1); } @@ -1502,32 +1546,40 @@ help () { printf ("Usage: gcjh [OPTION]... CLASS...\n\n"); printf ("Generate C++ header files from .class files\n\n"); + printf (" -stubs Generate an implementation stub file\n"); + printf ("\n"); + printf (" -add TEXT Insert TEXT into class body\n"); + printf (" -append TEXT Insert TEXT after class declaration\n"); + printf (" -friend TEXT Insert TEXT as `friend' declaration\n"); + printf (" -prepend TEXT Insert TEXT before start of class\n"); + printf ("\n"); printf (" --classpath PATH Set path to find .class files\n"); printf (" --CLASSPATH PATH Set path to find .class files\n"); printf (" -IDIR Append directory to class path\n"); printf (" -d DIRECTORY Set output directory name\n"); - printf (" --help Print this help, then exit\n"); printf (" -o FILE Set output file name\n"); - printf (" -stubs Generate a C++ implementation stub file\n"); printf (" -td DIRECTORY Set temporary directory name\n"); - printf (" -v, --verbose Print extra information while running\n"); + printf ("\n"); + printf (" --help Print this help, then exit\n"); printf (" --version Print version number, then exit\n"); - /* FIXME: print bug-report information. */ + printf (" -v, --verbose Print extra information while running\n"); + printf ("\n"); + printf (" -M Print all dependencies to stdout;\n"); + printf (" suppress ordinary output\n"); + printf (" -MM Print non-system dependencies to stdout;\n"); + printf (" suppress ordinary output\n"); + printf (" -MD Print all dependencies to stdout\n"); + printf (" -MMD Print non-system dependencies to stdout\n"); + /* We omit -MG until it is implemented. */ + printf ("\n"); + printf ("For bug reporting instructions, please see:\n"); + printf ("<URL:http://www.gnu.org/software/gcc/faq.html#bugreport>.\n"); exit (0); } static void -java_no_argument (opt) - const char *opt; -{ - fprintf (stderr, "gcjh: no argument given for option `%s'\n", opt); - exit (1); -} - -static void version () { - /* FIXME: use version.c? */ printf ("gcjh (%s)\n\n", version_string); printf ("Copyright (C) 1998, 1999 Free Software Foundation, Inc.\n"); printf ("This is free software; see the source for copying conditions. There is NO\n"); @@ -1543,148 +1595,123 @@ DEFUN(main, (argc, argv), int argi; char *output_file = NULL; int emit_dependencies = 0, suppress_output = 0; + int opt; if (argc <= 1) - usage (); + { + fprintf (stderr, "gcjh: no classes specified\n"); + usage (); + } jcf_path_init (); - for (argi = 1; argi < argc; argi++) + /* We use getopt_long_only to allow single `-' long options. For + some of our options this is more natural. */ + while ((opt = getopt_long_only (argc, argv, "I:d:o:v", options, NULL)) != -1) { - char *arg = argv[argi]; + switch (opt) + { + case 0: + /* Already handled. */ + break; - if (arg[0] != '-' || ! strcmp (arg, "--")) - break; + case 'o': + output_file = optarg; + break; - /* Just let all arguments be given in either "-" or "--" form. */ - if (arg[1] == '-') - ++arg; + case 'd': + output_directory = optarg; + break; - if (strcmp (arg, "-o") == 0) - { - if (argi + 1 < argc) - output_file = argv[++argi]; - else - java_no_argument (argv[argi]); - } - else if (strcmp (arg, "-d") == 0) - { - if (argi + 1 < argc) - output_directory = argv[++argi]; - else - java_no_argument (argv[argi]); - } - else if (strcmp (arg, "-td") == 0) - { - if (argi + 1 < argc) - temp_directory = argv[++argi]; - else - java_no_argument (argv[argi]); - } - else if (strcmp (arg, "-prepend") == 0) - { - if (argi + 1 < argc) - { - if (prepend_count == 0) - prepend_specs = (char**) ALLOC ((argc-argi) * sizeof (char*)); - prepend_specs[prepend_count++] = argv[++argi]; - } - else - java_no_argument (argv[argi]); - } - else if (strcmp (arg, "-friend") == 0) - { - if (argi + 1 < argc) - { - if (friend_count == 0) - friend_specs = (char**) ALLOC ((argc-argi) * sizeof (char*)); - friend_specs[friend_count++] = argv[++argi]; - } - else - java_no_argument (argv[argi]); - } - else if (strcmp (arg, "-add") == 0) - { - if (argi + 1 < argc) - { - if (add_count == 0) - add_specs = (char**) ALLOC ((argc-argi) * sizeof (char*)); - add_specs[add_count++] = argv[++argi]; - } - else - java_no_argument (argv[argi]); - } - else if (strcmp (arg, "-append") == 0) - { - if (argi + 1 < argc) - { - if (append_count == 0) - append_specs = (char**) ALLOC ((argc-argi) * sizeof (char*)); - append_specs[append_count++] = argv[++argi]; - } - else - java_no_argument (argv[argi]); - } - else if (strcmp (arg, "-classpath") == 0) - { - if (argi + 1 < argc) - jcf_path_classpath_arg (argv[++argi]); - else - java_no_argument (argv[argi]); - } - else if (strcmp (arg, "-CLASSPATH") == 0) - { - if (argi + 1 < argc) - jcf_path_CLASSPATH_arg (argv[++argi]); - else - java_no_argument (argv[argi]); - } - else if (strncmp (arg, "-I", 2) == 0) - jcf_path_include_arg (arg + 2); - else if (strcmp (arg, "-verbose") == 0 || strcmp (arg, "-v") == 0) - verbose++; - else if (strcmp (arg, "-stubs") == 0) - stubs++; - else if (strcmp (arg, "-help") == 0) - help (); - else if (strcmp (arg, "-version") == 0) - version (); - else if (strcmp (arg, "-M") == 0) - { + case 'I': + jcf_path_include_arg (optarg); + break; + + case 'v': + verbose++; + break; + + case OPT_classpath: + jcf_path_classpath_arg (optarg); + break; + + case OPT_CLASSPATH: + jcf_path_CLASSPATH_arg (optarg); + break; + + case OPT_HELP: + help (); + break; + + case OPT_TEMP: + temp_directory = optarg; + break; + + case OPT_VERSION: + version (); + break; + + case OPT_PREPEND: + if (prepend_count == 0) + prepend_specs = (char**) ALLOC (argc * sizeof (char*)); + prepend_specs[prepend_count++] = optarg; + break; + + case OPT_FRIEND: + if (friend_count == 0) + friend_specs = (char**) ALLOC (argc * sizeof (char*)); + friend_specs[friend_count++] = optarg; + break; + + case OPT_ADD: + if (add_count == 0) + add_specs = (char**) ALLOC (argc * sizeof (char*)); + add_specs[add_count++] = optarg; + break; + + case OPT_APPEND: + if (append_count == 0) + append_specs = (char**) ALLOC (argc * sizeof (char*)); + append_specs[append_count++] = optarg; + break; + + case OPT_M: emit_dependencies = 1; suppress_output = 1; jcf_dependency_init (1); - } - else if (strcmp (arg, "-MM") == 0) - { + break; + + case OPT_MM: emit_dependencies = 1; suppress_output = 1; jcf_dependency_init (0); - } - else if (strcmp (arg, "-MG") == 0) - { + break; + + case OPT_MG: fprintf (stderr, "gcjh: `%s' option is unimplemented\n", argv[argi]); exit (1); - } - else if (strcmp (arg, "-MD") == 0) - { + + case OPT_MD: emit_dependencies = 1; jcf_dependency_init (1); - } - else if (strcmp (arg, "-MMD") == 0) - { + break; + + case OPT_MMD: emit_dependencies = 1; jcf_dependency_init (0); - } - else - { - fprintf (stderr, "%s: illegal argument\n", argv[argi]); - exit (1); + break; + + default: + usage (); + break; } } - if (argi == argc) - usage (); + if (optind == argc) + { + fprintf (stderr, "gcjh: no classes specified\n"); + usage (); + } jcf_path_seal (); @@ -1694,7 +1721,7 @@ DEFUN(main, (argc, argv), exit (1); } - for (; argi < argc; argi++) + for (argi = optind; argi < argc; argi++) { char *classname = argv[argi]; char *current_output_file; @@ -1782,12 +1809,3 @@ DEFUN(main, (argc, argv), return found_error; } - -/* TODO: - - * Emit "structure forward declarations" when needed. - - * Generate C headers, like javah - - */ - diff --git a/gcc/java/jcf-dump.c b/gcc/java/jcf-dump.c index 2eda740..28092d2 100644 --- a/gcc/java/jcf-dump.c +++ b/gcc/java/jcf-dump.c @@ -53,6 +53,10 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "tree.h" #include "java-tree.h" +#include "version.c" + +#include <getopt.h> + /* Outout file. */ FILE *out; /* Name of output file, if NULL if stdout. */ @@ -86,7 +90,9 @@ static void disassemble_method PARAMS ((JCF*, const unsigned char *, int)); static void print_name PARAMS ((FILE*, JCF*, int)); static void print_signature PARAMS ((FILE*, JCF*, int, int)); static int utf8_equal_string PARAMS ((struct JCF*, int, const char *)); -static int usage PARAMS ((void)) ATTRIBUTE_NORETURN; +static void usage PARAMS ((void)) ATTRIBUTE_NORETURN; +static void help PARAMS ((void)) ATTRIBUTE_NORETURN; +static void version PARAMS ((void)) ATTRIBUTE_NORETURN; static void process_class PARAMS ((struct JCF *)); static void print_constant_pool PARAMS ((struct JCF *)); static void print_exception_table PARAMS ((struct JCF *, @@ -679,13 +685,6 @@ DEFUN(print_exception_table, (jcf, entries, count), #include "jcf-reader.c" -static int -DEFUN (usage, (), ) -{ - fprintf (stderr, "Usage: jcf-dump [-o outputfile] [-c] classname\n"); - exit(1); -} - static void DEFUN(process_class, (jcf), JCF *jcf) @@ -732,56 +731,140 @@ DEFUN(process_class, (jcf), jcf->filename = NULL; } + + +/* This is used to mark options with no short value. */ +#define LONG_OPT(Num) ((Num) + 128) + +#define OPT_classpath LONG_OPT (0) +#define OPT_CLASSPATH LONG_OPT (1) +#define OPT_HELP LONG_OPT (2) +#define OPT_VERSION LONG_OPT (3) +#define OPT_JAVAP LONG_OPT (4) + +static struct option options[] = +{ + { "classpath", required_argument, NULL, OPT_classpath }, + { "CLASSPATH", required_argument, NULL, OPT_CLASSPATH }, + { "help", no_argument, NULL, OPT_HELP }, + { "verbose", no_argument, NULL, 'v' }, + { "version", no_argument, NULL, OPT_VERSION }, + { "javap", no_argument, NULL, OPT_JAVAP }, + { "print-main", no_argument, &flag_print_main, 1 }, + { NULL, no_argument, NULL, 0 } +}; + +static void +usage () +{ + fprintf (stderr, "Try `jcf-dump --help' for more information.\n"); + exit (1); +} + +static void +help () +{ + printf ("Usage: jcf-dump [OPTION]... CLASS...\n\n"); + printf ("Display contents of a class file in readable form.\n\n"); + printf (" -c Disassemble method bodies\n"); + printf (" --javap Generate output in `javap' format\n"); + printf ("\n"); + printf (" --classpath PATH Set path to find .class files\n"); + printf (" --CLASSPATH PATH Set path to find .class files\n"); + printf (" -IDIR Append directory to class path\n"); + printf (" -o FILE Set output file name\n"); + printf ("\n"); + printf (" --help Print this help, then exit\n"); + printf (" --version Print version number, then exit\n"); + printf (" -v, --verbose Print extra information while running\n"); + printf ("\n"); + printf ("For bug reporting instructions, please see:\n"); + printf ("<URL:http://www.gnu.org/software/gcc/faq.html#bugreport>.\n"); + exit (0); +} + +static void +version () +{ + printf ("jcf-dump (%s)\n\n", version_string); + printf ("Copyright (C) 1998, 1999 Free Software Foundation, Inc.\n"); + printf ("This is free software; see the source for copying conditions. There is NO\n"); + printf ("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"); + exit (0); +} + int DEFUN(main, (argc, argv), int argc AND char** argv) { JCF jcf[1]; - int argi; + int argi, opt; + if (argc <= 1) - usage (); + { + fprintf (stderr, "jcf-dump: no classes specified\n"); + usage (); + } jcf_path_init (); - for (argi = 1; argi < argc; argi++) + /* We use getopt_long_only to allow single `-' long options. For + some of our options this is more natural. */ + while ((opt = getopt_long_only (argc, argv, "o:I:vc", options, NULL)) != -1) { - const char *arg = argv[argi]; + switch (opt) + { + case 0: + /* Already handled. */ + break; - if (arg[0] != '-' || ! strcmp (arg, "--")) - break; + case 'o': + output_file = optarg; + break; - /* Just let all arguments be given in either "-" or "--" form. */ - if (arg[1] == '-') - ++arg; - - if (strcmp (arg, "-o") == 0 && argi + 1 < argc) - output_file = argv[++argi]; - else if (strcmp (arg, "-classpath") == 0 && argi + 1 < argc) - jcf_path_classpath_arg (argv[++argi]); - else if (strcmp (arg, "-CLASSPATH") == 0 && argi + 1 < argc) - jcf_path_CLASSPATH_arg (argv[++argi]); - else if (strncmp (arg, "-I", 2) == 0) - jcf_path_include_arg (arg + 2); - else if (strcmp (arg, "-verbose") == 0) - verbose++; - else if (strcmp (arg, "-print-main") == 0) - flag_print_main++; - else if (strcmp (arg, "-c") == 0) - flag_disassemble_methods++; - else if (strcmp (arg, "-javap") == 0) - { + case 'I': + jcf_path_include_arg (optarg); + break; + + case 'v': + verbose++; + break; + + case 'c': + flag_disassemble_methods = 1; + break; + + case OPT_classpath: + jcf_path_classpath_arg (optarg); + break; + + case OPT_CLASSPATH: + jcf_path_CLASSPATH_arg (optarg); + break; + + case OPT_HELP: + help (); + break; + + case OPT_VERSION: + version (); + break; + + case OPT_JAVAP: flag_javap_compatible++; flag_print_constant_pool = 0; - } - else - { - fprintf (stderr, "%s: illegal argument\n", argv[argi]); - return FATAL_EXIT_CODE; + break; + + default: + usage (); } } - if (argi == argc) - usage (); + if (optind == argc) + { + fprintf (stderr, "jcf-dump: no classes specified\n"); + usage (); + } jcf_path_seal (); @@ -806,7 +889,7 @@ DEFUN(main, (argc, argv), else out = stdout; - if (argi >= argc) + if (optind >= argc) { fprintf (out, "Reading .class from <standard input>.\n"); #if JCF_USE_STDIO @@ -818,7 +901,7 @@ DEFUN(main, (argc, argv), } else { - for (; argi < argc; argi++) + for (argi = optind; argi < argc; argi++) { char *arg = argv[argi]; const char *class_filename = find_class (arg, strlen (arg), jcf, 0); @@ -927,6 +1010,8 @@ DEFUN(main, (argc, argv), return SUCCESS_EXIT_CODE; } + + static void DEFUN(disassemble_method, (jcf, byte_ops, len), JCF* jcf AND const unsigned char *byte_ops AND int len) diff --git a/gcc/java/jv-scan.c b/gcc/java/jv-scan.c index 3d5b3b6..d7c5a0c 100644 --- a/gcc/java/jv-scan.c +++ b/gcc/java/jv-scan.c @@ -24,10 +24,18 @@ Boston, MA 02111-1307, USA. */ #include "obstack.h" /* We use obstacks in lex.c */ +#include "version.c" + +#include <getopt.h> + void fatal PARAMS ((const char *s, ...)) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN; void warning PARAMS ((const char *s, ...)) ATTRIBUTE_PRINTF_1; void gcc_obstack_init PARAMS ((struct obstack *obstack)); +static void usage PARAMS ((void)) ATTRIBUTE_NORETURN; +static void help PARAMS ((void)) ATTRIBUTE_NORETURN; +static void version PARAMS ((void)) ATTRIBUTE_NORETURN; + #define JC1_LITE #include "jcf.h" #include "parse.h" @@ -46,6 +54,59 @@ int flag_find_main = 0; int flag_dump_class = 0; int flag_list_filename = 0; + + +/* This is used to mark options with no short value. */ +#define LONG_OPT(Num) ((Num) + 128) + +#define OPT_HELP LONG_OPT (0) +#define OPT_VERSION LONG_OPT (1) + +static struct option options[] = +{ + { "help", no_argument, NULL, OPT_HELP }, + { "version", no_argument, NULL, OPT_VERSION }, + { "print-main", no_argument, &flag_find_main, 1 }, + { "list-filename", no_argument, &flag_list_filename, 1 }, + { "list-class", no_argument, &flag_dump_class, 1 }, + { NULL, no_argument, NULL, 0 } +}; + +static void +usage () +{ + fprintf (stderr, "Try `jv-scan --help' for more information.\n"); + exit (1); +} + +static void +help () +{ + printf ("Usage: jv-scan [OPTION]... FILE...\n\n"); + printf ("Print useful information read from Java source files.\n\n"); + printf (" --print-main Print name of class containing `main'\n"); + printf (" --list-class List all classes defined in file\n"); + printf (" --list-filename Print input filename when listing class names\n"); + printf (" -o FILE Set output file name\n"); + printf ("\n"); + printf (" --help Print this help, then exit\n"); + printf (" --version Print version number, then exit\n"); + printf ("\n"); + printf ("For bug reporting instructions, please see:\n"); + printf ("<URL:http://www.gnu.org/software/gcc/faq.html#bugreport>.\n"); + exit (0); +} + +static void +version () +{ + printf ("jv-scan (%s)\n\n", version_string); + printf ("Copyright (C) 1998, 1999 Free Software Foundation, Inc.\n"); + printf ("This is free software; see the source for copying conditions. There is NO\n"); + printf ("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"); + exit (0); +} + /* jc1-lite main entry point */ int DEFUN (main, (argc, argv), @@ -54,43 +115,39 @@ DEFUN (main, (argc, argv), int i = 1; const char *output_file = NULL; long ft; + int opt; exec_name = argv[0]; /* Default for output */ out = stdout; - /* Process options first */ - while (argv [i]) + /* Process options first. We use getopt_long and not + getopt_long_only because we only support `--' long options here. */ + while ((opt = getopt_long (argc, argv, "o:", options, NULL)) != -1) { - if (argv [i][0] == '-') + switch (opt) { - /* Dump result into a file */ - if (!strcmp (argv [i], "-o") && i+1 < argc) - { - argv [i] = NULL; - output_file = argv [++i]; - argv [i] = NULL; - } - - /* Print the name of the class that contains main */ - else if (!strcmp (argv [i], "--print-main")) - flag_find_main = 1; - - else if (!strcmp (argv [i], "--list-filename")) - flag_list_filename = 1; - - /* List all the classes found in a source file */ - else if (!strcmp (argv [i], "--list-class")) - flag_dump_class = 1; - - else - warning ("Unrecognized argument `%s'", argv[i]); - - /* non recognized argument ignored silently */ - argv [i] = NULL; /* Nullify so it's not considered a file */ + case 0: + /* Already handled. */ + break; + + case 'o': + output_file = optarg; + break; + + case OPT_HELP: + help (); + break; + + case OPT_VERSION: + version (); + break; + + default: + usage (); + break; } - i++; } /* No flags? Do nothing */ @@ -109,7 +166,7 @@ DEFUN (main, (argc, argv), gcc_obstack_init (&temporary_obstack); java_push_parser_context (); - for ( i = 1; i < argc; i++ ) + for ( i = optind; i < argc; i++ ) if (argv [i]) { input_filename = argv [i]; @@ -136,6 +193,8 @@ DEFUN (main, (argc, argv), return 0; } + + /* Error report, memory, obstack initialization and other utility functions */ |