[BusyBox-cvs] busybox/coreutils printf.c,1.18,1.19

Erik Andersen andersen at busybox.net
Mon May 26 18:09:17 UTC 2003


Update of /var/cvs/busybox/coreutils
In directory winder:/tmp/cvs-serv12833/coreutils

Modified Files:
	printf.c 
Log Message:
cleanup a bit to remove needless verify() function


Index: printf.c
===================================================================
RCS file: /var/cvs/busybox/coreutils/printf.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- printf.c	19 Mar 2003 09:11:33 -0000	1.18
+++ printf.c	26 May 2003 18:09:14 -0000	1.19
@@ -55,6 +55,7 @@
 #include <stdlib.h>
 #include <fcntl.h>
 #include <ctype.h>
+#include <assert.h>
 #include "busybox.h"
 
 
@@ -105,14 +106,10 @@
 static int print_formatted __P((char *format, int argc, char **argv));
 static long xstrtol __P((char *s));
 static unsigned long xstrtoul __P((char *s));
-static void print_direc
-__P(
-
-	(char *start, size_t length, int field_width, int precision,
-	 char *argument));
+static void print_direc __P( (char *start, size_t length, 
+			int field_width, int precision, char *argument));
 static void print_esc_char __P((int c));
 static void print_esc_string __P((char *str));
-static void verify __P((char *s, char *end));
 
 /* The value to return to the calling program.  */
 static int exit_status;
@@ -405,51 +402,51 @@
 	free(p);
 }
 
-static unsigned long xstrtoul(char *s)
+static unsigned long xstrtoul(char *arg)
 {
-	char *end;
-	unsigned long val;
+	unsigned long result;
+	char *endptr;
+	//int errno_save = errno;
+
+	assert(arg!=NULL);
 
 	errno = 0;
-	val = strtoul(s, &end, 0);
-	verify(s, end);
-	return val;
+	result = strtoul(arg, &endptr, 10);
+	if (errno != 0 || *endptr!='\0' || endptr==arg)
+		fprintf(stderr, "%s", arg);
+	//errno = errno_save;
+	return result;
 }
 
-static long xstrtol(char *s)
+static long xstrtol(char *arg)
 {
-	char *end;
-	long val;
+	long result;
+	char *endptr;
+	//int errno_save = errno;
+
+	assert(arg!=NULL);
 
 	errno = 0;
-	val = strtol(s, &end, 0);
-	verify(s, end);
-	return val;
+	result = strtoul(arg, &endptr, 10);
+	if (errno != 0 || *endptr!='\0' || endptr==arg)
+		fprintf(stderr, "%s", arg);
+	//errno = errno_save;
+	return result;
 }
 
-static double xstrtod(char *s)
+static double xstrtod(char *arg)
 {
-	char *end;
-	double val;
+	double result;
+	char *endptr;
+	//int errno_save = errno;
+
+	assert(arg!=NULL);
 
 	errno = 0;
-	val = strtod(s, &end);
-	verify(s, end);
-	return val;
+	result = strtod(arg, &endptr);
+	if (errno != 0 || *endptr!='\0' || endptr==arg)
+		fprintf(stderr, "%s", arg);
+	//errno = errno_save;
+	return result;
 }
 
-static void verify(char *s, char *end)
-{
-	if (errno) {
-		fprintf(stderr, "%s", s);
-		exit_status = 1;
-	} else if (*end) {
-		/*
-		   if (s == end)
-		   fprintf(stderr, "%s: expected numeric", s);
-		   else
-		   fprintf(stderr, "%s: not completely converted", s);
-		 */
-		exit_status = 1;
-	}
-}



More information about the busybox-cvs mailing list