Changeset View
Changeset View
Standalone View
Standalone View
contrib/one-true-awk/b.c
Show First 20 Lines • Show All 355 Lines • ▼ Show 20 Lines | else if (c == 'x') { /* hexadecimal goo follows */ | ||||
} | } | ||||
c = n; | c = n; | ||||
} /* else */ | } /* else */ | ||||
/* c = c; */ | /* c = c; */ | ||||
*pp = p; | *pp = p; | ||||
return c; | return c; | ||||
} | } | ||||
static int collate_range_cmp(int a, int b) | |||||
{ | |||||
static char s[2][2]; | |||||
if ((uschar)a == (uschar)b) | |||||
return 0; | |||||
s[0][0] = a; | |||||
s[1][0] = b; | |||||
return (strcoll(s[0], s[1])); | |||||
} | |||||
char *cclenter(const char *argp) /* add a character class */ | char *cclenter(const char *argp) /* add a character class */ | ||||
{ | { | ||||
int i, c, c2, j; | int i, c, c2; | ||||
const uschar *op, *p = (const uschar *) argp; | const uschar *op, *p = (const uschar *) argp; | ||||
uschar *bp; | uschar *bp; | ||||
static uschar *buf = NULL; | static uschar *buf = NULL; | ||||
static int bufsz = 100; | static int bufsz = 100; | ||||
op = p; | op = p; | ||||
if (buf == NULL && (buf = (uschar *) malloc(bufsz)) == NULL) | if (buf == NULL && (buf = (uschar *) malloc(bufsz)) == NULL) | ||||
FATAL("out of space for character class [%.10s...] 1", p); | FATAL("out of space for character class [%.10s...] 1", p); | ||||
bp = buf; | bp = buf; | ||||
for (i = 0; (c = *p++) != 0; ) { | for (i = 0; (c = *p++) != 0; ) { | ||||
if (c == '\\') { | if (c == '\\') { | ||||
c = quoted(&p); | c = quoted(&p); | ||||
} else if (c == '-' && i > 0 && bp[-1] != 0) { | } else if (c == '-' && i > 0 && bp[-1] != 0) { | ||||
if (*p != 0) { | if (*p != 0) { | ||||
c = bp[-1]; | c = bp[-1]; | ||||
c2 = *p++; | c2 = *p++; | ||||
if (c2 == '\\') | if (c2 == '\\') | ||||
c2 = quoted(&p); | c2 = quoted(&p); | ||||
if (collate_range_cmp(c, c2) > 0) { | if (c > c2) { /* empty; ignore */ | ||||
bp--; | bp--; | ||||
i--; | i--; | ||||
continue; | continue; | ||||
} | } | ||||
for (j = 0; j < NCHARS; j++) { | while (c < c2) { | ||||
if ((collate_range_cmp(c, j) > 0) || | |||||
collate_range_cmp(j, c2) > 0) | |||||
continue; | |||||
if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, "cclenter1")) | if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, "cclenter1")) | ||||
FATAL("out of space for character class [%.10s...] 2", p); | FATAL("out of space for character class [%.10s...] 2", p); | ||||
*bp++ = j; | *bp++ = ++c; | ||||
i++; | i++; | ||||
} | } | ||||
continue; | continue; | ||||
} | } | ||||
} | } | ||||
if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, "cclenter2")) | if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, "cclenter2")) | ||||
FATAL("out of space for character class [%.10s...] 3", p); | FATAL("out of space for character class [%.10s...] 3", p); | ||||
*bp++ = c; | *bp++ = c; | ||||
▲ Show 20 Lines • Show All 946 Lines • Show Last 20 Lines |