From owner-freebsd-ports@FreeBSD.ORG Tue Jun 10 21:41:21 2008 Return-Path: Delivered-To: ports@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 672361065673; Tue, 10 Jun 2008 21:41:21 +0000 (UTC) (envelope-from kozlov@ravenloft.kiev.ua) Received: from istc.kiev.ua (wolf.istc.kiev.ua [193.108.236.1]) by mx1.freebsd.org (Postfix) with ESMTP id DF2CA8FC13; Tue, 10 Jun 2008 21:41:20 +0000 (UTC) (envelope-from kozlov@ravenloft.kiev.ua) Received: from [91.123.146.100] (helo=ravenloft.kiev.ua) by istc.kiev.ua with esmtp (Exim 4.52) id 1K6AQB-0004FL-2v; Tue, 10 Jun 2008 23:26:27 +0300 Received: from kozlov by ravenloft.kiev.ua with local (Exim 4.69 (FreeBSD)) (envelope-from ) id 1K6AQ7-0007Il-SA; Tue, 10 Jun 2008 23:26:19 +0300 Date: Tue, 10 Jun 2008 23:26:19 +0300 From: Alex Kozlov To: Kris Kennaway , ports@FreeBSD.org, spam@rm-rf.kiev.ua Message-ID: <20080610202619.GA94066@ravenloft.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: Alex Kozlov X-Spam-Score: 0.0 (/) X-Spam-Report: Content analysis detailz: (0.0 points, 10.0 required) Cc: Subject: Re: INDEX build optimizations - please review X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jun 2008 21:41:21 -0000 On Tue, Jun 10, 2008 at 06:45:32PM +0200, Kris Kennaway wrote: > Please review and test the following patches that optimize port INDEX > builds (and as a side-effect, other recursive tree traversals). I am > particularly interested in a comparison between old and new indexes > built locally: the only diff should be in audio/festvox-hvs [1]. Work on RELENG_6 only after this patch (maybe good candidate for MFC): Index: usr.bin/make/var.c @@ -1232,6 +1232,41 @@ } /** + * Remove adjacent duplicate words. + * + * Results: + * A string containing the resulting words. + */ +static char * +VarUniq(const char *str) +{ + ArgArray aa; + Buffer *buf; /* Buffer for new string */ + int i, j; + + buf = Buf_Init(0); + brk_string(&aa, str, FALSE); + + if (aa.argc > 2) { + for (j = 1, i = 2; i < aa.argc; i++) { + if (strcmp(aa.argv[i], aa.argv[j]) != 0 && (++j != i)) + aa.argv[j] = aa.argv[i]; + } + aa.argc = j + 1; + } + + for (i = 1; i < aa.argc; i++) { + Buf_AddBytes(buf, strlen(aa.argv[i]), (Byte *)aa.argv[i]); + if (i != aa.argc - 1) + Buf_AddByte(buf, ' '); + } + Buf_AddByte(buf, '\0'); + + ArgArray_Done(&aa); + return (Buf_Peel(buf)); +} + +/** * Pass through the tstr looking for 1) escaped delimiters, * '$'s and backslashes (place the escaped character in * uninterpreted) and 2) unescaped $'s that aren't before @@ -1681,6 +1716,7 @@ * the invocation. * :U Converts variable to upper-case. * :L Converts variable to lower-case. + * :u ("uniq") Remove adjacent duplicate words. * * XXXHB update this comment or remove it and point to the man page. */ @@ -1793,6 +1829,10 @@ newStr = VarModify(value, VarRoot, NULL); vp->ptr++; break; + case 'u': + newStr = VarUniq(value); + vp->ptr++; + break; default: newStr = sysVvarsub(vp, startc, v, value); break; -- Adios