svn commit: trunk/busybox/libbb

vda at busybox.net vda at busybox.net
Tue Dec 11 13:15:15 UTC 2007


Author: vda
Date: 2007-12-11 05:15:11 -0800 (Tue, 11 Dec 2007)
New Revision: 20637

Log:
num conversions: allow for leading '+' (renice needs that)



Modified:
   trunk/busybox/libbb/xatonum_template.c


Changeset:
Modified: trunk/busybox/libbb/xatonum_template.c
===================================================================
--- trunk/busybox/libbb/xatonum_template.c	2007-12-10 08:40:29 UTC (rev 20636)
+++ trunk/busybox/libbb/xatonum_template.c	2007-12-11 13:15:11 UTC (rev 20637)
@@ -21,9 +21,8 @@
 	int old_errno;
 	char *e;
 
-	/* Disallow '-' and any leading whitespace.  Speed isn't critical here
-	 * since we're parsing commandline args.  So make sure we get the
-	 * actual isspace function rather than a lnumstrer macro implementaion. */
+	/* Disallow '-' and any leading whitespace. Make sure we get the
+	 * actual isspace function rather than a macro implementaion. */
 	if (*numstr == '-' || *numstr == '+' || (isspace)(*numstr))
 		goto inval;
 
@@ -127,9 +126,12 @@
 	type r;
 	const char *p = numstr;
 
-	if (p[0] == '-') {
+	/* NB: if you'll decide to disallow '+':
+	 * at least renice applet needs to allow it */
+	if (p[0] == '+' || p[0] == '-') {
 		++p;
-		++u;	/* two's complement */
+		if (p[0] == '-')
+			++u; /* = <type>_MIN (01111... + 1 == 10000...) */
 	}
 
 	r = xstrtou(_range_sfx)(p, base, 0, u, suffixes);




More information about the busybox-cvs mailing list