cleanup a bit to remove needless verify() function

This commit is contained in:
Eric Andersen 2003-05-26 18:09:14 +00:00
parent fab3e12cec
commit a2d1982841

View File

@ -55,6 +55,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <fcntl.h> #include <fcntl.h>
#include <ctype.h> #include <ctype.h>
#include <assert.h>
#include "busybox.h" #include "busybox.h"
@ -105,14 +106,10 @@ static int print_esc __P((char *escstart));
static int print_formatted __P((char *format, int argc, char **argv)); static int print_formatted __P((char *format, int argc, char **argv));
static long xstrtol __P((char *s)); static long xstrtol __P((char *s));
static unsigned long xstrtoul __P((char *s)); static unsigned long xstrtoul __P((char *s));
static void print_direc static void print_direc __P( (char *start, size_t length,
__P( int field_width, int precision, char *argument));
(char *start, size_t length, int field_width, int precision,
char *argument));
static void print_esc_char __P((int c)); static void print_esc_char __P((int c));
static void print_esc_string __P((char *str)); static void print_esc_string __P((char *str));
static void verify __P((char *s, char *end));
/* The value to return to the calling program. */ /* The value to return to the calling program. */
static int exit_status; static int exit_status;
@ -405,51 +402,51 @@ print_direc(char *start, size_t length, int field_width, int precision,
free(p); free(p);
} }
static unsigned long xstrtoul(char *s) static unsigned long xstrtoul(char *arg)
{ {
char *end; unsigned long result;
unsigned long val; char *endptr;
//int errno_save = errno;
assert(arg!=NULL);
errno = 0; errno = 0;
val = strtoul(s, &end, 0); result = strtoul(arg, &endptr, 10);
verify(s, end); if (errno != 0 || *endptr!='\0' || endptr==arg)
return val; fprintf(stderr, "%s", arg);
//errno = errno_save;
return result;
} }
static long xstrtol(char *s) static long xstrtol(char *arg)
{ {
char *end; long result;
long val; char *endptr;
//int errno_save = errno;
assert(arg!=NULL);
errno = 0; errno = 0;
val = strtol(s, &end, 0); result = strtoul(arg, &endptr, 10);
verify(s, end); if (errno != 0 || *endptr!='\0' || endptr==arg)
return val; fprintf(stderr, "%s", arg);
//errno = errno_save;
return result;
} }
static double xstrtod(char *s) static double xstrtod(char *arg)
{ {
char *end; double result;
double val; char *endptr;
//int errno_save = errno;
assert(arg!=NULL);
errno = 0; errno = 0;
val = strtod(s, &end); result = strtod(arg, &endptr);
verify(s, end); if (errno != 0 || *endptr!='\0' || endptr==arg)
return val; 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;
}
}