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/w65/run.c | |
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/w65/run.c')
-rw-r--r-- | sim/w65/run.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/sim/w65/run.c b/sim/w65/run.c index da81dd2..ad08004 100644 --- a/sim/w65/run.c +++ b/sim/w65/run.c @@ -25,7 +25,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "bfd.h" #include "sysdep.h" -extern printf(); +void usage(); +extern int optind; int main (ac, av) @@ -39,22 +40,27 @@ main (ac, av) int verbose = 0; int trace = 0; char *name = ""; - - for (i = 1; i < ac; i++) - { - if (strcmp (av[i], "-v") == 0) - { - verbose = 1; - } - else if (strcmp (av[i], "-t") == 0) - { - trace = 1; - } - else - { - name = av[i]; - } - } + + while ((i = getopt (ac, av, "tv")) != EOF) + switch (i) + { + 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); @@ -107,3 +113,10 @@ main (ac, av) return 1; } + +void +usage() +{ + fprintf (stderr, "usage: run [-tv] program\n"); + exit (1); +} |