]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
Removed all uses of strftime() since it uses the localised version of the
authorDaniel Stenberg <daniel@haxx.se>
Fri, 11 Feb 2005 00:03:49 +0000 (00:03 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 11 Feb 2005 00:03:49 +0000 (00:03 +0000)
week day names and month names and servers don't like that.

CHANGES
RELEASE-NOTES
lib/Makefile.inc
lib/file.c
lib/ftp.c
lib/http.c
lib/parsedate.c
lib/parsedate.h [new file with mode: 0644]

diff --git a/CHANGES b/CHANGES
index 34c3a161a99fee3493f93aa557049ee6ac0f724f..acf549a12d405f1f07709fd508699cf73a118a36 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,10 @@
 
                                   Changelog
 
+Daniel (11 February 2005)
+- Removed all uses of strftime() since it uses the localised version of the
+  week day names and month names and servers don't like that.
+
 Daniel (10 February 2005)
 - Now the test script disables valgrind-testing when the test suite runs if
   libcurl is built shared. Otherwise valgrind only tests the shell that runs
index d159f7756939f21398cbc75fe7be507120aab68f..91027552e6471611e5015f7f00853246812d8a40 100644 (file)
@@ -22,10 +22,11 @@ This release includes the following bugfixes:
  o inflate buffer usage bugfix
  o better DICT protocol adherence
  o disable valgrind-checking while testing if libcurl is built shared
+ o locale names in some date strings
 
 Other curl-related news since the previous public release:
 
- o 
+ o pycurl 7.13.0: http://pycurl.sf.net/
 
 This release would not have looked like this without help, code, reports and
 advice from friends like these:
index 4d5778fb1b37073789598b98c03888a920cc5a00..f008736ebcf29cea8d0ab9b09894cc698219c1b9 100644 (file)
@@ -17,4 +17,4 @@ HHEADERS = arpa_telnet.h netrc.h file.h timeval.h base64.h hostip.h   \
   http_chunks.h strtok.h connect.h llist.h hash.h content_encoding.h   \
   share.h md5.h http_digest.h http_negotiate.h http_ntlm.h ca-bundle.h \
   inet_pton.h strtoofft.h strerror.h inet_ntop.h curlx.h memory.h      \
-  setup.h transfer.h select.h easyif.h multiif.h
+  setup.h transfer.h select.h easyif.h multiif.h parsedate.h
index 5bebf32876f867b6a1d4ee49b9407112a70e8645..c325a467372d1915f8ccbd0ce07f5bebd6e71636 100644 (file)
@@ -87,6 +87,7 @@
 #include "transfer.h"
 #include "url.h"
 #include "memory.h"
+#include "parsedate.h" /* for the week day and month names */
 
 #define _MPRINTF_REPLACE /* use our functions only */
 #include <curl/mprintf.h>
@@ -321,7 +322,6 @@ CURLcode Curl_file(struct connectdata *conn, bool *done)
     if(result)
       return result;
 
-#ifdef HAVE_STRFTIME
     if(fstated) {
       struct tm *tm;
       time_t clock = (time_t)statbuf.st_mtime;
@@ -332,11 +332,17 @@ CURLcode Curl_file(struct connectdata *conn, bool *done)
       tm = gmtime(&clock);
 #endif
       /* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
-      strftime(buf, BUFSIZE-1, "Last-Modified: %a, %d %b %Y %H:%M:%S GMT\r\n",
-               tm);
+      snprintf(buf, BUFSIZE-1,
+               "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
+               Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
+               tm->tm_mday,
+               Curl_month[tm->tm_mon],
+               tm->tm_year + 1900,
+               tm->tm_hour,
+               tm->tm_min,
+               tm->tm_sec);
       result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0);
     }
-#endif
     return result;
   }
 
index 8b628710a259475e6f20bdc35462ef271dbb9e2e..82683aae664aedfb08b68c0b8b8320b6869fd36a 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -94,6 +94,7 @@
 #include "memory.h"
 #include "inet_ntop.h"
 #include "select.h"
+#include "parsedate.h" /* for the week day and month names */
 
 #if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL)
 #include "inet_ntoa_r.h"
@@ -1738,7 +1739,6 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
       /* If we asked for a time of the file and we actually got one as well,
          we "emulate" a HTTP-style header in our output. */
 
-#ifdef HAVE_STRFTIME
       if(data->set.get_filetime && (data->info.filetime>=0) ) {
         struct tm *tm;
         time_t clock = (time_t)data->info.filetime;
@@ -1749,13 +1749,19 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
         tm = gmtime(&clock);
 #endif
         /* format: "Tue, 15 Nov 1994 12:45:26" */
-        strftime(buf, BUFSIZE-1,
-                 "Last-Modified: %a, %d %b %Y %H:%M:%S GMT\r\n", tm);
+        snprintf(buf, BUFSIZE-1,
+                 "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
+                 Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
+                 tm->tm_mday,
+                 Curl_month[tm->tm_mon],
+                 tm->tm_year + 1900,
+                 tm->tm_hour,
+                 tm->tm_min,
+                 tm->tm_sec);
         result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0);
         if(result)
           return result;
       }
-#endif
     }
     break;
   default:
