Lines Matching refs:p
43 #define PEEK() (*p->next)
44 #define PEEK2() (*(p->next+1))
45 #define MORE() (p->next < p->end)
46 #define MORE2() (p->next+1 < p->end)
51 #define NEXT() (p->next++)
52 #define NEXT2() (p->next += 2)
53 #define NEXTn(n) (p->next += (n))
54 #define GETNEXT() (*p->next++)
55 #define SETERROR(e) seterr(p, (e))
60 #define EMIT(op, sopnd) doemit(p, (sop)(op), (size_t)(sopnd))
61 #define INSERT(op, pos) doinsert(p, (sop)(op), HERE()-(pos)+1, pos)
62 #define AHEAD(pos) dofwd(p, pos, HERE()-(pos))
64 #define HERE() (p->slen)
65 #define THERE() (p->slen - 1)
66 #define THERETHERE() (p->slen - 2)
67 #define DROP(n) (p->slen -= (n))
95 register struct parse *p = &pa; variable
127 p->ssize = new_ssize;
129 p->strip = (sop *)malloc(p->ssize * sizeof(sop));
130 p->slen = 0;
131 if (p->strip == NULL) {
137 p->g = g;
138 p->next = (unsigned char *)pattern; /* convenience; we do not modify it */
139 p->end = p->next + len;
140 p->error = 0;
141 p->ncsalloc = 0;
143 p->pbegin[i] = 0;
144 p->pend[i] = 0;
166 p_ere(p, OUT);
168 p_str(p);
170 p_bre(p, OUT, OUT);
175 categorize(p, g);
176 stripsnug(p, g);
177 findmust(p, g);
178 g->nplus = pluscount(p, g);
190 if (p->error != 0) /* lose */
192 return(p->error);
200 p_ere(p, stop) in p_ere() argument
201 register struct parse *p; in p_ere()
214 p_ere_exp(p);
246 p_ere_exp(p) in p_ere_exp() argument
247 register struct parse *p; in p_ere_exp()
263 p->g->nsub++;
264 subno = p->g->nsub;
266 p->pbegin[subno] = HERE();
269 p_ere(p, ')');
271 p->pend[subno] = HERE();
272 assert(p->pend[subno] != 0);
291 p->g->iflags |= USEBOL;
292 p->g->nbol++;
297 p->g->iflags |= USEEOL;
298 p->g->neol++;
309 if (p->g->cflags®_NEWLINE)
310 nonnewline(p);
315 p_bracket(p);
320 ordinary(p, c);
326 ordinary(p, c);
362 count = p_count(p);
365 count2 = p_count(p);
371 repeat(p, pos, count, count2);
395 p_str(p) in p_str() argument
396 register struct parse *p; in p_str()
400 ordinary(p, GETNEXT());
416 p_bre(p, end1, end2) in p_bre() argument
417 register struct parse *p; in p_bre()
427 p->g->iflags |= USEBOL;
428 p->g->nbol++;
431 wasdollar = p_simp_re(p, first);
437 p->g->iflags |= USEEOL;
438 p->g->neol++;
449 p_simp_re(p, starordinary) in p_simp_re() argument
450 register struct parse *p; in p_simp_re()
471 if (p->g->cflags®_NEWLINE)
472 nonnewline(p);
477 p_bracket(p);
483 p->g->nsub++;
484 subno = p->g->nsub;
486 p->pbegin[subno] = HERE();
490 p_bre(p, '\\', ')');
492 p->pend[subno] = HERE();
493 assert(p->pend[subno] != 0);
513 if (p->pend[i] != 0) {
514 assert(i <= p->g->nsub);
516 assert(p->pbegin[i] != 0);
517 assert(OP(p->strip[p->pbegin[i]]) == OLPAREN);
518 assert(OP(p->strip[p->pend[i]]) == ORPAREN);
519 (void) dupl(p, p->pbegin[i]+1, p->pend[i]);
523 p->g->backrefs = 1;
529 ordinary(p, (unsigned char)c); /* takes off BACKSL, if any */
540 count = p_count(p);
543 count2 = p_count(p);
549 repeat(p, pos, count, count2);
567 p_count(p) in p_count() argument
568 register struct parse *p; in p_count()
590 p_bracket(p) in p_bracket() argument
591 register struct parse *p; in p_bracket()
593 register cset *cs = allocset(p);
597 if (p->next + 5 < p->end && strncmp(p->next, "[:<:]]", 6) == 0) {
602 if (p->next + 5 < p->end && strncmp(p->next, "[:>:]]", 6) == 0) {
615 p_b_term(p, cs);
620 if (p->error != 0) /* don't mess things up further */
623 if (p->g->cflags®_ICASE) {
627 for (i = p->g->csetsize - 1; i >= 0; i--)
634 mccase(p, cs);
639 for (i = p->g->csetsize - 1; i >= 0; i--)
644 if (p->g->cflags®_NEWLINE)
647 mcinvert(p, cs);
652 if (nch(p, cs) == 1) { /* optimize singleton sets */
653 ordinary(p, firstch(p, cs));
654 freeset(p, cs);
656 EMIT(OANYOF, freezeset(p, cs));
664 p_b_term(p, cs) in p_b_term() argument
665 register struct parse *p; in p_b_term()
692 p_b_cclass(p, cs);
701 p_b_eclass(p, cs);
707 start = p_b_symbol(p);
714 finish = p_b_symbol(p);
730 p_b_cclass(p, cs) in p_b_cclass() argument
731 register struct parse *p; in p_b_cclass()
734 register unsigned char *sp = p->next;
742 len = p->next - sp;
756 MCadd(p, cs, u);
766 p_b_eclass(p, cs) in p_b_eclass() argument
767 register struct parse *p; in p_b_eclass()
772 c = p_b_coll_elem(p, '=');
781 p_b_symbol(p) in p_b_symbol() argument
782 register struct parse *p; in p_b_symbol()
791 value = p_b_coll_elem(p, '.');
801 p_b_coll_elem(p, endc) in p_b_coll_elem() argument
802 register struct parse *p; in p_b_coll_elem()
805 register unsigned char *sp = p->next;
815 len = p->next - sp;
849 bothcases(p, ch) in bothcases() argument
850 register struct parse *p; in bothcases()
853 register unsigned char *oldnext = p->next;
854 register unsigned char *oldend = p->end;
858 p->next = bracket;
859 p->end = bracket+2;
863 p_bracket(p);
864 assert(p->next == bracket+2);
865 p->next = oldnext;
866 p->end = oldend;
874 ordinary(p, ch) in ordinary() argument
875 register struct parse *p; in ordinary()
878 register cat_t *cap = p->g->categories;
880 if ((p->g->cflags®_ICASE) && isalpha(ch) && othercase(ch) != ch)
881 bothcases(p, ch);
885 cap[ch] = p->g->ncategories++;
896 nonnewline(p) in nonnewline() argument
897 register struct parse *p; in nonnewline()
899 register unsigned char *oldnext = p->next;
900 register unsigned char *oldend = p->end;
903 p->next = bracket;
904 p->end = bracket+3;
909 p_bracket(p);
910 assert(p->next == bracket+3);
911 p->next = oldnext;
912 p->end = oldend;
920 repeat(p, start, from, to) in repeat() argument
921 register struct parse *p; in repeat()
933 if (p->error != 0) /* head off possible runaway recursion */
947 repeat(p, start+1, 1, to);
965 copy = dupl(p, start+1, finish+1);
967 repeat(p, copy, 1, to-1);
974 copy = dupl(p, start, finish);
975 repeat(p, copy, from-1, to-1);
978 copy = dupl(p, start, finish);
979 repeat(p, copy, from-1, to);
992 seterr(p, e) in seterr() argument
993 register struct parse *p; in seterr()
996 if (p->error == 0) /* keep earliest error condition */
997 p->error = e;
998 p->next = nuls; /* try to bring things to a halt */
999 p->end = nuls;
1008 allocset(p) in allocset() argument
1009 register struct parse *p; in allocset()
1011 register int no = p->g->ncsets++;
1015 register size_t css = (size_t)p->g->csetsize;
1018 if (no >= p->ncsalloc) { /* need another column of space */
1019 p->ncsalloc += CHAR_BIT;
1020 nc = p->ncsalloc;
1023 if (p->g->sets == NULL)
1024 p->g->sets = (cset *)malloc(nc * sizeof(cset));
1026 p->g->sets = (cset *)realloc((unsigned char *)p->g->sets,
1028 if (p->g->setbits == NULL)
1029 p->g->setbits = (uch *)malloc(nbytes);
1031 p->g->setbits = (uch *)realloc((unsigned char *)p->g->setbits,
1035 p->g->sets[i].ptr = p->g->setbits + css*(i/CHAR_BIT);
1037 if (p->g->sets != NULL && p->g->setbits != NULL)
1038 (void) memset((unsigned char *)p->g->setbits + (nbytes - css),
1047 assert(p->g->sets != NULL); /* xxx */
1048 cs = &p->g->sets[no];
1049 cs->ptr = p->g->setbits + css*((no)/CHAR_BIT);
1063 freeset(p, cs) in freeset() argument
1064 register struct parse *p; in freeset()
1068 register cset *top = &p->g->sets[p->g->ncsets];
1069 register size_t css = (size_t)p->g->csetsize;
1074 p->g->ncsets--;
1088 freezeset(p, cs) in freezeset() argument
1089 register struct parse *p; in freezeset()
1094 register cset *top = &p->g->sets[p->g->ncsets];
1096 register size_t css = (size_t)p->g->csetsize;
1099 for (cs2 = &p->g->sets[0]; cs2 < top; cs2++)
1110 freeset(p, cs);
1114 return((int)(cs - p->g->sets));
1122 firstch(p, cs) in firstch() argument
1123 register struct parse *p; in firstch()
1127 register size_t css = (size_t)p->g->csetsize;
1141 nch(p, cs) in nch() argument
1142 register struct parse *p; in nch()
1146 register size_t css = (size_t)p->g->csetsize;
1161 mcadd(p, cs, cp) in mcadd() argument
1162 register struct parse *p; in mcadd()
1232 register unsigned char *p;
1236 for (p = cs->multis; *p != '\0'; p += strlen(p) + 1)
1237 if (strcmp(cp, p) == 0)
1238 return(p);
1251 mcinvert(p, cs) in mcinvert() argument
1252 register struct parse *p; in mcinvert()
1266 mccase(p, cs) in mccase() argument
1267 register struct parse *p; in mccase()
1324 categorize(p, g) in categorize() argument
1325 struct parse *p; in categorize()
1334 if (p->error != 0)
1352 dupl(p, start, finish) in dupl() argument
1353 register struct parse *p; in dupl()
1363 enlarge(p, p->ssize + len); /* this many unexpected additions */
1364 assert(p->ssize >= p->slen + len);
1365 (void) memcpy((char *)(p->strip + p->slen),
1366 (char *)(p->strip + start), (size_t)len*sizeof(sop));
1367 p->slen += len;
1380 doemit(p, op, opnd) in doemit() argument
1381 register struct parse *p; in doemit()
1386 if (p->error != 0)
1393 if (p->slen >= p->ssize)
1394 enlarge(p, (p->ssize+1) / 2 * 3); /* +50% */
1395 assert(p->slen < p->ssize);
1398 p->strip[p->slen++] = SOP(op, opnd);
1406 doinsert(p, op, opnd, pos) in doinsert() argument
1407 register struct parse *p; in doinsert()
1417 if (p->error != 0)
1423 s = p->strip[sn];
1428 if (p->pbegin[i] >= pos) {
1429 p->pbegin[i]++;
1431 if (p->pend[i] >= pos) {
1432 p->pend[i]++;
1436 memmove((char *)&p->strip[pos+1], (char *)&p->strip[pos],
1438 p->strip[pos] = s;
1446 dofwd(p, pos, value) in dofwd() argument
1447 register struct parse *p; in dofwd()
1452 if (p->error != 0)
1456 p->strip[pos] = OP(p->strip[pos]) | value;
1464 enlarge(p, size) in enlarge() argument
1465 register struct parse *p; in enlarge()
1470 if (p->ssize >= size)
1473 sp = (sop *)realloc(p->strip, size*sizeof(sop));
1478 p->strip = sp;
1479 p->ssize = size;
1487 stripsnug(p, g) in stripsnug() argument
1488 register struct parse *p; in stripsnug()
1491 g->nstates = p->slen;
1492 g->strip = (sop *)realloc((unsigned char *)p->strip, p->slen * sizeof(sop));
1495 g->strip = p->strip;
1510 findmust(p, g) in findmust() argument
1511 struct parse *p; in findmust()
1523 if (p->error != 0)
1596 pluscount(p, g) in pluscount() argument
1597 struct parse *p; in pluscount()
1605 if (p->error != 0)