* use reentrant function
authorWilfried Göesgens <willi@citadel.org>
Tue, 20 Oct 2009 16:25:13 +0000 (16:25 +0000)
committerWilfried Göesgens <willi@citadel.org>
Tue, 20 Oct 2009 16:25:13 +0000 (16:25 +0000)
* remove trailing newline; if the user wants it, he will add it in his template.

webcit/http_datestring.c

index 2394391f202dc968a244a33e0271d9567f7f0809..2e2bef8dafbde31c11dee9811a0a652acdb97cd9 100644 (file)
@@ -66,9 +66,18 @@ void http_datestring(char *buf, size_t n, time_t xtime) {
 
 void tmplput_nowstr(StrBuf *Target, WCTemplputParams *TP)
 {
+       char buf[64];
+       long bufused;
        time_t now;
+       
        now = time(NULL);
-       StrEscAppend(Target, NULL, asctime(localtime(&now)), 0, 0);
+       asctime_r(localtime(&now), buf);
+       bufused = strlen(buf);
+       if ((bufused > 0) && (buf[bufused - 1] == '\n')) {
+               buf[bufused - 1] = '\0';
+               bufused --;
+       }
+       StrEscAppend(Target, NULL, buf, 0, 0);
 }
 void tmplput_nowno(StrBuf *Target, WCTemplputParams *TP)
 {