aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-05-26 18:09:14 +0000
committerEric Andersen <andersen@codepoet.org>2003-05-26 18:09:14 +0000
commita2d1982841adf21442c7574e784a45324e7f1db5 (patch)
tree72520d9a5d900f4ec220283608fe513e7bf26e43
parentfab3e12cec54854ec1e94ddd500a1b7ed23fb1c3 (diff)
downloadbusybox-w32-a2d1982841adf21442c7574e784a45324e7f1db5.tar.gz
busybox-w32-a2d1982841adf21442c7574e784a45324e7f1db5.tar.bz2
busybox-w32-a2d1982841adf21442c7574e784a45324e7f1db5.zip
cleanup a bit to remove needless verify() function
-rw-r--r--coreutils/printf.c75
1 files changed, 36 insertions, 39 deletions
diff --git a/coreutils/printf.c b/coreutils/printf.c
index 9602788de..28f8aa45c 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -55,6 +55,7 @@
55#include <stdlib.h> 55#include <stdlib.h>
56#include <fcntl.h> 56#include <fcntl.h>
57#include <ctype.h> 57#include <ctype.h>
58#include <assert.h>
58#include "busybox.h" 59#include "busybox.h"
59 60
60 61
@@ -105,14 +106,10 @@ static int print_esc __P((char *escstart));
105static int print_formatted __P((char *format, int argc, char **argv)); 106static int print_formatted __P((char *format, int argc, char **argv));
106static long xstrtol __P((char *s)); 107static long xstrtol __P((char *s));
107static unsigned long xstrtoul __P((char *s)); 108static unsigned long xstrtoul __P((char *s));
108static void print_direc 109static void print_direc __P( (char *start, size_t length,
109__P( 110 int field_width, int precision, char *argument));
110
111 (char *start, size_t length, int field_width, int precision,
112 char *argument));
113static void print_esc_char __P((int c)); 111static void print_esc_char __P((int c));
114static void print_esc_string __P((char *str)); 112static void print_esc_string __P((char *str));
115static void verify __P((char *s, char *end));
116 113
117/* The value to return to the calling program. */ 114/* The value to return to the calling program. */
118static int exit_status; 115static int exit_status;
@@ -405,51 +402,51 @@ print_direc(char *start, size_t length, int field_width, int precision,
405 free(p); 402 free(p);
406} 403}
407 404
408static unsigned long xstrtoul(char *s) 405static unsigned long xstrtoul(char *arg)
409{ 406{
410 char *end; 407 unsigned long result;
411 unsigned long val; 408 char *endptr;
409 //int errno_save = errno;
410
411 assert(arg!=NULL);
412 412
413 errno = 0; 413 errno = 0;
414 val = strtoul(s, &end, 0); 414 result = strtoul(arg, &endptr, 10);
415 verify(s, end); 415 if (errno != 0 || *endptr!='\0' || endptr==arg)
416 return val; 416 fprintf(stderr, "%s", arg);
417 //errno = errno_save;
418 return result;
417} 419}
418 420
419static long xstrtol(char *s) 421static long xstrtol(char *arg)
420{ 422{
421 char *end; 423 long result;
422 long val; 424 char *endptr;
425 //int errno_save = errno;
426
427 assert(arg!=NULL);
423 428
424 errno = 0; 429 errno = 0;
425 val = strtol(s, &end, 0); 430 result = strtoul(arg, &endptr, 10);
426 verify(s, end); 431 if (errno != 0 || *endptr!='\0' || endptr==arg)
427 return val; 432 fprintf(stderr, "%s", arg);
433 //errno = errno_save;
434 return result;
428} 435}
429 436
430static double xstrtod(char *s) 437static double xstrtod(char *arg)
431{ 438{
432 char *end; 439 double result;
433 double val; 440 char *endptr;
441 //int errno_save = errno;
442
443 assert(arg!=NULL);
434 444
435 errno = 0; 445 errno = 0;
436 val = strtod(s, &end); 446 result = strtod(arg, &endptr);
437 verify(s, end); 447 if (errno != 0 || *endptr!='\0' || endptr==arg)
438 return val; 448 fprintf(stderr, "%s", arg);
449 //errno = errno_save;
450 return result;
439} 451}
440 452
441static void verify(char *s, char *end)
442{
443 if (errno) {
444 fprintf(stderr, "%s", s);
445 exit_status = 1;
446 } else if (*end) {
447 /*
448 if (s == end)
449 fprintf(stderr, "%s: expected numeric", s);
450 else
451 fprintf(stderr, "%s: not completely converted", s);
452 */
453 exit_status = 1;
454 }
455}