Print this page
3141 strptime() doesn't support %t

@@ -1,6 +1,7 @@
 /*
+ * Copyright (c) 2014 Gary Mills
  * Copyright 2011, Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 1994 Powerdog Industries.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

@@ -213,13 +214,10 @@
                                 if (i > 60)
                                         return (NULL);
                                 tm->tm_sec = i;
                         }
 
-                        if (isspace(*buf))
-                                while (*ptr != 0 && !isspace(*ptr))
-                                        ptr++;
                         break;
 
                 case 'H':
                 case 'I':
                 case 'k':

@@ -247,13 +245,10 @@
                         } else if (i > 12)
                                 return (NULL);
 
                         tm->tm_hour = i;
 
-                        if (isspace(*buf))
-                                while (*ptr != 0 && !isspace(*ptr))
-                                        ptr++;
                         break;
 
                 case 'p':
                         /*
                          * XXX This is bogus if parsed before hour-related

@@ -317,13 +312,10 @@
                                 len--;
                         }
                         if (i > 53)
                                 return (NULL);
 
-                        if (isspace(*buf))
-                                while (*ptr != 0 && !isspace(*ptr))
-                                        ptr++;
                         break;
 
                 case 'w':
                         if (!isdigit(*buf))
                                 return (NULL);

@@ -332,24 +324,20 @@
                         if (i > 6)
                                 return (NULL);
 
                         tm->tm_wday = i;
 
-                        if (isspace(*buf))
-                                while (*ptr != 0 && !isspace(*ptr))
-                                        ptr++;
                         break;
 
+                case 'd':
                 case 'e':
                         /*
                          * The %e format has a space before single digits
                          * which we need to skip.
                          */
                         if (isspace(*buf))
                                 buf++;
-                        /* FALLTHROUGH */
-                case 'd':
                         /*
                          * The %e specifier is explicitly documented as not
                          * being zero-padded but there is no harm in allowing
                          * such padding.
                          *

@@ -368,13 +356,10 @@
                         if (i > 31)
                                 return (NULL);
 
                         tm->tm_mday = i;
 
-                        if (isspace(*buf))
-                                while (*ptr != 0 && !isspace(*ptr))
-                                        ptr++;
                         break;
 
                 case 'B':
                 case 'b':
                 case 'h':

@@ -415,13 +400,10 @@
                         if (i < 1 || i > 12)
                                 return (NULL);
 
                         tm->tm_mon = i - 1;
 
-                        if (isspace(*buf))
-                                while (*ptr != NULL && !isspace(*ptr))
-                                        ptr++;
                         break;
 
                 case 's':
                         {
                         char *cp;

@@ -463,13 +445,10 @@
                         if (i < 0)
                                 return (NULL);
 
                         tm->tm_year = i;
 
-                        if (isspace(*buf))
-                                while (*ptr != 0 && !isspace(*ptr))
-                                        ptr++;
                         break;
 
                 case 'Z':
                         {
                         const char *cp = buf;

@@ -519,10 +498,15 @@
                         tm->tm_hour -= sign * (i / 100);
                         tm->tm_min -= sign * (i % 100);
                         *flagsp |= F_GMT;
                         }
                         break;
+                case 'n':
+                case 't':
+                        while (isspace(*buf))
+                                buf++;
+                        break;
                 }
         }
 
         if (!recurse) {
                 if (buf && (*flagsp & F_GMT)) {