From 56849bc6aade3a04eb051dc383a2091c220385c4 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Thu, 16 Feb 2017 08:14:36 +0200 Subject: [PATCH] 8322 nl: misleading-indentation Reviewed by: Jason King Reviewed by: Robert Mustacchi Approved by: Gordon Ross --- usr/src/cmd/nl/nl.c | 90 +++++++++++++++++++++-------------------------------- 1 file changed, 35 insertions(+), 55 deletions(-) diff --git a/usr/src/cmd/nl/nl.c b/usr/src/cmd/nl/nl.c index d927172e86..9c5a5f045f 100644 --- a/usr/src/cmd/nl/nl.c +++ b/usr/src/cmd/nl/nl.c @@ -28,8 +28,6 @@ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include #include #include @@ -90,9 +88,7 @@ extern char *optarg; /* getopt support */ extern int optind; int -main(argc, argv) -int argc; -char *argv[]; +main(int argc, char *argv[]) { register int j; register int i = 0; @@ -139,7 +135,7 @@ char *argv[]; while (argc > 0) { while ((c = getopt(argc, argv, - "pb:d:f:h:i:l:n:s:v:w:")) != EOF) { + "pb:d:f:h:i:l:n:s:v:w:")) != EOF) { switch (c) { case 'h': @@ -157,7 +153,7 @@ char *argv[]; (void) strcpy(pat, optarg+1); header = 'h'; hexpbuf = - compile(pat, (char *)0, (char *)0); + compile(pat, NULL, NULL); if (regerrno) regerr(regerrno); break; @@ -183,7 +179,7 @@ char *argv[]; (void) strcpy(pat, optarg+1); body = 'b'; bexpbuf = - compile(pat, (char *)0, (char *)0); + compile(pat, NULL, NULL); if (regerrno) regerr(regerrno); break; @@ -209,7 +205,7 @@ char *argv[]; (void) strcpy(pat, optarg+1); footer = 'f'; fexpbuf = - compile(pat, (char *)0, (char *)0); + compile(pat, NULL, NULL); if (regerrno) regerr(regerrno); break; @@ -337,10 +333,10 @@ for (j = 1; j < argc; j++) { } pat[r] = '\0'; header = 'h'; - hexpbuf = - compile(pat, (char *)0, (char *)0); - if (regerrno) - regerr(regerrno); + hexpbuf = + compile(pat, NULL, NULL); + if (regerrno) + regerr(regerrno); break; case '\0': header = 'n'; @@ -371,10 +367,10 @@ for (j = 1; j < argc; j++) { } pat[r] = '\0'; body = 'b'; - bexpbuf = - compile(pat, (char *)0, (char *)0); - if (regerrno) - regerr(regerrno); + bexpbuf = + compile(pat, NULL, NULL); + if (regerrno) + regerr(regerrno); break; case '\0': body = 't'; @@ -405,10 +401,10 @@ for (j = 1; j < argc; j++) { } pat[r] = '\0'; footer = 'f'; - fexpbuf = - compile(pat, (char *)0, (char *)0); - if (regerrno) - regerr(regerrno); + fexpbuf = + compile(pat, NULL, NULL); + if (regerrno) + regerr(regerrno); break; case '\0': footer = 'n'; @@ -653,20 +649,17 @@ for (j = 1; j < argc; j++) { /* REGEXP ERR ROUTINE */ static void -regerr(c) -int c; +regerr(int c) { (void) fprintf(stderr, gettext( - "nl: invalid regular expression: error code %d\n"), c); + "nl: invalid regular expression: error code %d\n"), c); exit(1); } /* CALCULATE NUMBER ROUTINE */ static void -pnum(n, sep) -int n; -char * sep; +pnum(int n, char *sep) { register int i; @@ -689,8 +682,7 @@ char * sep; /* IF NUM > 10, THEN USE THIS CALCULATE ROUTINE */ static void -num(v, p) -int v, p; +num(int v, int p) { if (v < 10) nbuf[p] = v + '0'; @@ -705,9 +697,7 @@ int v, p; #ifdef XPG4 static int -convert(c, option_arg) -int c; -char *option_arg; +convert(int c, char *option_arg) { s = option_arg; q = r = 0; @@ -726,23 +716,19 @@ char *option_arg; #else /* Solaris version */ static int -convert(argv) -char *argv; +convert(char *argv) { s = (char *)argv; q = 2; r = 0; while (s[q] != '\0') { - if (s[q] >= '0' && s[q] <= '9') - { - s1[r] = s[q]; - r++; - q++; + if (s[q] >= '0' && s[q] <= '9') { + s1[r] = s[q]; + r++; + q++; + } else { + optmsg(argv); } - else - { - optmsg(argv); - } } s1[r] = '\0'; k = atoi(s1); @@ -753,9 +739,7 @@ char *argv; /* CALCULATE NUM/TEXT SEPRATOR */ static void -npad(width, sep) - int width; - char * sep; +npad(int width, char *sep) { register int i; @@ -764,19 +748,17 @@ npad(width, sep) nbuf[i] = pad; (void) printf("%s", nbuf); - for (i = 0; i < (int) strlen(sep); i++) + for (i = 0; i < (int)strlen(sep); i++) (void) printf(" "); } #ifdef XPG4 static void -optmsg(option, option_arg) -int option; -char *option_arg; +optmsg(int option, char *option_arg) { if (option_arg != (char *)NULL) { (void) fprintf(stderr, gettext( - "nl: invalid option (-%c %s)\n"), option, option_arg); + "nl: invalid option (-%c %s)\n"), option, option_arg); } /* else getopt() will print illegal option message */ usage(); @@ -784,11 +766,9 @@ char *option_arg; #else /* Solaris version */ static void -optmsg(option) -char *option; +optmsg(char *option) { - (void) fprintf(stderr, gettext( - "nl: invalid option (%s)\n"), option); + (void) fprintf(stderr, gettext("nl: invalid option (%s)\n"), option); usage(); } #endif -- 2.11.4.GIT