scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 2f447b6852197777c05333923299ae10def18c32
parent 77fc1f4d9d2c406bf920784bc8ca84a77fd90963
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 24 Nov 2017 20:50:39 +0100

[nm] Add parsing of options in command line

The options are not use at this moment, but the flags
are set and can be used in any moment.

Diffstat:
Mnm/main.c | 30+++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/nm/main.c b/nm/main.c @@ -14,6 +14,11 @@ static char sccsid[] = "@(#) ./nm/main.c"; char *argv0; int radix = 16; +int Pflag; +int Aflag; +int vflag; +int gflag; +int uflag; static int myrofile(char *fname, FILE *fp) @@ -159,20 +164,39 @@ file_error: void usage(void) { - fputs("nm [-APv][ -g| -u][-t format] file...\n", stderr); + fputs("nm [-APv][ -g| -u][-t format] [file...]\n", stderr); exit(1); } int main(int argc, char *argv[]) { + char *t; + ARGBEGIN { case 'A': + Aflag = 1; + break; case 'g': + gflag = 1; + break; case 'u': + uflag = 1; + break; case 'v': - /* case 't': */ - ; + vflag = 1; + break; + case 't': + t = EARGF(usage()); + if (!strcmp(t, "o")) + radix = 8; + else if (!strcmp(t, "d")) + radix = 10; + else if (!strcmp(t, "x")) + radix = 16; + else + usage(); + break; default: usage(); } ARGEND