From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3130 invoked by alias); 23 Feb 2015 14:33:08 -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: 34619 Received: (qmail 3203 invoked from network); 23 Feb 2015 14:33:05 -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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; bh=rAKLS2SzoDdd8V8OWlWI6zeWNGCm3OK+PHqNbJwwhF4=; b=MFEWM8s77wDVtDAByWl6s3Rswt20TRBA6ccoIEEzpYwLj3kJIxFs3SvF/PvZf5i+e7 rDzqU1ks1EXnCG8UA/suFVw5V8nHwlXPM2sWLEy42Jh28ziPZRM8Ximdry6QmjXAh+8r CqrXaK7ZEUVnF/kvHy1unhEA5TzI3dbK6aB1Dz45Ca85ZtP6YDbNMXwEJMj0FTPCJA64 uWWIMUXpdeIwZUESAfHCX7NkNOU/P9nmktBkLdEK0mKioUNOenrJPyCbirgmirctR/vX DHcfJBwOwYm3VQ5wPDvKF7ICgahPZ2dlN2+PATxhQHwObg5JElahm+gam17FL6WQEcHU 2yyA== X-Received: by 10.112.64.2 with SMTP id k2mr10257257lbs.54.1424701981595; Mon, 23 Feb 2015 06:33:01 -0800 (PST) From: Mikael Magnusson To: zsh-workers@zsh.org Subject: Re: PATCH: Remeta one frame earlier Date: Mon, 23 Feb 2015 15:32:55 +0100 Message-Id: <1424701975-17215-1-git-send-email-mikachu@gmail.com> X-Mailer: git-send-email 2.2.0.GIT In-Reply-To: <20150223140541.6cdb0fc2@pwslap01u.europe.root.pri> References: <20150223140541.6cdb0fc2@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Mon, Feb 23, 2015 at 3:05 PM, Peter Stephenson wrote: > On Mon, 23 Feb 2015 14:51:09 +0100 > Mikael Magnusson wrote: >> + int remeta; > > ... except you haven't initialised remeta to 0. Oops, I added it here after the compiler complained, and then removed it from the other file after, so overlooked the initialization. I guess I got lucky with my zero pages. Here's an incremental patch that fixes this, and stops having two separate pt/ptr variables. > If we do stick with the heap, I'm wondering if we need to free it more > often than we do. Maybe the freeheap() below should be if (uselex || > remeta), and maybe it should be right at the end of the loop for > safety. I'll leave this part to you... At least nothing after the freeheap() uses pt, so it shouldn't be any less safe than beforeā„¢. > Long discussion for moving a bit of code... But super fun~ --- Src/hist.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Src/hist.c b/Src/hist.c index c5cf43e..5a8c75e 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -2501,9 +2501,8 @@ readhistfile(char *fn, int err, int readflags) || (hist_ignore_all_dups && newflags & hist_skip_flags)) newflags |= HIST_MAKEUNIQUE; while (fpos = ftell(in), (l = readhistline(0, &buf, &bufsiz, in))) { - char *pt = buf; - char *ptr; - int remeta; + char *pt; + int remeta = 0; if (l < 0) { zerr("corrupt history file %s", fn); @@ -2521,17 +2520,19 @@ readhistfile(char *fn, int err, int readflags) * This is rare so doesn't need to be that efficient; just * allocate space off the heap. */ - for (ptr = pt; *ptr; ptr++) { - if (*ptr == Meta && ptr[1]) - ptr++; - else if (imeta(*ptr)) { + for (pt = buf; *pt; pt++) { + if (*pt == Meta && pt[1]) + pt++; + else if (imeta(*pt)) { remeta = 1; break; } } if (remeta) { - unmetafy(pt, &remeta); - pt = metafy(pt, remeta, META_USEHEAP); + unmetafy(buf, &remeta); + pt = metafy(buf, remeta, META_USEHEAP); + } else { + pt = buf; } if (*pt == ':') { -- 2.2.0.GIT