diff options
author | J.T. Conklin <jtc@acorntoolworks.com> | 1995-03-27 18:49:58 +0000 |
---|---|---|
committer | J.T. Conklin <jtc@acorntoolworks.com> | 1995-03-27 18:49:58 +0000 |
commit | 057af5c96c91bb3e31f526c7ca1c73f3836b09ac (patch) | |
tree | 253123d27f671f46084f5b2a80364abf1d1b8ee2 /sim/h8300 | |
parent | 8b550686c0bf98fe7f040e348414a7d95c2faf64 (diff) | |
download | gdb-057af5c96c91bb3e31f526c7ca1c73f3836b09ac.zip gdb-057af5c96c91bb3e31f526c7ca1c73f3836b09ac.tar.gz gdb-057af5c96c91bb3e31f526c7ca1c73f3836b09ac.tar.bz2 |
* run.c: parse arguments with getopt().
Diffstat (limited to 'sim/h8300')
-rw-r--r-- | sim/h8300/run.c | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/sim/h8300/run.c b/sim/h8300/run.c index 49c0868..8078025 100644 --- a/sim/h8300/run.c +++ b/sim/h8300/run.c @@ -24,6 +24,10 @@ #include "sysdep.h" #include "remote-sim.h" +void usage(); +extern int optind; +extern char *optarg; + int main (ac, av) int ac; @@ -37,25 +41,31 @@ main (ac, av) int trace = 0; char *name = ""; - for (i = 1; i < ac; i++) - { - if (strcmp(av[i],"-v") == 0) - verbose++; - - else if (strcmp(av[i],"-t") == 0) - { - trace = 1; - } - else if (strcmp(av[i],"-c") == 0) - { - sim_csize(atoi(av[i+1])); - i++; - } - else if (strcmp(av[i],"-h") == 0) + while ((i = getopt (ac, av, "c:htv")) != EOF) + switch (i) + { + case 'c': + sim_csize (atoi (optarg)); + break; + case 'h': set_h8300h (1); - else - name = av[i]; - } + break; + case 't': + trace = 1; + break; + case 'v': + verbose = 1; + break; + default: + usage(); + } + ac -= optind; + av += optind; + + if (ac != 1) + usage(); + + name = *av; if (verbose) printf ("run %s\n", name); @@ -99,3 +109,10 @@ printf_filtered (va_alist) vfprintf (stdout, msg, args); va_end (args); } + +void +usage() +{ + fprintf (stderr, "usage: run [-tv] program\n"); + exit (1); +} |