From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25680 invoked by alias); 23 Feb 2015 13:51:51 -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: 34615 Received: (qmail 4796 invoked from network); 23 Feb 2015 13:51:39 -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; bh=y4uBXs1CmEUimG26xLu/KoHK7fzxxLsLfEQ0glWMGCw=; b=sG3gyz4x990XhRYB667KXVY6ZEN+5raY8jj1o5oC8Xsk/xtQYGmTueBCjUnu5oEZBF sMWQFT09QXc6q2sSBO9/NQbfVdCPMLY/AAgw+7lZ8tSrEQW60rHmaC7CBL2gTttSZ0HW eUafkRCHkpUiCQ0BgZW1GCvUUanoYeTj17i5ldFDFvirt+YnyPbdhin+mAMH+B6lSo0+ p+8fEVLTJMedZuIhPdFYgUUAwZn1Y3z8lJybzsOAG7w0j8nVtGJ9JgHoljmxVCr6je50 2z3dB1174nHsWI5XG5cARSfYjo+wP+QUw3lxj/5ZDCW2GhAuVYunHESz/QHlIjKDJlwA Z/eg== X-Received: by 10.112.215.9 with SMTP id oe9mr10003071lbc.40.1424699495447; Mon, 23 Feb 2015 05:51:35 -0800 (PST) From: Mikael Magnusson To: zsh-workers@zsh.org Subject: PATCH: Remeta one frame earlier Date: Mon, 23 Feb 2015 14:51:09 +0100 Message-Id: <1424699469-11744-1-git-send-email-mikachu@gmail.com> X-Mailer: git-send-email 2.2.0.GIT In-Reply-To: References: I realized I generated the last patch on top of yours since I applied it with git-am, so here's a proper patch send from git send-mail instead, against upstream git master. --- Src/hist.c | 62 ++++++++++++++++++++++++++++---------------------------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/Src/hist.c b/Src/hist.c index 689a793..c5cf43e 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -2502,11 +2502,38 @@ readhistfile(char *fn, int err, int readflags) newflags |= HIST_MAKEUNIQUE; while (fpos = ftell(in), (l = readhistline(0, &buf, &bufsiz, in))) { char *pt = buf; + char *ptr; + int remeta; if (l < 0) { zerr("corrupt history file %s", fn); break; } + + /* + * Handle the special case that we're reading from an + * old shell with fewer meta characters, so we need to + * metafy some more. (It's not clear why the history + * file is metafied at all; some would say this is plain + * stupid. But we're stuck with it now without some + * hairy workarounds for compatibility). + * + * 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)) { + remeta = 1; + break; + } + } + if (remeta) { + unmetafy(pt, &remeta); + pt = metafy(pt, remeta, META_USEHEAP); + } + if (*pt == ':') { pt++; stim = zstrtol(pt, NULL, 0); @@ -3380,40 +3407,7 @@ histsplitwords(char *lineptr, short **wordsp, int *nwordsp, int *nwordposp, if (uselex) { LinkList wordlist; LinkNode wordnode; - int nwords_max, remeta = 0; - char *ptr; - - /* - * Handle the special case that we're reading from an - * old shell with fewer meta characters, so we need to - * metafy some more. (It's not clear why the history - * file is metafied at all; some would say this is plain - * stupid. But we're stuck with it now without some - * hairy workarounds for compatibility). - * - * This is rare so doesn't need to be that efficient; just - * allocate space off the heap. - * - * Note that our it's currently believed this all comes out in - * the wash in the non-uselex case owing to where unmetafication - * and metafication happen. - */ - for (ptr = lineptr; *ptr; ptr++) { - if (*ptr != Meta && imeta(*ptr)) - remeta++; - } - if (remeta) { - char *ptr2, *line2; - ptr2 = line2 = (char *)zhalloc((ptr - lineptr) + remeta + 1); - for (ptr = lineptr; *ptr; ptr++) { - if (*ptr != Meta && imeta(*ptr)) { - *ptr2++ = Meta; - *ptr2++ = *ptr ^ 32; - } else - *ptr2++ = *ptr; - } - lineptr = line2; - } + int nwords_max; wordlist = bufferwords(NULL, lineptr, NULL, LEXFLAGS_COMMENTS_KEEP); -- 2.2.0.GIT