changeset 2232:8e3602f394e2

* tests/strptime.c: Add a testcase for the previous fix. * src/strptime.cxx: Removed the initialization of the struct tm fields to prevent clobbering of time values when using the following format specifiers: %D, %r, %R, %T, %X, %x.
author asl
date Fri, 16 Jun 2006 18:46:10 +0000
parents e11e2c73b1b2
children 42c9e3ed9654
files packages/language/c/libc/time/current/ChangeLog packages/language/c/libc/time/current/src/strptime.cxx packages/language/c/libc/time/current/tests/strptime.c
diffstat 3 files changed, 22 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/packages/language/c/libc/time/current/ChangeLog
+++ b/packages/language/c/libc/time/current/ChangeLog
@@ -1,3 +1,13 @@
+2006-06-16  Andrew Lunn  <andrew.lunn@ascom.ch>
+
+	* tests/strptime.c: Add a testcase for the previous fix.
+
+2006-06-13  Dan Jakubiec  <dan.jakubiec@systech.com>
+
+	* src/strptime.cxx: Removed the initialization of the struct tm fields
+	to prevent clobbering of time values when using the following format
+	specifiers: %D, %r, %R, %T, %X, %x.
+
 2005-03-27  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* include/time.h: Added CYGBLD_ATTRIB_STRFTIME_FORMAT where
--- a/packages/language/c/libc/time/current/src/strptime.cxx
+++ b/packages/language/c/libc/time/current/src/strptime.cxx
@@ -186,17 +186,6 @@ strptime (const char *buf, const char *f
 {
     char c;
 
-    timeptr->tm_yday = 1;  // Initialize to a well known, valid date
-    timeptr->tm_isdst = 0; //   Tuesday March 18 14:05:00 2003 UTC
-    timeptr->tm_sec = 0;
-    timeptr->tm_min = 5;
-    timeptr->tm_hour = 14;
-    timeptr->tm_mday = 18;
-    timeptr->tm_mon = 2;
-    timeptr->tm_year = 103;
-    timeptr->tm_wday = 2;
-    timeptr->tm_yday = 77;
-
     for (; (c = *format) != '\0'; ++format) {
 	char *s;
 	int ret;
--- a/packages/language/c/libc/time/current/tests/strptime.c
+++ b/packages/language/c/libc/time/current/tests/strptime.c
@@ -57,7 +57,7 @@
 
 #include <time.h>
 #include <cyg/infra/testcase.h>
-
+#include <string.h>                     // strlen()
 // HOW TO START TESTS
 
 # define START_TEST( test ) test(0)
@@ -96,6 +96,17 @@ test( CYG_ADDRWORD data )
     size = strftime(s, sizeof(s), fp, &tm1);
     CYG_TEST_PASS_FAIL(((size==strlen(dp)) && (my_strcmp(s, dp) == 0)), "strptime test #4");
 
+    dp = "2006:06:13 12:22:01";
+    fp = "%x %X";
+    sp = strptime(dp, fp, &tm1);    
+    CYG_TEST_PASS_FAIL(((sp!=NULL) && (*sp=='\0')), "strptime test #5");
+    CYG_TEST_PASS_FAIL((tm1.tm_sec == 01) &&
+                       (tm1.tm_min == 22) &&
+                       (tm1.tm_hour == 12) &&
+                       (tm1.tm_mday == 13) &&
+                       (tm1.tm_mon ==  (06 - 1)) &&
+                       (tm1.tm_year == (2006 - 1900)), "strptime test #6");
+    size = strftime(s, sizeof(s), fp, &tm1);
     CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library "
                     "strptime() function");
 } // test()