2 * Copyright (c) 2010, 2013 The NetBSD Foundation, Inc.
5 * This code is derived from software contributed to The NetBSD Foundation
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
42 struct expansionitem {
43 enum { EI_STRING, EI_PARAM, EI_FILE, EI_LINE } itemtype;
45 char *ei_string; /* for EI_STRING */
46 unsigned ei_param; /* for EI_PARAM */
49 DECLARRAY(expansionitem, static UNUSED);
50 DEFARRAY(expansionitem, static);
52 #ifdef NEED_UNION_ACCESSORS
53 #define ei_string un.ei_string
54 #define ei_param un.ei_param
59 struct place defplace;
60 struct place expansionplace;
64 struct stringarray params;
65 struct expansionitemarray expansion;
68 DECLARRAY(macro, static UNUSED);
69 DEFARRAY(macro, static);
70 DECLARRAY(macroarray, static UNUSED);
71 DEFARRAY(macroarray, static);
73 static struct macroarrayarray macros;
74 static unsigned total_macros;
75 static unsigned hashmask;
77 ////////////////////////////////////////////////////////////
78 // macro structure ops
81 struct expansionitem *
82 expansionitem_create_string(const char *string)
84 struct expansionitem *ei;
86 ei = domalloc(sizeof(*ei));
87 ei->itemtype = EI_STRING;
88 ei->ei_string = dostrdup(string);
93 struct expansionitem *
94 expansionitem_create_stringlen(const char *string, size_t len)
96 struct expansionitem *ei;
98 ei = domalloc(sizeof(*ei));
99 ei->itemtype = EI_STRING;
100 ei->ei_string = dostrndup(string, len);
105 struct expansionitem *
106 expansionitem_create_param(unsigned param)
108 struct expansionitem *ei;
110 ei = domalloc(sizeof(*ei));
111 ei->itemtype = EI_PARAM;
112 ei->ei_param = param;
117 struct expansionitem *
118 expansionitem_create_file(void)
120 struct expansionitem *ei;
122 ei = domalloc(sizeof(*ei));
123 ei->itemtype = EI_FILE;
128 struct expansionitem *
129 expansionitem_create_line(void)
131 struct expansionitem *ei;
133 ei = domalloc(sizeof(*ei));
134 ei->itemtype = EI_LINE;
140 expansionitem_destroy(struct expansionitem *ei)
142 switch (ei->itemtype) {
144 dostrfree(ei->ei_string);
151 dofree(ei, sizeof(*ei));
156 expansionitem_eq(const struct expansionitem *ei1,
157 const struct expansionitem *ei2)
159 if (ei1->itemtype != ei2->itemtype) {
162 switch (ei1->itemtype) {
164 if (strcmp(ei1->ei_string, ei2->ei_string) != 0) {
169 if (ei1->ei_param != ei2->ei_param) {
182 macro_create(struct place *p1, const char *name, unsigned hash,
187 m = domalloc(sizeof(*m));
189 m->expansionplace = *p2;
191 m->name = dostrdup(name);
192 m->hasparams = false;
193 stringarray_init(&m->params);
194 expansionitemarray_init(&m->expansion);
199 DESTROYALL_ARRAY(expansionitem, );
203 macro_destroy(struct macro *m)
205 expansionitemarray_destroyall(&m->expansion);
206 expansionitemarray_cleanup(&m->expansion);
208 dofree(m, sizeof(*m));
213 macro_eq(const struct macro *m1, const struct macro *m2)
215 unsigned num1, num2, i;
216 struct expansionitem *ei1, *ei2;
219 if (strcmp(m1->name, m2->name) != 0) {
223 if (m1->hasparams != m2->hasparams) {
227 num1 = expansionitemarray_num(&m1->expansion);
228 num2 = expansionitemarray_num(&m2->expansion);
233 for (i=0; i<num1; i++) {
234 ei1 = expansionitemarray_get(&m1->expansion, i);
235 ei2 = expansionitemarray_get(&m2->expansion, i);
236 if (!expansionitem_eq(ei1, ei2)) {
241 num1 = stringarray_num(&m1->params);
242 num2 = stringarray_num(&m2->params);
247 for (i=0; i<num1; i++) {
248 p1 = stringarray_get(&m1->params, i);
249 p2 = stringarray_get(&m2->params, i);
250 if (strcmp(p1, p2) != 0) {
257 ////////////////////////////////////////////////////////////
261 * Unless I've screwed up, this is something called Fletcher's Checksum
262 * that showed up in Dr. Dobbs in, according to my notes, May 1992. The
263 * implementation is new.
267 hashfunc(const char *s, size_t len)
272 x1 = (uint16_t) (len >> 16);
273 x2 = (uint16_t) (len);
281 for (i=0; i<len; i+=2) {
283 a = (unsigned char)s[i];
284 /* don't run off the end of the array */
287 a = (unsigned char)s[i] +
288 ((uint16_t)(unsigned char)s[i+1] << 8);
302 return ((uint32_t)x2)*65535U + x1;
307 macrotable_init(void)
311 macroarrayarray_init(¯os);
312 macroarrayarray_setsize(¯os, 4);
313 for (i=0; i<4; i++) {
314 macroarrayarray_set(¯os, i, NULL);
320 DESTROYALL_ARRAY(macro, );
324 macrotable_cleanup(void)
326 struct macroarray *bucket;
327 unsigned numbuckets, i;
329 numbuckets = macroarrayarray_num(¯os);
330 for (i=0; i<numbuckets; i++) {
331 bucket = macroarrayarray_get(¯os, i);
332 if (bucket != NULL) {
333 macroarray_destroyall(bucket);
334 macroarray_destroy(bucket);
337 macroarrayarray_setsize(¯os, 0);
338 macroarrayarray_cleanup(¯os);
343 macrotable_findlen(const char *name, size_t len, bool remove_it)
346 struct macroarray *bucket;
347 struct macro *m, *m2;
351 hash = hashfunc(name, len);
352 bucket = macroarrayarray_get(¯os, hash & hashmask);
353 if (bucket == NULL) {
356 num = macroarray_num(bucket);
357 for (i=0; i<num; i++) {
358 m = macroarray_get(bucket, i);
359 if (hash != m->hash) {
362 mlen = strlen(m->name);
363 if (len == mlen && !memcmp(name, m->name, len)) {
366 m2 = macroarray_get(bucket, num-1);
367 macroarray_set(bucket, i, m2);
369 macroarray_setsize(bucket, num-1);
380 macrotable_find(const char *name, bool remove_it)
382 return macrotable_findlen(name, strlen(name), remove_it);
387 macrotable_rehash(void)
389 struct macroarray *newbucket, *oldbucket;
391 unsigned newmask, tossbit;
392 unsigned numbuckets, i;
393 unsigned oldnum, j, k;
395 numbuckets = macroarrayarray_num(¯os);
396 macroarrayarray_setsize(¯os, numbuckets*2);
398 assert(hashmask == numbuckets - 1);
399 newmask = (hashmask << 1) | 1U;
400 tossbit = newmask & ~hashmask;
403 for (i=0; i<numbuckets; i++) {
405 oldbucket = macroarrayarray_get(¯os, i);
406 if (oldbucket == NULL) {
407 macroarrayarray_set(¯os, numbuckets + i, NULL);
410 oldnum = macroarray_num(oldbucket);
411 for (j=0; j<oldnum; j++) {
412 m = macroarray_get(oldbucket, j);
413 if (m->hash & tossbit) {
414 if (newbucket == NULL) {
415 newbucket = macroarray_create();
417 macroarray_set(oldbucket, j, NULL);
418 macroarray_add(newbucket, m, NULL);
421 for (j=k=0; j<oldnum; j++) {
422 m = macroarray_get(oldbucket, j);
425 macroarray_set(oldbucket, k, m);
430 macroarray_setsize(oldbucket, k);
431 macroarrayarray_set(¯os, numbuckets + i, newbucket);
437 macrotable_add(struct macro *m)
440 struct macroarray *bucket;
443 numbuckets = macroarrayarray_num(¯os);
444 if (total_macros > 0 && total_macros / numbuckets > 9) {
448 hash = hashfunc(m->name, strlen(m->name));
449 bucket = macroarrayarray_get(¯os, hash & hashmask);
450 if (bucket == NULL) {
451 bucket = macroarray_create();
452 macroarrayarray_set(¯os, hash & hashmask, bucket);
454 macroarray_add(bucket, m, NULL);
458 ////////////////////////////////////////////////////////////
459 // external macro definition interface
463 macro_define_common_start(struct place *p1, const char *macro,
469 if (!is_identifier(macro)) {
470 complain(p1, "Invalid macro name %s", macro);
474 hash = hashfunc(macro, strlen(macro));
475 m = macro_create(p1, macro, hash, p2);
481 macro_define_common_end(struct macro *m)
486 oldm = macrotable_find(m->name, false);
488 ok = macro_eq(m, oldm);
490 /* in traditional cpp this is silent */
491 //complain(&m->defplace,
492 // "Warning: redefinition of %s", m->name);
493 //complain(&oldm->defplace,
494 // "Previous definition was here");
499 complain(&m->defplace,
500 "Warning: non-identical redefinition of %s",
502 complain(&oldm->defplace,
503 "Previous definition was here");
504 /* in traditional cpp this is not fatal */
517 macro_parse_parameters(struct macro *m, struct place *p, const char *params)
523 while (params != NULL) {
524 len = strspn(params, ws);
526 place_addcolumns(p, len);
527 s = strchr(params, ',');
530 param = dostrndup(params, len);
533 len = strlen(params);
534 param = dostrndup(params, len);
536 notrailingws(param, strlen(param));
537 if (!is_identifier(param)) {
538 complain(p, "Invalid macro parameter name %s", param);
541 stringarray_add(&m->params, param, NULL);
544 place_addcolumns(p, len);
550 isparam(struct macro *m, const char *name, size_t len, unsigned *num_ret)
555 num = stringarray_num(&m->params);
556 for (i=0; i<num; i++) {
557 param = stringarray_get(&m->params, i);
558 if (strlen(param) == len && !memcmp(name, param, len)) {
568 macro_parse_expansion(struct macro *m, const char *buf)
570 size_t blockstart, wordstart, pos;
571 struct expansionitem *ei;
574 pos = blockstart = 0;
575 while (buf[pos] != '\0') {
576 pos += strspn(buf+pos, ws);
577 if (strchr(alnum, buf[pos])) {
579 pos += strspn(buf+pos, alnum);
580 if (isparam(m, buf+wordstart, pos-wordstart, ¶m)) {
581 if (wordstart > blockstart) {
582 ei = expansionitem_create_stringlen(
584 wordstart - blockstart);
585 expansionitemarray_add(&m->expansion,
588 ei = expansionitem_create_param(param);
589 expansionitemarray_add(&m->expansion, ei,NULL);
597 if (pos > blockstart) {
598 ei = expansionitem_create_stringlen(buf + blockstart,
600 expansionitemarray_add(&m->expansion, ei, NULL);
605 macro_define_plain(struct place *p1, const char *macro,
606 struct place *p2, const char *expansion)
609 struct expansionitem *ei;
611 m = macro_define_common_start(p1, macro, p2);
612 ei = expansionitem_create_string(expansion);
613 expansionitemarray_add(&m->expansion, ei, NULL);
614 macro_define_common_end(m);
618 macro_define_params(struct place *p1, const char *macro,
619 struct place *p2, const char *params,
620 struct place *p3, const char *expansion)
624 m = macro_define_common_start(p1, macro, p3);
626 macro_parse_parameters(m, p2, params);
627 macro_parse_expansion(m, expansion);
628 macro_define_common_end(m);
632 macro_define_magic(struct place *p, const char *macro)
635 struct expansionitem *ei;
637 m = macro_define_common_start(p, macro, p);
638 if (!strcmp(macro, "__FILE__")) {
639 ei = expansionitem_create_file();
642 assert(!strcmp(macro, "__LINE__"));
643 ei = expansionitem_create_line();
645 expansionitemarray_add(&m->expansion, ei, NULL);
646 macro_define_common_end(m);
650 macro_undef(const char *macro)
654 m = macrotable_find(macro, true);
661 macro_isdefined(const char *macro)
665 m = macrotable_find(macro, false);
669 ////////////////////////////////////////////////////////////
674 enum { ES_NORMAL, ES_WANTLPAREN, ES_NOARG, ES_HAVEARG } state;
675 struct macro *curmacro;
676 struct stringarray args;
681 size_t bufpos, bufmax;
684 static struct expstate mainstate;
686 static void doexpand(struct expstate *es, struct place *p,
687 const char *buf, size_t len);
691 expstate_init(struct expstate *es, bool tobuf, bool honordefined)
693 es->honordefined = honordefined;
694 es->state = ES_NORMAL;
696 stringarray_init(&es->args);
706 expstate_cleanup(struct expstate *es)
708 assert(es->state == ES_NORMAL);
709 stringarray_cleanup(&es->args);
711 dofree(es->buf, es->bufmax);
717 expstate_destroyargs(struct expstate *es)
721 num = stringarray_num(&es->args);
722 for (i=0; i<num; i++) {
723 dostrfree(stringarray_get(&es->args, i));
725 stringarray_setsize(&es->args, 0);
730 expand_send(struct expstate *es, struct place *p, const char *buf, size_t len)
735 assert(es->bufpos <= es->bufmax);
736 if (es->bufpos + len > es->bufmax) {
738 if (es->bufmax == 0) {
741 while (es->bufpos + len > es->bufmax) {
744 es->buf = dorealloc(es->buf, oldmax, es->bufmax);
746 memcpy(es->buf + es->bufpos, buf, len);
748 assert(es->bufpos <= es->bufmax);
756 expand_send_eof(struct expstate *es, struct place *p)
759 expand_send(es, p, "", 1);
768 expand_newarg(struct expstate *es, const char *buf, size_t len)
772 text = dostrndup(buf, len);
773 stringarray_add(&es->args, text, NULL);
778 expand_appendarg(struct expstate *es, const char *buf, size_t len)
784 num = stringarray_num(&es->args);
787 text = stringarray_get(&es->args, num - 1);
788 oldlen = strlen(text);
789 text = dorealloc(text, oldlen + 1, oldlen + len + 1);
790 memcpy(text + oldlen, buf, len);
791 text[oldlen+len] = '\0';
792 stringarray_set(&es->args, num - 1, text);
797 expand_substitute(struct place *p, struct expstate *es)
799 struct expansionitem *ei;
804 unsigned numargs, numparams;
807 numargs = stringarray_num(&es->args);
808 numparams = stringarray_num(&es->curmacro->params);
810 if (numargs == 0 && numparams == 1) {
811 /* no arguments <=> one empty argument */
812 stringarray_add(&es->args, dostrdup(""), NULL);
815 if (numargs != numparams) {
816 complain(p, "Wrong number of arguments for macro %s; "
817 "found %u, expected %u",
818 es->curmacro->name, numargs, numparams);
820 while (numargs < numparams) {
821 stringarray_add(&es->args, dostrdup(""), NULL);
827 num = expansionitemarray_num(&es->curmacro->expansion);
828 for (i=0; i<num; i++) {
829 ei = expansionitemarray_get(&es->curmacro->expansion, i);
830 switch (ei->itemtype) {
832 len += strlen(ei->ei_string);
835 arg = stringarray_get(&es->args, ei->ei_param);
839 len += strlen(place_getname(p)) + 2;
842 len += snprintf(numbuf, sizeof(numbuf), "%u", p->line);
847 ret = domalloc(len+1);
849 for (i=0; i<num; i++) {
850 ei = expansionitemarray_get(&es->curmacro->expansion, i);
851 switch (ei->itemtype) {
853 strcat(ret, ei->ei_string);
856 arg = stringarray_get(&es->args, ei->ei_param);
861 strcat(ret, place_getname(p));
865 snprintf(numbuf, sizeof(numbuf), "%u", p->line);
876 expand_domacro(struct expstate *es, struct place *p)
879 const char *name, *val;
880 char *newbuf, *newbuf2;
882 if (es->curmacro == NULL) {
884 if (stringarray_num(&es->args) != 1) {
885 complain(p, "Too many arguments for defined()");
887 expand_send(es, p, "0", 1);
890 name = stringarray_get(&es->args, 0);
891 m = macrotable_find(name, false);
892 val = (m != NULL) ? "1" : "0";
893 debuglog(p, "defined(%s): %s", name, val);
894 expand_send(es, p, val, 1);
895 expstate_destroyargs(es);
900 assert(m->inuse == false);
903 debuglog(p, "Expanding macro %s", m->name);
904 newbuf = expand_substitute(p, es);
905 debuglog(p, "Substituting for %s: %s", m->name, newbuf);
907 newbuf2 = macroexpand(p, newbuf, strlen(newbuf), false);
909 expstate_destroyargs(es);
910 debuglog(p, "Complete expansion for %s: %s", m->name, newbuf2);
912 doexpand(es, p, newbuf2, strlen(newbuf2));
919 * The traditional behavior if a function-like macro appears without
920 * arguments is to pretend it isn't a macro; that is, just emit its
925 expand_missingargs(struct expstate *es, struct place *p, bool needspace)
927 if (es->curmacro == NULL) {
929 expand_send(es, p, "defined", 7);
932 expand_send(es, p, es->curmacro->name, strlen(es->curmacro->name));
933 /* send a space in case we ate whitespace after the macro name */
935 expand_send(es, p, " ", 1);
941 expand_got_ws(struct expstate *es, struct place *p,
942 const char *buf, size_t len)
946 expand_send(es, p, buf, len);
950 //expand_send(es, p, buf, len);
953 expand_newarg(es, buf, len);
954 es->state = ES_HAVEARG;
957 expand_appendarg(es, buf, len);
964 expand_got_word(struct expstate *es, struct place *p,
965 const char *buf, size_t len)
971 if (es->honordefined &&
972 len == 7 && !memcmp(buf, "defined", 7)) {
974 es->state = ES_WANTLPAREN;
977 m = macrotable_findlen(buf, len, false);
978 if (m == NULL || m->inuse) {
979 expand_send(es, p, buf, len);
980 } else if (!m->hasparams) {
982 expand_domacro(es, p);
985 es->state = ES_WANTLPAREN;
989 if (es->curmacro != NULL) {
990 expand_missingargs(es, p, true);
991 es->state = ES_NORMAL;
993 expand_got_word(es, p, buf, len);
995 /* "defined foo" means "defined(foo)" */
996 expand_newarg(es, buf, len);
997 es->state = ES_NORMAL;
998 expand_domacro(es, p);
1002 expand_newarg(es, buf, len);
1003 es->state = ES_HAVEARG;
1006 expand_appendarg(es, buf, len);
1013 expand_got_lparen(struct expstate *es, struct place *p,
1014 const char *buf, size_t len)
1016 switch (es->state) {
1018 expand_send(es, p, buf, len);
1021 es->state = ES_NOARG;
1024 expand_newarg(es, buf, len);
1025 es->state = ES_HAVEARG;
1029 expand_appendarg(es, buf, len);
1037 expand_got_rparen(struct expstate *es, struct place *p,
1038 const char *buf, size_t len)
1040 switch (es->state) {
1042 expand_send(es, p, buf, len);
1045 expand_missingargs(es, p, false);
1046 es->state = ES_NORMAL;
1048 expand_got_rparen(es, p, buf, len);
1051 assert(es->argparens == 0);
1052 if (stringarray_num(&es->args) > 0) {
1053 /* we are after a comma; enter an empty argument */
1054 expand_newarg(es, buf, 0);
1056 es->state = ES_NORMAL;
1057 expand_domacro(es, p);
1060 if (es->argparens > 0) {
1062 expand_appendarg(es, buf, len);
1064 es->state = ES_NORMAL;
1065 expand_domacro(es, p);
1073 expand_got_comma(struct expstate *es, struct place *p,
1074 const char *buf, size_t len)
1076 switch (es->state) {
1078 expand_send(es, p, buf, len);
1081 expand_missingargs(es, p, false);
1082 es->state = ES_NORMAL;
1084 expand_got_comma(es, p, buf, len);
1087 assert(es->argparens == 0);
1088 expand_newarg(es, buf, 0);
1091 if (es->argparens > 0) {
1092 expand_appendarg(es, buf, len);
1094 es->state = ES_NOARG;
1102 expand_got_other(struct expstate *es, struct place *p,
1103 const char *buf, size_t len)
1105 switch (es->state) {
1107 expand_send(es, p, buf, len);
1110 expand_missingargs(es, p, false);
1111 es->state = ES_NORMAL;
1113 expand_got_other(es, p, buf, len);
1116 expand_newarg(es, buf, len);
1117 es->state = ES_HAVEARG;
1120 expand_appendarg(es, buf, len);
1127 expand_got_eof(struct expstate *es, struct place *p)
1129 switch (es->state) {
1133 expand_missingargs(es, p, false);
1138 complain(p, "Unclosed argument list for macro %s",
1139 es->curmacro->name);
1141 complain(p, "Unclosed argument list for defined()");
1144 expstate_destroyargs(es);
1147 expand_send_eof(es, p);
1148 es->state = ES_NORMAL;
1149 es->curmacro = NULL;
1155 doexpand(struct expstate *es, struct place *p, const char *buf, size_t len)
1159 bool inquote = false;
1163 x = strspn(buf, ws);
1165 /* XXX gross, need strnspn */
1170 expand_got_ws(es, p, buf, x);
1176 x = strspn(buf, alnum);
1178 /* XXX gross, need strnspn */
1182 if (!inquote && x > 0) {
1183 expand_got_word(es, p, buf, x);
1189 if (!inquote && len > 1 && buf[0] == '/' && buf[1] == '*') {
1190 s = strstr(buf, "*/");
1196 expand_got_ws(es, p, buf, x);
1202 if (!inquote && buf[0] == '(') {
1203 expand_got_lparen(es, p, buf, 1);
1209 if (!inquote && buf[0] == ')') {
1210 expand_got_rparen(es, p, buf, 1);
1216 if (!inquote && buf[0] == ',') {
1217 expand_got_comma(es, p, buf, 1);
1223 if (len > 1 && buf[0] == '\\' &&
1224 (buf[1] == '"' || buf[1] == '\'')) {
1225 expand_got_other(es, p, buf, 2);
1230 if (!inquote && (buf[0] == '"' || buf[0] == '\'')) {
1233 } else if (inquote && buf[0] == quote) {
1237 expand_got_other(es, p, buf, 1);
1244 macroexpand(struct place *p, const char *buf, size_t len, bool honordefined)
1249 expstate_init(&es, true, honordefined);
1250 doexpand(&es, p, buf, len);
1251 expand_got_eof(&es, p);
1253 /* trim to fit, so the malloc debugging won't complain */
1254 es.buf = dorealloc(es.buf, es.bufmax, strlen(es.buf) + 1);
1258 es.bufpos = es.bufmax = 0;
1260 expstate_cleanup(&es);
1266 macro_sendline(struct place *p, const char *buf, size_t len)
1268 doexpand(&mainstate, p, buf, len);
1269 switch (mainstate.state) {
1272 * If we were sent a blank line, don't emit a newline
1273 * for it. This matches the prior behavior of tradcpp.
1283 * Apparently to match gcc's -traditional behavior we
1284 * need to emit a space for each newline that appears
1285 * while processing macro args.
1287 expand_got_ws(&mainstate, p, " ", 1);
1293 macro_sendeof(struct place *p)
1295 expand_got_eof(&mainstate, p);
1298 ////////////////////////////////////////////////////////////
1299 // module initialization
1305 expstate_init(&mainstate, false, false);
1309 macros_cleanup(void)
1311 expstate_cleanup(&mainstate);
1312 macrotable_cleanup();