summaryrefslogtreecommitdiff
path: root/cpp/main.c
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>2002-08-30 20:22:10 +0200
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:48:48 +0200
commit67ef77f9e0744e524188c01fe314b609edd53456 (patch)
tree8a29acbf686764a050b4960a579e2a6d71f43ae2 /cpp/main.c
parent26ade8d624457b7164502ed9c190ca3f146bda0c (diff)
downloaddev86-67ef77f9e0744e524188c01fe314b609edd53456.tar.gz
Import Dev86src-0.16.9.tar.gzv0.16.9
Diffstat (limited to 'cpp/main.c')
-rw-r--r--cpp/main.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/cpp/main.c b/cpp/main.c
index 0cbdaa3..dfe0e5c 100644
--- a/cpp/main.c
+++ b/cpp/main.c
@@ -7,6 +7,7 @@
#include <ctype.h>
#include <string.h>
#include <malloc.h>
+#include <time.h>
#include "cc.h"
@@ -138,6 +139,22 @@ static char Usage[] = "Usage: cpp -E -0 -Dxxx -Uxxx -Ixxx infile -o outfile";
if (!curfile)
cfatal(Usage);
+ /* Define date and time macros. */
+ if (dialect != DI_KNR) {
+ time_t now;
+ char * timep;
+ char buf[128];
+ time(&now);
+ timep = ctime(&now);
+
+ /* Yes, well */
+ sprintf(buf, "__TIME__=\"%.8s\"", timep + 11);
+ define_macro(buf);
+ /* US order; Seems to be mandated by standard. */
+ sprintf(buf, "__DATE__=\"%.3s %.2s %.4s\"", timep + 4, timep + 8, timep + 20);
+ define_macro(buf);
+ }
+
if (outfile) ofd = fopen(outfile, "w");
else ofd = stdout;
if (!ofd)