about summary refs log tree commit diff
path: root/Src/hist.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2005-08-10 10:56:40 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2005-08-10 10:56:40 +0000
commit2a888b3d5ae1f485649b811ea433f286238fd308 (patch)
tree11f21c9ee2e716c8ab247c6d4ca834c6586ba101 /Src/hist.c
parentef913283407fdc8166e5b937dcb08d1b4abde10d (diff)
downloadzsh-2a888b3d5ae1f485649b811ea433f286238fd308.tar.gz
zsh-2a888b3d5ae1f485649b811ea433f286238fd308.tar.xz
zsh-2a888b3d5ae1f485649b811ea433f286238fd308.zip
c.f. 21590: metafy_line()/unmetafy_line() now support wide characters
Diffstat (limited to 'Src/hist.c')
-rw-r--r--Src/hist.c56
1 files changed, 34 insertions, 22 deletions
diff --git a/Src/hist.c b/Src/hist.c
index 6b3aa3b33..00773cd74 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -222,12 +222,12 @@ iaddtoline(int c)
 	exlast--;
 	zleaddtolineptr('\\');
     }
-    if (excs > zlecs) {
+    if (excs > zlemetacs) {
 	excs += 1 + inbufct - exlast;
-	if (excs < zlecs)
+	if (excs < zlemetacs)
 	    /* this case could be handled better but it is    *
 	     * so rare that it does not worth it              */
-	    excs = zlecs;
+	    excs = zlemetacs;
     }
     exlast = inbufct;
     zleaddtolineptr(itok(c) ? ztokens[c - Pound] : c);
@@ -662,8 +662,8 @@ ihungetc(int c)
 	    hungetc('\n'), hungetc('\\');
 
 	if (expanding) {
-	    zlecs--;
-	    zlell--;
+	    zlemetacs--;
+	    zlemetall--;
 	    exlast++;
 	}
 	DPUTS(hptr <= chline, "BUG: hungetc attempted at buffer start");
@@ -2241,15 +2241,27 @@ histfileIsLocked(void)
     return lockhistct > 0;
 }
 
-/* Get the words in the current buffer. Using the lexer. */
+/*
+ * Get the words in the current buffer. Using the lexer. 
+ *
+ * As far as I can make out, this is a gross hack based on a gross hack.
+ * When analysing lines from within zle, we tweak the metafied line
+ * positions (zlemetall and zlemetacs) directly in the lexer.  That's
+ * bad enough, but this function appears to be designed to be called
+ * from outside zle, pretending to be in zle and calling out, so
+ * we set zlemetall and zlemetacs locally and copy the current zle line,
+ * which may not even be valid at this point.
+ *
+ * However, I'm so confused it could simply be baking Bakewell tarts.
+ */
 
 /**/
 mod_export LinkList
 bufferwords(LinkList list, char *buf, int *index)
 {
-    int num = 0, cur = -1, got = 0, ne = noerrs, ocs = zlecs, oll = zlell;
+    int num = 0, cur = -1, got = 0, ne = noerrs;
     int owb = wb, owe = we, oadx = addedx, ozp = zleparse, onc = nocomments;
-    int ona = noaliases;
+    int ona = noaliases, ocs = zlemetacs, oll = zlemetall;
     char *p;
 
     if (!list)
@@ -2267,47 +2279,47 @@ bufferwords(LinkList list, char *buf, int *index)
 	p[l] = ' ';
 	p[l + 1] = '\0';
 	inpush(p, 0, NULL);
-	zlell = strlen(p) ;
-	zlecs = zlell + 1;
+	zlemetall = strlen(p) ;
+	zlemetacs = zlemetall + 1;
 	nocomments = 1;
     } else {
 	int ll, cs;
 	char *linein;
 
 	if (zlegetlineptr) {
-	    linein = zlegetlineptr(&ll, &cs);
+	    linein = (char *)zlegetlineptr(&ll, &cs);
 	} else {
 	    linein = ztrdup("");
 	    ll = cs = 0;
 	}
-	zlell = ll + 1; /* length of line plus space added below */
-	zlecs = cs;
+	zlemetall = ll + 1; /* length of line plus space added below */
+	zlemetacs = cs;
 
 	if (!isfirstln && chline) {
 	    p = (char *) zhalloc(hptr - chline + ll + 2);
 	    memcpy(p, chline, hptr - chline);
 	    memcpy(p + (hptr - chline), linein, ll);
 	    p[(hptr - chline) + ll] = ' ';
-	    p[(hptr - chline) + zlell] = '\0';
+	    p[(hptr - chline) + zlemetall] = '\0';
 	    inpush(p, 0, NULL);
 
 	    /*
 	     * advance line length and character position over
 	     * prepended string.
 	     */
-	    zlell += hptr - chline;
-	    zlecs += hptr - chline;
+	    zlemetall += hptr - chline;
+	    zlemetacs += hptr - chline;
 	} else {
 	    p = (char *) zhalloc(ll + 2);
 	    memcpy(p, linein, ll);
 	    p[ll] = ' ';
-	    p[zlell] = '\0';
+	    p[zlemetall] = '\0';
 	    inpush(p, 0, NULL);
 	}
-    zsfree(linein);
+	zsfree(linein);
     }
-    if (zlecs)
-	zlecs--;
+    if (zlemetacs)
+	zlemetacs--;
     strinbeg(0);
     noaliases = 1;
     do {
@@ -2363,8 +2375,8 @@ bufferwords(LinkList list, char *buf, int *index)
     nocomments = onc;
     noerrs = ne;
     lexrestore();
-    zlecs = ocs;
-    zlell = oll;
+    zlemetacs = ocs;
+    zlemetall = oll;
     wb = owb;
     we = owe;
     addedx = oadx;