Deleted Added
sdiff udiff text old ( 108072 ) new ( 112336 )
full compact
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
285char *cclenter(const char *argp) /* add a character class */
286{
287 int i, c, c2;
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);
306 if (c > c2) { /* empty; ignore */
307 bp--;
308 i--;
309 continue;
310 }
311 while (c < c2) {
312 if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0))
313 FATAL("out of space for character class [%.10s...] 2", p);
314 *bp++ = ++c;
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 */
698struct charclass {
699 const char *cc_name;
700 int cc_namelen;
701 const char *cc_expand;
702} 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" },
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;
727 const uschar *p;
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;
776 for (p = (const uschar *) cc->cc_expand; *p; p++)
777 *bp++ = *p;
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 ---