summaryrefslogtreecommitdiff
path: root/Src/Zle
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/compcore.c22
-rw-r--r--Src/Zle/zle_main.c23
-rw-r--r--Src/Zle/zle_params.c12
-rw-r--r--Src/Zle/zle_thingy.c2
4 files changed, 47 insertions, 12 deletions
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 52b0c173f..8eca39447 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -1610,9 +1610,11 @@ set_comp_sep(void)
inpush(dupstrspace(tmp), 0, NULL);
zlemetaline = tmp;
/*
- * Length of temporary string, calculated above.
+ * tl is the length of temporary string, calculated above.
+ * It seems zlemetall need not include the 'x' added at the cursor.
+ * addedx is taken care of in function gotword() (lex.c).
*/
- zlemetall = tl;
+ zlemetall = tl - addedx;
strinbeg(0);
noaliases = 1;
do {
@@ -1638,7 +1640,7 @@ set_comp_sep(void)
p[-1] = '\0';
}
}
- if (tok == ENDINPUT || tok == LEXERR)
+ if (tok == ENDINPUT)
break;
if (tokstr && *tokstr) {
for (p = tokstr; dq && *p; p++) {
@@ -1667,9 +1669,9 @@ set_comp_sep(void)
if (!got && !lexflags) {
DPUTS(!p, "no current word in substr");
got = 1;
- cur = i;
- swb = wb - 1 - dq - sq - dolq;
- swe = we - 1 - dq - sq - dolq;
+ cur = countlinknodes(foo) - 1; /* cur is 0 offset */
+ swb = wb - dq - sq - dolq;
+ swe = we - dq - sq - dolq;
sqq = lsq;
soffs = zlemetacs - swb - css;
DPUTS2(p[soffs] != 'x', "expecting 'x' at offset %d of \"%s\"",
@@ -1901,7 +1903,11 @@ set_comp_sep(void)
p = compwords[i] = (char *) getdata(n);
untokenize(p);
}
- compcurrent = cur + 1;
+ /* The current position shouldn't exceed the new word count */
+ if ((compcurrent = cur + 1) > i) {
+ DPUTS2(1, "compcurrent=%d > number_of_words=%d", compcurrent, i);
+ compcurrent = i;
+ }
compwords[i] = NULL;
}
instring = ois;
@@ -3550,6 +3556,8 @@ freematches(Cmgroup g, int cm)
}
free(g->expls);
}
+ if (g->widths)
+ free(g->widths);
zsfree(g->name);
free(g);
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index be2b062b0..db70e7d7e 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -58,6 +58,11 @@ mod_export int incompctlfunc;
/**/
mod_export int hascompmod;
+/* Increment for each nested recursive-edit */
+
+/**/
+mod_export int zle_recursive;
+
/* ZLRF_* flags passed to zleread() */
/**/
@@ -631,6 +636,8 @@ raw_getbyte(long do_keytmout, char *cptr)
continue;
}
if (selret == 0) {
+ zlong save_lastval;
+
/*
* Nothing ready and no error, so we timed out.
*/
@@ -648,6 +655,7 @@ raw_getbyte(long do_keytmout, char *cptr)
break;
case ZTM_FUNC:
+ save_lastval = lastval;
while (firstnode(timedfns)) {
Timedfn tfdat = (Timedfn)getdata(firstnode(timedfns));
/*
@@ -661,6 +669,7 @@ raw_getbyte(long do_keytmout, char *cptr)
break;
tfdat->func();
}
+ lastval = save_lastval;
/* Function may have messed up the display */
if (resetneeded)
zrefresh();
@@ -800,6 +809,8 @@ raw_getbyte(long do_keytmout, char *cptr)
}
# endif
}
+ /* If looping, need to recalculate timeout */
+ calc_timeout(&tmout, do_keytmout);
}
# ifdef HAVE_POLL
zfree(fds, sizeof(struct pollfd) * nfds);
@@ -1648,6 +1659,7 @@ bin_vared(char *name, char **args, Options ops, UNUSED(int func))
Param pm = 0;
int ifl;
int type = PM_SCALAR, obreaks = breaks, haso = 0, oSHTTY = 0;
+ int warn_flags;
char *p1, *p2, *main_keymapname, *vicmd_keymapname, *init, *finish;
Keymap main_keymapsave = NULL, vicmd_keymapsave = NULL;
FILE *oshout = NULL;
@@ -1661,6 +1673,7 @@ bin_vared(char *name, char **args, Options ops, UNUSED(int func))
return 1;
}
+ warn_flags = OPT_ISSET(ops, 'g') ? 0 : ASSPM_WARN;
if (OPT_ISSET(ops,'A'))
{
if (OPT_ISSET(ops, 'a'))
@@ -1841,11 +1854,11 @@ bin_vared(char *name, char **args, Options ops, UNUSED(int func))
a = spacesplit(t, 1, 0, 1);
zsfree(t);
if (PM_TYPE(pm->node.flags) == PM_ARRAY)
- setaparam(args[0], a);
+ assignaparam(args[0], a, warn_flags);
else
sethparam(args[0], a);
} else
- setsparam(args[0], t);
+ assignsparam(args[0], t, warn_flags);
unqueue_signals();
return 0;
}
@@ -1933,6 +1946,8 @@ recursiveedit(UNUSED(char **args))
int locerror;
int q = queue_signal_level();
+ ++zle_recursive;
+
/* zlecore() expects to be entered with signal queue disabled */
dont_queue_signals();
@@ -1942,6 +1957,8 @@ recursiveedit(UNUSED(char **args))
restore_queue_signals(q);
+ --zle_recursive;
+
locerror = errflag ? 1 : 0;
errflag = done = eofsent = 0;
@@ -2144,7 +2161,7 @@ zle_main_entry(int cmd, va_list ap)
static struct builtin bintab[] = {
BUILTIN("bindkey", 0, bin_bindkey, 0, -1, 0, "evaM:ldDANmrsLRp", NULL),
- BUILTIN("vared", 0, bin_vared, 1, 1, 0, "aAcef:hi:M:m:p:r:t:", NULL),
+ BUILTIN("vared", 0, bin_vared, 1, 1, 0, "aAcef:ghi:M:m:p:r:t:", NULL),
BUILTIN("zle", 0, bin_zle, 0, -1, 0, "aAcCDfFgGIKlLmMNrRTUw", NULL),
};
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index f3112165a..9f4fb5ac2 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -93,6 +93,8 @@ static const struct gsu_integer numeric_gsu =
{ get_numeric, set_numeric, unset_numeric };
static const struct gsu_integer pending_gsu =
{ get_pending, NULL, zleunsetfn };
+static const struct gsu_integer recursive_gsu =
+{ get_recursive, NULL, zleunsetfn };
static const struct gsu_integer region_active_gsu =
{ get_region_active, set_region_active, zleunsetfn };
static const struct gsu_integer undo_change_no_gsu =
@@ -180,6 +182,7 @@ static struct zleparam {
{ "SUFFIX_START", PM_INTEGER, GSU(suffixstart_gsu), NULL },
{ "SUFFIX_END", PM_INTEGER, GSU(suffixend_gsu), NULL },
{ "SUFFIX_ACTIVE", PM_INTEGER | PM_READONLY, GSU(suffixactive_gsu), NULL },
+ { "ZLE_RECURSIVE", PM_INTEGER | PM_READONLY, GSU(recursive_gsu), NULL },
{ "ZLE_STATE", PM_SCALAR | PM_READONLY, GSU(zle_state_gsu), NULL },
{ NULL, 0, NULL, NULL }
};
@@ -528,6 +531,13 @@ get_pending(UNUSED(Param pm))
/**/
static zlong
+get_recursive(UNUSED(Param pm))
+{
+ return zle_recursive;
+}
+
+/**/
+static zlong
get_yankstart(UNUSED(Param pm))
{
return yankb;
@@ -819,7 +829,7 @@ get_registers(UNUSED(HashTable ht), const char *name)
/**/
static void
-set_registers(UNUSED(Param pm), HashTable ht)
+set_registers(Param pm, HashTable ht)
{
int i;
HashNode hn;
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index 5601c1178..6b892b822 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -725,13 +725,13 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
remetafy = 0;
while (*args && **args == '-') {
+ char skip_this_arg[2] = "x";
char *num;
if (!args[0][1] || args[0][1] == '-') {
args++;
break;
}
while (*++(*args)) {
- char skip_this_arg[2] = "x";
switch (**args) {
case 'n':
num = args[0][1] ? args[0]+1 : args[1];