diff options
author | obrien <obrien@FreeBSD.org> | 2002-12-19 04:33:15 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2002-12-19 04:33:15 +0000 |
commit | bf37c5ab938db103c46d0b6252e8e37dbf1fe008 (patch) | |
tree | eb6b59426e6b1c2a423f21eabeea9fbea8e416d2 | |
parent | 279a30e7a9812f477c5991f0df7082a9736bdc00 (diff) | |
download | FreeBSD-src-bf37c5ab938db103c46d0b6252e8e37dbf1fe008.zip FreeBSD-src-bf37c5ab938db103c46d0b6252e8e37dbf1fe008.tar.gz |
Vendor import of bwk's 13-Dec-2002 release.
-rw-r--r-- | contrib/one-true-awk/FIXES | 6 | ||||
-rw-r--r-- | contrib/one-true-awk/b.c | 63 | ||||
-rw-r--r-- | contrib/one-true-awk/main.c | 4 | ||||
-rw-r--r-- | contrib/one-true-awk/run.c | 4 |
4 files changed, 28 insertions, 49 deletions
diff --git a/contrib/one-true-awk/FIXES b/contrib/one-true-awk/FIXES index e511394..76b2553 100644 --- a/contrib/one-true-awk/FIXES +++ b/contrib/one-true-awk/FIXES @@ -25,6 +25,12 @@ THIS SOFTWARE. This file lists all bug fixes, changes, etc., made since the AWK book was sent to the printers in August, 1987. +Dec 13, 2002: + for the moment, the internationalization changes of nov 29 are + rolled back -- programs like x = 1.2 don't work in some locales, + because the parser is expecting x = 1,2. until i understand this + better, this will have to wait. + Nov 29, 2002: modified b.c (with tiny changes in main and run) to support locales, using strcoll and iswhatever tests for posix character diff --git a/contrib/one-true-awk/b.c b/contrib/one-true-awk/b.c index 1adb6c2..aa2ad15 100644 --- a/contrib/one-true-awk/b.c +++ b/contrib/one-true-awk/b.c @@ -282,24 +282,9 @@ int quoted(char **pp) /* pick up next thing after a \\ */ return c; } -static int collate_range_cmp(int a, int b) -{ - int r; - static char s[2][2]; - - if ((uschar)a == (uschar)b) - return 0; - s[0][0] = a; - s[1][0] = b; - if ((r = strcoll(s[0], s[1])) == 0) - r = (uschar)a - (uschar)b; - return r; -} - 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; @@ -318,18 +303,15 @@ char *cclenter(const char *argp) /* add a character class */ c2 = *p++; if (c2 == '\\') c2 = quoted((char **) &p); - if (collate_range_cmp(c, c2) > 0) { /* empty; ignore */ + if (c > c2) { /* empty; ignore */ bp--; i--; continue; } - for (j = 0; j < NCHARS; j++) { - if ((collate_range_cmp(c, j) > 0) || - collate_range_cmp(j, c2) > 0) - continue; + while (c < c2) { if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0)) FATAL("out of space for character class [%.10s...] 2", p); - *bp++ = j; + *bp++ = ++c; i++; } continue; @@ -713,24 +695,23 @@ Node *unary(Node *np) * relex(), the expanded character class (prior to range expansion) * must be less than twice the size of their full name. */ - struct charclass { const char *cc_name; int cc_namelen; - int (*cc_func)(int); + const char *cc_expand; } charclasses[] = { - { "alnum", 5, isalnum }, - { "alpha", 5, isalpha }, - { "blank", 5, isblank }, - { "cntrl", 5, iscntrl }, - { "digit", 5, isdigit }, - { "graph", 5, isgraph }, - { "lower", 5, islower }, - { "print", 5, isprint }, - { "punct", 5, ispunct }, - { "space", 5, isspace }, - { "upper", 5, isupper }, - { "xdigit", 6, isxdigit }, + { "alnum", 5, "0-9A-Za-z" }, + { "alpha", 5, "A-Za-z" }, + { "blank", 5, " \t" }, + { "cntrl", 5, "\000-\037\177" }, + { "digit", 5, "0-9" }, + { "graph", 5, "\041-\176" }, + { "lower", 5, "a-z" }, + { "print", 5, " \041-\176" }, + { "punct", 5, "\041-\057\072-\100\133-\140\173-\176" }, + { "space", 5, " \f\n\r\t\v" }, + { "upper", 5, "A-Z" }, + { "xdigit", 6, "0-9A-Fa-f" }, { NULL, 0, NULL }, }; @@ -743,7 +724,7 @@ int relex(void) /* lexical analyzer for reparse */ static int bufsz = 100; uschar *bp; struct charclass *cc; - int i; + const uschar *p; switch (c = *prestr++) { case '|': return OR; @@ -792,14 +773,8 @@ int relex(void) /* lexical analyzer for reparse */ if (cc->cc_name != NULL && prestr[1 + cc->cc_namelen] == ':' && prestr[2 + cc->cc_namelen] == ']') { prestr += cc->cc_namelen + 3; - for (i = 0; i < NCHARS; i++) { - if (!adjbuf((char **) &buf, &bufsz, bp-buf+1, 100, (char **) &bp, 0)) - FATAL("out of space for reg expr %.10s...", lastre); - if (cc->cc_func(i)) { - *bp++ = i; - n++; - } - } + for (p = (const uschar *) cc->cc_expand; *p; p++) + *bp++ = *p; } else *bp++ = c; } else if (c == '\0') { diff --git a/contrib/one-true-awk/main.c b/contrib/one-true-awk/main.c index 491f1dc..b0d2807 100644 --- a/contrib/one-true-awk/main.c +++ b/contrib/one-true-awk/main.c @@ -22,12 +22,11 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ****************************************************************/ -const char *version = "version 20021129"; +const char *version = "version 20021213"; #define DEBUG #include <stdio.h> #include <ctype.h> -#include <locale.h> #include <stdlib.h> #include <string.h> #include <signal.h> @@ -55,7 +54,6 @@ int main(int argc, char *argv[]) { const char *fs = NULL; - setlocale(LC_ALL, ""); cmdname = argv[0]; if (argc == 1) { fprintf(stderr, "Usage: %s [-f programfile | 'program'] [-Ffieldsep] [-v var=value] [files]\n", cmdname); diff --git a/contrib/one-true-awk/run.c b/contrib/one-true-awk/run.c index 617ac7d..64722bd 100644 --- a/contrib/one-true-awk/run.c +++ b/contrib/one-true-awk/run.c @@ -1509,11 +1509,11 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis if (t == FTOUPPER) { for (p = buf; *p; p++) if (islower((uschar) *p)) - *p = toupper((uschar)*p); + *p = toupper(*p); } else { for (p = buf; *p; p++) if (isupper((uschar) *p)) - *p = tolower((uschar)*p); + *p = tolower(*p); } tempfree(x); x = gettemp(); |