=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/m4/main.c,v retrieving revision 1.58 retrieving revision 1.59 diff -c -r1.58 -r1.59 *** src/usr.bin/m4/main.c 2003/06/18 21:08:07 1.58 --- src/usr.bin/m4/main.c 2003/06/30 21:42:50 1.59 *************** *** 1,4 **** ! /* $OpenBSD: main.c,v 1.58 2003/06/18 21:08:07 espie Exp $ */ /* $NetBSD: main.c,v 1.12 1997/02/08 23:54:49 cgd Exp $ */ /*- --- 1,4 ---- ! /* $OpenBSD: main.c,v 1.59 2003/06/30 21:42:50 espie Exp $ */ /* $NetBSD: main.c,v 1.12 1997/02/08 23:54:49 cgd Exp $ */ /*- *************** *** 43,49 **** #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; #else ! static char rcsid[] = "$OpenBSD: main.c,v 1.58 2003/06/18 21:08:07 espie Exp $"; #endif #endif /* not lint */ --- 43,49 ---- #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; #else ! static char rcsid[] = "$OpenBSD: main.c,v 1.59 2003/06/30 21:42:50 espie Exp $"; #endif #endif /* not lint */ *************** *** 207,213 **** addtoincludepath(optarg); break; case 'U': /* undefine... */ ! remhash(optarg, TOP); break; case 'g': mimic_gnu = 1; --- 207,213 ---- addtoincludepath(optarg); break; case 'U': /* undefine... */ ! macro_popdef(optarg); break; case 'g': mimic_gnu = 1; *************** *** 317,340 **** t = gpbc(); if (t == '_' || isalpha(t)) { p = inspect(t, token); ! if (p != nil) putback(l = gpbc()); ! if (p == nil || (l != LPAREN && ! (p->type & NEEDARGS) != 0)) outputstr(token); else { /* * real thing.. First build a call frame: */ pushf(fp); /* previous call frm */ ! pushf(p->type); /* type of the call */ pushf(0); /* parenthesis level */ fp = sp; /* new frame pointer */ /* * now push the string arguments: */ ! pushs1(p->defn); /* defn string */ ! pushs1(p->name); /* macro name */ pushs(ep); /* start next..*/ if (l != LPAREN && PARLEV == 0) { --- 317,340 ---- t = gpbc(); if (t == '_' || isalpha(t)) { p = inspect(t, token); ! if (p != NULL) putback(l = gpbc()); ! if (p == NULL || (l != LPAREN && ! (macro_getdef(p)->type & NEEDARGS) != 0)) outputstr(token); else { /* * real thing.. First build a call frame: */ pushf(fp); /* previous call frm */ ! pushf(macro_getdef(p)->type); /* type of the call */ pushf(0); /* parenthesis level */ fp = sp; /* new frame pointer */ /* * now push the string arguments: */ ! pushs1(macro_getdef(p)->defn); /* defn string */ ! pushs1((char *)macro_name(p)); /* macro name */ pushs(ep); /* start next..*/ if (l != LPAREN && PARLEV == 0) { *************** *** 528,535 **** /* * build an input token.. ! * consider only those starting with _ or A-Za-z. This is a ! * combo with lookup to speed things up. */ static ndptr inspect(int c, char *tp) --- 528,534 ---- /* * build an input token.. ! * consider only those starting with _ or A-Za-z. */ static ndptr inspect(int c, char *tp) *************** *** 539,548 **** ndptr p; unsigned int h; ! h = *tp++ = c; while ((isalnum(c = gpbc()) || c == '_') && tp < etp) ! h = (h << 5) + h + (*tp++ = c); if (c != EOF) PUTBACK(c); *tp = EOS; --- 538,547 ---- ndptr p; unsigned int h; ! *tp++ = c; while ((isalnum(c = gpbc()) || c == '_') && tp < etp) ! *tp++ = c; if (c != EOF) PUTBACK(c); *tp = EOS; *************** *** 557,569 **** CHRSAVE(c); } *name = EOS; ! return nil; } ! for (p = hashtab[h % HASHSIZE]; p != nil; p = p->nxtptr) ! if (h == p->hv && STREQ(name, p->name)) ! break; ! return p; } /* --- 556,565 ---- CHRSAVE(c); } *name = EOS; ! return NULL; } ! return lookup(name); } /* *************** *** 576,596 **** static void initkwds(void) { ! size_t i; ! unsigned int h; ! ndptr p; for (i = 0; i < MAXKEYS; i++) { ! h = hash(keywrds[i].knam); ! p = (ndptr) xalloc(sizeof(struct ndblock)); ! p->nxtptr = hashtab[h % HASHSIZE]; ! hashtab[h % HASHSIZE] = p; ! p->name = xstrdup(keywrds[i].knam); ! p->defn = xstrdup(keywrds[i].knam); ! p->hv = h; ! p->type = keywrds[i].ktyp & TYPEMASK; if ((keywrds[i].ktyp & NOARGS) == 0) ! p->type |= NEEDARGS; } } --- 572,585 ---- static void initkwds(void) { ! unsigned int type; ! int i; for (i = 0; i < MAXKEYS; i++) { ! type = keywrds[i].ktyp & TYPEMASK; if ((keywrds[i].ktyp & NOARGS) == 0) ! type |= NEEDARGS; ! setup_builtin(keywrds[i].knam, type); } }