summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1995-01-27 05:22:23 +0000
committerJim Meyering <jim@meyering.net>1995-01-27 05:22:23 +0000
commitb554fee4014e41b73937931d95d6174de4cc5c01 (patch)
tree515d4af89e4d0c7bbdd66af4669c68c335cfe939 /lib
parent293530a4c8bceea8fc6c96fef3b4356538cf82a2 (diff)
downloadcoreutils-b554fee4014e41b73937931d95d6174de4cc5c01.tar.xz
.
Diffstat (limited to 'lib')
-rw-r--r--lib/getdate.y4
-rw-r--r--lib/strtod.c5
-rw-r--r--lib/xstrtol.c1
-rw-r--r--lib/xstrtol.h17
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_ */