index 0516431261289d16b5bc2dfa9eac82f9f1f178ff..706cf7e308a523d2c45e98624984335598d21b85 100644 (file)
@@ -95,6 +95,7 @@
 #include "http.h"
 #include "memory.h"
 #include "select.h"
+#include "parsedate.h" /* for the week day and month names */
 
 #define _MPRINTF_REPLACE /* use our functions only */
 #include <curl/mprintf.h>
@@ -1783,7 +1784,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
 #endif
 
     if(data->set.timecondition) {
-      struct tm *thistime;
+      struct tm *tm;
 
       /* Phil Karn (Fri, 13 Apr 2001) pointed out that the If-Modified-Since
        * header family should have their times set in GMT as RFC2616 defines:
@@ -1795,18 +1796,22 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
 #ifdef HAVE_GMTIME_R
       /* thread-safe version */
       struct tm keeptime;
-      thistime = (struct tm *)gmtime_r(&data->set.timevalue, &keeptime);
+      tm = (struct tm *)gmtime_r(&data->set.timevalue, &keeptime);
 #else
-      thistime = gmtime(&data->set.timevalue);
+      tm = gmtime(&data->set.timevalue);
 #endif
 
-#ifdef HAVE_STRFTIME
       /* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
-      strftime(buf, BUFSIZE-1, "%a, %d %b %Y %H:%M:%S GMT", thistime);
-#else
-      /* TODO: Right, we *could* write a replacement here */
-      strcpy(buf, "no strftime() support");
-#endif
+      snprintf(buf, BUFSIZE-1,
+               "%s, %02d %s %4d %02d:%02d:%02d GMT",
+               Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
+               tm->tm_mday,
+               Curl_month[tm->tm_mon],
+               tm->tm_year + 1900,
+               tm->tm_hour,
+               tm->tm_min,
+               tm->tm_sec);
+
       switch(data->set.timecondition) {
       case CURL_TIMECOND_IFMODSINCE:
       default:
index 198f70101f9c48bd55b118b5a1dad3e4e0c03b33..063d0c44a316c60b5651093ec6399f7e73f9d961 100644 (file)
 
 static time_t Curl_parsedate(const char *date);
 
-static const char * const wkday[] =
-  {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
+const char * const Curl_wkday[] =
+{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
 static const char * const weekday[] =
-  { "Monday", "Tuesday", "Wednesday", "Thursday",
-                                 "Friday", "Saturday", "Sunday" };
-static const char * const month[]=
-  { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
-    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+{ "Monday", "Tuesday", "Wednesday", "Thursday",
+  "Friday", "Saturday", "Sunday" };
+const char * const Curl_month[]=
+{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
 
 struct tzinfo {
   const char *name;
@@ -161,7 +161,7 @@ static int checkday(char *check, size_t len)
   if(len > 3)
     what = &weekday[0];
   else
-    what = &wkday[0];
+    what = &Curl_wkday[0];
   for(i=0; i<7; i++) {
     if(curl_strequal(check, what[0])) {
       found=TRUE;
@@ -178,7 +178,7 @@ static int checkmonth(char *check)
   const char * const *what;
   bool found= FALSE;
 
-  what = &month[0];
+  what = &Curl_month[0];
   for(i=0; i<12; i++) {
     if(curl_strequal(check, what[0])) {
       found=TRUE;
diff --git a/lib/parsedate.h b/lib/parsedate.h
new file mode 100644 (file)
index 0000000..4738117
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef __PARSEDATE_H
+#define __PARSEDATEL_H
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ * $Id$
+ ***************************************************************************/
+extern const char * const Curl_wkday[7];
+extern const char * const Curl_month[12];
+
+#endif