Deleted Added
full compact
b.c (108072) b.c (112336)
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
285char *cclenter(const char *argp) /* add a character class */
286{
287 int i, c, c2;
299char *cclenter(const char *argp) /* add a character class */
300{
301 int i, c, c2;
302 int j;
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);
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);
306 if (c > c2) { /* empty; ignore */
321 if (collate_range_cmp(c, c2) > 0) { /* empty; ignore */
307 bp--;
308 i--;
309 continue;
310 }
322 bp--;
323 i--;
324 continue;
325 }
311 while (c < c2) {
326 for (j = 0; j < NCHARS; j++) {
327 if ((collate_range_cmp(c, j) > 0) ||
328 collate_range_cmp(j, c2) > 0)
329 continue;
312 if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0))
313 FATAL("out of space for character class [%.10s...] 2", p);
330 if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0))
331 FATAL("out of space for character class [%.10s...] 2", p);
314 *bp++ = ++c;
332 *bp++ = j;
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 */
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 */
716
717/* Because isblank doesn't show up in any of the header files on any
718 * system i use, it's defined here. if some other locale has a richer
719 * definition of "blank", define HAS_ISBLANK and provide your own
720 * version.
721 */
722
723#ifndef HAS_ISBLANK
724
725int isblank(int c)
726{
727 return c==' ' || c=='\t';
728}
729
730#endif
731
698struct charclass {
699 const char *cc_name;
700 int cc_namelen;
732struct charclass {
733 const char *cc_name;
734 int cc_namelen;
701 const char *cc_expand;
735 int (*cc_func)(int);
702} charclasses[] = {
736} charclasses[] = {
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" },
737 { "alnum", 5, isalnum },
738 { "alpha", 5, isalpha },
739 { "blank", 5, isblank },
740 { "cntrl", 5, iscntrl },
741 { "digit", 5, isdigit },
742 { "graph", 5, isgraph },
743 { "lower", 5, islower },
744 { "print", 5, isprint },
745 { "punct", 5, ispunct },
746 { "space", 5, isspace },
747 { "upper", 5, isupper },
748 { "xdigit", 6, isxdigit },
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;
749 { NULL, 0, NULL },
750};
751
752
753int relex(void) /* lexical analyzer for reparse */
754{
755 int c, n;
756 int cflag;
757 static uschar *buf = 0;
758 static int bufsz = 100;
759 uschar *bp;
760 struct charclass *cc;
727 const uschar *p;
761 int i;
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;
762
763 switch (c = *prestr++) {
764 case '|': return OR;
765 case '*': return STAR;
766 case '+': return PLUS;
767 case '?': return QUEST;
768 case '.': return DOT;
769 case '\0': prestr--; return '\0';

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

802 } else if (c == '[' && *prestr == ':') {
803 /* POSIX char class names, Dag-Erling Smorgrav, des@ofug.org */
804 for (cc = charclasses; cc->cc_name; cc++)
805 if (strncmp((const char *) prestr + 1, (const char *) cc->cc_name, cc->cc_namelen) == 0)
806 break;
807 if (cc->cc_name != NULL && prestr[1 + cc->cc_namelen] == ':' &&
808 prestr[2 + cc->cc_namelen] == ']') {
809 prestr += cc->cc_namelen + 3;
776 for (p = (const uschar *) cc->cc_expand; *p; p++)
777 *bp++ = *p;
810 for (i = 0; i < NCHARS; i++) {
811 if (!adjbuf((char **) &buf, &bufsz, bp-buf+1, 100, (char **) &bp, 0))
812 FATAL("out of space for reg expr %.10s...", lastre);
813 if (cc->cc_func(i)) {
814 *bp++ = i;
815 n++;
816 }
817 }
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 ---
818 } else
819 *bp++ = c;
820 } else if (c == '\0') {
821 FATAL("nonterminated character class %.20s", lastre);
822 } else if (bp == buf) { /* 1st char is special */
823 *bp++ = c;
824 } else if (c == ']') {
825 *bp++ = 0;

--- 117 unchanged lines hidden ---