diff options
| author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-05-26 18:09:14 +0000 |
|---|---|---|
| committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-05-26 18:09:14 +0000 |
| commit | 89b716e5482ad9c365633ddde2ca565cd06c6bdd (patch) | |
| tree | 72520d9a5d900f4ec220283608fe513e7bf26e43 | |
| parent | b8272edab77fb93498e54b48deec0ee326b00778 (diff) | |
| download | busybox-w32-89b716e5482ad9c365633ddde2ca565cd06c6bdd.tar.gz busybox-w32-89b716e5482ad9c365633ddde2ca565cd06c6bdd.tar.bz2 busybox-w32-89b716e5482ad9c365633ddde2ca565cd06c6bdd.zip | |
cleanup a bit to remove needless verify() function
git-svn-id: svn://busybox.net/trunk/busybox@6857 69ca8d6d-28ef-0310-b511-8ec308f3f277
| -rw-r--r-- | coreutils/printf.c | 75 |
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)); | |||
| 105 | static int print_formatted __P((char *format, int argc, char **argv)); | 106 | static int print_formatted __P((char *format, int argc, char **argv)); |
| 106 | static long xstrtol __P((char *s)); | 107 | static long xstrtol __P((char *s)); |
| 107 | static unsigned long xstrtoul __P((char *s)); | 108 | static unsigned long xstrtoul __P((char *s)); |
| 108 | static void print_direc | 109 | static 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)); | ||
| 113 | static void print_esc_char __P((int c)); | 111 | static void print_esc_char __P((int c)); |
| 114 | static void print_esc_string __P((char *str)); | 112 | static void print_esc_string __P((char *str)); |
| 115 | static 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. */ |
| 118 | static int exit_status; | 115 | static 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 | ||
| 408 | static unsigned long xstrtoul(char *s) | 405 | static 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 | ||
| 419 | static long xstrtol(char *s) | 421 | static 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 | ||
| 430 | static double xstrtod(char *s) | 437 | static 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 | ||
| 441 | static 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 | } | ||
