On 08/09/16 06:06, Assaf Gordon wrote:
> 
>> On 08/20/2016 09:38 PM, Assaf Gordon wrote:
>>> With gnulib updated (
>>> https://lists.gnu.org/archive/html/bug-gnulib/2016-08/msg00051.html
>>> ), the corresponding coreutils' patch for "date --debug" is
>>> attached.
>>
>> I'll push it tomorrow if there are no objections.
> 
> Pushed in:
> http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=c6389a1340cdc2a74dbbba5db13df009ada3c04c

Thanks a lot for completing this useful feature.

I noticed a small issue where random data was output
if all data was parsed, but the date was still invalid.
You can see this with `date --debug -d 'now +1'`

Is the following OK to push to gnulib?

diff --git a/lib/parse-datetime.y b/lib/parse-datetime.y
index 152cb41..9978955 100644
--- a/lib/parse-datetime.y
+++ b/lib/parse-datetime.y
@@ -1704,6 +1704,7 @@ parse_datetime2 (struct timespec *result, char const *p,
   bool ok = true;
   char dbg_ord[DBGBUFSIZE];
   char dbg_tm[DBGBUFSIZE];
+  char const *input_sentinel = p + strlen (p);

   if (! now)
     {
@@ -1862,7 +1863,15 @@ parse_datetime2 (struct timespec *result, char const *p,
   if (yyparse (&pc) != 0)
     {
       if (pc.parse_datetime_debug)
-        dbg_printf (_("error: parsing failed, stopped at '%s'\n"), pc.input);
+        {
+          if (input_sentinel <= pc.input)
+            dbg_printf (_("error: parsing failed\n"), pc.input);
+          else
+            {
+              dbg_printf (_("error: parsing failed, stopped at '%s'\n"),
+                          pc.input);
+            }
+         }
       goto fail;
     }


Reply via email to