From 2479445562a9b5a9f226d0b00c41dbd533e63213 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Sat, 6 Mar 2004 22:11:45 +0000 Subject: Fix/eliminate use of atol --- coreutils/printf.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'coreutils') diff --git a/coreutils/printf.c b/coreutils/printf.c index 181c70bfb..76f59686b 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; } -- cgit v1.2.3