tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] patch for __DATE__ & __TIME__ support to tcc.0.9.16


From: Basile STARYNKEVITCH
Subject: [Tinycc-devel] patch for __DATE__ & __TIME__ support to tcc.0.9.16
Date: Tue, 31 Dec 2002 15:44:09 +0100

Sorry the previous patch is reversed.

use patch -r to apply it, or use the following patch

--- tcc.c.orig  2002-12-31 13:34:46.000000000 +0100
+++ tcc.c       2002-12-31 14:07:14.000000000 +0100
@@ -29,6 +29,10 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <setjmp.h>
+
+#include <locale.h>
+#include <time.h>
+
 #ifdef WIN32
 #include <sys/timeb.h>
 #endif
@@ -3660,6 +3664,8 @@
     int mstr_allocated, parlevel, *mstr, t;
     TokenString str;
     char *cstrval;
+    static char datbuf[20];
+    static char timbuf[12];
     CValue cval;
     CString cstr;
             
@@ -3674,10 +3680,18 @@
         goto add_cstr;
         tok_str_add2(tok_str, TOK_STR, &cval);
     } else if (tok == TOK___DATE__) {
-        cstrval = "Jan  1 2002";
-        goto add_cstr;
+      time_t nowtim = (time_t)0;
+      time(&nowtim);
+      memset(datbuf, 0, sizeof(datbuf));
+      strftime(datbuf, 12, "%b %e %Y", localtime(&nowtim));
+      cstrval = datbuf;
+      goto add_cstr;
     } else if (tok == TOK___TIME__) {
-        cstrval = "00:00:00";
+      time_t nowtim = (time_t)0;
+      time(&nowtim);
+      memset(timbuf, 0, sizeof(timbuf));
+      strftime(timbuf, 9, "%H:%M:%S", localtime(&nowtim));
+      cstrval = timbuf;
     add_cstr:
         cstr_new(&cstr);
         cstr_cat(&cstr, cstrval);
@@ -9413,6 +9427,8 @@
     const char *optarg, *p1, *r1, *outfile;
     int print_search_dirs;
 
+    /* to avoid surprises, and for __DATE__ & __TIME__ support */
+    setlocale(LC_ALL, "C");
     s = tcc_new();
     output_type = TCC_OUTPUT_MEMORY;
 

-- 

Basile STARYNKEVITCH         http://starynkevitch.net/Basile/ 
email: basile<at>starynkevitch<dot>net 
alias: basile<at>tunes<dot>org 
8, rue de la Faïencerie, 92340 Bourg La Reine, France



reply via email to

[Prev in Thread] Current Thread [Next in Thread]