zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: Re: PATCH: Remeta one frame earlier
Date: Mon, 23 Feb 2015 15:32:55 +0100	[thread overview]
Message-ID: <1424701975-17215-1-git-send-email-mikachu@gmail.com> (raw)
In-Reply-To: <20150223140541.6cdb0fc2@pwslap01u.europe.root.pri>

On Mon, Feb 23, 2015 at 3:05 PM, Peter Stephenson <p.stephenson@samsung.com> wrote:
> On Mon, 23 Feb 2015 14:51:09 +0100
> Mikael Magnusson <mikachu@gmail.com> 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


  reply	other threads:[~2015-02-23 14:33 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-19 10:13 PATCH: parse from even deeper in hell Peter Stephenson
2015-02-19 21:47 ` Mikael Magnusson
2015-02-19 22:03   ` Peter Stephenson
2015-02-20  3:16     ` Mikael Magnusson
2015-02-20  3:22       ` Mikael Magnusson
2015-02-20  3:33         ` Mikael Magnusson
2015-02-20  3:43           ` Mikael Magnusson
2015-02-20  4:19             ` Ray Andrews
2015-02-20  9:54               ` Peter Stephenson
2015-02-20 10:00             ` Peter Stephenson
2015-02-20 10:12               ` Mikael Magnusson
2015-02-22 18:26                 ` Peter Stephenson
2015-02-23  9:54                   ` Peter Stephenson
2015-02-23 10:11                     ` Peter Stephenson
2015-02-23 11:35                       ` Mikael Magnusson
2015-02-23 12:36                         ` Peter Stephenson
2015-02-23 12:57                           ` Peter Stephenson
2015-02-23 13:38                             ` Mikael Magnusson
2015-02-23 13:46                               ` Mikael Magnusson
2015-02-23 13:51                                 ` PATCH: Remeta one frame earlier Mikael Magnusson
2015-02-23 13:58                                   ` Peter Stephenson
2015-02-23 14:05                                   ` Peter Stephenson
2015-02-23 14:32                                     ` Mikael Magnusson [this message]
2015-02-23 17:32                                       ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1424701975-17215-1-git-send-email-mikachu@gmail.com \
    --to=mikachu@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).