2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 /* $Id: init.c,v 1.9 1994/06/27 08:00:14 ceriel Exp $ */
6 /* PREPROCESSOR: INITIALIZATION ROUTINES */
18 extern char *sprint();
32 {"include", K_INCLUDE},
41 static char *months[12] = {
42 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
43 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
45 long clock, sys_time();
50 /* Initialise the control line keywords (if, include, define, etc)
51 Although the lexical analyzer treats them as identifiers, the
52 control line handler can recognize them as keywords by the
53 id_resmac field of the identifier.
56 register struct mkey *mk = &mkey[0];
58 while (mk->mk_reserved) {
59 register struct idf *idf = str2idf(mk->mk_reserved, 0);
62 fatal("maximum identifier length insufficient");
63 idf->id_resmac = mk->mk_key;
68 /* Initialize __LINE__, __FILE__, __DATE__, __TIME__,
69 and __STDC__ macro definitions.
72 tp = localtime(&clock);
75 sprint(dbuf, "\"%s %02d %d\"", months[tp->tm_mon],
76 tp->tm_mday, tp->tm_year+1900);
77 if (tp->tm_mday < 10) dbuf[5] = ' '; /* hack */
78 macro_def(str2idf("__DATE__", 0), dbuf, -1, strlen(dbuf), NOUNDEF);
81 sprint(tbuf, "\"%02d:%02d:%02d\"", tp->tm_hour, tp->tm_min, tp->tm_sec);
82 macro_def(str2idf("__TIME__", 0), tbuf, -1, strlen(tbuf), NOUNDEF);
85 macro_def(str2idf("__LINE__", 0), "0", -1, 1, NOUNDEF | FUNC);
88 macro_def(str2idf("__FILE__", 0), "", -1, 1, NOUNDEF | FUNC);
91 macro_def(str2idf("__STDC__", 0), "1", -1, 1, NOUNDEF);
94 macro_def(str2idf("defined", 0), "", 1, 1, NOUNDEF | FUNC);