Lines Matching +full:scan +full:- +full:count
2 * regcomp and regexec -- regsub and regerror are elsewhere
23 * regular-expression syntax might require a total rethink.
27 * Added regexec2 with notbol parameter. -- 4/19/99 Mark Nudelman
48 * reganch is the match anchored (at beginning-of-line only)?
64 * of a nondeterministic finite-state machine (aka syntax charts or
72 * a literal string; for others, it is a node leading into a sub-FSM. In
120 * "Next" pointers are stored as two 8-bit pieces, high order first. The
161 static constant char *regparse; /* Input-scan pointer. */
162 static int regnpar; /* () count. */
164 static char *regcode; /* Code-emit pointer; ®dummy = don't. */
195 - regcomp - compile a regular expression into internal code
206 * Beware that the optimization-preparation code in here knows about some
213 register char *scan;
230 /* Small enough for pointer-storage convention? */
242 regcode = r->program;
251 r->regstart = '\0'; /* Worst-case defaults. */
252 r->reganch = 0;
253 r->regmust = NULL;
254 r->regmlen = 0;
255 scan = r->program+1; /* First BRANCH. */
256 if (OP(regnext(scan)) == END) { /* Only one top-level choice. */
257 scan = OPERAND(scan);
259 /* Starting-point info. */
260 if (OP(scan) == EXACTLY)
261 r->regstart = *OPERAND(scan);
262 else if (OP(scan) == BOL)
263 r->reganch++;
276 for (; scan != NULL; scan = regnext(scan))
277 if (OP(scan) == EXACTLY && ((int) strlen(OPERAND(scan))) >= len) {
278 longest = OPERAND(scan);
279 len = (int) strlen(OPERAND(scan));
281 r->regmust = longest;
282 r->regmlen = len;
290 - reg - regular expression, i.e. main body or parenthesized thing
324 regtail(ret, br); /* OPEN -> first. */
335 regtail(ret, br); /* BRANCH -> BRANCH. */
364 - regbranch - one alternative of an | operator
398 - regpiece - something followed by possible [*+?]
462 - regatom - the lowest level
497 if (*regparse == ']' || *regparse == '-')
500 if (*regparse == '-') {
503 regc('-');
505 clss = UCHARAT(regparse-2)+1;
553 regparse--;
559 len--; /* Back off clear of ?+* operand. */
566 len--;
577 - regnode - emit a node
601 - regc - emit (if appropriate) a byte of code
613 - reginsert - insert an operator in front of already-emitted operand
633 *--dst = *--src;
642 - regtail - set the next-pointer at the end of a node chain
647 register char *scan;
655 scan = p;
657 temp = regnext(scan);
660 scan = temp;
663 if (OP(scan) == BACK)
664 offset = (int) (scan - val);
666 offset = (int) (val - scan);
667 *(scan+1) = (offset>>8)&0377;
668 *(scan+2) = offset&0377;
672 - regoptail - regtail on operand of first argument; nop if operandless
690 static constant char *reginput; /* String-input pointer. */
709 - regexec - match a regexp against a string
723 if (UCHARAT(prog->program) != MAGIC) {
729 if (prog->regmust != NULL) {
731 while ((s = strchr(s, prog->regmust[0])) != NULL) {
732 if (strncmp(s, prog->regmust, prog->regmlen) == 0)
747 if (prog->reganch)
752 if (prog->regstart != '\0')
754 while ((s = strchr(s, prog->regstart)) != NULL) {
760 /* We don't -- general case. */
777 - regtry - try match at specific point
787 regstartp = prog->startp;
788 regendp = prog->endp;
790 sp = prog->startp;
791 ep = prog->endp;
792 for (i = NSUBEXP; i > 0; i--) {
796 if (regmatch(prog->program + 1)) {
797 prog->startp[0] = string;
798 prog->endp[0] = reginput;
805 - regmatch - main matching routine
817 register char *scan; /* Current node. */
820 scan = prog;
822 if (scan != NULL && regnarrate)
823 fprintf(stderr, "%s(\n", regprop(scan));
825 while (scan != NULL) {
828 fprintf(stderr, "%s...\n", regprop(scan));
830 next = regnext(scan);
832 switch (OP(scan)) {
850 opnd = OPERAND(scan);
861 if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == NULL)
866 if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != NULL)
886 no = OP(scan) - OPEN;
915 no = OP(scan) - CLOSE;
936 next = OPERAND(scan); /* Avoid recursion. */
940 if (regmatch(OPERAND(scan)))
943 scan = regnext(scan);
944 } while (scan != NULL && OP(scan) == BRANCH);
965 min = (OP(scan) == STAR) ? 0 : 1;
967 no = regrepeat(OPERAND(scan));
973 /* Couldn't or didn't -- back up. */
974 no--;
992 scan = next;
996 * We get here only if there's trouble -- normally "case END" is
1004 - regrepeat - repeatedly match something simple, report how many
1009 register int count = 0;
1010 register constant char *scan;
1013 scan = reginput;
1017 count = (int) strlen(scan);
1018 scan += count;
1021 while (*opnd == *scan) {
1022 count++;
1023 scan++;
1027 while (*scan != '\0' && strchr(opnd, *scan) != NULL) {
1028 count++;
1029 scan++;
1033 while (*scan != '\0' && strchr(opnd, *scan) == NULL) {
1034 count++;
1035 scan++;
1040 count = 0; /* Best compromise. */
1043 reginput = scan;
1045 return(count);
1049 - regnext - dig the "next" pointer out of a node
1064 return(p-offset);
1074 - regdump - dump a regexp onto stdout in vaguely comprehensible form
1081 register char op = EXACTLY; /* Arbitrary non-END op. */
1085 s = r->program + 1;
1088 printf("%2d%s", s-r->program, regprop(s)); /* Where, what. */
1093 printf("(%d)", (s-r->program)+(next-s));
1107 if (r->regstart != '\0')
1108 printf("start `%c' ", r->regstart);
1109 if (r->reganch)
1111 if (r->regmust != NULL)
1112 printf("must have \"%s\"", r->regmust);
1117 - regprop - printable representation of opcode
1168 sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN);
1180 sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE);
1202 * about it; at least one public-domain implementation of those (highly
1207 * strcspn - find length of initial segment of s1 consisting entirely
1216 register int count;
1218 count = 0;
1222 return(count);
1223 count++;
1225 return(count);