Import upstream version 1.29
[debian/tar] / gnu / parse-datetime.c
index 972632eb3243a74fd6f887bf0a6592b9aded3c14..21317c3c07ebc022ee8de919c357962e0690882b 100644 (file)
@@ -70,7 +70,7 @@
 
 /* Parse a string into an internal time stamp.
 
-   Copyright (C) 1999-2000, 2002-2013 Free Software Foundation, Inc.
+   Copyright (C) 1999-2000, 2002-2015 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -3024,7 +3024,7 @@ lookup_word (parser_control const *pc, char *word)
 }
 
 static int
-yylex (YYSTYPE *lvalp, parser_control *pc)
+yylex (union YYSTYPE *lvalp, parser_control *pc)
 {
   unsigned char c;
   size_t count;
@@ -3154,7 +3154,7 @@ yylex (YYSTYPE *lvalp, parser_control *pc)
 
           do
             {
-              if (p - buff < sizeof buff - 1)
+              if (p < buff + sizeof buff - 1)
                 *p++ = c;
               c = *++pc->input;
             }
@@ -3296,8 +3296,6 @@ parse_datetime (struct timespec *result, char const *p,
             char tz1buf[TZBUFSIZE];
             bool large_tz = TZBUFSIZE < tzsize;
             bool setenv_ok;
-            /* Free tz0, in case this is the 2nd or subsequent time through. */
-            free (tz0);
             tz0 = get_tz (tz0buf);
             z = tz1 = large_tz ? xmalloc (tzsize) : tz1buf;
             for (s = tzbase; *s != '"'; s++)
@@ -3309,7 +3307,12 @@ parse_datetime (struct timespec *result, char const *p,
             if (!setenv_ok)
               goto fail;
             tz_was_altered = true;
+
             p = s + 1;
+            while (c = *p, c_isspace (c))
+              p++;
+
+            break;
           }
     }