aolserver4 (4.5.1-15.1) httptime

Summary

 nsd/httptime.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

    
download this patch

Patch contents

#! /bin/sh /usr/share/dpatch/dpatch-run
## httptime.dpatch by Francesco Paolo Lovergine <frankie@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix for non en locales

@DPATCH@
diff -urNad aolserver4-4.0.10~/nsd/httptime.c aolserver4-4.0.10/nsd/httptime.c
--- aolserver4-4.0.10~/nsd/httptime.c	2003-01-18 20:24:20.000000000 +0100
+++ aolserver4-4.0.10/nsd/httptime.c	2005-11-10 00:05:53.000000000 +0100
@@ -27,6 +27,9 @@
  * version of this file under either the License or the GPL.
  */
 
+static char *weekdays_names[7] =
+{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
+
 
 /* 
  * time.c --
@@ -92,11 +95,14 @@
     }
 
     /*
-     * This will most likely break if the locale is not an english one.
+     * Using snprintf instead of strftime to always use english names
      * The format is RFC 1123: "Sun, 06 Nov 1997 09:12:45 GMT"
      */
     
-    strftime(buf, 40, "%a, %d %b %Y %H:%M:%S GMT", tmPtr);
+    snprintf(buf, 40, "%s, %d %s %d %02d:%02d:%02d GMT",
+    weekdays_names[tmPtr->tm_wday], tmPtr->tm_mday,
+    month_names[tmPtr->tm_mon], tmPtr->tm_year + 1900,
+    tmPtr->tm_hour, tmPtr->tm_min, tmPtr->tm_sec);
 
     Ns_DStringAppend(pds, buf);
     return pds->string;