summaryrefslogtreecommitdiff
path: root/coreutils/printf.c
diff options
context:
space:
mode:
authorEric Andersen2004-03-06 22:11:45 +0000
committerEric Andersen2004-03-06 22:11:45 +0000
commit2479445562a9b5a9f226d0b00c41dbd533e63213 (patch)
treee4891420283c085d688683a41cc217dc896917b8 /coreutils/printf.c
parentc4db0833a6c91dd3714bec1db076a80910af6e30 (diff)
downloadbusybox-2479445562a9b5a9f226d0b00c41dbd533e63213.zip
busybox-2479445562a9b5a9f226d0b00c41dbd533e63213.tar.gz
Fix/eliminate use of atol
Diffstat (limited to 'coreutils/printf.c')
-rw-r--r--coreutils/printf.c30
1 files changed, 3 insertions, 27 deletions
diff --git a/coreutils/printf.c b/coreutils/printf.c
index 181c70b..76f5968 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -405,48 +405,24 @@ print_direc(char *start, size_t length, int field_width, int precision,
static unsigned long xstrtoul(char *arg)
{
unsigned long result;
- char *endptr;
- //int errno_save = errno;
-
- assert(arg!=NULL);
-
- errno = 0;
- result = strtoul(arg, &endptr, 0);
- if (errno != 0 || *endptr!='\0' || endptr==arg)
+ if (safe_strtoul(arg, &result))
fprintf(stderr, "%s", arg);
- //errno = errno_save;
return result;
}
static long xstrtol(char *arg)
{
long result;
- char *endptr;
- //int errno_save = errno;
-
- assert(arg!=NULL);
-
- errno = 0;
- result = strtoul(arg, &endptr, 0);
- if (errno != 0 || *endptr!='\0' || endptr==arg)
+ if (safe_strtol(arg, &result))
fprintf(stderr, "%s", arg);
- //errno = errno_save;
return result;
}
static double xstrtod(char *arg)
{
double result;
- char *endptr;
- //int errno_save = errno;
-
- assert(arg!=NULL);
-
- errno = 0;
- result = strtod(arg, &endptr);
- if (errno != 0 || *endptr!='\0' || endptr==arg)
+ if (safe_strtod(arg, &result))
fprintf(stderr, "%s", arg);
- //errno = errno_save;
return result;
}