* run.c: parse arguments with getopt().

This commit is contained in:
J.T. Conklin 1995-03-27 18:49:58 +00:00
parent 8b550686c0
commit 057af5c96c
4 changed files with 112 additions and 67 deletions

View file

@ -24,6 +24,10 @@
#include "sysdep.h" #include "sysdep.h"
#include "remote-sim.h" #include "remote-sim.h"
void usage();
extern int optind;
extern char *optarg;
int int
main (ac, av) main (ac, av)
int ac; int ac;
@ -37,25 +41,31 @@ main (ac, av)
int trace = 0; int trace = 0;
char *name = ""; char *name = "";
for (i = 1; i < ac; i++) while ((i = getopt (ac, av, "c:htv")) != EOF)
{ switch (i)
if (strcmp(av[i],"-v") == 0) {
verbose++; case 'c':
sim_csize (atoi (optarg));
else if (strcmp(av[i],"-t") == 0) break;
{ case 'h':
trace = 1;
}
else if (strcmp(av[i],"-c") == 0)
{
sim_csize(atoi(av[i+1]));
i++;
}
else if (strcmp(av[i],"-h") == 0)
set_h8300h (1); set_h8300h (1);
else break;
name = av[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) if (verbose)
printf ("run %s\n", name); printf ("run %s\n", name);
@ -99,3 +109,10 @@ printf_filtered (va_alist)
vfprintf (stdout, msg, args); vfprintf (stdout, msg, args);
va_end (args); va_end (args);
} }
void
usage()
{
fprintf (stderr, "usage: run [-tv] program\n");
exit (1);
}

View file

@ -1,7 +1,7 @@
/* run front end support for H8/500 /* run front end support for SH
Copyright (C) 1987, 1992 Free Software Foundation, Inc. Copyright (C) 1987, 1992 Free Software Foundation, Inc.
This file is part of H8300 SIM This file is part of SH SIM
GNU CC is free software; you can redistribute it and/or modify GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -27,6 +27,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "sysdep.h" #include "sysdep.h"
#include "remote-sim.h" #include "remote-sim.h"
void usage();
extern int optind;
extern char *optarg;
int target_byte_order; int target_byte_order;
int int
@ -42,36 +46,35 @@ main (ac, av)
int trace = 0; int trace = 0;
char *name = ""; char *name = "";
for (i = 1; i < ac; i++) while ((i = getopt (ac, av, "m:p:s:tv")) != EOF)
{ switch (i)
if (strcmp (av[i], "-v") == 0) {
{ case 'm':
verbose = 1; sim_size (atoi (optarg));
} break;
else if (strcmp (av[i], "-t") == 0) case 'p':
{ sim_set_profile (atoi (optarg));
trace = 1; break;
} case 's':
else if (strcmp (av[i], "-p") == 0) sim_set_profile_size (atoi (optarg));
{ break;
sim_set_profile (atoi (av[i + 1])); case 't':
i++; trace = 1;
} break;
else if (strcmp (av[i], "-s") == 0) case 'v':
{ verbose = 1;
sim_set_profile_size (atoi (av[i + 1])); break;
i++; default:
} usage();
else if (strcmp (av[i], "-m") == 0) }
{ ac -= optind;
sim_size (atoi (av[i + 1])); av += optind;
i++;
} if (ac != 1)
else usage();
{
name = av[i]; name = *av;
}
}
if (verbose) if (verbose)
{ {
printf ("run %s\n", name); printf ("run %s\n", name);
@ -126,6 +129,14 @@ main (ac, av)
return 1; return 1;
} }
void
usage()
{
fprintf (stderr, "usage: run [-tv] program\n");
exit (1);
}
/* Callbacks used by the simulator proper. */ /* Callbacks used by the simulator proper. */

View file

@ -1,3 +1,7 @@
Mon Mar 27 10:32:34 1995 J.T. Conklin <jtc@rtl.cygnus.com>
* run.c: parse arguments with getopt().
Tue Feb 28 17:31:36 1995 Ian Lance Taylor <ian@cygnus.com> Tue Feb 28 17:31:36 1995 Ian Lance Taylor <ian@cygnus.com>
* configure.in: Use ../../bfd/hosts/std-host.h if specific * configure.in: Use ../../bfd/hosts/std-host.h if specific

View file

@ -25,7 +25,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "bfd.h" #include "bfd.h"
#include "sysdep.h" #include "sysdep.h"
extern printf(); void usage();
extern int optind;
int int
main (ac, av) main (ac, av)
@ -39,22 +40,27 @@ main (ac, av)
int verbose = 0; int verbose = 0;
int trace = 0; int trace = 0;
char *name = ""; char *name = "";
for (i = 1; i < ac; i++) while ((i = getopt (ac, av, "tv")) != EOF)
{ switch (i)
if (strcmp (av[i], "-v") == 0) {
{ case 't':
verbose = 1; trace = 1;
} break;
else if (strcmp (av[i], "-t") == 0) case 'v':
{ verbose = 1;
trace = 1; break;
} default:
else usage();
{ }
name = av[i]; ac -= optind;
} av += optind;
}
if (ac != 1)
usage();
name = *av;
if (verbose) if (verbose)
{ {
printf ("run %s\n", name); printf ("run %s\n", name);
@ -107,3 +113,10 @@ main (ac, av)
return 1; return 1;
} }
void
usage()
{
fprintf (stderr, "usage: run [-tv] program\n");
exit (1);
}