about summary refs log tree commit diff
path: root/Src/Zle
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-04-15 18:09:05 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-04-15 18:09:05 +0000
commit9003d99d16c46b5679da7fcf1f2a41adef495ff9 (patch)
tree95244be534cc37c03a628068faf7712da6317196 /Src/Zle
parentf13624e0f8a3c28c90aa0ce8ee36b639a491e4a9 (diff)
downloadzsh-9003d99d16c46b5679da7fcf1f2a41adef495ff9.tar.gz
zsh-9003d99d16c46b5679da7fcf1f2a41adef495ff9.tar.xz
zsh-9003d99d16c46b5679da7fcf1f2a41adef495ff9.zip
zsh-3.1.5-pws-3 zsh-3.1.5-pws-3
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/comp1.c2
-rw-r--r--Src/Zle/zle_main.c2
-rw-r--r--Src/Zle/zle_params.c3
-rw-r--r--Src/Zle/zle_thingy.c4
-rw-r--r--Src/Zle/zle_tricky.c66
-rw-r--r--Src/Zle/zle_vi.c2
-rw-r--r--Src/Zle/zle_word.c2
7 files changed, 35 insertions, 46 deletions
diff --git a/Src/Zle/comp1.c b/Src/Zle/comp1.c
index 68aa5ef52..5ffce0da2 100644
--- a/Src/Zle/comp1.c
+++ b/Src/Zle/comp1.c
@@ -44,7 +44,7 @@ Cmlist cmatcher;
 /* pointers to functions required by zle */
 
 /**/
