diff options
-rw-r--r-- | lib/getdate.y | 4 | ||||
-rw-r--r-- | lib/strtod.c | 5 | ||||
-rw-r--r-- | lib/xstrtol.c | 1 | ||||
-rw-r--r-- | lib/xstrtol.h | 17 |
4 files changed, 21 insertions, 6 deletions
diff --git a/lib/getdate.y b/lib/getdate.y index 77d63a9e9..8f0872d72 100644 --- a/lib/getdate.y +++ b/lib/getdate.y @@ -585,10 +585,14 @@ ToSeconds (Hours, Minutes, Seconds, Meridian) case MERam: if (Hours < 1 || Hours > 12) return -1; + if (Hours == 12) + Hours = 0; return (Hours * 60L + Minutes) * 60L + Seconds; case MERpm: if (Hours < 1 || Hours > 12) return -1; + if (Hours == 12) + Hours = 0; return ((Hours + 12) * 60L + Minutes) * 60L + Seconds; default: abort (); diff --git a/lib/strtod.c b/lib/strtod.c index 2f6b894cf..0d364f238 100644 --- a/lib/strtod.c +++ b/lib/strtod.c @@ -19,6 +19,10 @@ #endif #include <errno.h> +#ifndef errno +extern int errno; +#endif + #include <ctype.h> #include <math.h> @@ -34,7 +38,6 @@ #include <string.h> #else #define NULL 0 -extern int errno; #ifndef HUGE_VAL #define HUGE_VAL HUGE #endif diff --git a/lib/xstrtol.c b/lib/xstrtol.c index a7386343f..383225233 100644 --- a/lib/xstrtol.c +++ b/lib/xstrtol.c @@ -98,6 +98,7 @@ __xstrtol (s, ptr, base, val, valid_suffixes) ++(*p); break; + case 'B': case 'k': BKM_SCALE (tmp, 1024, LONGINT_OVERFLOW); ++(*p); diff --git a/lib/xstrtol.h b/lib/xstrtol.h index 45043d01d..ff44d6bec 100644 --- a/lib/xstrtol.h +++ b/lib/xstrtol.h @@ -27,9 +27,9 @@ typedef enum strtol_error strtol_error; strtol_error __xstrtol __P ((const char *s, char **ptr, int base, - __unsigned long int *val, int allow_bkm_suffix)); + __unsigned long int *val, const char *valid_suffixes)); -#define STRTOL_FATAL_ERROR(str, argument_type_string, err) \ +#define _STRTOL_ERROR(exit_code, str, argument_type_string, err) \ do \ { \ switch ((err)) \ @@ -38,20 +38,27 @@ strtol_error abort (); \ \ case LONGINT_INVALID: \ - error (2, 0, "invalid %s `%s'", (argument_type_string), (str));\ + error ((exit_code), 0, "invalid %s `%s'", \ + (argument_type_string), (str)); \ break; \ \ case LONGINT_INVALID_SUFFIX_CHAR: \ - error (2, 0, "invalid character following %s `%s'", \ + error ((exit_code), 0, "invalid character following %s `%s'", \ (argument_type_string), (str)); \ break; \ \ case LONGINT_OVERFLOW: \ - error (2, 0, "%s `%s' larger than maximum long int", \ + error ((exit_code), 0, "%s `%s' larger than maximum long int",\ (argument_type_string), (str)); \ break; \ } \ } \ while (0) +#define STRTOL_FATAL_ERROR(str, argument_type_string, err) \ + _STRTOL_ERROR (2, str, argument_type_string, err) + +#define STRTOL_FAIL_WARN(str, argument_type_string, err) \ + _STRTOL_ERROR (0, str, argument_type_string, err) + #endif /* _xstrtol_h_ */ |