coreutils

General Software Utilities
git clone http://git.omkov.net/coreutils
Log | Tree | Refs | README | LICENCE | Download

AuthorJamozed <[email protected]>
Date2021-02-22 00:01:57
Commita3ab15f487b316c6907b74cfcb8239d4ef2191fd
Parentf072a5b059f337d8d5ed986b4d7f5268b8edee1c

nice: Update formatting

Diffstat

M src/nice.c | 16 ++++++++--------

1 files changed, 8 insertions, 8 deletions

diff --git a/src/nice.c b/src/nice.c
index 45394a6..bb26a1c 100644
--- a/src/nice.c
+++ b/src/nice.c
@@ -57,15 +57,13 @@ int main(int ac, char *av[]) { A0 = av[0];
 	struct opt opt = OPTGET_INIT; opt.str = "n:"; opt.lops = lops;
 	for (int o; (o = optget(&opt, av, 0)) != -1;) switch (o) {
 	case 'n': {
-		register int d; register char *p = opt.arg; bool neg = false;
-		if (*p == '-') { neg = true; ++p; } else if (*p == '+') { ++p; }
-		for (n = 0; *p >= '0' && *p <= '9'; ++p) {
-			d = (int)*p - '0';
-			if (n > (INT_MAX - d) / 10) { break; }
-			n = n * 10 + d;
+		register char *s = opt.arg; register int c; bool neg = false;
+		if (*s == '+') { ++s; } else if (*s == '-') { ++s; neg = true; }
+		for (n = 0; *s >= '0' && *s <= '9'; ++s) { c = *s - '0';
+			if (n > (INT_MAX - c) / 10) { break; } n = n * 10 + c;
 		}
 
-		if (*p) { error(1, "%s: invalid nice value", opt.arg); }
+		if (*s) { error(1, "%s: invalid nice value", opt.arg); }
 		if (neg) { n = -n; } break;
 	}
 	case 256: { hlp(); return 0; }
@@ -74,7 +72,7 @@ int main(int ac, char *av[]) { A0 = av[0];
 	}
 
 	if (ac == 1) { printf("%d\n", nice(0)); return 0; }
-	else if (opt.ind == ac) { error(1, "missing operand\n"); }
+	else if (opt.ind == ac) { error(1, "missing operand"); }
 
 	errno = 0; nice(n); if (errno) { warn("%s", serr()); }
 	execvp(av[opt.ind], &av[opt.ind]);
@@ -83,6 +81,7 @@ int main(int ac, char *av[]) { A0 = av[0];
 	return errno = ENOENT ? 127 : 126;
 }
 
+/* Print help information */
 static void hlp(void) {
 	puts("nice - invoke with an altered nice value\n");
 	puts("usage: nice [-n increment] [command [argument...]]\n");
@@ -93,6 +92,7 @@ static void hlp(void) {
 	return;
 }
 
+/* Print version information */
 static void ver(void) {
 	puts("OMKOV coreutils nice, version " VERSION);
 	puts("Copyright (C) 2020, Jakob Wakeling");