From owner-freebsd-current Tue Nov 19 19:28:12 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 307F637B404; Tue, 19 Nov 2002 19:28:08 -0800 (PST) Received: from smtp01.iprimus.net.au (smtp01.iprimus.net.au [210.50.30.70]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0792343E8A; Tue, 19 Nov 2002 19:28:06 -0800 (PST) (envelope-from tim@robbins.dropbear.id.au) Received: from dilbert.robbins.dropbear.id.au ([210.50.219.18]) by smtp01.iprimus.net.au with Microsoft SMTPSVC(5.0.2195.5600); Wed, 20 Nov 2002 14:27:57 +1100 Received: from dilbert.robbins.dropbear.id.au (rycwsfzlli3g38q8@localhost [127.0.0.1]) by dilbert.robbins.dropbear.id.au (8.12.6/8.12.6) with ESMTP id gAK3RtEi012870; Wed, 20 Nov 2002 14:27:56 +1100 (EST) (envelope-from tim@dilbert.robbins.dropbear.id.au) Received: (from tim@localhost) by dilbert.robbins.dropbear.id.au (8.12.6/8.12.6/Submit) id gAK3RrHI012869; Wed, 20 Nov 2002 14:27:53 +1100 (EST) (envelope-from tim) Date: Wed, 20 Nov 2002 14:27:53 +1100 From: Tim Robbins To: "Andrey A. Chernov" Cc: Ruslan Ermilov , "David O'Brien" , current@FreeBSD.org Subject: Re: awk(1) is locale unaware (was: Re: buildworld breakage during "make depend" at usr.bin/kdump) Message-ID: <20021120142753.A11292@dilbert.robbins.dropbear.id.au> References: <20011101220836.A76061@nagual.pp.ru> <91693.1004642592@axl.seasidesoftware.co.za> <20011101114213.F79520@dragon.nuxi.com> <20011102044411.A81844@nagual.pp.ru> <20011101175808.A82798@dragon.nuxi.com> <20021119125202.GA37987@sunbay.com> <20021120013838.GB19233@nagual.pp.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20021120013838.GB19233@nagual.pp.ru>; from ache@nagual.pp.ru on Wed, Nov 20, 2002 at 04:38:38AM +0300 X-OriginalArrivalTime: 20 Nov 2002 03:27:58.0482 (UTC) FILETIME=[D292FF20:01C29044] Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, Nov 20, 2002 at 04:38:38AM +0300, Andrey A. Chernov wrote: > On Tue, Nov 19, 2002 at 14:52:02 +0200, Ruslan Ermilov wrote: > > It seems that this patch has never been committed. This is a critical > > bug that should be fixed before 5.0-RELEASE is out. > > I agree. There is no locale yet and I never see that patch. This patch seems to work, I used the logic from regcomp.c in libc. Long lines make it ugly, but it was like that when I got here ;) Tim Index: src/usr.bin/awk/Makefile =================================================================== RCS file: /x/freebsd/src/usr.bin/awk/Makefile,v retrieving revision 1.9 diff -u -r1.9 Makefile --- src/usr.bin/awk/Makefile 10 May 2002 20:36:21 -0000 1.9 +++ src/usr.bin/awk/Makefile 20 Nov 2002 03:13:50 -0000 @@ -6,7 +6,7 @@ PROG= nawk SRCS= awkgram.y b.c lex.c lib.c main.c parse.c proctab.c run.c tran.c ytab.h -CFLAGS+= -I. -I${AWKSRC} +CFLAGS+= -I. -I${AWKSRC} -I${.CURDIR}/../../lib/libc/locale DPADD= ${LIBM} LDADD= -lm Index: src/contrib/one-true-awk/b.c =================================================================== RCS file: /x/freebsd/src/contrib/one-true-awk/b.c,v retrieving revision 1.1.1.2 diff -u -r1.1.1.2 b.c --- src/contrib/one-true-awk/b.c 19 Feb 2002 09:35:24 -0000 1.1.1.2 +++ src/contrib/one-true-awk/b.c 20 Nov 2002 03:16:10 -0000 @@ -32,6 +32,7 @@ #include #include "awk.h" #include "ytab.h" +#include "collate.h" #define HAT (NCHARS-2) /* matches ^ in regular expr */ /* NCHARS is 2**n */ @@ -284,7 +285,7 @@ char *cclenter(char *argp) /* add a character class */ { - int i, c, c2; + int i, j, c, c2; uschar *p = (uschar *) argp; uschar *op, *bp; static uschar *buf = 0; @@ -308,12 +309,24 @@ i--; 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++ = ++c; - i++; - } + if (__collate_load_error) { + 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++ = ++c; + i++; + } + } else { + for (j = CHAR_MIN; j <= CHAR_MAX; j++) { + if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0)) + FATAL("out of space for character class [%.10s...] 2", p); + if (__collate_range_cmp(c, j) <= 0 + && __collate_range_cmp(j, c2) <= 0) { + *bp++ = j; + i++; + } + } + } continue; } } Index: src/contrib/one-true-awk/main.c =================================================================== RCS file: /x/freebsd/src/contrib/one-true-awk/main.c,v retrieving revision 1.1.1.3 diff -u -r1.1.1.3 main.c --- src/contrib/one-true-awk/main.c 16 Mar 2002 16:50:56 -0000 1.1.1.3 +++ src/contrib/one-true-awk/main.c 20 Nov 2002 03:03:38 -0000 @@ -27,6 +27,7 @@ #define DEBUG #include #include +#include #include #include #include @@ -55,6 +56,7 @@ char *fs = NULL; cmdname = argv[0]; + setlocale(LC_ALL, ""); if (argc == 1) { fprintf(stderr, "Usage: %s [-f programfile | 'program'] [-Ffieldsep] [-v var=value] [files]\n", cmdname); exit(1); Index: src/contrib/one-true-awk/run.c =================================================================== RCS file: /x/freebsd/src/contrib/one-true-awk/run.c,v retrieving revision 1.1.1.2 diff -u -r1.1.1.2 run.c --- src/contrib/one-true-awk/run.c 19 Feb 2002 09:35:25 -0000 1.1.1.2 +++ src/contrib/one-true-awk/run.c 20 Nov 2002 03:02:29 -0000 @@ -1504,11 +1504,11 @@ if (t == FTOUPPER) { for (p = buf; *p; p++) if (islower((uschar) *p)) - *p = toupper(*p); + *p = toupper((uschar)*p); } else { for (p = buf; *p; p++) if (isupper((uschar) *p)) - *p = tolower(*p); + *p = tolower((uschar)*p); } tempfree(x); x = gettemp(); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message