shithub: scc

Download patch

ref: 382246c710d899190d9c0dbc2f971e4542ece1ff
parent: 69dcb84e15e76e302abc2e68c7d56364885c9944
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Nov 24 15:50:39 EST 2017

[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.

--- a/nm/main.c
+++ b/nm/main.c
@@ -14,6 +14,11 @@
 
 char *argv0;
 int radix = 16;
+int Pflag;
+int Aflag;
+int vflag;
+int gflag;
+int uflag;
 
 static int
 myrofile(char *fname, FILE *fp)
@@ -159,7 +164,7 @@
 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);
 }
 
@@ -166,13 +171,32 @@
 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