Treat an empty date string exactly like "0".
authorJim Meyering <meyering@redhat.com>
Wed, 31 Oct 2007 19:32:07 +0000 (20:32 +0100)
committerJim Meyering <meyering@redhat.com>
Wed, 31 Oct 2007 23:57:30 +0000 (00:57 +0100)
* lib/getdate.y (get_date): Once any isspace or TZ= prefix is consumed,
if the remaining date string (to be parsed) is empty, use "0".
Reported by Mischa Molhoek and discussed in this thread:
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/11726>.

ChangeLog
lib/getdate.y

index d3b165205dcf5b4f6ab5ac2ca10856a1405c2d30..c5348926b95c1f943f210a3b1b899ce511fb9485 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-11-01  Jim Meyering  <meyering@redhat.com>
+
+       Treat an empty date string exactly like "0".
+       * lib/getdate.y (get_date): Once any isspace or TZ= prefix is consumed,
+       if the remaining date string (to be parsed) is empty, use "0".
+       Reported by Mischa Molhoek and discussed in this thread:
+       <http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/11726>.
+
 2007-10-31  Bruno Haible  <bruno@clisp.org>
 
        * m4/intmax_t.m4 (gl_AC_TYPE_INTMAX_T, gt_AC_TYPE_INTMAX_T): Use
index 80e484d2fef20b261e442fb05cf55767867517f7..591c7f0fcae1cbfc2c79b5a336c7e00f9f9e3aff 100644 (file)
@@ -1238,6 +1238,12 @@ get_date (struct timespec *result, char const *p, struct timespec const *now)
          }
     }
 
+  /* As documented, be careful to treat the empty string just like
+     a date string of "0".  Without this, an empty string would be
+     declared invalid when parsed during a DST transition.  */
+  if (*p == '\0')
+    p = "0";
+
   pc.input = p;
   pc.year.value = tmp->tm_year;
   pc.year.value += TM_YEAR_BASE;