bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getdate broken on FreeBSD/arm; catch this at compile-time


From: Paul Eggert
Subject: getdate broken on FreeBSD/arm; catch this at compile-time
Date: Mon, 18 Jun 2007 16:24:36 -0700
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)

Xin Li reports in
<http://lists.gnu.org/archive/html/bug-gnu-utils/2007-06/msg00091.html>
that FreeBSD/arm has a time_t that is wider than long int.  This
configuration breaks the mktime and getdate modules of gnulib, but the
problem is caught at compile-time only by mktime.  I installed the
following so that getdate can catch it too.

Of course it'd be nicer if gnulib code works even on that unusual
configuration, but that can be put off until someone finds the time to
do the port.

2007-06-18  Paul Eggert  <address@hidden>

        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.

Index: modules/getdate
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/getdate,v
retrieving revision 1.16
diff -u -p -r1.16 getdate
--- modules/getdate     12 Feb 2007 18:49:19 -0000      1.16
+++ modules/getdate     18 Jun 2007 23:09:08 -0000
@@ -12,9 +12,11 @@ m4/getdate.m4
 Depends-on:
 stdbool
 gettime
+intprops
 mktime
 setenv
 time
+verify
 xalloc

 configure.ac:
Index: lib/getdate.y
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/getdate.y,v
retrieving revision 1.108
diff -u -p -r1.108 getdate.y
--- lib/getdate.y       23 Feb 2007 18:25:21 -0000      1.108
+++ lib/getdate.y       18 Jun 2007 23:09:08 -0000
@@ -35,7 +35,10 @@
 #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.  */
@@ -107,6 +110,13 @@

 #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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]