=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/awk/parse.c,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** src/usr.bin/awk/parse.c 1996/07/04 20:34:45 1.1 --- src/usr.bin/awk/parse.c 1997/08/25 16:17:13 1.2 *************** *** 1,5 **** /**************************************************************** ! Copyright (C) AT&T and Lucent Technologies 1996 All Rights Reserved Permission to use, copy, modify, and distribute this software and --- 1,6 ---- + /* $OpenBSD: parse.c,v 1.2 1997/08/25 16:17:13 kstailey Exp $ */ /**************************************************************** ! Copyright (C) Lucent Technologies 1997 All Rights Reserved Permission to use, copy, modify, and distribute this software and *************** *** 7,25 **** granted, provided that the above copyright notice appear in all copies and that both that the copyright notice and this permission notice and warranty disclaimer appear in supporting ! documentation, and that the names of AT&T or Lucent Technologies ! or any of their entities not be used in advertising or publicity ! pertaining to distribution of the software without specific, ! written prior permission. ! AT&T AND LUCENT DISCLAIM ALL WARRANTIES WITH REGARD TO THIS ! SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND ! FITNESS. IN NO EVENT SHALL AT&T OR LUCENT OR ANY OF THEIR ! ENTITIES BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL ! DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, ! DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR ! OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE ! USE OR PERFORMANCE OF THIS SOFTWARE. ****************************************************************/ #define DEBUG --- 8,26 ---- granted, provided that the above copyright notice appear in all copies and that both that the copyright notice and this permission notice and warranty disclaimer appear in supporting ! documentation, and that the name Lucent Technologies or any of ! its entities not be used in advertising or publicity pertaining ! to distribution of the software without specific, written prior ! permission. ! LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, ! INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. ! IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY ! SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ! WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER ! IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ! ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ! THIS SOFTWARE. ****************************************************************/ #define DEBUG *************** *** 27,33 **** #include #include #include "awk.h" ! #include "awkgram.h" Node *nodealloc(int n) { --- 28,34 ---- #include #include #include "awk.h" ! #include "ytab.h" Node *nodealloc(int n) { *************** *** 165,171 **** return(x); } ! Node *valtonode(Cell *a, int b) { Node *x; --- 166,172 ---- return(x); } ! Node *celltonode(Cell *a, int b) { Node *x; *************** *** 178,184 **** Node *rectonode(void) /* make $0 into a Node */ { ! return valtonode(recloc, CFLD); } Node *makearr(Node *p) --- 179,186 ---- Node *rectonode(void) /* make $0 into a Node */ { ! extern Cell *literal0; ! return op1(INDIRECT, celltonode(literal0, CUNK)); } Node *makearr(Node *p) *************** *** 187,193 **** if (isvalue(p)) { cp = (Cell *) (p->narg[0]); ! if (isfunc(cp)) ERROR "%s is a function, not an array", cp->nval SYNTAX; else if (!isarr(cp)) { xfree(cp->sval); --- 189,195 ---- if (isvalue(p)) { cp = (Cell *) (p->narg[0]); ! if (isfcn(cp)) ERROR "%s is a function, not an array", cp->nval SYNTAX; else if (!isarr(cp)) { xfree(cp->sval); *************** *** 198,209 **** return p; } Node *pa2stat(Node *a, Node *b, Node *c) /* pat, pat {...} */ { Node *x; x = node4(PASTAT2, a, b, c, (Node *) paircnt); ! paircnt++; x->ntype = NSTAT; return(x); } --- 200,216 ---- return p; } + #define PA2NUM 50 /* max number of pat,pat patterns allowed */ + int paircnt; /* number of them in use */ + int pairstack[PA2NUM]; /* state of each pat,pat */ + Node *pa2stat(Node *a, Node *b, Node *c) /* pat, pat {...} */ { Node *x; x = node4(PASTAT2, a, b, c, (Node *) paircnt); ! if (paircnt++ >= PA2NUM) ! ERROR "limited to %d pat,pat statements", PA2NUM SYNTAX; x->ntype = NSTAT; return(x); }