Deleted Added
full compact
b.c (107806) b.c (108072)
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

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

277 }
278 c = n;
279 } /* else */
280 /* c = c; */
281 *pp = p;
282 return c;
283}
284
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

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

277 }
278 c = n;
279 } /* else */
280 /* c = c; */
281 *pp = p;
282 return c;
283}
284
285static int collate_range_cmp(int a, int b)
286{
287 int r;
288 static char s[2][2];
289
290 if ((uschar)a == (uschar)b)
291 return 0;
292 s[0][0] = a;
293 s[1][0] = b;
294 if ((r = strcoll(s[0], s[1])) == 0)
295 r = (uschar)a - (uschar)b;
296 return r;
297}
298
299char *cclenter(const char *argp) /* add a character class */
300{
301 int i, c, c2;
285char *cclenter(const char *argp) /* add a character class */
286{
287 int i, c, c2;
302 int j;
303 uschar *p = (uschar *) argp;
304 uschar *op, *bp;
305 static uschar *buf = 0;
306 static int bufsz = 100;
307
308 op = p;
309 if (buf == 0 && (buf = (uschar *) malloc(bufsz)) == NULL)
310 FATAL("out of space for character class [%.10s...] 1", p);
311 bp = buf;
312 for (i = 0; (c = *p++) != 0; ) {
313 if (c == '\\') {
314 c = quoted((char **) &p);
315 } else if (c == '-' && i > 0 && bp[-1] != 0) {
316 if (*p != 0) {
317 c = bp[-1];
318 c2 = *p++;
319 if (c2 == '\\')
320 c2 = quoted((char **) &p);
288 uschar *p = (uschar *) argp;
289 uschar *op, *bp;
290 static uschar *buf = 0;
291 static int bufsz = 100;
292
293 op = p;
294 if (buf == 0 && (buf = (uschar *) malloc(bufsz)) == NULL)
295 FATAL("out of space for character class [%.10s...] 1", p);
296 bp = buf;
297 for (i = 0; (c = *p++) != 0; ) {
298 if (c == '\\') {
299 c = quoted((char **) &p);
300 } else if (c == '-' && i > 0 && bp[-1] != 0) {
301 if (*p != 0) {
302 c = bp[-1];
303 c2 = *p++;
304 if (c2 == '\\')
305 c2 = quoted((char **) &p);
321 if (collate_range_cmp(c, c2) > 0) { /* empty; ignore */
306 if (c > c2) { /* empty; ignore */
322 bp--;
323 i--;
324 continue;
325 }
307 bp--;
308 i--;
309 continue;
310 }
326 for (j = 0; j < NCHARS; j++) {
327 if ((collate_range_cmp(c, j) > 0) ||
328 collate_range_cmp(j, c2) > 0)
329 continue;
311 while (c < c2) {
330 if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0))
331 FATAL("out of space for character class [%.10s...] 2", p);
312 if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0))
313 FATAL("out of space for character class [%.10s...] 2", p);
332 *bp++ = j;
314 *bp++ = ++c;
333 i++;
334 }
335 continue;
336 }
337 }
338 if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0))
339 FATAL("out of space for character class [%.10s...] 3", p);
340 *bp++ = c;

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

708 * defined in IEEE P1003.1 draft 7 of June 2001, assuming the source
709 * and operating character sets are both ASCII (ISO646) or supersets
710 * thereof.
711 *
712 * Note that to avoid overflowing the temporary buffer used in
713 * relex(), the expanded character class (prior to range expansion)
714 * must be less than twice the size of their full name.
715 */
315 i++;
316 }
317 continue;
318 }
319 }
320 if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0))
321 FATAL("out of space for character class [%.10s...] 3", p);
322 *bp++ = c;

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

