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.5 1994/06/24 11:37:24 ceriel Exp $ */
6 /* PREPROCESSOR: INITIALIZATION ROUTINES */
27 {"include", K_INCLUDE},
39 static char *months[12] = {
40 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
41 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
43 long clock, sys_time();
48 /* Initialise the control line keywords (if, include, define, etc)
49 Although the lexical analyzer treats them as identifiers, the
50 control line handler can recognize them as keywords by the
51 id_resmac field of the identifier.
54 register struct mkey *mk = &mkey[0];
56 while (mk->mk_reserved) {
57 register struct idf *idf = str2idf(mk->mk_reserved, 0);
60 fatal("maximum identifier length insufficient");
61 idf->id_resmac = mk->mk_key;
66 /* Initialize __LINE__, __FILE__, __DATE__, __TIME__,
67 and __STDC__ macro definitions.
70 tp = localtime(&clock);
73 sprint(dbuf, "\"%s %2d %d\"", months[tp->tm_mon],
74 tp->tm_mday, tp->tm_year+1900);
75 /* if (tp->tm_mday < 10) dbuf[5] = ' '; /* hack */
76 macro_def(str2idf("__DATE__", 0), dbuf, -1, strlen(dbuf), NOUNDEF);
79 sprint(tbuf, "\"%02d:%02d:%02d\"", tp->tm_hour, tp->tm_min, tp->tm_sec);
80 macro_def(str2idf("__TIME__", 0), tbuf, -1, strlen(tbuf), NOUNDEF);
83 macro_def(str2idf("__LINE__", 0), "0", -1, 1, NOUNDEF | FUNC);
86 macro_def(str2idf("__FILE__", 0), "", -1, 1, NOUNDEF | FUNC);
89 macro_def(str2idf("__STDC__", 0), "1", -1, 1, NOUNDEF);
92 macro_def(str2idf("defined", 0), "", 1, 1, NOUNDEF | FUNC);