From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14005 invoked by alias); 28 Feb 2010 09:12:30 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 27761 Received: (qmail 23576 invoked from network); 28 Feb 2010 09:12:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VERIFIED autolearn=ham version=3.2.5 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.220.212 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :user-agent:cc:references:in-reply-to:mime-version:content-type :content-transfer-encoding:message-id; bh=spxReWzz965UysDapf89CbsyuKbRjQENIXbT9gbqJRg=; b=MbDchHOtA2HGbETiWq2Mb1nONOZgXATi4sWuecbNFX7NQ7Fxu3krMawYewIIIBXUNr CpOamntNj+COBtGWNgDDypnvIBQw8c1bmOLDKZMClGucAx0uk4PJX2BF+6kxXITjWjFA 3ZSpgmtUavwi3kAbhByoUpeI2gk8pBuRntNbM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding:message-id; b=Kw2lJBfeF0Cl4E0sW7zbDnyZfY+zRk0+e2+yLx4Z4m3i9+WQv9LC7h3GHm53CatLhr AnOSZrgJbO4ARX3TuNBoftQER/9GYyfUF5dAQBIxQIviQL9kDTMgkYfAKHhO9riYV0RA LqcljrLQ5s+8F/XXBd1GrLPOL06EUvWd+e+0M= From: Andrey Borzenkov To: zsh-workers@zsh.org Subject: Re: LinkList implementation Date: Sun, 28 Feb 2010 12:06:47 +0300 User-Agent: KMail/1.13.0 (Linux/2.6.33-desktop-1mnb; KDE/4.4.0; x86_64; ; ) Cc: Michael Hwang References: <22a0ef081002271433u713e1923lb04c7d1bf369d3d0@mail.gmail.com> In-Reply-To: <22a0ef081002271433u713e1923lb04c7d1bf369d3d0@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1685207.XiZtPLhITd"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201002281206.53953.arvidjaar@gmail.com> --nextPart1685207.XiZtPLhITd Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable On Sunday 28 of February 2010 01:33:24 Michael Hwang wrote: > In the process of writing a new builtin, I discovered an oddity of > zsh's implementation of LinkList, which is a doubly linked list. >=20 > LinkList alist =3D newlinklist(); > LinkNode node; > for (node =3D lastnode(alist); node; decnode(alist)) { > ((SomeStructPointer) getdata(node))->someField; > } >=20 BTW decnode applies to node, not list - it should be decnode(node) > Since no nodes have been added to the LinkList, one would expect the > body of the loop to not run at all. Well, you have to accept that and use another termination condition,=20 like e.g. in zle_hist.c:isearch_newpos(): for (node =3D lastnode(matchlist); node !=3D (LinkNode)matchlist; decnode(node)) { =46or the sake of purity this actually should be node !=3D &matchlist->node The games linklist.c plays are really daunting ... but to change it now=20 you have to carefully go through all of code to adjust snippets like=20 above. --nextPart1685207.XiZtPLhITd Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEABECAAYFAkuKMigACgkQR6LMutpd94xKCwCgv/vRbFMH8bajC0DbNtawj57c qVcAnA2i5SAct9nCUw2LoutnRj8/VEN1 =ErVk -----END PGP SIGNATURE----- --nextPart1685207.XiZtPLhITd--