From owner-freebsd-i18n@FreeBSD.ORG Thu Jul 31 19:02:50 2003 Return-Path: Delivered-To: freebsd-i18n@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1543E37B405; Thu, 31 Jul 2003 19:02:50 -0700 (PDT) Received: from smtp02.syd.iprimus.net.au (smtp02.syd.iprimus.net.au [210.50.76.52]) by mx1.FreeBSD.org (Postfix) with ESMTP id 82AA543F85; Thu, 31 Jul 2003 19:02:49 -0700 (PDT) (envelope-from tim@robbins.dropbear.id.au) Received: from mail.robbins.dropbear.id.au (210.50.250.240) by smtp02.syd.iprimus.net.au (7.0.018) id 3F13130D0035FD6E; Fri, 1 Aug 2003 12:02:48 +1000 Received: by mail.robbins.dropbear.id.au (Postfix, from userid 1000) id 6CC9EC975; Fri, 1 Aug 2003 12:02:04 +1000 (EST) Date: Fri, 1 Aug 2003 12:02:04 +1000 From: Tim Robbins To: Andrey Chernov Message-ID: <20030801020204.GA32843@dilbert.robbins.dropbear.id.au> References: <20030801004408.GA22054@nagual.pp.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030801004408.GA22054@nagual.pp.ru> User-Agent: Mutt/1.4.1i cc: current@freebsd.org cc: i18n@freebsd.org Subject: Re: Serious 'tr' bug, patch for review included X-BeenThere: freebsd-i18n@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: FreeBSD Internationalization Effort List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Aug 2003 02:02:50 -0000 On Fri, Aug 01, 2003 at 04:44:08AM +0400, Andrey Chernov wrote: > @@ -208,10 +210,18 @@ > if ((func)(cnt)) > *p++ = cnt; > *p = OOBCH; > + n = p - cp->set; > > s->cnt = 0; > - s->state = SET; > s->set = cp->set; > + if (strcmp(s->str, "upper") == 0) > + s->state = SET_UPPER; > + else if (strcmp(s->str, "lower") == 0) { > + s->state = SET_LOWER; > + } else > + s->state = SET; > + if ((s->state == SET_LOWER || s->state == SET_UPPER) && n > 1) > + mergesort(s->set, n, sizeof(*(s->set)), charcoll); > } > > static int I haven't tested the patch yet, but I don't think it's safe to use charcoll() to sort "set", which is a char array; charcoll() casts its arguments to int *, dereferences them, then discards all but the low 8 bits by casting to char. Using charcoll() to sort char arrays may work on little endian machines, but may not on big endian machines. Also, watch out for this warning in qsort(3): The qsort() and heapsort() functions sort an array of nmemb objects, the initial member of which is pointed to by base. The size of each object is specified by size. Mergesort() behaves similarly, but requires that size be greater than ``sizeof(void *) / 2''. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Tim