Detect porting problems to FreeBSD/arm, which has time_t wider than
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 18 Jun 2007 23:09:12 +0000 (23:09 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 18 Jun 2007 23:09:12 +0000 (23:09 +0000)
long int.  Original problem reported for GNU diff by Xin Li in
<http://lists.gnu.org/archive/html/bug-gnu-utils/2007-06/msg00091.html>.
* modules/getdate (Depends-on): Add intprops, verify.
* lib/getdate.y: Include intprops.h, verify.h.  Verify that time_t
is an integer type no wider than long int.

ChangeLog
lib/getdate.y
modules/getdate

index 12fd89f5bc3b0107c21ccf5b41686d89bc81993c..5fe1932a02444e58b02eef05ccc27686a9777544 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-06-18  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Detect porting problems to FreeBSD/arm, which has time_t wider than
+       long int.  Original problem reported for GNU diff by Xin Li in
+       <http://lists.gnu.org/archive/html/bug-gnu-utils/2007-06/msg00091.html>.
+       * modules/getdate (Depends-on): Add intprops, verify.
+       * lib/getdate.y: Include intprops.h, verify.h.  Verify that time_t
+       is an integer type no wider than long int.
+
 2007-06-18  Jim Meyering  <jim@meyering.net>
 
        New module: mreadlink-with-size.
index cbf3ca104aa877d3192335843f03cc3f723aa335..e34f4a942eef3318c735256ef04af0d5a00b0eb9 100644 (file)
 #include <config.h>
 
 #include "getdate.h"
+
+#include "intprops.h"
 #include "timespec.h"
+#include "verify.h"
 
 /* There's no need to extend the stack, so there's no need to involve
    alloca.  */
 
 #define HOUR(x) ((x) * 60)
 
+/* Lots of this code assumes time_t and time_t-like values fit into
+   long int.  It also assumes that signed integer overflow silently
+   wraps around, but there's no portable way to check for that at
+   compile-time.  */
+verify (TYPE_IS_INTEGER (time_t));
+verify (LONG_MIN <= TYPE_MINIMUM (time_t) && TYPE_MAXIMUM (time_t) <= LONG_MAX);
+
 /* An integer value, and the number of digits in its textual
    representation.  */
 typedef struct
index 653fd7a53cedc51182bde3b946cab7506da360d5..88b51af37c40495395072b6c277d86c3823052eb 100644 (file)
@@ -12,9 +12,11 @@ m4/getdate.m4
 Depends-on:
 stdbool
 gettime
+intprops
 mktime
 setenv
 time
+verify
 xalloc
 
 configure.ac: