Deleted Added
full compact
b.c (85587) b.c (90902)
1/****************************************************************
2Copyright (C) Lucent Technologies 1997
3All Rights Reserved
4
5Permission to use, copy, modify, and distribute this software and
6its documentation for any purpose and without fee is hereby
7granted, provided that the above copyright notice appear in all
8copies and that both that the copyright notice and this

--- 79 unchanged lines hidden (view full) ---

88 if (setvec == 0 || tmpset == 0)
89 overflo("out of space initializing makedfa");
90 }
91
92 if (compile_time) /* a constant for sure */
93 return mkdfa(s, anchor);
94 for (i = 0; i < nfatab; i++) /* is it there already? */
95 if (fatab[i]->anchor == anchor
1/****************************************************************
2Copyright (C) Lucent Technologies 1997
3All Rights Reserved
4
5Permission to use, copy, modify, and distribute this software and
6its documentation for any purpose and without fee is hereby
7granted, provided that the above copyright notice appear in all
8copies and that both that the copyright notice and this

--- 79 unchanged lines hidden (view full) ---

88 if (setvec == 0 || tmpset == 0)
89 overflo("out of space initializing makedfa");
90 }
91
92 if (compile_time) /* a constant for sure */
93 return mkdfa(s, anchor);
94 for (i = 0; i < nfatab; i++) /* is it there already? */
95 if (fatab[i]->anchor == anchor
96 && strcmp(fatab[i]->restr, s) == 0) {
96 && strcmp((const char *) fatab[i]->restr, s) == 0) {
97 fatab[i]->use = now++;
98 return fatab[i];
99 }
100 pfa = mkdfa(s, anchor);
101 if (nfatab < NFA) { /* room for another */
102 fatab[nfatab] = pfa;
103 fatab[nfatab]->use = now++;
104 nfatab++;

--- 573 unchanged lines hidden (view full) ---

678 case QUEST:
679 rtok = relex();
680 return (unary(op2(QUEST, np, NIL)));
681 default:
682 return (np);
683 }
684}
685
97 fatab[i]->use = now++;
98 return fatab[i];
99 }
100 pfa = mkdfa(s, anchor);
101 if (nfatab < NFA) { /* room for another */
102 fatab[nfatab] = pfa;
103 fatab[nfatab]->use = now++;
104 nfatab++;

--- 573 unchanged lines hidden (view full) ---

678 case QUEST:
679 rtok = relex();
680 return (unary(op2(QUEST, np, NIL)));
681 default:
682 return (np);
683 }
684}
685
686/*
687 * Character class definitions conformant to the POSIX locale as
688 * defined in IEEE P1003.1 draft 7 of June 2001, assuming the source
689 * and operating character sets are both ASCII (ISO646) or supersets
690 * thereof.
691 *
692 * Note that to avoid overflowing the temporary buffer used in
693 * relex(), the expanded character class (prior to range expansion)
694 * must be less than twice the size of their full name.
695 */
696struct charclass {
697 const char *cc_name;
698 int cc_namelen;
699 const char *cc_expand;
700} charclasses[] = {
701 { "alnum", 5, "0-9A-Za-z" },
702 { "alpha", 5, "A-Za-z" },
703 { "blank", 5, " \t" },
704 { "cntrl", 5, "\000-\037\177" },
705 { "digit", 5, "0-9" },
706 { "graph", 5, "\041-\176" },
707 { "lower", 5, "a-z" },
708 { "print", 5, " \041-\176" },
709 { "punct", 5, "\041-\057\072-\100\133-\140\173-\176" },
710 { "space", 5, " \f\n\r\t\v" },
711 { "upper", 5, "A-Z" },
712 { "xdigit", 6, "0-9A-Fa-f" },
713 { NULL, 0, NULL },
714};
715
716
686int relex(void) /* lexical analyzer for reparse */
687{
688 int c, n;
689 int cflag;
690 static uschar *buf = 0;
691 static int bufsz = 100;
692 uschar *bp;
717int relex(void) /* lexical analyzer for reparse */
718{
719 int c, n;
720 int cflag;
721 static uschar *buf = 0;
722 static int bufsz = 100;
723 uschar *bp;
724 struct charclass *cc;
725 const uschar *p;
693
694 switch (c = *prestr++) {
695 case '|': return OR;
696 case '*': return STAR;
697 case '+': return PLUS;
698 case '?': return QUEST;
699 case '.': return DOT;
700 case '\0': prestr--; return '\0';

--- 13 unchanged lines hidden (view full) ---

714 FATAL("out of space in reg expr %.10s..", lastre);
715 bp = buf;
716 if (*prestr == '^') {
717 cflag = 1;
718 prestr++;
719 }
720 else
721 cflag = 0;
726
727 switch (c = *prestr++) {
728 case '|': return OR;
729 case '*': return STAR;
730 case '+': return PLUS;
731 case '?': return QUEST;
732 case '.': return DOT;
733 case '\0': prestr--; return '\0';

--- 13 unchanged lines hidden (view full) ---

747 FATAL("out of space in reg expr %.10s..", lastre);
748 bp = buf;
749 if (*prestr == '^') {
750 cflag = 1;
751 prestr++;
752 }
753 else
754 cflag = 0;
722 n = 2 * strlen(prestr)+1;
755 n = 2 * strlen((const char *) prestr)+1;
723 if (!adjbuf((char **) &buf, &bufsz, n, n, (char **) &bp, 0))
724 FATAL("out of space for reg expr %.10s...", lastre);
725 for (; ; ) {
726 if ((c = *prestr++) == '\\') {
727 *bp++ = '\\';
728 if ((c = *prestr++) == '\0')
729 FATAL("nonterminated character class %.20s...", lastre);
730 *bp++ = c;
731 /* } else if (c == '\n') { */
732 /* FATAL("newline in character class %.20s...", lastre); */
756 if (!adjbuf((char **) &buf, &bufsz, n, n, (char **) &bp, 0))
757 FATAL("out of space for reg expr %.10s...", lastre);
758 for (; ; ) {
759 if ((c = *prestr++) == '\\') {
760 *bp++ = '\\';
761 if ((c = *prestr++) == '\0')
762 FATAL("nonterminated character class %.20s...", lastre);
763 *bp++ = c;
764 /* } else if (c == '\n') { */
765 /* FATAL("newline in character class %.20s...", lastre); */
766 } else if (c == '[' && *prestr == ':') {
767 /* POSIX char class names, Dag-Erling Smorgrav, des@ofug.org */
768 for (cc = charclasses; cc->cc_name; cc++)
769 if (strncmp((const char *) prestr + 1, (const char *) cc->cc_name, cc->cc_namelen) == 0)
770 break;
771 if (cc->cc_name != NULL && prestr[1 + cc->cc_namelen] == ':' &&
772 prestr[2 + cc->cc_namelen] == ']') {
773 prestr += cc->cc_namelen + 3;
774 for (p = (const uschar *) cc->cc_expand; *p; p++)
775 *bp++ = *p;
776 } else
777 *bp++ = c;
733 } else if (c == '\0') {
734 FATAL("nonterminated character class %.20s", lastre);
735 } else if (bp == buf) { /* 1st char is special */
736 *bp++ = c;
737 } else if (c == ']') {
738 *bp++ = 0;
739 rlxstr = (uschar *) tostring((char *) buf);
740 if (cflag == 0)

--- 115 unchanged lines hidden ---
778 } else if (c == '\0') {
779 FATAL("nonterminated character class %.20s", lastre);
780 } else if (bp == buf) { /* 1st char is special */
781 *bp++ = c;
782 } else if (c == ']') {
783 *bp++ = 0;
784 rlxstr = (uschar *) tostring((char *) buf);
785 if (cflag == 0)

--- 115 unchanged lines hidden ---