From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15354 invoked by alias); 1 Oct 2014 16:04:18 -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: 33309 Received: (qmail 27344 invoked from network); 1 Oct 2014 16:04:17 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <141001090421.ZM5838@torch.brasslantern.com> Date: Wed, 01 Oct 2014 09:04:21 -0700 In-reply-to: <20141001164002.0f9b1e01@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: zsh 5.0.6 hanged in freejob from TRAPCHLD" (Oct 1, 4:40pm) References: <20140930172125.GA2703@xvii.vinc17.org> <20141001100033.0e10a30c@pwslap01u.europe.root.pri> <141001075325.ZM5718@torch.brasslantern.com> <28552.1412177133@thecus.kiddle.eu> <20141001164002.0f9b1e01@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh hackers list Subject: Re: zsh 5.0.6 hanged in freejob from TRAPCHLD MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Oct 1, 4:40pm, Peter Stephenson wrote: } Subject: Re: zsh 5.0.6 hanged in freejob from TRAPCHLD } } On Wed, 01 Oct 2014 17:25:33 +0200 } Oliver Kiddle wrote: } > } > Eww. Wouldn't it perhaps be easier and better in the long run to replace } > this whole save/restore/globals concept with non-global structs and make } > all the lexer functions take a pointer to the relevant instance of the } > struct. } } You'll soon find the paths you need to pass the structures through } proliferate somewhat hair-raisingly. That may lead to useful } simplifications, though, so this isn't an argument against doing it. It's not even quite that simple, some of the fields require their own memory management. Moving it onto the call stack and passing it around that way would only change the lexsave/lexrestore calls into something that allocates/cleans up a local lexstack object. (Hey, why don't we rewrite the whole shell in C++ instead?) It'd be a large step in the right direction to have ONE global -- a single (struct lexstack *) -- and have lexsave/lexrestore swap that pointer rather than copy each of the fields. However, doesn't remove the need for the signal queuing (see "fields require their own memory management"). Futher, that still means finding everything that references those globals -- some of them are used outside the lexer to examine the current lexer state -- and replacing all those mentions with deref through the new global pointer. Yeah, the compiler will sort that out if we just remove the declarations of the globals. Busywork. Then you get to do that for all the other things that use batches of globals in this way (see execsave/execrestrore, trap scopes, etc.)