c == '#' || c == '{' || c == '}' || c == '.') {
/* single-char command */
rdadd(&rs, c);
+ prevpos = rsc.pos;
} else if (c == 'u') {
int len = 0;
do {
/*
* Reads a single file (ie until get() returns EOF)
*/
-static void read_file(paragraph ***ret, input *in, indexdata *idx) {
+static void read_file(paragraph ***ret, input *in, indexdata *idx,
+ tree234 *macros) {
token t;
paragraph par;
word wd, **whptr, **idximplicit;
- tree234 *macros;
wchar_t utext[2], *wdtext;
int style, spcstyle;
int already;
t.text = NULL;
t.origtext = NULL;
- macros = newtree234(macrocmp);
already = FALSE;
crossparastk = stk_new();
continue;
}
+ while (t.type == tok_cmd &&
+ macrolookup(macros, in, t.text, &t.pos)) {
+ dtor(t), t = get_token(in);
+ }
+
/*
* This token begins a paragraph. See if it's one of the
* special commands that define a paragraph type.
* this cleanup doesn't happen.
*/
dtor(t);
- macrocleanup(macros);
stk_free(crossparastk);
}
paragraph *read_input(input *in, indexdata *idx) {
paragraph *head = NULL;
paragraph **hptr = &head;
+ tree234 *macros;
+
+ macros = newtree234(macrocmp);
while (in->currindex < in->nfiles) {
in->currfp = fopen(in->filenames[in->currindex], "r");
in->csstate = charset_init_state;
in->wcpos = in->nwc = 0;
in->pushback_chars = NULL;
- read_file(&hptr, in, idx);
+ read_file(&hptr, in, idx, macros);
}
in->currindex++;
}
+ macrocleanup(macros);
+
return head;
}