This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Data Structures | |
| struct | includelist |
| struct | nlist |
| struct | source |
| struct | token |
| struct | tokenrow |
Defines | |
| #define | EOB 0xFE |
| #define | EOF (-1) |
| #define | EOFC 0xFD |
| #define | INS 32768 |
| #define | ISDEFINED 01 |
| #define | ISKW 02 |
| #define | ISMAC 010 |
| #define | ISUNCHANGE 04 |
| #define | NARG 32 |
| #define | new(t) (t *)domalloc(sizeof(t)) |
| #define | NIF 32 |
| #define | NINCLUDE 32 |
| #define | NULL 0 |
| #define | OBS 4096 |
| #define | quicklook(a, b) (namebit[(a)&077] & (1<<((b)&037))) |
| #define | quickset(a, b) namebit[(a)&077] |= (1<<((b)&037)) |
| #define | rowlen(tokrow) ((tokrow)->lp - (tokrow)->bp) |
| #define | XPWS 1 |
Typedefs | |
| typedef includelist | Includelist |
| typedef nlist | Nlist |
| typedef source | Source |
| typedef token | Token |
| typedef tokenrow | Tokenrow |
| typedef unsigned char | uchar |
Enumerations | |
| enum | errtype { WARNING, ERROR, FATAL } |
| enum | kwtype { KIF, KIFDEF, KIFNDEF, KELIF, KELSE, KENDIF, KINCLUDE, KDEFINE, KUNDEF, KLINE, KERROR, KPRAGMA, KDEFINED, KLINENO, KFILE, KDATE, KTIME, KSTDC, KEVAL } |
| enum | toktype { END, UNCLASS, NAME, NUMBER, STRING, CCON, NL, WS, DSHARP, EQ, NEQ, LEQ, GEQ, LSH, RSH, LAND, LOR, PPLUS, MMINUS, ARROW, SBRA, SKET, LP, RP, DOT, AND = 38<<4, STAR, PLUS, MINUS, TILDE, NOT, SLASH, PCT, LT, GT, CIRC, OR, QUEST, COLON, ASGN, COMMA, SHARP, SEMIC, CBRA, CKET, ASPLUS, ASMINUS, ASSTAR, ASSLASH, ASPCT, ASCIRC, ASLSH, ASRSH, ASOR, ASAND, ELLIPS, DSHARP1, NAME1, DEFINED, UMINUS } |
Functions | |
| void | adjustrow (Tokenrow *, int) |
| void | builtin (Tokenrow *, int) |
| int | checkhideset (int, Nlist *) |
| int | close (int) |
| int | comparetokens (Tokenrow *, Tokenrow *) |
| void | control (Tokenrow *) |
| Tokenrow * | copytokenrow (Tokenrow *, Tokenrow *) |
| int | creat (char *, int) |
| int | digit (int) |
| void | doadefine (Tokenrow *, int) |
| void | doconcat (Tokenrow *) |
| void | dodefine (Tokenrow *) |
| void | dofree (void *) |
| void | doif (Tokenrow *, enum kwtype) |
| void | doinclude (Tokenrow *) |
| void * | domalloc (int) |
| int | dup2 (int, int) |
| void | error (enum errtype, char *,...) |
| long | eval (Tokenrow *, int) |
| void | expand (Tokenrow *, Nlist *) |
| void | expandlex (void) |
| void | expandrow (Tokenrow *, char *) |
| int | fillbuf (Source *) |
| void | fixlex (void) |
| void | flushout (void) |
| int | foldline (Source *) |
| int | gatherargs (Tokenrow *, Tokenrow **, int *) |
| void | genline (void) |
| int | gettokens (Tokenrow *, int) |
| Token * | growtokenrow (Tokenrow *) |
| void | iniths (void) |
| void | insertrow (Tokenrow *, int, Tokenrow *) |
| Nlist * | lookup (Token *, int) |
| int | lookuparg (Nlist *, Token *) |
| void | makespace (Tokenrow *) |
| void | maketokenrow (int, Tokenrow *) |
| void | movetokenrow (Tokenrow *, Tokenrow *) |
| int | newhideset (int, Nlist *) |
| uchar * | newstring (uchar *, int, int) |
| Tokenrow * | normtokenrow (Tokenrow *) |
| int | open (char *, int) |
| char * | outnum (char *, int) |
| void | peektokens (Tokenrow *, char *) |
| void | prhideset (int) |
| void | process (Tokenrow *) |
| void | puttokens (Tokenrow *) |
| int | read (int, char *, size_t) |
| void | setempty (Tokenrow *) |
| void | setobjname (char *) |
| Source * | setsource (char *, int, char *) |
| void | setup (int, char **) |
| Tokenrow * | stringify (Tokenrow *) |
| void | substargs (Nlist *, Tokenrow *, Tokenrow **) |
| int | trigraph (Source *) |
| int | unionhideset (int, int) |
| void | unsetsource (void) |
| int | write (int, char *, size_t) |
Variables | |
| int | Cplusplus |
| Source * | cursource |
| char * | curtime |
| int | ifdepth |
| int | ifsatisfied [NIF] |
| int | incdepth |
| Includelist | includelist [NINCLUDE] |
| Nlist * | kwdefined |
| int | Mflag |
| unsigned long | namebit [077+1] |
| Token | nltoken |
| char * | outp |
| int | skipping |
| int | verbose |
| char | wd [] |
|
|
Definition at line 35 of file cpp.h. Referenced by encode_mcu_AC_refine(). |
|
|
|
|
|
|
|
|
Definition at line 1 of file cpp.h. Referenced by fillbuf(), gettokens(), and setsource(). |
|
|
Definition at line 30 of file cpp.h. Referenced by eval(), expandrow(), and tokval(). |
|
|
|
|
|
|
|
|
|
|
|
Definition at line 3 of file cpp.h. Referenced by expand(), and gatherargs(). |
|
|
|
|
|
|
|
|
Definition at line 4 of file cpp.h. Referenced by doinclude(), and setup(). |
|
|
|
|
|
Definition at line 2 of file cpp.h. Referenced by puttokens(). |
|
|
Definition at line 84 of file cpp.h. Referenced by expandrow(), and gettokens(). |
|
|
Definition at line 85 of file cpp.h. Referenced by lookup(). |
|
|
Definition at line 141 of file cpp.h. Referenced by copytokenrow(), expand(), and insertrow(). |
|
|
Definition at line 37 of file cpp.h. Referenced by makespace(). |
|
|
Referenced by doinclude(). |
|
|
Referenced by checkhideset(), control(), doadefine(), dodefine(), eval(), expand(), expandrow(), inserths(), lookup(), lookuparg(), newhideset(), setup_kwtab(), substargs(), and tokval(). |
|
|
Referenced by builtin(), error(), fillbuf(), foldline(), gettokens(), setsource(), trigraph(), and unsetsource(). |
|
|
Referenced by builtin(), comparetokens(), control(), doadefine(), doconcat(), dodefine(), error(), eval(), expand(), expandrow(), gatherargs(), genline(), gettokens(), growtokenrow(), lookup(), lookuparg(), makespace(), maketokenrow(), normtokenrow(), peektokens(), puttokens(), setup_kwtab(), stringify(), substargs(), and tokval(). |
|
|
|
Definition at line 14 of file cpp.h. Referenced by builtin(), doadefine(), doinclude(), genline(), gettokens(), lookup(), makespace(), newstring(), puttokens(), setup(), setup_kwtab(), stringify(), and tokval(). |
|
|
Definition at line 88 of file cpp.h. 00088 { WARNING, ERROR, FATAL };
|
|
|
Definition at line 26 of file cpp.h. 00026 { KIF, KIFDEF, KIFNDEF, KELIF, KELSE, KENDIF, KINCLUDE, KDEFINE,
00027 KUNDEF, KLINE, KERROR, KPRAGMA, KDEFINED,
00028 KLINENO, KFILE, KDATE, KTIME, KSTDC, KEVAL };
|
|
|
Definition at line 17 of file cpp.h. 00017 { END, UNCLASS, NAME, NUMBER, STRING, CCON, NL, WS, DSHARP,
00018 EQ, NEQ, LEQ, GEQ, LSH, RSH, LAND, LOR, PPLUS, MMINUS,
00019 ARROW, SBRA, SKET, LP, RP, DOT, AND, STAR, PLUS, MINUS,
00020 TILDE, NOT, SLASH, PCT, LT, GT, CIRC, OR, QUEST,
00021 COLON, ASGN, COMMA, SHARP, SEMIC, CBRA, CKET,
00022 ASPLUS, ASMINUS, ASSTAR, ASSLASH, ASPCT, ASCIRC, ASLSH,
00023 ASRSH, ASOR, ASAND, ELLIPS,
00024 DSHARP1, NAME1, DEFINED, UMINUS };
|
|
||||||||||||
|
Definition at line 195 of file tokens.c. References tokenrow::bp, growtokenrow(), tokenrow::lp, tokenrow::max, memmove(), Tokenrow, and tokenrow::tp. Referenced by gatherargs(), and insertrow(). 00196 {
00197 int nby, size;
00198
00199 if (nt==0)
00200 return;
00201 size = (trp->lp - trp->bp) + nt;
00202 while (size > trp->max)
00203 growtokenrow(trp);
00204 /* nby = sizeof(Token) * (trp->lp - trp->tp); */
00205 nby = (char *)trp->lp - (char *)trp->tp;
00206 if (nby)
00207 memmove(trp->tp+nt, trp->tp, nby);
00208 trp->lp += nt;
00209 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 457 of file macro.c. References curtime, error(), ERROR, source::fd, source::filename, KDATE, KFILE, KLINENO, KTIME, token::len, source::line, source::next, op, outnum(), outp, s, Source, src, strncpy(), token::t, Token, Tokenrow, tokenrow::tp, token::type, uchar, and token::wslen. Referenced by expandrow(), and PC_AddBuiltinDefines(). 00458 {
00459 char *op;
00460 Token *tp;
00461 Source *s;
00462
00463 tp = trp->tp;
00464 trp->tp++;
00465 /* need to find the real source */
00466 s = cursource;
00467 while (s && s->fd==-1)
00468 s = s->next;
00469 if (s==NULL)
00470 s = cursource;
00471 /* most are strings */
00472 tp->type = STRING;
00473 if (tp->wslen) {
00474 *outp++ = ' ';
00475 tp->wslen = 1;
00476 }
00477 op = outp;
00478 *op++ = '"';
00479 switch (biname) {
00480
00481 case KLINENO:
00482 tp->type = NUMBER;
00483 op = outnum(op-1, s->line);
00484 break;
00485
00486 case KFILE: {
00487 char *src = s->filename;
00488 while ((*op++ = *src++) != 0)
00489 if (src[-1] == '\\')
00490 *op++ = '\\';
00491 op--;
00492 break;
00493 }
00494
00495 case KDATE:
00496 strncpy(op, curtime+4, 7);
00497 strncpy(op+7, curtime+20, 4);
00498 op += 11;
00499 break;
00500
00501 case KTIME:
00502 strncpy(op, curtime+11, 8);
00503 op += 8;
00504 break;
00505
00506 default:
00507 error(ERROR, "cpp botch: unknown internal macro");
00508 return;
00509 }
00510 if (tp->type==STRING)
00511 *op++ = '"';
00512 tp->t = (uchar*)outp;
00513 tp->len = op - outp;
00514 outp = op;
00515 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 23 of file hideset.c. References abort(), Hideset, hidesets, and Nlist. Referenced by expandrow(). 00024 {
00025 Hideset hsp;
00026
00027 if (hs>=nhidesets)
00028 abort();
00029 for (hsp = hidesets[hs]; *hsp; hsp++) {
00030 if (*hsp == np)
00031 return 1;
00032 }
00033 return 0;
00034 }
|
Here is the call graph for this function:

|
|
Referenced by NET_IPSocket(), NET_Shutdown(), SNDDMA_GetDMAPos(), SNDDMA_Init(), Spk_Close(), and unsetsource(). |
|
||||||||||||
|
Definition at line 107 of file tokens.c. References token::len, tokenrow::lp, strncmp(), token::t, Token, Tokenrow, tokenrow::tp, token::type, and token::wslen. Referenced by dodefine(). 00108 {
00109 Token *tp1, *tp2;
00110
00111 tp1 = tr1->tp;
00112 tp2 = tr2->tp;
00113 if (tr1->lp-tp1 != tr2->lp-tp2)
00114 return 1;
00115 for (; tp1<tr1->lp ; tp1++, tp2++) {
00116 if (tp1->type != tp2->type
00117 || (tp1->wslen==0) != (tp2->wslen==0)
00118 || tp1->len != tp2->len
00119 || strncmp((char*)tp1->t, (char*)tp2->t, tp1->len)!=0)
00120 return 1;
00121 }
00122 return 0;
00123 }
|
Here is the call graph for this function:

|
|
Definition at line 90 of file cpp.c. References atol(), tokenrow::bp, cursource, dodefine(), doinclude(), ERROR, error(), eval(), expandrow(), FATAL, source::filename, nlist::flag, source::ifdepth, ifdepth, ifsatisfied, KDEFINE, KDEFINED, KELIF, KELSE, KENDIF, KERROR, KEVAL, KIF, KIFDEF, KIFNDEF, KINCLUDE, KLINE, KPRAGMA, KUNDEF, token::len, source::line, lookup(), tokenrow::lp, NAME, newstring(), Nlist, np, NULL, NUMBER, setempty(), skipping, token::t, Token, Tokenrow, tokenrow::tp, token::type, nlist::val, and WARNING. Referenced by AAS_ApplyFriction(), Controls_Update(), PM_Friction(), PM_NoclipMove(), and process(). 00091 {
00092 Nlist *np;
00093 Token *tp;
00094
00095 tp = trp->tp;
00096 if (tp->type!=NAME) {
00097 if (tp->type==NUMBER)
00098 goto kline;
00099 if (tp->type != NL)
00100 error(ERROR, "Unidentifiable control line");
00101 return; /* else empty line */
00102 }
00103 if ((np = lookup(tp, 0))==NULL || (np->flag&ISKW)==0 && !skipping) {
00104 error(WARNING, "Unknown preprocessor control %t", tp);
00105 return;
00106 }
00107 if (skipping) {
00108 switch (np->val) {
00109 case KENDIF:
00110 if (--ifdepth<skipping)
00111 skipping = 0;
00112 --cursource->ifdepth;
00113 setempty(trp);
00114 return;
00115
00116 case KIFDEF:
00117 case KIFNDEF:
00118 case KIF:
00119 if (++ifdepth >= NIF)
00120 error(FATAL, "#if too deeply nested");
00121 ++cursource->ifdepth;
00122 return;
00123
00124 case KELIF:
00125 case KELSE:
00126 if (ifdepth<=skipping)
00127 break;
00128 return;
00129
00130 default:
00131 return;
00132 }
00133 }
00134 switch (np->val) {
00135 case KDEFINE:
00136 dodefine(trp);
00137 break;
00138
00139 case KUNDEF:
00140 tp += 1;
00141 if (tp->type!=NAME || trp->lp - trp->bp != 4) {
00142 error(ERROR, "Syntax error in #undef");
00143 break;
00144 }
00145 if ((np = lookup(tp, 0)) != NULL)
00146 np->flag &= ~ISDEFINED;
00147 break;
00148
00149 case KPRAGMA:
00150 return;
00151
00152 case KIFDEF:
00153 case KIFNDEF:
00154 case KIF:
00155 if (++ifdepth >= NIF)
00156 error(FATAL, "#if too deeply nested");
00157 ++cursource->ifdepth;
00158 ifsatisfied[ifdepth] = 0;
00159 if (eval(trp, np->val))
00160 ifsatisfied[ifdepth] = 1;
00161 else
00162 skipping = ifdepth;
00163 break;
00164
00165 case KELIF:
00166 if (ifdepth==0) {
00167 error(ERROR, "#elif with no #if");
00168 return;
00169 }
00170 if (ifsatisfied[ifdepth]==2)
00171 error(ERROR, "#elif after #else");
00172 if (eval(trp, np->val)) {
00173 if (ifsatisfied[ifdepth])
00174 skipping = ifdepth;
00175 else {
00176 skipping = 0;
00177 ifsatisfied[ifdepth] = 1;
00178 }
00179 } else
00180 skipping = ifdepth;
00181 break;
00182
00183 case KELSE:
00184 if (ifdepth==0 || cursource->ifdepth==0) {
00185 error(ERROR, "#else with no #if");
00186 return;
00187 }
00188 if (ifsatisfied[ifdepth]==2)
00189 error(ERROR, "#else after #else");
00190 if (trp->lp - trp->bp != 3)
00191 error(ERROR, "Syntax error in #else");
00192 skipping = ifsatisfied[ifdepth]? ifdepth: 0;
00193 ifsatisfied[ifdepth] = 2;
00194 break;
00195
00196 case KENDIF:
00197 if (ifdepth==0 || cursource->ifdepth==0) {
00198 error(ERROR, "#endif with no #if");
00199 return;
00200 }
00201 --ifdepth;
00202 --cursource->ifdepth;
00203 if (trp->lp - trp->bp != 3)
00204 error(WARNING, "Syntax error in #endif");
00205 break;
00206
00207 case KERROR:
00208 trp->tp = tp+1;
00209 error(WARNING, "#error directive: %r", trp);
00210 break;
00211
00212 case KLINE:
00213 trp->tp = tp+1;
00214 expandrow(trp, "<line>");
00215 tp = trp->bp+2;
00216 kline:
00217 if (tp+1>=trp->lp || tp->type!=NUMBER || tp+3<trp->lp
00218 || (tp+3==trp->lp && ((tp+1)->type!=STRING)||*(tp+1)->t=='L')){
00219 error(ERROR, "Syntax error in #line");
00220 return;
00221 }
00222 cursource->line = atol((char*)tp->t)-1;
00223 if (cursource->line<0 || cursource->line>=32768)
00224 error(WARNING, "#line specifies number out of range");
00225 tp = tp+1;
00226 if (tp+1<trp->lp)
00227 cursource->filename=(char*)newstring(tp->t+1,tp->len-2,0);
00228 return;
00229
00230 case KDEFINED:
00231 error(ERROR, "Bad syntax for control line");
00232 break;
00233
00234 case KINCLUDE:
00235 doinclude(trp);
00236 trp->lp = trp->bp;
00237 return;
00238
00239 case KEVAL:
00240 eval(trp, np->val);
00241 break;
00242
00243 default:
00244 error(ERROR, "Preprocessor control `%t' not yet implemented", tp);
00245 break;
00246 }
00247 setempty(trp);
00248 return;
00249 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 216 of file tokens.c. References tokenrow::lp, maketokenrow(), movetokenrow(), rowlen, and Tokenrow. Referenced by expand(), and substargs(). 00217 {
00218 int len = rowlen(str);
00219
00220 maketokenrow(len, dtr);
00221 movetokenrow(dtr, str);
00222 dtr->lp += len;
00223 return dtr;
00224 }
|
Here is the call graph for this function:

|
||||||||||||
|
Referenced by setup(). |
|
|
Definition at line 509 of file eval.c. References i. Referenced by tokval(). 00510 {
00511 if ('0'<=i && i<='9')
00512 i -= '0';
00513 else if ('a'<=i && i<='f')
00514 i -= 'a'-10;
00515 else if ('A'<=i && i<='F')
00516 i -= 'A'-10;
00517 else
00518 i = -1;
00519 return i;
00520 }
|
|
||||||||||||
|
Definition at line 92 of file macro.c. References tokenrow::bp, error(), FATAL, nlist::flag, lookup(), tokenrow::lp, Nlist, normtokenrow(), np, Token, Tokenrow, tokenrow::tp, type, token::type, uchar, and nlist::vp. Referenced by setup(). 00093 {
00094 Nlist *np;
00095 static Token onetoken[1] = {{ NUMBER, 0, 0, 0, 1, (uchar*)"1" }};
00096 static Tokenrow onetr = { onetoken, onetoken, onetoken+1, 1 };
00097
00098 trp->tp = trp->bp;
00099 if (type=='U') {
00100 if (trp->lp-trp->tp != 2 || trp->tp->type!=NAME)
00101 goto syntax;
00102 if ((np = lookup(trp->tp, 0)) == NULL)
00103 return;
00104 np->flag &= ~ISDEFINED;
00105 return;
00106 }
00107 if (trp->tp >= trp->lp || trp->tp->type!=NAME)
00108 goto syntax;
00109 np = lookup(trp->tp, 1);
00110 np->flag |= ISDEFINED;
00111 trp->tp += 1;
00112 if (trp->tp >= trp->lp || trp->tp->type==END) {
00113 np->vp = &onetr;
00114 return;
00115 }
00116 if (trp->tp->type!=ASGN)
00117 goto syntax;
00118 trp->tp += 1;
00119 if ((trp->lp-1)->type == END)
00120 trp->lp -= 1;
00121 np->vp = normtokenrow(trp);
00122 return;
00123 syntax:
00124 error(FATAL, "Illegal -D or -U argument %r", trp);
00125 }
|
Here is the call graph for this function:

|
|
Definition at line 360 of file macro.c. References tokenrow::bp, dofree(), error(), ERROR, gettokens(), insertrow(), token::len, tokenrow::lp, makespace(), maketokenrow(), setsource(), strncpy(), token::t, Token, Tokenrow, tokenrow::tp, token::type, unsetsource(), and WARNING. Referenced by expand(). 00361 {
00362 Token *ltp, *ntp;
00363 Tokenrow ntr;
00364 int len;
00365
00366 for (trp->tp=trp->bp; trp->tp<trp->lp; trp->tp++) {
00367 if (trp->tp->type==DSHARP1)
00368 trp->tp->type = DSHARP;
00369 else if (trp->tp->type==DSHARP) {
00370 char tt[128];
00371 ltp = trp->tp-1;
00372 ntp = trp->tp+1;
00373 if (ltp<trp->bp || ntp>=trp->lp) {
00374 error(ERROR, "## occurs at border of replacement");
00375 continue;
00376 }
00377 len = ltp->len + ntp->len;
00378 strncpy((char*)tt, (char*)ltp->t, ltp->len);
00379 strncpy((char*)tt+ltp->len, (char*)ntp->t, ntp->len);
00380 tt[len] = '\0';
00381 setsource("<##>", -1, tt);
00382 maketokenrow(3, &ntr);
00383 gettokens(&ntr, 1);
00384 unsetsource();
00385 if (ntr.lp-ntr.bp!=2 || ntr.bp->type==UNCLASS)
00386 error(WARNING, "Bad token %r produced by ##", &ntr);
00387 ntr.lp = ntr.bp+1;
00388 trp->tp = ltp;
00389 makespace(&ntr);
00390 insertrow(trp, (ntp-ltp)+1, &ntr);
00391 dofree(ntr.bp);
00392 trp->tp--;
00393 }
00394 }
00395 }
|
Here is the call graph for this function:

|
|
Definition at line 10 of file macro.c. References nlist::ap, tokenrow::bp, comparetokens(), dofree(), err(), error(), ERROR, nlist::flag, growtokenrow(), token::len, lookup(), tokenrow::lp, LP, maketokenrow(), tokenrow::max, Nlist, normtokenrow(), np, strncmp(), token::t, Token, Tokenrow, tokenrow::tp, token::type, nlist::vp, and token::wslen. Referenced by control(). 00011 {
00012 Token *tp;
00013 Nlist *np;
00014 Tokenrow *def, *args;
00015
00016 tp = trp->tp+1;
00017 if (tp>=trp->lp || tp->type!=NAME) {
00018 error(ERROR, "#defined token is not a name");
00019 return;
00020 }
00021 np = lookup(tp, 1);
00022 if (np->flag&ISUNCHANGE) {
00023 error(ERROR, "#defined token %t can't be redefined", tp);
00024 return;
00025 }
00026 /* collect arguments */
00027 tp += 1;
00028 args = NULL;
00029 if (tp<trp->lp && tp->type==LP && tp->wslen==0) {
00030 /* macro with args */
00031 int narg = 0;
00032 tp += 1;
00033 args = new(Tokenrow);
00034 maketokenrow(2, args);
00035 if (tp->type!=RP) {
00036 |