diff options
author | ache <ache@FreeBSD.org> | 1997-10-15 15:37:46 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1997-10-15 15:37:46 +0000 |
commit | edce646e6cec03bcb56bfcba4ee7cb8ea8d242c7 (patch) | |
tree | 369ff488f236097d95052ae9bef7007eeae046d3 /contrib | |
parent | 50f061ebcd4c9f81f4690c0923e0d117ca1d39e2 (diff) | |
download | FreeBSD-src-edce646e6cec03bcb56bfcba4ee7cb8ea8d242c7.zip FreeBSD-src-edce646e6cec03bcb56bfcba4ee7cb8ea8d242c7.tar.gz |
Unspam l10n ranges check
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/awk/dfa.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/contrib/awk/dfa.c b/contrib/awk/dfa.c index 03dd9e7..957d5b7 100644 --- a/contrib/awk/dfa.c +++ b/contrib/awk/dfa.c @@ -132,6 +132,23 @@ static char **comsubs _RE_ARGS((char *left, char *right)); static char **addlists _RE_ARGS((char **old, char **new)); static char **inboth _RE_ARGS((char **left, char **right)); +#ifdef __FreeBSD__ +static int collate_range_cmp (a, b) + int a, b; +{ + int r; + static char s[2][2]; + + if ((unsigned char)a == (unsigned char)b) + return 0; + s[0][0] = a; + s[1][0] = b; + if ((r = strcoll(s[0], s[1])) == 0) + r = (unsigned char)a - (unsigned char)b; + return r; +} +#endif + static ptr_t xcalloc(n, s) size_t n; @@ -700,6 +717,27 @@ lex() } else c2 = c; +#ifdef __FreeBSD__ + { token c3; + + if (collate_range_cmp(c, c2) > 0) { + FETCH(c2, "Invalid range"); + goto skip; + } + + for (c3 = 0; c3 < NOTCHAR; ++c3) + if ( collate_range_cmp(c, c3) <= 0 + && collate_range_cmp(c3, c2) <= 0 + ) { + setbit(c3, ccl); + if (case_fold) + if (ISUPPER(c3)) + setbit(tolower(c3), ccl); + else if (ISLOWER(c3)) + setbit(toupper(c3), ccl); + } + } +#else while (c <= c2) { setbit(c, ccl); @@ -710,6 +748,7 @@ lex() setbit(toupper(c), ccl); ++c; } +#endif skip: ; } |