coreutils
[Top][All Lists]
Advanced

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

Re: suggested feautre: "date --debug" - print date parsing diagnostics


From: Pádraig Brady
Subject: Re: suggested feautre: "date --debug" - print date parsing diagnostics
Date: Thu, 8 Sep 2016 12:42:24 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

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

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