-void (*printcompctlptr) _((char *, Compctl, int));
+void (*printcompctlptr) _((char *, Compctl, int, int));
 
 /**/
 Compctl (*compctl_widgetptr) _((char *, char **));
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 254021bed..57b75cd39 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -605,7 +605,7 @@ execzlefunc(Thingy func)
 	} else {
 	  startparamscope();
 	  makezleparams();
-	  doshfunc(l, NULL, 0, 1);
+	  doshfunc(w->u.fnnam, l, NULL, 0, 1);
 	  endparamscope();
 	  lastcmd = 0;
 	}
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index ed1420829..e0c4e94ec 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -72,6 +72,9 @@ makezleparams(void)
 
     for(zp = zleparams; zp->name; zp++) {
 	Param pm = createparam(zp->name, zp->type | PM_SPECIAL);
+	if (!pm)
+	    pm = (Param) paramtab->getnode(paramtab, zp->name);
+	DPUTS(!pm, "param not set in makezleparams");
 
 	pm->level = locallevel;
 	pm->u.data = zp->data;
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index f8de14f17..68329be65 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -394,7 +394,7 @@ scanlistwidgets(HashNode hn, int list)
 	quotedzputs(t->nam, stdout);
 	if (w->flags & WIDGET_COMP) {
 	    if (printcompctlptr && w->u.cc)
-		printcompctlptr(NULL, w->u.cc, PRINT_LIST);
+		printcompctlptr(NULL, w->u.cc, PRINT_LIST, 0);
 	} else if(strcmp(t->nam, w->u.fnnam)) {
 	    fputc(' ', stdout);
 	    quotedzputs(w->u.fnnam, stdout);
@@ -404,7 +404,7 @@ scanlistwidgets(HashNode hn, int list)
 	if (w->flags & WIDGET_COMP) {
 	    fputs(" -C", stdout);
 	    if (printcompctlptr && w->u.cc)
-		printcompctlptr(NULL, w->u.cc, PRINT_TYPE);
+		printcompctlptr(NULL, w->u.cc, PRINT_TYPE, 0);
 	} else if(strcmp(t->nam, w->u.fnnam)) {
 	    fputs(" (", stdout);
 	    nicezputs(w->u.fnnam, stdout);
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index a8998739c..cbc744601 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -2730,18 +2730,16 @@ maketildelist(void)
 
 /**/
 static int
-getcpat(char *wrd, int cpatindex, char *cpat, int class)
+getcpat(char *str, int cpatindex, char *cpat, int class)
 {
-    char *str, *s, *t, *p;
+    char *s, *t, *p;
     int d = 0;
 
-    if (!wrd || !*wrd)
+    if (!str || !*str)
 	return -1;
 
     cpat = rembslash(cpat);
 
-    str = ztrdup(wrd);
-    untokenize(str);
     if (!cpatindex)
 	cpatindex++, d = 0;
     else if ((d = (cpatindex < 0)))
@@ -2752,23 +2750,14 @@ getcpat(char *wrd, int cpatindex, char *cpat, int class)
 	 d ? s-- : s++) {
 	for (t = s, p = cpat; *t && *p; p++) {
 	    if (class) {
-		if (*p == *s && !--cpatindex) {
-		    zsfree(str);
+		if (*p == *s && !--cpatindex)
 		    return (int)(s - str + 1);
-		}
 	    } else if (*t++ != *p)
 		break;
 	}
-	if (!class && !*p && !--cpatindex) {
-	    zsfree(str);
-	    t += wrd - str;
-	    for (d = 0; --t >= wrd;)
-		if (! INULL(*t))
-		    d++;
-	    return d;
-	}
+	if (!class && !*p && !--cpatindex)
+	    return t - str;
     }
-    zsfree(str);
     return -1;
 }
 
@@ -3336,8 +3325,9 @@ makecomplistext(Compctl occ, char *os, int incmd)
 			break;
 		    case CCT_CURSUF:
 		    case CCT_CURPRE:
-			s = ztrdup(clwpos < clwnum ? clwords[clwpos] : "");
+			s = ztrdup(clwpos < clwnum ? os : "");
 			untokenize(s);
+			if (isset(COMPLETEINWORD)) s[offs] = '\0';
 			sc = rembslash(cc->u.s.s[i]);
 			a = strlen(sc);
 			if (!strncmp(s, sc, a)) {
@@ -3347,10 +3337,13 @@ makecomplistext(Compctl occ, char *os, int incmd)
 			break;
 		    case CCT_CURSUB:
 		    case CCT_CURSUBC:
-			if (clwpos < 0 || clwpos > clwnum)
+			if (clwpos < 0 || clwpos >= clwnum)
 			    t = 0;
 			else {
-			    a = getcpat(clwords[clwpos],
+			    s = ztrdup(os);
+			    untokenize(s);
+			    if (isset(COMPLETEINWORD)) s[offs] = '\0';
+			    a = getcpat(s,
 					cc->u.s.p[i],
 					cc->u.s.s[i],
 					cc->type == CCT_CURSUBC);
@@ -4107,7 +4100,7 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd)
 	    /* This flag allows us to use read -l and -c. */
 	    incompctlfunc = 1;
 	    /* Call the function. */
-	    doshfunc(list, args, 0, 1);
+	    doshfunc(cc->func, list, args, 0, 1);
 	    incompctlfunc = 0;
 	    /* And get the result from the reply parameter. */
 	    if ((r = get_user_var("reply")))
@@ -4270,7 +4263,7 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd)
 
 	    /* No harm in allowing read -l and -c here, too */
 	    incompctlfunc = 1;
-	    doshfunc(list, args, 0, 1);
+	    doshfunc(cc->ylist, list, args, 0, 1);
 	    incompctlfunc = 0;
 	    uv = "reply";
 	}
@@ -4912,7 +4905,7 @@ do_ambiguous(void)
      * if it is needed.                                                     */
     if (isset(LISTBEEP))
 	feep();
-    if (isset(AUTOLIST) && !amenu && !showinglist)
+    if (isset(AUTOLIST) && !amenu && !showinglist && smatches >= 2)
 	showinglist = -2;
     if (am)
 	lastambig = 1;
@@ -5233,14 +5226,10 @@ listmatches(void)
     Cmgroup g;
     Cmatch *p, m;
     Cexpl *e;
-    int nlines = 0, ncols, colsz, ngr = 0, nlist = 0, longest = 1, pnl = 0;
+    int nlines = 0, ncols, nlist = 0, longest = 1, pnl = 0;
     int of = isset(LISTTYPES), opl = 0;
     int listmax = getiparam("LISTMAX");
 
-    if (smatches < 2) {
-	showinglist = 0;
-	return;
-    }
 #ifdef DEBUG
     /* Sanity check */
     if(!validlist) {
@@ -5310,16 +5299,13 @@ listmatches(void)
 		e++;
 	    }
 	}
-	if (g->lcount)
-	    ngr++;
     }
     longest += 2 + of;
     if ((ncols = (columns + 1) / longest)) {
-	colsz = (nlist + ncols - 1) / ncols;
-	nlines += ngr - 1 + colsz + (nlist == 0);
+	for (g = amatches; g; g = g->next)
+	    nlines += (g->lcount + ncols - 1) / ncols;
     } else {
 	ncols = 1;
-	colsz = 1;
 	opl = 1;
 	for (g = amatches; g; g = g->next) {
 	    char **pp = g->ylist;
@@ -5396,12 +5382,11 @@ listmatches(void)
 		}
 	    }
 	    else {
-		int n = g->lcount, nl = (n + ncols - 1) / ncols, i, a;
-		int nc = (opl ? 1 : (n + colsz - 1) / colsz);
+		int n = g->lcount, nl = (n + ncols - 1) / ncols, nc = nl, i, a;
 		char **pq;
 
 		while (n && nl--) {
-		    i = nc;
+		    i = ncols;
 		    pq = pp;
 		    while (n && i--) {
 			if (pq - g->ylist >= g->lcount)
@@ -5412,7 +5397,7 @@ listmatches(void)
 			    while (a--)
 				putc(' ', shout);
 			}
-			pq += colsz;
+			pq += nc;
 			n--;
 		    }
 		    if (n)
@@ -5422,8 +5407,7 @@ listmatches(void)
 	    }
 	}
 	else if (g->lcount) {
-	    int n = g->lcount, nl = (n + ncols - 1) / ncols, i, j, a;
-	    int nc = (opl ? 1 : (n + colsz - 1) / colsz);
+	    int n = g->lcount, nl = (n + ncols - 1) / ncols, nc = nl, i, j, a;
 	    Cmatch *q;
 
 	    if (n && pnl) {
@@ -5431,7 +5415,7 @@ listmatches(void)
 		pnl = 0;
 	    }
 	    for (p = skipnolist(g->matches); n && nl--;) {
-		i = nc;
+		i = ncols;
 		q = p;
 		while (n && i--) {
 		    if (!(m = *q))
@@ -5460,7 +5444,7 @@ listmatches(void)
 			while (a--)
 			    putc(' ', shout);
 		    if (--n)
-			for (j = colsz; j && *q; j--)
+			for (j = nc; j && *q; j--)
 			    q = skipnolist(q + 1);
 		}
 		if (n) {
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index 46c6a705b..e699e438c 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -567,7 +567,9 @@ vioperswapcase(void)
 	}
 	/* go back to the first line of the range */
 	cs = oldcs;
+#if 0
 	vifirstnonblank();
+#endif
     }
     vichgflag = 0;
 }
diff --git a/Src/Zle/zle_word.c b/Src/Zle/zle_word.c
index 923216ef8..afd860066 100644
--- a/Src/Zle/zle_word.c
+++ b/Src/Zle/zle_word.c
@@ -73,7 +73,7 @@ viforwardword(void)
 		cs++;
 	if (wordflag && !n)
 	    return;
-	while (cs != ll && iblank(line[cs]))
+	while (cs != ll && (iblank(line[cs]) || line[cs] == '\n'))
 	    cs++;
     }
 }