From 270ba02de1ffa85c9293d73669cae997f42c62b1 Mon Sep 17 00:00:00 2001 From: ru Date: Sun, 10 Jan 2010 08:02:07 +0000 Subject: Apply patches directly to sources. Their effect is as follows: - Make one-true-awk respect locale's collating order in [a-z] bracket expressions, until a more complete fix (like handing BREs) is ready. - Don't require a space between -[fv] and its argument. --- contrib/one-true-awk/b.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'contrib/one-true-awk/b.c') diff --git a/contrib/one-true-awk/b.c b/contrib/one-true-awk/b.c index 4c6d61b..baefe6f 100644 --- a/contrib/one-true-awk/b.c +++ b/contrib/one-true-awk/b.c @@ -24,6 +24,9 @@ THIS SOFTWARE. /* lasciate ogne speranza, voi ch'intrate. */ +#include +__FBSDID("$FreeBSD$"); + #define DEBUG #include @@ -285,9 +288,21 @@ int quoted(char **pp) /* pick up next thing after a \\ */ 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 */ { int i, c, c2; + int j; uschar *p = (uschar *) argp; uschar *op, *bp; static uschar *buf = 0; @@ -306,15 +321,18 @@ char *cclenter(const char *argp) /* add a character class */ c2 = *p++; if (c2 == '\\') c2 = quoted((char **) &p); - if (c > c2) { /* empty; ignore */ + if (collate_range_cmp(c, c2) > 0) { bp--; i--; continue; } - while (c < c2) { + for (j = 0; j < NCHARS; j++) { + 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")) FATAL("out of space for character class [%.10s...] 2", p); - *bp++ = ++c; + *bp++ = j; i++; } continue; -- cgit v1.1