Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: LinkList implementation
- X-seq: zsh-workers 27761
- From: Andrey Borzenkov <arvidjaar@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: LinkList implementation
- Date: Sun, 28 Feb 2010 12:06:47 +0300
- Cc: Michael Hwang <michael.a.hwang@xxxxxxxxx>
- 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=
- In-reply-to: <22a0ef081002271433u713e1923lb04c7d1bf369d3d0@xxxxxxxxxxxxxx>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <22a0ef081002271433u713e1923lb04c7d1bf369d3d0@xxxxxxxxxxxxxx>
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.
>
> LinkList alist = newlinklist();
> LinkNode node;
> for (node = lastnode(alist); node; decnode(alist)) {
> ((SomeStructPointer) getdata(node))->someField;
> }
>
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,
like e.g. in zle_hist.c:isearch_newpos():
for (node = lastnode(matchlist);
node != (LinkNode)matchlist; decnode(node)) {
For the sake of purity this actually should be
node != &matchlist->node
The games linklist.c plays are really daunting ... but to change it now
you have to carefully go through all of code to adjust snippets like
above.
Attachment:
signature.asc
Description: This is a digitally signed message part.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author