690 * defined in IEEE P1003.1 draft 7 of June 2001, assuming the source
691 * and operating character sets are both ASCII (ISO646) or supersets
692 * thereof.
693 *
694 * Note that to avoid overflowing the temporary buffer used in
695 * relex(), the expanded character class (prior to range expansion)
696 * must be less than twice the size of their full name.
697 */
716
717struct charclass {
718 const char *cc_name;
719 int cc_namelen;
698struct charclass {
699 const char *cc_name;
700 int cc_namelen;
720 int (*cc_func)(int);
701 const char *cc_expand;
721} charclasses[] = {
702} charclasses[] = {
722 { "alnum", 5, isalnum },
723 { "alpha", 5, isalpha },
724 { "blank", 5, isblank },
725 { "cntrl", 5, iscntrl },
726 { "digit", 5, isdigit },
727 { "graph", 5, isgraph },
728 { "lower", 5, islower },
729 { "print", 5, isprint },
730 { "punct", 5, ispunct },
731 { "space", 5, isspace },
732 { "upper", 5, isupper },
733 { "xdigit", 6, isxdigit },
703 { "alnum", 5, "0-9A-Za-z" },
704 { "alpha", 5, "A-Za-z" },
705 { "blank", 5, " \t" },
706 { "cntrl", 5, "\000-\037\177" },
707 { "digit", 5, "0-9" },
708 { "graph", 5, "\041-\176" },
709 { "lower", 5, "a-z" },
710 { "print", 5, " \041-\176" },
711 { "punct", 5, "\041-\057\072-\100\133-\140\173-\176" },
712 { "space", 5, " \f\n\r\t\v" },
713 { "upper", 5, "A-Z" },
714 { "xdigit", 6, "0-9A-Fa-f" },
734 { NULL, 0, NULL },
735};
736
737
738int relex(void) /* lexical analyzer for reparse */
739{
740 int c, n;
741 int cflag;
742 static uschar *buf = 0;
743 static int bufsz = 100;
744 uschar *bp;
745 struct charclass *cc;
715 { NULL, 0, NULL },
716};
717
718
719int relex(void) /* lexical analyzer for reparse */
720{
721 int c, n;
722 int cflag;
723 static uschar *buf = 0;
724 static int bufsz = 100;
725 uschar *bp;
726 struct charclass *cc;
746 int i;
727 const uschar *p;
747
748 switch (c = *prestr++) {
749 case '|': return OR;
750 case '*': return STAR;
751 case '+': return PLUS;
752 case '?': return QUEST;
753 case '.': return DOT;
754 case '\0': prestr--; return '\0';

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

787 } else if (c == '[' && *prestr == ':') {
788 /* POSIX char class names, Dag-Erling Smorgrav, des@ofug.org */
789 for (cc = charclasses; cc->cc_name; cc++)
790 if (strncmp((const char *) prestr + 1, (const char *) cc->cc_name, cc->cc_namelen) == 0)
791 break;
792 if (cc->cc_name != NULL && prestr[1 + cc->cc_namelen] == ':' &&
793 prestr[2 + cc->cc_namelen] == ']') {
794 prestr += cc->cc_namelen + 3;
728
729 switch (c = *prestr++) {
730 case '|': return OR;
731 case '*': return STAR;
732 case '+': return PLUS;
733 case '?': return QUEST;
734 case '.': return DOT;
735 case '\0': prestr--; return '\0';

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

768 } else if (c == '[' && *prestr == ':') {
769 /* POSIX char class names, Dag-Erling Smorgrav, des@ofug.org */
770 for (cc = charclasses; cc->cc_name; cc++)
771 if (strncmp((const char *) prestr + 1, (const char *) cc->cc_name, cc->cc_namelen) == 0)
772 break;
773 if (cc->cc_name != NULL && prestr[1 + cc->cc_namelen] == ':' &&
774 prestr[2 + cc->cc_namelen] == ']') {
775 prestr += cc->cc_namelen + 3;
795 for (i = 0; i < NCHARS; i++) {
796 if (!adjbuf((char **) &buf, &bufsz, bp-buf+1, 100, (char **) &bp, 0))
797 FATAL("out of space for reg expr %.10s...", lastre);
798 if (cc->cc_func(i)) {
799 *bp++ = i;
800 n++;
801 }
802 }
776 for (p = (const uschar *) cc->cc_expand; *p; p++)
777 *bp++ = *p;
803 } else
804 *bp++ = c;
805 } else if (c == '\0') {
806 FATAL("nonterminated character class %.20s", lastre);
807 } else if (bp == buf) { /* 1st char is special */
808 *bp++ = c;
809 } else if (c == ']') {
810 *bp++ = 0;

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

--- 117 unchanged lines hidden ---