summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2015-02-23 14:49:39 +0100
committerMikael Magnusson <mikachu@gmail.com>2015-02-23 18:09:47 +0100
commited43cf27682ee98cb8cf867e9d8e52ca72a52591 (patch)
tree432351e800c6aedb08ae735d6aac4545b3893ada
parent6fa63a0ce2b2aa31a343ca0841b57895d11b5754 (diff)
downloadzsh-ed43cf27682ee98cb8cf867e9d8e52ca72a52591.tar.gz
zsh-ed43cf27682ee98cb8cf867e9d8e52ca72a52591.zip
34615 + 34619: Remeta one frame earlier
-rw-r--r--ChangeLog4
-rw-r--r--Src/hist.c65
2 files changed, 34 insertions, 35 deletions
diff --git a/ChangeLog b/ChangeLog
index 31988c5b6..9e98f5550 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-02-23 Mikael Magnusson <mikachu@gmail.com>
+
+ * 34615 + 34619: Src/hist.c: Remeta one frame earlier
+
2015-02-22 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 34606: Src/subst.c, Test/C01arith.ztst: fix up arithmetic
diff --git a/Src/hist.c b/Src/hist.c
index acc425994..c530e7283 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -2500,12 +2500,40 @@ 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 *pt;
+ int remeta = 0;
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 (pt = buf; *pt; pt++) {
+ if (*pt == Meta && pt[1])
+ pt++;
+ else if (imeta(*pt)) {
+ remeta = 1;
+ break;
+ }
+ }
+ if (remeta) {
+ unmetafy(buf, &remeta);
+ pt = metafy(buf, remeta, META_USEHEAP);
+ } else {
+ pt = buf;
+ }
+
if (*pt == ':') {
pt++;
stim = zstrtol(pt, NULL, 0);
@@ -3379,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);