From 560a23033d2d0e029bbbcda0366053d8d87a37d9 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Fri, 11 Sep 2015 21:23:21 +0100
Subject: unposted: update internal build string to 5.1.1-dev-0
---
ChangeLog | 3 +++
Config/version.mk | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 83db49234..06427e7a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2015-09-11 Peter Stephenson
+ * unposted: Config/version.mk: Update internal build to
+ 5.1.1-dev-0
+
* unposted: Config/version.mk: 5.1.1
* Sebastian Gniazdowski: 36489: Src/Modules/curses.c: fix bug
diff --git a/Config/version.mk b/Config/version.mk
index 21577997b..7ec276df2 100644
--- a/Config/version.mk
+++ b/Config/version.mk
@@ -27,5 +27,5 @@
# This must also serve as a shell script, so do not add spaces around the
# `=' signs.
-VERSION=5.1.1
+VERSION=5.1.1-dev-0
VERSION_DATE='September 11, 2015'
--
cgit v1.2.3
From e1c0a947cc845c71dd844db44016d07922cfcefa Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Fri, 11 Sep 2015 21:40:45 +0100
Subject: Read full multibyte string early for self-insert
---
ChangeLog | 5 +++++
Src/Zle/zle_hist.c | 4 ++--
Src/Zle/zle_keymap.c | 37 +++++++++++++++++++++++++++++--------
Src/Zle/zle_main.c | 10 ++++++++--
Src/Zle/zle_misc.c | 6 ++----
Src/Zle/zle_vi.c | 2 +-
6 files changed, 47 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 06427e7a9..914ee4e47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2015-09-11 Peter Stephenson
+ * 36496 (plus tweak for key buffer length): Src/Zle/zle_hist.c,
+ Src/Zle/zle_keymap.c, Src/Zle/zle_main.c, Src/Zle/zle_misc.c,
+ Src/Zle/zle_vi.c: Read full multibyte string early for
+ self-insert.
+
* unposted: Config/version.mk: Update internal build to
5.1.1-dev-0
diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c
index c61b4ef0e..0cff0391a 100644
--- a/Src/Zle/zle_hist.c
+++ b/Src/Zle/zle_hist.c
@@ -1643,7 +1643,7 @@ doisearch(char **args, int dir, int pattern)
} else if (cmd == Th(z_selfinsert)) {
#ifdef MULTIBYTE_SUPPORT
if (!lastchar_wide_valid)
- if (getrestchar(lastchar) == WEOF) {
+ if (getrestchar(lastchar, NULL, NULL) == WEOF) {
handlefeep(zlenoargs);
continue;
}
@@ -1877,7 +1877,7 @@ getvisrchstr(void)
} else {
#ifdef MULTIBYTE_SUPPORT
if (!lastchar_wide_valid)
- if (getrestchar(lastchar) == WEOF) {
+ if (getrestchar(lastchar, NULL, NULL) == WEOF) {
handlefeep(zlenoargs);
continue;
}
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index 5b4189faa..069580f8a 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -1501,6 +1501,20 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp)
* they wait till a key is pressed for the movement anyway */
timeout = !(!virangeflag && !region_active && f && f->widget &&
f->widget->flags & ZLE_VIOPER);
+#ifdef MULTIBYTE_SUPPORT
+ if ((f == Th(z_selfinsert) || f == Th(z_selfinsertunmeta)) &&
+ !lastchar_wide_valid) {
+ int len;
+ VARARR(char, mbc, MB_CUR_MAX);
+ ZLE_INT_T inchar = getrestchar(lastchar, mbc, &len);
+ if (inchar != WEOF && len) {
+ char *ptr = mbc;
+ while (len--)
+ addkeybuf(STOUC(*ptr++));
+ lastlen = keybuflen;
+ }
+ }
+#endif
}
if (!ispfx)
break;
@@ -1521,6 +1535,20 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp)
return keybuf;
}
+/**/
+static void
+addkeybuf(int c)
+{
+ if(keybuflen + 3 > keybufsz)
+ keybuf = realloc(keybuf, keybufsz *= 2);
+ if(imeta(c)) {
+ keybuf[keybuflen++] = Meta;
+ keybuf[keybuflen++] = c ^ 32;
+ } else
+ keybuf[keybuflen++] = c;
+ keybuf[keybuflen] = 0;
+}
+
/*
* Add a (possibly metafied) byte to the key input so far.
* This handles individual bytes of a multibyte string separately;
@@ -1542,14 +1570,7 @@ getkeybuf(int w)
if(c < 0)
return EOF;
- if(keybuflen + 3 > keybufsz)
- keybuf = realloc(keybuf, keybufsz *= 2);
- if(imeta(c)) {
- keybuf[keybuflen++] = Meta;
- keybuf[keybuflen++] = c ^ 32;
- } else
- keybuf[keybuflen++] = c;
- keybuf[keybuflen] = 0;
+ addkeybuf(c);
return c;
}
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index ec3d2c354..992f152df 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -933,7 +933,7 @@ getfullchar(int do_keytmout)
int inchar = getbyte((long)do_keytmout, NULL);
#ifdef MULTIBYTE_SUPPORT
- return getrestchar(inchar);
+ return getrestchar(inchar, NULL, NULL);
#else
return inchar;
#endif
@@ -951,7 +951,7 @@ getfullchar(int do_keytmout)
/**/
mod_export ZLE_INT_T
-getrestchar(int inchar)
+getrestchar(int inchar, char *outstr, int *outcount)
{
char c = inchar;
wchar_t outchar;
@@ -965,6 +965,8 @@ getrestchar(int inchar)
*/
lastchar_wide_valid = 1;
+ if (outcount)
+ *outcount = 0;
if (inchar == EOF) {
/* End of input, so reset the shift state. */
memset(&mbs, 0, sizeof mbs);
@@ -1013,6 +1015,10 @@ getrestchar(int inchar)
return lastchar_wide = WEOF;
}
c = inchar;
+ if (outstr) {
+ *outstr++ = c;
+ (*outcount)++;
+ }
}
return lastchar_wide = (ZLE_INT_T)outchar;
}
diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c
index 2d1862813..12143e05f 100644
--- a/Src/Zle/zle_misc.c
+++ b/Src/Zle/zle_misc.c
@@ -115,9 +115,7 @@ selfinsert(UNUSED(char **args))
ZLE_CHAR_T tmp;
#ifdef MULTIBYTE_SUPPORT
- if (!lastchar_wide_valid)
- if (getrestchar(lastchar) == WEOF)
- return 1;
+ DPUTS(!lastchar_wide_valid, "keybuf did not read full wide character");
#endif
tmp = LASTFULLCHAR;
doinsert(&tmp, 1);
@@ -1431,7 +1429,7 @@ executenamedcommand(char *prmt)
else {
#ifdef MULTIBYTE_SUPPORT
if (!lastchar_wide_valid)
- getrestchar(lastchar);
+ getrestchar(lastchar, NULL, NULL);
if (lastchar_wide == WEOF)
feep = 1;
else
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index 42dc46e7e..86840bdd6 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -151,7 +151,7 @@ vigetkey(void)
#ifdef MULTIBYTE_SUPPORT
if (!lastchar_wide_valid)
{
- getrestchar(lastchar);
+ getrestchar(lastchar, NULL, NULL);
}
#endif
return LASTFULLCHAR;
--
cgit v1.2.3
From d37b59fe0969a619f049dee081b15af696070009 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf
Date: Fri, 11 Sep 2015 21:47:53 +0000
Subject: 36443: Revert "35834: strip a final newline from pasted text:
inserting is hard to tell apart from accepting it"
This reverts commit f17eb26a34af69a2238a3d8b46079445e09c096e.
Conflicts:
ChangeLog
Src/Zle/zle_misc.c
---
ChangeLog | 5 +++++
Src/Zle/zle_misc.c | 6 ------
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 914ee4e47..a484ad7fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-09-11 Daniel Shahaf
+
+ * 36443: Revert 35834.
+
2015-09-11 Peter Stephenson
* 36496 (plus tweak for key buffer length): Src/Zle/zle_hist.c,
@@ -438,6 +442,7 @@
* 35834 (tweaked): Src/Zle/zle_misc.c: strip a final newline from
pasted text: inserting is hard to tell apart from accepting it
+ [reverted in 36443]
2015-08-12 Mikael Magnusson
diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c
index 12143e05f..297dc4ca8 100644
--- a/Src/Zle/zle_misc.c
+++ b/Src/Zle/zle_misc.c
@@ -785,12 +785,6 @@ bracketedpaste(char **args)
zmult = 1;
if (region_active)
killregion(zlenoargs);
- /* Chop a final newline if its insertion would be hard to
- * distinguish by the user from the line being accepted. */
- else if (n > 1 && zlecontext != ZLCON_VARED &&
- (zlecs + (insmode ? 0 : n - 1)) >= zlell &&
- wpaste[n-1] == ZWC('\n'))
- n--;
yankcs = yankb = zlecs;
doinsert(wpaste, n);
yanke = zlecs;
--
cgit v1.2.3
From c76f4f96a65c7bfbba2183c422a1fb567069981f Mon Sep 17 00:00:00 2001
From: Daniel Shahaf
Date: Mon, 7 Sep 2015 15:50:26 +0000
Subject: 36443: Set zle_highlight=(paste:standout) by default.
---
ChangeLog | 3 +++
Doc/Zsh/zle.yo | 2 +-
Src/Zle/zle_refresh.c | 3 ++-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a484ad7fc..aedeaed4c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2015-09-11 Daniel Shahaf
+ * 36443: Doc/Zsh/zle.yo Src/Zle/zle_refresh.c: Set
+ zle_highlight=(paste:standout) by default.
+
* 36443: Revert 35834.
2015-09-11 Peter Stephenson
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index 2c539c460..71a7af0d7 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -2679,7 +2679,7 @@ If tt(zle_highlight) is not set or no value applies to a particular
context, the defaults applied are equivalent to
example(zle_highlight=LPAR()region:standout special:standout
-suffix:bold isearch:underline+RPAR())
+suffix:bold isearch:underline paste:standout+RPAR())
i.e. both the region and special characters are shown in standout mode.
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index 0c28c0a2d..6facff429 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -372,7 +372,8 @@ zle_set_highlight(void)
region_highlights[1].atr = TXTUNDERLINE;
if (!suffix_atr_on_set)
region_highlights[2].atr = TXTBOLDFACE;
- /* paste defaults to 0 */
+ if (!paste_atr_on_set)
+ region_highlights[3].atr = TXTSTANDOUT;
allocate_colour_buffer();
}
--
cgit v1.2.3
From 8b1676e3b7bca183fea725d38d62350d2688078b Mon Sep 17 00:00:00 2001
From: Jun-ichi Takimoto
Date: Sat, 12 Sep 2015 20:35:56 +0900
Subject: 36491: Multibyte support for parameter expansion flags B,E,N
---
ChangeLog | 5 +++++
Src/glob.c | 6 +++---
Test/D07multibyte.ztst | 15 +++++++++++++++
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index aedeaed4c..c70396dd4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-12 Jun-ichi Takimoto
+
+ * 36491: Src/glob.c, Test/D07multibyte.ztst: Multibyte
+ support for the parameter expansion flags B, E and N.
+
2015-09-11 Daniel Shahaf
* 36443: Doc/Zsh/zle.yo Src/Zle/zle_refresh.c: Set
diff --git a/Src/glob.c b/Src/glob.c
index dea1bf50e..43d135b99 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2491,17 +2491,17 @@ get_match_ret(char *s, int b, int e, int fl, char *replstr,
ll += 1 + (l - (e - b));
if (fl & SUB_BIND) {
/* position of start of matched portion */
- sprintf(buf, "%d ", b + 1);
+ sprintf(buf, "%d ", MB_METASTRLEN2END(s, 0, s+b) + 1);
ll += (bl = strlen(buf));
}
if (fl & SUB_EIND) {
/* position of end of matched portion */
- sprintf(buf + bl, "%d ", e + 1);
+ sprintf(buf + bl, "%d ", MB_METASTRLEN2END(s, 0, s+e) + 1);
ll += (bl = strlen(buf));
}
if (fl & SUB_LEN) {
/* length of matched portion */
- sprintf(buf + bl, "%d ", e - b);
+ sprintf(buf + bl, "%d ", MB_METASTRLEN2END(s+b, 0, s+e));
ll += (bl = strlen(buf));
}
if (bl)
diff --git a/Test/D07multibyte.ztst b/Test/D07multibyte.ztst
index ace191f06..5ae9b2c12 100644
--- a/Test/D07multibyte.ztst
+++ b/Test/D07multibyte.ztst
@@ -293,6 +293,21 @@
>Ἐν ἀρχῇ ἦν ὁ λόγος, καὶ ὁ λόγος ἦν πρὸς τὸν θεόν, καὶ ἦν ὁ λόγος
>Ἐν ἀρχῇ ἦν ὁ λόγος, καὶ ὁ λόγος ἦν πρὸς τὸν θεόν, καὶ
+ a="1ë34ë6"
+ print ${(BEN)a#*4}
+ print ${(BEN)a##*ë}
+ print ${(BEN)a%4*}
+ print ${(BEN)a%%ë*}
+ print ${(SBEN)a#ë3}
+ print ${(SBEN)a%4ë}
+0:Flags B, E, N and S in ${...#...} and ${...%...}
+>1 5 4
+>1 6 5
+>4 7 3
+>2 7 5
+>2 4 2
+>4 6 2
+
foo=(κατέβην χθὲς εἰς Πειραιᾶ)
print ${(l.3..¥.r.3..£.)foo}
print ${(l.4..¥.r.2..£.)foo}
--
cgit v1.2.3
From 6ff0628182ac74bbf22dc02edcc9a148f12767db Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sat, 12 Sep 2015 09:53:39 -0700
Subject: 36509: allocate hash table nodes with zshcalloc() to avoid garbage
flag values
---
ChangeLog | 5 +++++
Src/Modules/curses.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c70396dd4..3aa4f208a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-12 Barton E. Schaefer
+
+ * 36509: Src/Modules/curses.c: allocate hash table nodes with
+ zshcalloc() to avoid garbage flag values
+
2015-09-12 Jun-ichi Takimoto
* 36491: Src/glob.c, Test/D07multibyte.ztst: Multibyte
diff --git a/Src/Modules/curses.c b/Src/Modules/curses.c
index 0054aef52..64329f643 100644
--- a/Src/Modules/curses.c
+++ b/Src/Modules/curses.c
@@ -370,7 +370,7 @@ zcurses_colorget(const char *nam, char *colorpair)
return NULL;
}
- cpn = (Colorpairnode)zalloc(sizeof(struct colorpairnode));
+ cpn = (Colorpairnode)zshcalloc(sizeof(struct colorpairnode));
if (!cpn) {
zsfree(cp);
@@ -462,7 +462,7 @@ zccmd_init(const char *nam, char **args)
use_default_colors();
#endif
/* Initialise the default color pair, always 0 */
- cpn = (Colorpairnode)zalloc(sizeof(struct colorpairnode));
+ cpn = (Colorpairnode)zshcalloc(sizeof(struct colorpairnode));
if (cpn) {
cpn->colorpair = 0;
addhashnode(zcurses_colorpairs,
--
cgit v1.2.3
From 8e77fcb050ed09042cc2464f804ac023c0f88b42 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sat, 12 Sep 2015 16:13:01 -0700
Subject: 36522: unmetafy the argument of "zle -U"
---
ChangeLog | 2 ++
Src/Zle/zle_thingy.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 3aa4f208a..1ce47d7f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2015-09-12 Barton E. Schaefer
+ * 36522: Src/Zle/zle_thingy.c: unmetafy the argument of "zle -U"
+
* 36509: Src/Modules/curses.c: allocate hash table nodes with
zshcalloc() to avoid garbage flag values
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index 7fd3a5941..da3a6d458 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -466,7 +466,7 @@ bin_zle_mesg(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
static int
bin_zle_unget(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
{
- char *b = *args, *p = b + strlen(b);
+ char *b = unmeta(*args), *p = b + strlen(b);
if (!zleactive) {
zwarnnam(name, "can only be called from widget function");
--
cgit v1.2.3
From b957cdd21a8997739aba48c3637fc3b9f88b2168 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sat, 12 Sep 2015 17:16:43 -0700
Subject: unposted: revert 36483 as multibyte is now handled by "zle
.read-command"; adapt to new default behavior of zle_highlight for paste
---
ChangeLog | 4 ++++
Functions/Zle/bracketed-paste-magic | 18 +++++-------------
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1ce47d7f1..53772e565 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2015-09-12 Barton E. Schaefer
+ * unposted: Functions/Zle/bracketed-paste-magic: revert 36483 as
+ multibyte is now handled by "zle .read-command"; adapt to new
+ default behavior of zle_highlight for paste
+
* 36522: Src/Zle/zle_thingy.c: unmetafy the argument of "zle -U"
* 36509: Src/Modules/curses.c: allocate hash table nodes with
diff --git a/Functions/Zle/bracketed-paste-magic b/Functions/Zle/bracketed-paste-magic
index 464c6b339..cd4a7085b 100644
--- a/Functions/Zle/bracketed-paste-magic
+++ b/Functions/Zle/bracketed-paste-magic
@@ -164,25 +164,17 @@ bracketed-paste-magic() {
integer bpm_limit=$UNDO_LIMIT_NO bpm_undo=$UNDO_CHANGE_NO
UNDO_LIMIT_NO=$UNDO_CHANGE_NO
- local mbchar
- integer ismb
while [[ -n $PASTED ]] && zle .read-command; do
- mbchar=$KEYS
- ismb=0
- while [[ $mbchar = [[:INCOMPLETE:]]* ]] && zle .read-command; do
- mbchar+=$KEYS
- ismb=1
- done
- PASTED=${PASTED#$mbchar}
- if [[ ismb -ne 0 || $mbchar = ${(~j:|:)${(b)bpm_inactive}} ]]; then
- LBUFFER+=$mbchar
+ PASTED=${PASTED#$KEYS}
+ if [[ $KEYS = ${(~j:|:)${(b)bpm_inactive}} ]]; then
+ zle .self-insert-unmeta
else
case $REPLY in
(${~bpm_active}) function () {
emulate -L $bpm_emulate; set -$bpm_opts
zle $REPLY
};;
- (*) LBUFFER+=$mbchar;
+ (*) zle .self-insert-unmeta;;
esac
fi
done
@@ -221,7 +213,7 @@ bracketed-paste-magic() {
zle .split-undo
# Arrange to display highlighting if necessary
- if [[ -n ${(M)zle_highlight:#paste:*} ]]; then
+ if [[ -z $zle_highlight || -n ${(M)zle_highlight:#paste:*} ]]; then
zle -R
zle .read-command && zle -U - $KEYS
fi
--
cgit v1.2.3
From 9cb8c3f4b5d9918028791d975cf3aa7d745b4b22 Mon Sep 17 00:00:00 2001
From: Axel Beckert
Date: Sun, 13 Sep 2015 02:02:59 +0200
Subject: 36523: Completion/…/_gphoto2: Replace --delete-files with
--delete-file
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ChangeLog | 5 +++++
Completion/Unix/Command/_gphoto2 | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 53772e565..db594cc5d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-13 Axel Beckert
+
+ * 36523: Thue Janus Kristensen: Completion/Unix/Command/_gphoto2:
+ Replace --delete-files with --delete-file.
+
2015-09-12 Barton E. Schaefer
* unposted: Functions/Zle/bracketed-paste-magic: revert 36483 as
diff --git a/Completion/Unix/Command/_gphoto2 b/Completion/Unix/Command/_gphoto2
index 95d8a49b7..314d83e3a 100644
--- a/Completion/Unix/Command/_gphoto2
+++ b/Completion/Unix/Command/_gphoto2
@@ -32,7 +32,7 @@ _arguments -s \
'--get-all-raw-data[get all raw data from folder]' \
'--get-audio-data[get audio data given in range]:range' \
'--get-all-audio-data[get all audio data from folder]' \
- '--delete-files[delete files given in range]:range' \
+ '--delete-file[delete files given in range]:range' \
'--delete-all-files[delete all files in folder]' \
'(-u --upload-file)'{-u,--upload-file}'[upload a file to camera]:file:_files' \
'--capture-preview[capture a quick preview]' \
--
cgit v1.2.3
From 8a818381cfa843f6bdc25e3517500da31d63c282 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sat, 12 Sep 2015 20:49:13 -0700
Subject: 36525: revert only the selfinsert() bit of 36496
selfinsert() may be called with incomplete wide character processing from
places other than getkeymapcmd()
---
ChangeLog | 4 ++++
Src/Zle/zle_misc.c | 5 ++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index db594cc5d..79fb2c779 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,10 @@
2015-09-12 Barton E. Schaefer
+ * 36525: Src/Zle/zle_misc.c: revert only the selfinsert() bit of
+ 36496 because selfinsert() may be called with incomplete wide
+ character processing from places other than getkeymapcmd()
+
* unposted: Functions/Zle/bracketed-paste-magic: revert 36483 as
multibyte is now handled by "zle .read-command"; adapt to new
default behavior of zle_highlight for paste
diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c
index 297dc4ca8..0483f758d 100644
--- a/Src/Zle/zle_misc.c
+++ b/Src/Zle/zle_misc.c
@@ -115,7 +115,10 @@ selfinsert(UNUSED(char **args))
ZLE_CHAR_T tmp;
#ifdef MULTIBYTE_SUPPORT
- DPUTS(!lastchar_wide_valid, "keybuf did not read full wide character");
+ /* may be redundant with getkeymapcmd(), but other widgets call here too */
+ if (!lastchar_wide_valid)
+ if (getrestchar(lastchar, NULL, NULL) == WEOF)
+ return 1;
#endif
tmp = LASTFULLCHAR;
doinsert(&tmp, 1);
--
cgit v1.2.3
From aeb1ac6a9cbbf4c135dc2feedc2322e12bb7e549 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf
Date: Mon, 14 Sep 2015 20:31:43 +0000
Subject: unposted (see 36526): Update changelog for 36443.
---
ChangeLog | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 79fb2c779..3445b69cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,8 +25,9 @@
2015-09-11 Daniel Shahaf
- * 36443: Doc/Zsh/zle.yo Src/Zle/zle_refresh.c: Set
- zle_highlight=(paste:standout) by default.
+ * 36443: Doc/Zsh/zle.yo Src/Zle/zle_refresh.c:
+ Highlight pasted/yanked text as standout by default (i.e., when
+ $zle_highlight doesn't specify otherwise).
* 36443: Revert 35834.
--
cgit v1.2.3
From 9955bbdb9faeac388abec68c6b5b976bce27df92 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf
Date: Mon, 14 Sep 2015 20:32:57 +0000
Subject: unposted: docs: Typo fixes
---
ChangeLog | 4 ++++
Doc/Zsh/zle.yo | 2 +-
README | 2 +-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3445b69cf..d1143449a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-09-14 Daniel Shahaf
+
+ * unposted: Doc/Zsh/zle.yo README: docs: Typo fixes
+
2015-09-13 Axel Beckert
* 36523: Thue Janus Kristensen: Completion/Unix/Command/_gphoto2:
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index 71a7af0d7..7d95eb377 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -1012,7 +1012,7 @@ xitem(tt(YANK_ACTIVE) (integer))
xitem(tt(YANK_START) (integer))
item(tt(YANK_END) (integer))(
These three parameters indicate whether text has just been yanked (pasted)
-into the buffer. tt(YANK_START) and tt(YANK_END) are in the same unit sas
+into the buffer. tt(YANK_START) and tt(YANK_END) are in the same units as
tt(CURSOR), and are only valid when tt(YANK_ACTIVE) is non-zero.
All three are read-only.
diff --git a/README b/README
index 1ebc8cd95..4b840b5c9 100644
--- a/README
+++ b/README
@@ -10,7 +10,7 @@ a few visible improvements since 5.0.8 as well as many bugfixes. Note
in particular the two changes highlighted under "Incompatibilites
between 5.0.8 and 5.1" below. See NEWS for more information.
-There are mostly bug fixes between 5.1 and 5.1.1; however, a fewer minor
+There are mostly bug fixes between 5.1 and 5.1.1; however, a few minor
features useful in resolving problems with shell functions were added.
Installing Zsh
--
cgit v1.2.3
From 18130bed7fa032513261d426b8c3915cf11e20c1 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Thu, 17 Sep 2015 21:44:14 -0700
Subject: 36552 plus test: fix Nularg string in quotestring(QT_DOLLARS)
---
ChangeLog | 6 ++++++
Src/utils.c | 6 ++++++
Test/D04parameter.ztst | 4 ++++
3 files changed, 16 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index d1143449a..6e02eae27 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-17 Barton E. Schaefer
+
+ * unposted: Test/D04parameter.ztst: test for 36552
+
+ * 36552: Src/utils.c: fix Nularg string in quotestring(QT_DOLLARS)
+
2015-09-14 Daniel Shahaf
* unposted: Doc/Zsh/zle.yo README: docs: Typo fixes
diff --git a/Src/utils.c b/Src/utils.c
index ca68eae32..d5fd88c00 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -5384,6 +5384,12 @@ quotestring(const char *s, char **e, int instring)
"BUG: bad quote type in quotestring");
u = s;
if (instring == QT_DOLLARS) {
+ /*
+ * The only way to get Nularg here is when
+ * it is placeholding for the empty string?
+ */
+ if (inull(*u))
+ *u++;
/*
* As we test for printability here we need to be able
* to look for multibyte characters.
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index c7d506a51..e380e19b8 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -413,6 +413,10 @@
>$'playing \'stupid\' "games" \\w\\i\\t\\h $quoting.'
>'playing '\'stupid\'' "games" \w\i\t\h $quoting.'
+ print -r ${(qqqq):-""}
+0:workers/36551: literal empty string in ${(qqqq)...}
+>$''
+
x=( a '' '\b' 'c d' '$e' )
print -r ${(q)x}
print -r ${(q-)x}
--
cgit v1.2.3
From 18d82a6c401758e8bd49fef9478168c68d7d2652 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Fri, 18 Sep 2015 10:10:35 -0700
Subject: cf. users/20586: clean up cross-references to the "Autoloading
Functions" doc
---
ChangeLog | 5 +++++
Doc/Zsh/builtins.yo | 18 ++++++++++--------
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6e02eae27..ab1b0bbf9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-18 Barton E. Schaefer
+
+ * unposted (cf. users/20586): Doc/Zsh/builtins.yo: clean up
+ cross-references to the "Autoloading Functions" section.
+
2015-09-17 Barton E. Schaefer
* unposted: Test/D04parameter.ztst: test for 36552
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 5bbe7e70b..67e3131cb 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -144,8 +144,12 @@ findex(autoload)
cindex(functions, autoloading)
cindex(autoloading functions)
item(tt(autoload) [ {tt(PLUS())|tt(-)}tt(TUXkmtz) ] [ tt(-w) ] [ var(name) ... ])(
+vindex(fpath, searching)
Equivalent to tt(functions -u), with the exception of tt(-X)/tt(+X) and
-tt(-w).
+tt(-w). See the section `Autoloading Functions' in ifzman(zmanref(zshmisc))\
+ifnzman(noderef(Functions)) for full details. The tt(fpath) parameter
+will be searched to find the function definition when the function is
+first referenced.
The flag tt(-X) may be used only inside a shell function, and may not be
followed by a var(name). It causes the calling function to be marked for
@@ -170,7 +174,8 @@ pattern are loaded.
With the tt(-w) flag, the var(name)s are taken as names of files compiled
with the tt(zcompile) builtin, and all functions defined in them are
-marked for autoloading.
+marked for autoloading. Note this does not otherwise change the search
+order for
The flags tt(-z) and tt(-k) mark the function to be autoloaded using the
zsh or ksh style, as if the option tt(KSH_AUTOLOAD) were unset or were
@@ -1981,12 +1986,8 @@ for this function; the flag tt(-T) does the same, but turns off tracing
on any function called from the present one, unless that function also
has the tt(-t) or tt(-T) flag. The tt(-u) and tt(-U) flags cause the
function to be marked for autoloading; tt(-U) also causes alias
-expansion to be suppressed when the function is loaded. The tt(fpath)
-parameter will be searched to find the function definition when the
-function is first referenced; see noderef(Functions). The tt(-k) and
-tt(-z) flags make the function be loaded using ksh-style or zsh-style
-autoloading respectively. If neither is given, the setting of the
-tt(KSH_AUTOLOAD) option determines how the function is loaded.
+expansion to be suppressed when the function is loaded. See the
+description of the `tt(autoload)' builtin for details.
Note that the builtin tt(functions) provides the same basic capabilities
as tt(typeset -f) but gives access to a few extra options.
@@ -2338,6 +2339,7 @@ noderef(Functions)
for a description of how autoloaded functions are searched. The
extension tt(.zwc) stands for `zsh word code'.
+vindex(fpath, with zcompile)
If there is at least one var(name) argument, all the named files
are compiled into the output var(file) given as the first argument. If
var(file) does not end in tt(.zwc), this extension is automatically
--
cgit v1.2.3
From 07796811b03f58f2f143cd2860c67c9896c71acb Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sat, 19 Sep 2015 09:34:05 -0700
Subject: cf. 36554: remove unnecessary pointer dereference
---
Src/utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Src/utils.c b/Src/utils.c
index d5fd88c00..1de3d9578 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -5389,7 +5389,7 @@ quotestring(const char *s, char **e, int instring)
* it is placeholding for the empty string?
*/
if (inull(*u))
- *u++;
+ u++;
/*
* As we test for printability here we need to be able
* to look for multibyte characters.
--
cgit v1.2.3
From cc44b10da1bcc4af87fb7bb0336177a31798608e Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Sat, 19 Sep 2015 20:22:19 +0100
Subject: unposted: fix typo in test
---
ChangeLog | 4 ++++
Test/D07multibyte.ztst | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index ab1b0bbf9..2852b4de9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-09-19 Peter Stephenson
+
+ * unposted: Test/D07multibyte.ztst: fix typo.
+
2015-09-18 Barton E. Schaefer
* unposted (cf. users/20586): Doc/Zsh/builtins.yo: clean up
diff --git a/Test/D07multibyte.ztst b/Test/D07multibyte.ztst
index 5ae9b2c12..dff2ec12f 100644
--- a/Test/D07multibyte.ztst
+++ b/Test/D07multibyte.ztst
@@ -543,6 +543,6 @@
[[ $'\xe3' == [[:INCOMPLETE:]] ]] || print fail 1
[[ $'\xe3\x83' == [[:INCOMPLETE:]][[:INVALID:]] ]] || print fail 2
- [[ $'\xe3\x83\x9b' != [[:INCOMPLETE:][:NVALID:]] ]] || print fail 3
+ [[ $'\xe3\x83\x9b' != [[:INCOMPLETE:][:INVALID:]] ]] || print fail 3
[[ $'\xe3\x83\x9b' = ? ]] || print fail 4
0:Testing incomplete and invalid multibyte character components
--
cgit v1.2.3
From df0d86b847fbf5bd1ad383531cd52b261dc07717 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Sat, 19 Sep 2015 23:08:46 +0100
Subject: 36559: test earlier for overflow in pattern range
---
ChangeLog | 3 +++
Src/pattern.c | 23 ++++++++++++++++++-----
Src/zsh.h | 7 +++++++
3 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2852b4de9..bb03894a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2015-09-19 Peter Stephenson
+ * 36559: Src/pattern.c: test earlier for overflow in pattern
+ range.
+
* unposted: Test/D07multibyte.ztst: fix typo.
2015-09-18 Barton E. Schaefer
diff --git a/Src/pattern.c b/Src/pattern.c
index 3b55ccf1c..af56bd9cc 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -220,8 +220,10 @@ typedef union upat *Upat;
#if defined(ZSH_64_BIT_TYPE) || defined(LONG_IS_64_BIT)
typedef zlong zrange_t;
#define ZRANGE_T_IS_SIGNED (1)
+#define ZRANGE_MAX ZLONG_MAX
#else
typedef unsigned long zrange_t;
+#define ZRANGE_MAX ULONG_MAX
#endif
#ifdef MULTIBYTE_SUPPORT
@@ -2641,19 +2643,30 @@ patmatch(Upat prog)
start = compend = patinput;
comp = 0;
while (patinput < patinend && idigit(*patinput)) {
- if (comp)
- comp *= 10;
- comp += *patinput - '0';
+ int out_of_range = 0;
+ int digit = *patinput - '0';
+ if (comp > ZRANGE_MAX / (zlong)10) {
+ out_of_range = 1;
+ } else {
+ zrange_t c10 = comp ? comp * 10 : 0;
+ if (ZRANGE_MAX - c10 < digit) {
+ out_of_range = 1;
+ } else {
+ comp = c10;
+ comp += digit;
+ }
+ }
patinput++;
compend++;
- if (comp & ((zrange_t)1 << (sizeof(comp)*8 -
+ if (out_of_range ||
+ (comp & ((zrange_t)1 << (sizeof(comp)*8 -
#ifdef ZRANGE_T_IS_SIGNED
2
#else
1
#endif
- ))) {
+ )))) {
/*
* Out of range (allowing for signedness, which
* we need if we are using zlongs).
diff --git a/Src/zsh.h b/Src/zsh.h
index 4e2cb656e..9c7e5d9dc 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -36,6 +36,12 @@
*/
#ifdef ZSH_64_BIT_TYPE
typedef ZSH_64_BIT_TYPE zlong;
+#if defind(ZLONG_IS_LONG_LONG) && defined(LLONG_MAX)
+#define ZLONG_MAX LLONG_MAX
+#else
+/* umm... */
+#define ZLONG_MAX ((zlong)9223372036854775807)
+#endif
#ifdef ZSH_64_BIT_UTYPE
typedef ZSH_64_BIT_UTYPE zulong;
#else
@@ -44,6 +50,7 @@ typedef unsigned zlong zulong;
#else
typedef long zlong;
typedef unsigned long zulong;
+#define ZLONG_MAX LONG_MAX
#endif
/*
--
cgit v1.2.3
From 4375d7b905dca266c3a14bf603a908eb7c3dfbf2 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sat, 19 Sep 2015 23:03:39 -0700
Subject: 36562: sanitize $PWD on import, per POSIX
---
ChangeLog | 4 ++++
Src/utils.c | 20 +++++++++++++++++---
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index bb03894a0..6d99ccd81 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-09-19 Barton E. Schaefer
+
+ * 36562: Src/utils.c: sanitize $PWD on import, per POSIX
+
2015-09-19 Peter Stephenson
* 36559: Src/pattern.c: test earlier for overflow in pattern
diff --git a/Src/utils.c b/Src/utils.c
index 1de3d9578..ab3b0c274 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -692,9 +692,23 @@ ispwd(char *s)
{
struct stat sbuf, tbuf;
- if (stat(unmeta(s), &sbuf) == 0 && stat(".", &tbuf) == 0)
- if (sbuf.st_dev == tbuf.st_dev && sbuf.st_ino == tbuf.st_ino)
- return 1;
+ /* POSIX: environment PWD must be absolute */
+ if (*s != '/')
+ return 0;
+
+ if (stat((s = unmeta(s)), &sbuf) == 0 && stat(".", &tbuf) == 0)
+ if (sbuf.st_dev == tbuf.st_dev && sbuf.st_ino == tbuf.st_ino) {
+ /* POSIX: No element of $PWD may be "." or ".." */
+ while (*s) {
+ if (s[0] == '.' &&
+ (!s[1] || s[1] == '/' ||
+ (s[1] == '.' && (!s[2] || s[2] == '/'))))
+ break;
+ while (*s++ != '/' && *s)
+ continue;
+ }
+ return !*s;
+ }
return 0;
}
--
cgit v1.2.3
From e61717b6061e77b582313ffc883f40bc5e11ae70 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sat, 19 Sep 2015 23:05:44 -0700
Subject: 36566: check for regular file before lseek()
---
ChangeLog | 2 ++
Src/parse.c | 3 +++
2 files changed, 5 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 6d99ccd81..70407ca50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2015-09-19 Barton E. Schaefer
+ * 36566: Src/parse.c: check for regular file before lseek()
+
* 36562: Src/utils.c: sanitize $PWD on import, per POSIX
2015-09-19 Peter Stephenson
diff --git a/Src/parse.c b/Src/parse.c
index 7c2d20250..a26df6f0a 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -3227,6 +3227,8 @@ build_dump(char *nam, char *dump, char **files, int ali, int map, int flags)
noaliases = ali;
for (hlen = FD_PRELEN, tlen = 0; *files; files++) {
+ struct stat st;
+
if (!strcmp(*files, "-k")) {
flags = (flags & ~(FDHF_KSHLOAD | FDHF_ZSHLOAD)) | FDHF_KSHLOAD;
continue;
@@ -3235,6 +3237,7 @@ build_dump(char *nam, char *dump, char **files, int ali, int map, int flags)
continue;
}
if ((fd = open(*files, O_RDONLY)) < 0 ||
+ fstat(fd, &st) != 0 || !S_ISREG(st.st_mode) ||
(flen = lseek(fd, 0, 2)) == -1) {
if (fd >= 0)
close(fd);
--
cgit v1.2.3
From bdcdb562d97f7ed604ead37ccda52792dff9a93f Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sat, 19 Sep 2015 23:06:55 -0700
Subject: cf. users/20606: zcompile prepares scripts for sourcing, not for
execution
---
ChangeLog | 3 +++
Doc/Zsh/builtins.yo | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 70407ca50..74226a8f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2015-09-19 Barton E. Schaefer
+ * unposted: Doc/Zsh/builtins.yo: zcompile prepares scripts for
+ sourcing, not for execution
+
* 36566: Src/parse.c: check for regular file before lseek()
* 36562: Src/utils.c: sanitize $PWD on import, per POSIX
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 67e3131cb..97c337071 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -2321,7 +2321,7 @@ item(tt(zcompile -t) var(file) [ var(name) ... ])(
This builtin command can be used to compile functions or scripts,
storing the compiled form in a file, and to examine files containing
the compiled form. This allows faster autoloading of functions and
-execution of scripts by avoiding parsing of the text when the files
+sourcing of scripts by avoiding parsing of the text when the files
are read.
The first form (without the tt(-c), tt(-a) or tt(-t) options) creates a
--
cgit v1.2.3
From 05ec830c943378baf8b9feeb69b97ba6c8eaf257 Mon Sep 17 00:00:00 2001
From: Jun-ichi Takimoto
Date: Mon, 21 Sep 2015 21:08:29 +0900
Subject: 36574: new completion for the lldb debbuger
---
Completion/Unix/Command/_lldb | 55 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
create mode 100644 Completion/Unix/Command/_lldb
diff --git a/Completion/Unix/Command/_lldb b/Completion/Unix/Command/_lldb
new file mode 100644
index 000000000..16e346cfb
--- /dev/null
+++ b/Completion/Unix/Command/_lldb
@@ -0,0 +1,55 @@
+#compdef lldb
+
+local curcontext=$curcontext state state_descr line expl ret=1
+typeset -A opt_args
+local -a args
+
+args=(
+ '*'{-o+,--one-line=}'[run one-line lldb command after loading executable]:lldb command: '
+ '*'{-s+,--source=}'[run lldb commands from a file after loading executable]:file:_files'
+ '*'{-O+,--one-line-before-file=}'[run one-line lldb command before loading executable]:lldb command'
+ '*'{-S+,--source-before-file=}'[run lldb commands from a file before loading executable]:file:_files'
+ '(-k --one-line-on-crash)'{-k+,--one-line-on-crash=}'[run one-line lldb command if target crashes in batch mode]:lldb command'
+ '(-K --source-on-crash)'{-K+,--source-on-crash=}'[run lldb commands from a file if target crashes in batch mode]:file:_files'
+ '(-b --batch)'{-b,--batch}'[run commands from -s -S -o -O and quit]'
+ '(-Q --source-quietly)'{-Q,--source-quietly}'[suppress output from -s, -S, -o or -O]'
+ '(-e --editor)'{-e,--editor}'[open source files using "external editor" mechanism]'
+ '(-x --no-lldbinit)'{-x,--no-lldbinit}'[do not automatically parse .lldbinit files]'
+ '(-X --no-use-colors)'{-X,--no-use-colors}'[do not use colors]'
+ '(-d --debug)'{-d,--debug}'[print extra information for debugging itself]'
+ '(-r --repl)'{-r,--repl}'[run lldb in REPL mode]'
+ '(-l --script-language)'{-l+,--script-language=}'[use the specified scripting language]:language:(Python Perl Ruby Tcl)'
+ - info
+ '(-)'{-h,--help}'[print the usage information]'
+ '(-)'{-v,--version}'[print the current version number]'
+ '(-)'{-P,--python-path}'[print path to the lldb.py file]'
+ - file
+ '(-f --file)'{-f+,--file=}'[specify executable file to debug]:executable:_files -g "*(-*)"'
+ '(-a --arch)'{-a+,--arch=}'[use the specified architecture]:arch'
+ '(-c --core)'{-c+,--core=}'[specify core file to open]:core file:_files -g "*core*(-.)"'
+ '*::executable and arguments:->exe_args'
+ - name
+ '(-n --attach-name)'{-n+,--attach-name=}'[attach to the named process]:process name'
+ '(-w --wait-for)'{-w,--wait-for}'[wait for the specified process to launch]'
+ - pid
+ '(-p --attach-pid)'{-p+,--attach-pid=}'[attach to the specified process]:pid:_pids'
+)
+
+_arguments -C -s -S : $args && return 0
+
+case $state in
+ (exe_args)
+ if [[ -z $opt_args[(I)file-(-f|--file)] ]]; then
+ if [[ $CURRENT -eq 1 ]]; then
+ _wanted executables expl 'executable' _files -g '*(-*)' && ret=0
+ else
+ _normal && ret=0
+ fi
+ else
+ words=( ${(v)opt_args[(i)file-(-f|--file)]} "$words[@]" )
+ (( CURRENT++ ))
+ _normal && ret=0
+ fi
+esac
+
+return ret
--
cgit v1.2.3
From 6fa5f0612b9866ead0859cd5bbbce9fd8c6488e2 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Mon, 21 Sep 2015 13:27:35 +0100
Subject: unposted: typo in 36559
---
ChangeLog | 4 ++++
Src/zsh.h | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 74226a8f8..f59377031 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-09-21 Peter Stephenson
+
+ * unposted: Src/zsh.h: typo in 36559.
+
2015-09-19 Barton E. Schaefer
* unposted: Doc/Zsh/builtins.yo: zcompile prepares scripts for
diff --git a/Src/zsh.h b/Src/zsh.h
index 9c7e5d9dc..b98fc5c43 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -36,7 +36,7 @@
*/
#ifdef ZSH_64_BIT_TYPE
typedef ZSH_64_BIT_TYPE zlong;
-#if defind(ZLONG_IS_LONG_LONG) && defined(LLONG_MAX)
+#if defined(ZLONG_IS_LONG_LONG) && defined(LLONG_MAX)
#define ZLONG_MAX LLONG_MAX
#else
/* umm... */
--
cgit v1.2.3
From 9b35a04f98300469ad33b44849920c4c3cb2d986 Mon Sep 17 00:00:00 2001
From: Jun-ichi Takimoto
Date: Mon, 21 Sep 2015 21:38:41 +0900
Subject: 36556: complete two or more options for zsh
---
ChangeLog | 8 ++++++++
Completion/Unix/Command/_sh | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index f59377031..b6755caac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2015-09-21 Jun-ichi Takimoto
+
+ * 36574: Completion/Unix/Command/_lldb: new completion for
+ the lldb debugger
+
+ * 36556: Completion/Unix/Command/_sh: remove unnecessary
+ helpspec to '_argument --'
+
2015-09-21 Peter Stephenson
* unposted: Src/zsh.h: typo in 36559.
diff --git a/Completion/Unix/Command/_sh b/Completion/Unix/Command/_sh
index 21ebfc3b2..1b5112212 100644
--- a/Completion/Unix/Command/_sh
+++ b/Completion/Unix/Command/_sh
@@ -24,6 +24,6 @@ fi
local ret=$?
-[[ $service == zsh ]] && _arguments -S -s -- '*:' && ret=0
+[[ $service == zsh ]] && _arguments -S -s -- && ret=0
return ret
--
cgit v1.2.3
From d4a640775f8e6aad3a32a2ebcf4d049d728a9e8b Mon Sep 17 00:00:00 2001
From: Frank Terbeck
Date: Mon, 21 Sep 2015 14:41:40 +0200
Subject: 36575: _tmux: ‘lock-server’ option is gone in tmux.git
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ChangeLog | 5 +++++
Completion/Unix/Command/_tmux | 2 --
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b6755caac..29d45e721 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-21 Frank Terbeck
+
+ * 36575: Completion/Unix/Command/_tmux: _tmux: ‘lock-server’
+ option is gone in tmux.git
+
2015-09-21 Jun-ichi Takimoto
* 36574: Completion/Unix/Command/_lldb: new completion for
diff --git a/Completion/Unix/Command/_tmux b/Completion/Unix/Command/_tmux
index 49c2b63ed..3d4734bcd 100644
--- a/Completion/Unix/Command/_tmux
+++ b/Completion/Unix/Command/_tmux
@@ -1270,7 +1270,6 @@ function __tmux-option-guard() {
'history-limit:'${int_guard}
'lock-after-time:'${int_guard}
'lock-command:MSG:command string'
- 'lock-server:DESC:on off'
'message-command-style:__tmux-style'
'message-style:__tmux-style'
'mouse:DESC:on off'
@@ -1394,7 +1393,6 @@ function __tmux-session-options() {
'history-limit:number of copy-mode lines per window'
'lock-after-time:lock sessions after N seconds'
'lock-command:command to run for locking a client'
- 'lock-server:make lock-after-time lock the server instead of sessions'
'message-command-style:status line message command style'
'message-style:status line message style'
'mouse:enable mouse support'
--
cgit v1.2.3
From 5476e011f16664e601092c1e94e3332efe80720f Mon Sep 17 00:00:00 2001
From: Frank Terbeck
Date: Mon, 21 Sep 2015 14:41:41 +0200
Subject: 36576: _tmux: Fix tmux homepage URI
---
ChangeLog | 3 +++
Completion/Unix/Command/_tmux | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 29d45e721..221f57fbd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@
* 36575: Completion/Unix/Command/_tmux: _tmux: ‘lock-server’
option is gone in tmux.git
+ * 36576: Completion/Unix/Command/_tmux: _tmux: Fix tmux homepage
+ URI
+
2015-09-21 Jun-ichi Takimoto
* 36574: Completion/Unix/Command/_lldb: new completion for
diff --git a/Completion/Unix/Command/_tmux b/Completion/Unix/Command/_tmux
index 3d4734bcd..6f2cac790 100644
--- a/Completion/Unix/Command/_tmux
+++ b/Completion/Unix/Command/_tmux
@@ -1,6 +1,6 @@
#compdef tmux
-# tmux completion for zsh .
+# tmux completion for zsh .
#
# Configuration:
#
--
cgit v1.2.3
From 8b84419f45298ee564bd6fa2b531c8991b2a1983 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Mon, 21 Sep 2015 14:39:21 +0100
Subject: 36577: supplement 36559 to using LONG_MAX for 64-bit long
---
ChangeLog | 3 +++
Src/zsh.h | 4 ++++
configure.ac | 6 ++++++
3 files changed, 13 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 221f57fbd..1dd57123c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,9 @@
2015-09-21 Peter Stephenson
+ * 36577: configure.ac, Src/zsh.h: supplement 36559 to
+ use LONG_MAX for 64-bit long.
+
* unposted: Src/zsh.h: typo in 36559.
2015-09-19 Barton E. Schaefer
diff --git a/Src/zsh.h b/Src/zsh.h
index b98fc5c43..dd0596116 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -39,9 +39,13 @@ typedef ZSH_64_BIT_TYPE zlong;
#if defined(ZLONG_IS_LONG_LONG) && defined(LLONG_MAX)
#define ZLONG_MAX LLONG_MAX
#else
+#ifdef ZLONG_IS_LONG_64
+#define ZLONG_MAX LONG_MAX
+#else
/* umm... */
#define ZLONG_MAX ((zlong)9223372036854775807)
#endif
+#endif
#ifdef ZSH_64_BIT_UTYPE
typedef ZSH_64_BIT_UTYPE zulong;
#else
diff --git a/configure.ac b/configure.ac
index d7db8ba8d..c3bd713c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1079,9 +1079,15 @@ main() { return sizeof(ino_t) < 8; }
fi
AH_TEMPLATE([ZLONG_IS_LONG_LONG],
[Define to 1 if the zlong type uses long long int.])
+AH_TEMPLATE([ZLONG_IS_LONG_64],
+[Define to 1 if the zlong type uses 64-bit long int.])
if test "$zsh_cv_64_bit_type" = "long long"; then
dnl Remember this so we can get (s)printf output right.
AC_DEFINE(ZLONG_IS_LONG_LONG)
+else
+ if test "$zsh_cv_64_bit_type" = "long"; then
+ AC_DEFINE(ZLONG_IS_LONG_64)
+ fi
fi
dnl We'll blithely assume (f)printf supports the same types as sprintf.
--
cgit v1.2.3
From 729f6ddfff8a229c404f0ec2b9d83c89395e541d Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Mon, 21 Sep 2015 20:33:58 +0100
Subject: 36580: don't copy empty buffer in compmatch.
Also check if length is non-zero when buffer is empty.
---
ChangeLog | 5 +++++
Src/Zle/compmatch.c | 11 +++++++++--
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1dd57123c..4a8c0531a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-21 Peter Stephenson
+
+ * 36580: Src/Zle/compmatch.c: don't copy empty buffer and check
+ size is consistent.
+
2015-09-21 Frank Terbeck
* 36575: Completion/Unix/Command/_tmux: _tmux: ‘lock-server’
diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index 05ae43ae6..b5728a5fe 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -338,8 +338,15 @@ add_match_str(Cmatcher m, char *l, char *w, int wl, int sfx)
char *buf;
buf = (char *) zalloc(blen);
- memcpy(buf, matchbuf, matchbuflen);
- zfree(matchbuf, matchbuflen);
+ if (matchbuf) {
+ memcpy(buf, matchbuf, matchbuflen);
+ zfree(matchbuf, matchbuflen);
+ }
+#ifdef DEBUG
+ else {
+ DPUTS(matchbuflen, "matchbuflen with no matchbuf");
+ }
+#endif
matchbuf = buf;
matchbuflen = blen;
}
--
cgit v1.2.3
From 53fcadc1f8a735ee0194ec83bebe1afd6ff14d1c Mon Sep 17 00:00:00 2001
From: Jun-ichi Takimoto
Date: Tue, 22 Sep 2015 11:16:32 +0900
Subject: 36578: option in a set has key "set-opt" in $opt_args
---
ChangeLog | 5 +++++
Doc/Zsh/compsys.yo | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 4a8c0531a..6523ff8bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-22 Jun-ichi Takimoto
+
+ * 36578: Doc/Zsh/compsys.yo: option in a mutually exclusive set
+ has key "set-opt" in $opt_args
+
2015-09-21 Peter Stephenson
* 36580: Src/Zle/compmatch.c: don't copy empty buffer and check
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index d067795dd..d6b180301 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -3982,6 +3982,11 @@ possible completions. When it contains `tt(-d)' or an argument, the
option `tt(-c)' will not be considered. However, after `tt(-a)'
both sets will still be considered valid.
+If an option in a set appears on the command line, it is stored in the
+associative array `tt(opt_args)' with 'var(set)tt(-)var(option)'
+as a key. In the example above, a key `tt(set1--c)' is used if the option
+`tt(-c)' is on the command line.
+
If the name given for one of the mutually exclusive sets is of the form
`tt(LPAR())var(name)tt(RPAR())' then only one value from each set will ever
be completed; more formally, all specifications are mutually
--
cgit v1.2.3
From d2910fd64f584d57dbf544db8aa36ac909ea212f Mon Sep 17 00:00:00 2001
From: Han Pingtian
Date: Tue, 15 Sep 2015 16:23:09 +0800
Subject: 36538: fix description of b and B completion match anchors
---
ChangeLog | 5 +++++
Doc/Zsh/compwid.yo | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6523ff8bd..897aa1ad6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-22 Peter Stephenson
+
+ * 36538: Han Pingtian: Doc/Zsh/compwid.yo: tweak code for match
+ anchors to get correct difference between b and B.
+
2015-09-22 Jun-ichi Takimoto
* 36578: Doc/Zsh/compsys.yo: option in a mutually exclusive set
diff --git a/Doc/Zsh/compwid.yo b/Doc/Zsh/compwid.yo
index 40cabea88..303c19db5 100644
--- a/Doc/Zsh/compwid.yo
+++ b/Doc/Zsh/compwid.yo
@@ -899,8 +899,8 @@ var(lanchor), the var(ranchor) only needs to match the trial
completion string.
The tt(b) and tt(B) forms are similar to tt(l) and tt(L) with an empty
-anchor, but need to match only the beginning of the trial completion
-or the word on the command line, respectively.
+anchor, but need to match only the beginning of the word on the command line
+or trial completion, respectively.
)
xitem(tt(r:)var(lpat)tt(|)var(ranchor)tt(=)var(tpat))
xitem(tt(R:)var(lpat)tt(|)var(ranchor)tt(=)var(tpat))
--
cgit v1.2.3
From acf5bd766a7b5d656cdf1c636c8508492c1aadf4 Mon Sep 17 00:00:00 2001
From: Han Pingtian
Date: Tue, 22 Sep 2015 05:55:23 +0800
Subject: 36586: fix completion match right anchor
---
ChangeLog | 8 +++++++-
Doc/Zsh/compwid.yo | 2 +-
Src/Zle/compmatch.c | 6 ++++--
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 897aa1ad6..e5ea4fd30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
2015-09-22 Peter Stephenson
- * 36538: Han Pingtian: Doc/Zsh/compwid.yo: tweak code for match
+ * 36586: Han Pingtian: Src/Zle/compmatch.c: tweak to completion
+ matching with right anchor.
+
+ * 36545: Han Pingtian: Doc/Zsh/compwid.yo: tweak doc for match
+ anchors e and E.
+
+ * 36538: Han Pingtian: Doc/Zsh/compwid.yo: tweak doc for match
anchors to get correct difference between b and B.
2015-09-22 Jun-ichi Takimoto
diff --git a/Doc/Zsh/compwid.yo b/Doc/Zsh/compwid.yo
index 303c19db5..c01763316 100644
--- a/Doc/Zsh/compwid.yo
+++ b/Doc/Zsh/compwid.yo
@@ -911,7 +911,7 @@ item(tt(E:)var(lpat)tt(=)var(tpat))(
As tt(l), tt(L), tt(b) and tt(B), with the difference that the command
line and trial completion patterns are anchored on the right side.
Here an empty var(ranchor) and the tt(e) and tt(E) forms force the
-match to the end of the trial completion or command line string.
+match to the end of the command line or trial completion string.
)
enditem()
diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index b5728a5fe..948144006 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -820,10 +820,12 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp,
continue;
else if (mp->right)
t = pattern_match(mp->right,
- tl + mp->llen - mp->ralen,
+ //tl + mp->llen - mp->ralen,
+ tl + mp->llen,
NULL, NULL) &&
pattern_match(mp->right,
- tw + mp->wlen - mp->ralen,
+ //tw + mp->wlen - mp->ralen,
+ tw + mp->wlen,
NULL, NULL) &&
(!mp->lalen ||
pattern_match(mp->left, tw + mp->wlen -
--
cgit v1.2.3
From 56ed4df8988249338b0f8f2d999df4217ca533e6 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Tue, 22 Sep 2015 08:52:52 -0700
Subject: 36587: use +LINE:COLUMN to place the cursor when invoking emacs
variants, for emacsclient
---
ChangeLog | 5 +++++
Functions/Zle/edit-command-line | 9 ++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e5ea4fd30..6d69e6d61 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-22 Barton E. Schaefer
+
+ * 36587: Functions/Zle/edit-command-line: use +LINE:COLUMN to
+ place the cursor when invoking emacs variants, for emacsclient
+
2015-09-22 Peter Stephenson
* 36586: Han Pingtian: Src/Zle/compmatch.c: tweak to completion
diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line
index 2c7f34b8b..103a1c1a5 100644
--- a/Functions/Zle/edit-command-line
+++ b/Functions/Zle/edit-command-line
@@ -11,13 +11,16 @@
# Compute the cursor's position in bytes, not characters.
setopt localoptions nomultibyte
- integer byteoffset=$(( $#PREBUFFER + $#LBUFFER + 1 ))
# Open the editor, placing the cursor at the right place if we know how.
local editor=${${VISUAL:-${EDITOR:-vi}}}
case $editor in
- (*vim*) ${=editor} -c "normal! ${byteoffset}go" -- $1;;
- (*emacs*) ${=editor} $1 -eval "(goto-char ${byteoffset})";;
+ (*vim*)
+ integer byteoffset=$(( $#PREBUFFER + $#LBUFFER + 1 ))
+ ${=editor} -c "normal! ${byteoffset}go" -- $1;;
+ (*emacs*)
+ local lines=( ${(f):-"$PREBUFFER$LBUFFER"} )
+ ${=editor} +${#lines}:$((${#lines[-1]} + 1)) $1;;
(*) ${=editor} $1;;
esac
--
cgit v1.2.3
From 0f2f34363d24974dcdcb9aecb03df139969b3d18 Mon Sep 17 00:00:00 2001
From: Mikael Magnusson
Date: Wed, 23 Sep 2015 01:13:26 +0200
Subject: unposted: replace multi-byte curly-quotes with plain quotes in
ChangeLog entry
---
ChangeLog | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 6d69e6d61..6bad31903 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -26,7 +26,7 @@
2015-09-21 Frank Terbeck
- * 36575: Completion/Unix/Command/_tmux: _tmux: ‘lock-server’
+ * 36575: Completion/Unix/Command/_tmux: _tmux: 'lock-server'
option is gone in tmux.git
* 36576: Completion/Unix/Command/_tmux: _tmux: Fix tmux homepage
--
cgit v1.2.3
From 002d68525c9de1230565d1a1c317996635d39172 Mon Sep 17 00:00:00 2001
From: Eric Cook
Date: Sun, 20 Sep 2015 20:36:09 -0400
Subject: 36571: Completion for zsocket and updated losetup's completion
---
ChangeLog | 6 ++++++
Completion/Linux/Command/_losetup | 36 +++++++++++++++++++++++++-----------
Completion/Zsh/Command/_zsocket | 14 ++++++++++++++
3 files changed, 45 insertions(+), 11 deletions(-)
create mode 100644 Completion/Zsh/Command/_zsocket
diff --git a/ChangeLog b/ChangeLog
index 6bad31903..f948328a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-23 Mikael Magnusson
+
+ * Eric Cook: 36571: Completion/Linux/Command/_losetup,
+ Completion/Zsh/Command/_zsocket: Completion for zsocket and
+ updated losetup's completion
+
2015-09-22 Barton E. Schaefer
* 36587: Functions/Zle/edit-command-line: use +LINE:COLUMN to
diff --git a/Completion/Linux/Command/_losetup b/Completion/Linux/Command/_losetup
index ff18681f1..359a9e0ea 100644
--- a/Completion/Linux/Command/_losetup
+++ b/Completion/Linux/Command/_losetup
@@ -1,14 +1,28 @@
#compdef losetup
+# based on util-linux 2.26.2
-local cyphers
-cyphers=( /proc/crypto/cipher/*(N:t) )
-cyphers="${cyphers[@]%-*}"
-
-_arguments -S \
+_arguments -S -A '-*' \
+ '(-l --list)'{-l,--list}'[list currently used loop devices]' \
+ '(-n --noheadings)'{-n,--noheadings}'[do not print heading for --list output]' \
+ '(-d --delete --detach -o --offset -a --all)'{-o,--offset}'+[specify data start is offset]:offset (bytes)' \
+ '(-O --output)'{-O,--output}'[specify columns to be printed with --list]:column: _values -s , column name sizelimit offset autoclear ro back-file' \
+ '(-P --partscan)'{-P,--partscan}'[scan the partition table of newly created loop devices]' \
+ '--raw[raw output format]' \
+ '(-r --read-only)'{-r,--read-only}'[set up a read-only loop device]' \
+ '(-v --verbose)'{-v,--verbose}'[verbose mode]' \
+ '(-V --version)'{-V,--version}'[display version information]' \
+ '(-h --help)'{-h,--help}'[display help]' \
+ '1:device:_files -g "/dev/loop<->"' \
+ '(-d --delete --detach)2:file:_files' \
+ - '(set1)' \
+ '(-o --offset)'{-a,--all}'[show the status of all loop devices]' \
+ - '(set2)' \
+ {-c,--set-capacity}'[reread the size of the file associated with the loop device]' \
+ - '(set3)' \
'(- 2)'{--delete,--detach,-d}'[detach from specified loop device]' \
- '(-d --delete --detach -e --encryption)'{-e,--encryption}"+[enable encryption]:cypher:( $cyphers )" \
- '(-d --delete --detach -o --offset)'{-o,--offset}'+[specify data start is offset]:offset (bytes)' \
- '(-d --delete --detach -p --pass-fd)'{-p,--pass-fd}'+[read passphrase from specified file descriptor]:file descriptor:_file_descriptors' \
- '(-d --delete --detach -k --keybits)'{-k,--keybits}'+[set the number of bits to use in key]:key size:(64 128 160 192 256)' \
- '1:device:_files -g "loop*(-.)"' \
- '(-d --delete --detach)2:file:_files'
+ - '(set4)' \
+ '(-D --detach-all)'{-D,--detach-all}'[detach all associated loop devices]' \
+ - '(set5)' \
+ {-f,--find}'[find the first unused loop device]' \
+ - '(set6)' \
+ {-j,--associated}'[show the status of all loop devices associated with an file]: : _files'
diff --git a/Completion/Zsh/Command/_zsocket b/Completion/Zsh/Command/_zsocket
new file mode 100644
index 000000000..eeed9f1d8
--- /dev/null
+++ b/Completion/Zsh/Command/_zsocket
@@ -0,0 +1,14 @@
+#compdef zsocket
+
+_arguments -s -w -A "-*" \
+ '-v[verbose output]' \
+ '-d[target file descriptor]:fd:_file_descriptors' \
+ - outbound \
+ '1: :_files' \
+ - listen \
+ '-l[open a socket listening]' \
+ '1: :_files' \
+ - accept \
+ '-a[accept an incoming connection]' \
+ '-t[return if no incoming connections are pending]' \
+ '1:fd:{ (( words[(I)-*a*] )) && _file_descriptors }'
--
cgit v1.2.3
From 1b5987cdb11253e2f399bfff72016af22bad9240 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf
Date: Wed, 23 Sep 2015 21:40:34 +0000
Subject: unposted: Followup to 36586: Change C99 comment syntax to the C89
syntax.
---
ChangeLog | 5 +++++
Src/Zle/compmatch.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f948328a7..b92432044 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-23 Daniel Shahaf
+
+ * unposted: Src/Zle/compmatch.c: Followup to 36586: Change C99
+ comment syntax to the C89 syntax.
+
2015-09-23 Mikael Magnusson
* Eric Cook: 36571: Completion/Linux/Command/_losetup,
diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index 948144006..0e41ac3a5 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -820,11 +820,11 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp,
continue;
else if (mp->right)
t = pattern_match(mp->right,
- //tl + mp->llen - mp->ralen,
+ /* tl + mp->llen - mp->ralen, */
tl + mp->llen,
NULL, NULL) &&
pattern_match(mp->right,
- //tw + mp->wlen - mp->ralen,
+ /* tw + mp->wlen - mp->ralen, */
tw + mp->wlen,
NULL, NULL) &&
(!mp->lalen ||
--
cgit v1.2.3
From 8d5c0c77609d814de7c0749602a595236f76b487 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Wed, 23 Sep 2015 23:16:38 -0700
Subject: 36604: fix getopts+shift calculation
---
ChangeLog | 4 ++++
Functions/Misc/zrecompile | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index b92432044..e5044931f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-09-23 Barton E. Schaefer
+
+ * 36604: Functions/Misc/zrecompile: fix getopts+shift calculation
+
2015-09-23 Daniel Shahaf
* unposted: Src/Zle/compmatch.c: Followup to 36586: Change C99
diff --git a/Functions/Misc/zrecompile b/Functions/Misc/zrecompile
index 8fe990086..d9fc55020 100644
--- a/Functions/Misc/zrecompile
+++ b/Functions/Misc/zrecompile
@@ -52,7 +52,7 @@ while getopts ":tqp" opt; do
fi
esac
done
-shift OPTIND-${#tmp:-1}
+shift OPTIND-${#tmp}-1
if [[ -n $check ]]; then
ret=1
--
cgit v1.2.3
From 1aafc028b392ae85f6670a1c0b8cf00da975e304 Mon Sep 17 00:00:00 2001
From: Christoph Mathys
Date: Thu, 24 Sep 2015 16:12:27 +0000
Subject: 36613: _hg: extend completion for hg push to support branch and
bookmark
---
ChangeLog | 5 +++++
Completion/Unix/Command/_hg | 11 +++++++++++
2 files changed, 16 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index e5044931f..dcecc8031 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-24 Christoph Mathys
+
+ * 36613: Completion/Unix/Command/_hg: _hg: extend completion
+ for hg push to support branch and bookmark
+
2015-09-23 Barton E. Schaefer
* 36604: Functions/Misc/zrecompile: fix getopts+shift calculation
diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg
index e7c21b9d1..2db5c55a5 100644
--- a/Completion/Unix/Command/_hg
+++ b/Completion/Unix/Command/_hg
@@ -176,6 +176,13 @@ _hg_bookmarks_internal() {
_wanted bookmarks expl 'bookmarks' compadd -a - hgbookmarks
}
+_hg_branches_internal() {
+ local expl
+ typeset -a hgbranches
+ hgbranches=( ${(f)"$(_hg_cmd branches -q 2>/dev/null)"} )
+ _wanted branches expl 'branches' compadd -a - hgbranches
+}
+
_hg_tags() {
_alternative \
'bookmarks:bookmark:_hg_bookmarks_internal' \
@@ -659,6 +666,10 @@ _hg_cmd_push() {
_arguments -s -w : $_hg_global_opts $_hg_remote_opts \
'(--force -f)'{-f,--force}'[force push]' \
'(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]:revision:_hg_tags' \
+ '*'{-B,--bookmark=}'[bookmark to push]:bookmark:_hg_bookmarks_internal' \
+ '*'{-b,--branch=}'[branch to push]:branch:_hg_branches_internal' \
+ '--insecure[do not verify server certificate]' \
+ '--new-branch[allow pushing a new branch]' \
':destination:_hg_remote'
}
--
cgit v1.2.3
From 4c935b9f85d25999a2ff9844274827f7905380f3 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf
Date: Thu, 24 Sep 2015 16:15:15 +0000
Subject: unposted: _hg: Declare $expl as an array
---
ChangeLog | 5 +++++
Completion/Unix/Command/_hg | 6 +++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index dcecc8031..80a7d19c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-24 Daniel Shahaf
+
+ * unposted: Completion/Unix/Command/_hg: _hg: Declare $expl as
+ an array
+
2015-09-24 Christoph Mathys
* 36613: Completion/Unix/Command/_hg: _hg: extend completion
diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg
index 2db5c55a5..9dd023653 100644
--- a/Completion/Unix/Command/_hg
+++ b/Completion/Unix/Command/_hg
@@ -163,21 +163,21 @@ _hg_revrange() {
}
_hg_tags_internal() {
- local expl
+ local -a expl
typeset -a hgtags
hgtags=( ${(f)"$(_hg_cmd tags -q 2>/dev/null)"} )
_wanted tags expl 'tags' compadd -a - hgtags
}
_hg_bookmarks_internal() {
- local expl
+ local -a expl
typeset -a hgbookmarks
hgbookmarks=( ${(f)"$(_hg_cmd bookmarks -q 2>/dev/null)"} )
_wanted bookmarks expl 'bookmarks' compadd -a - hgbookmarks
}
_hg_branches_internal() {
- local expl
+ local -a expl
typeset -a hgbranches
hgbranches=( ${(f)"$(_hg_cmd branches -q 2>/dev/null)"} )
_wanted branches expl 'branches' compadd -a - hgbranches
--
cgit v1.2.3
From bd5806aa0a98d8de6e1b6e7e4b7694b89952f08d Mon Sep 17 00:00:00 2001
From: Mikael Magnusson
Date: Thu, 24 Sep 2015 20:51:59 +0200
Subject: 36603: glob: fix dirfd leak during Y shortcut qualifier
---
ChangeLog | 11 +++++++----
Src/glob.c | 4 +++-
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 80a7d19c4..41a56f966 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,15 @@
+2015-09-24 Mikael Magnusson
+
+ * 36603: Src/glob.c: fix dirfd leak during Y shortcut qualifier
+
2015-09-24 Daniel Shahaf
- * unposted: Completion/Unix/Command/_hg: _hg: Declare $expl as
- an array
+ * unposted: Completion/Unix/Command/_hg: Declare $expl as an array
2015-09-24 Christoph Mathys
- * 36613: Completion/Unix/Command/_hg: _hg: extend completion
- for hg push to support branch and bookmark
+ * 36613: Completion/Unix/Command/_hg: extend completion for hg
+ push to support branch and bookmark
2015-09-23 Barton E. Schaefer
diff --git a/Src/glob.c b/Src/glob.c
index 43d135b99..fa3ce25f4 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -634,8 +634,10 @@ scanner(Complist q, int shortcircuit)
} else {
/* if the last filename component, just add it */
insert(fn, 1);
- if (shortcircuit && shortcircuit == matchct)
+ if (shortcircuit && shortcircuit == matchct) {
+ closedir(lock);
return;
+ }
}
}
}
--
cgit v1.2.3
From 377e2400b7b6fc21ff333791461d615538b18cb9 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Thu, 24 Sep 2015 18:46:27 -0700
Subject: 36623: document bracketed-paste-magic and url-quote-magic; add
cross-reference to vim text object widgets
---
ChangeLog | 5 ++
Doc/Zsh/contrib.yo | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 166 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 41a56f966..ef35827d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-24 Barton E. Schaefer
+
+ * 36623: Doc/Zsh/contrib.yo: document bracketed-paste-magic and
+ url-quote-magic; add cross-reference to vim text object widgets
+
2015-09-24 Mikael Magnusson
* 36603: Src/glob.c: fix dirfd leak during Y shortcut qualifier
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index 741d4ad07..b966e781c 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -1705,7 +1705,10 @@ item(tt(select-word-style), tt(match-word-context), tt(match-words-by-style))(
The eight `tt(-match)' functions are drop-in replacements for the
builtin widgets without the suffix. By default they behave in a similar
way. However, by the use of styles and the function tt(select-word-style),
-the way words are matched can be altered.
+the way words are matched can be altered. For comparison, the widgets
+described in ifzman(zmanref(zshzle) under Text Objects)\
+ifnzman(noderef(Text Objects)) use fixed definitions of words, compatible
+with the tt(vim) editor.
The simplest way of configuring the functions is to use
tt(select-word-style), which can either be called as a normal function with
@@ -1895,6 +1898,100 @@ The tt(word-context) style is implemented by the function
tt(match-word-context). This should not usually need to be called
directly.
)
+tindex(bracketed-paste-magic)
+item(bracketed-paste-magic)(
+The tt(bracketed-paste) widget (see ifzman(subsection Miscellaneous in
+zmanref(zshzle))ifnzman(noderef(Miscellaneous) in noderef(Zle Widgets)))
+inserts pasted text literally into the editor buffer rather than interpret
+it as keystrokes. This disables some common usages where the self-insert
+widget is replaced in order to accomplish some extra processing. An
+example is the contributed tt(url-quote-magic) widget described below.
+
+The tt(bracketed-paste-magic) widget is meant to replace tt(bracketed-paste)
+with a wrapper that re-enables these self-insert actions, and other
+actions as selected by zstyles. Therefore this widget is installed with
+ifzman()
+example(autoload -Uz bracketed-paste-magic
+zle -N bracketed-paste bracketed-paste-magic)
+
+Other than enabling some widget processing, tt(bracketed-paste-magic)
+attempts to replicate tt(bracketed-paste) as faithfully as possible.
+
+The following zstyles may be set to control processing of pasted text.
+All are looked up in the context `tt(:bracketed-paste-magic)'.
+
+startitem()
+item(tt(active-widgets))(
+A list of patterns matching widget names that should be activated during
+the paste. All other key sequences are processed as self-insert-unmeta.
+The default is `tt(self-*)' so any user-defined widgets named with that
+prefix are active along with the builtin self-insert.
+
+If this style is not set (explicitly deleted) or set to an empty value,
+no widgets are active and the pasted text is inserted literally. If the
+value includes `tt(undefined-key)', any unknown sequences are discarded
+from the pasted text.
+)
+item(tt(inactive-keys))(
+The inverse of tt(active-widgets), a list of key sequences that always use
+tt(self-insert-unmeta) even when bound to an active widget. Note that
+this is a list of literal key sequences, not patterns.
+)
+item(tt(paste-init))(
+A list of function names, called in widget context (but not as widgets).
+The functions are called in order until one of them returns a non-zero
+status. The parameter `tt(PASTED)' contains the initial state of the
+pasted text. All other ZLE parameters such as `tt(BUFFER)' have their
+normal values and side-effects, and full history is available, so for
+example tt(paste-init) functions may move words from tt(BUFFER) into
+tt(PASTED) to make those words visible to the tt(active-widgets).
+
+A non-zero return from a tt(paste-init) function does em(not) prevent the
+paste itself from proceeding.
+
+Loading tt(bracketed-paste-magic) defines tt(backward-extend-paste), a
+helper function for use in tt(paste-init).
+
+example(zstyle :bracketed-paste-magic paste-init \
+ backward-extend-paste)
+
+When a paste would insert into the middle of a word or append text to a
+word already on the line, tt(backward-extend-paste) moves the prefix
+from tt(LBUFFER) into tt(PASTED) so that the tt(active-widgets) see the
+full word so far. This may be useful with tt(url-quote-magic).
+)
+item(tt(paste-finish))(
+Another list of function names called in order until one returns non-zero.
+These functions are called em(after) the pasted text has been processed
+by the tt(active-widgets), but em(before) it is inserted into `tt(BUFFER)'.
+ZLE parameters have their normal values and side-effects.
+
+A non-zero return from a tt(paste-finish) function does em(not) prevent
+the paste itself from proceeding.
+
+Loading tt(bracketed-paste-magic) also defines tt(quote-paste), a helper
+function for use in tt(paste-finish).
+
+example(zstyle :bracketed-paste-magic paste-finish \
+ quote-paste
+zstyle :bracketed-paste-magic:finish quote-style \
+ qqq)
+
+When the pasted text is inserted into tt(BUFFER), it is quoted per the
+tt(quote-style) value. To forcibly turn off the built-in numeric prefix
+quoting of tt(bracketed-paste), use:
+
+example(zstyle :bracketed-paste-magic:finish quote-style \
+ none)
+)
+enditem()
+
+em(Important:) During tt(active-widgets) processing of the paste (after
+tt(paste-init) and before tt(paste-finish)), tt(BUFFER) starts empty and
+history is restricted, so cursor motions, etc., may not pass outside of
+the pasted content. Text assigned to tt(BUFFER) by the active widgets
+is copied back into tt(PASTED) before tt(paste-finish).
+)
tindex(copy-earlier-word)
item(tt(copy-earlier-word))(
This widget works like a combination of tt(insert-last-word) and
@@ -2557,6 +2654,69 @@ start of the previous line. Using a numeric argument less than -1
has the effect of moving the line above the cursor up by minus that
number of lines.
)
+tindex(url-quote-magic)
+item(tt(url-quote-magic))(
+This widget replaces the built-in tt(self-insert) to make it easier to
+type URLs as command line arguments. As you type, the input character is
+analyzed and, if it may need quoting, the current word is checked for a
+URI scheme. If one is found and the current word is not already in
+quotes, a backslash is inserted before the input character.
+
+Styles to control quoting behavior:
+
+startitem()
+item(tt(url-metas))(
+This style is looked up in the context `tt(:url-quote-magic:)var(scheme)'
+(where var(scheme) is that of the current URL, e.g. "tt(ftp)"). The value
+is a string listing the characters to be treated as globbing
+metacharacters when appearing in a URL using that scheme. The default is
+to quote all zsh extended globbing characters, excluding 'tt(<)' and
+'tt(>)' but including braces (as in brace expansion). See also
+tt(url-seps).
+)
+item(tt(url-seps))(
+Like tt(url-metas), but lists characters that should be considered command
+separators, redirections, history references, etc. The default is to
+quote the standard set of shell separators, excluding those that overlap
+with the extended globbing characters, but including 'tt(<)' and
+'tt(>)' and the first character of tt($histchars).
+)
+item(tt(url-globbers))(
+This style is looked up in the context `tt(:url-quote-magic)'. The values
+form a list of command names that are expected to do their own globbing
+on the URL string. This implies that they are aliased to use the
+`tt(noglob)' modifier. When the first word on the line matches one of the
+values em(and) the URL refers to a local file (see tt(url-local-schema)),
+only the tt(url-seps) characters are quoted; the tt(url-metas) are left
+alone, allowing them to affect command-line parsing, completion, etc. The
+default values are a literal `tt(noglob)' plus (when the tt(zsh/parameter)
+module is available) any commands aliased to the helper function
+`tt(urlglobber)' or its alias `tt(globurl)'.
+)
+item(tt(url-local-schema))(
+This style is always looked up in the context `tt(:urlglobber)', even
+though it is used by both url-quote-magic and urlglobber. The values form
+a list of URI schema that should be treated as referring to local files by
+their real local path names, as opposed to files which are specified
+relative to a web-server-defined document root. The defaults are
+"tt(ftp)" and "tt(file)".
+)
+item(tt(url-other-schema))(
+Like tt(url-local-schema), but lists all other URI schema upon which
+tt(urlglobber) and tt(url-quote-magic) should act. If the URI on the
+command line does not have a scheme appearing either in this list or in
+tt(url-local-schema), it is not magically quoted. The default values are
+"tt(http)", "tt(https)", and "tt(ftp)". When a scheme appears both here
+and in tt(url-local-schema), it is quoted differently depending on whether
+the command name appears in tt(url-globbers).
+)
+enditem()
+
+Loading tt(url-quote-magic) also defines a helper function `tt(urlglobber)'
+and aliases `tt(globurl)' to `tt(noglob urlglobber)'. This function takes
+a local URL apart, attempts to pattern-match the local file portion of the
+URL path, and then puts the results back into URL format again.
+)
tindex(which-command)
item(tt(which-command))(
This function is a drop-in replacement for the builtin widget
--
cgit v1.2.3
From 649d06a8cdd9948e3d49fa717f9088d8a87a6262 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Fri, 25 Sep 2015 21:30:34 +0100
Subject: 36630: new function zsh_directory_name_generic
---
ChangeLog | 5 +
Doc/Zsh/contrib.yo | 187 ++++++++++++++++++++++++++++-
Doc/Zsh/manual.yo | 1 +
Functions/Chpwd/zsh_directory_name_generic | 151 +++++++++++++++++++++++
4 files changed, 342 insertions(+), 2 deletions(-)
create mode 100644 Functions/Chpwd/zsh_directory_name_generic
diff --git a/ChangeLog b/ChangeLog
index ef35827d2..7055836fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-25 Peter Stephenson
+
+ * 36630: Doc/Zsh/contrib.yo, Doc/Zsh/manual.yo,
+ Functions/Chpwd/zsh_directory_name_generic: new helper function.
+
2015-09-24 Barton E. Schaefer
* 36623: Doc/Zsh/contrib.yo: document bracketed-paste-magic and
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index b966e781c..330c6f588 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -12,6 +12,7 @@ such as shell functions, look for comments in the function source files.
startmenu()
menu(Utilities)
menu(Recent Directories)
+menu(Other Directory Functions)
menu(Version Control Information)
menu(Prompt Themes)
menu(ZLE Functions)
@@ -324,7 +325,7 @@ options tt(-Uz) are appropriate.
)
enditem()
-texinode(Recent Directories)(Version Control Information)(Utilities)(User Contributions)
+texinode(Recent Directories)(Other Directory Functions)(Utilities)(User Contributions)
cindex(recent directories, maintaining list of)
cindex(directories, maintaining list of recent)
findex(cdr)
@@ -585,7 +586,189 @@ avoid side effects if the change to the directory is to be invisible at the
command line. See the contents of the function tt(chpwd_recent_dirs) for
more details.
-texinode(Version Control Information)(Prompt Themes)(Recent Directories)(User Contributions)
+texinode(Other Directory Functions)(Version Control Information)(Recent Directories)(User Contributions)
+cindex(directories, named, dynamic, helper function)
+cindex(dynamic directory naming, helper function)
+cindex(named directories, dynamic, helper function)
+findex(zsh_directory_name_generic)
+sect(Abbreviated dynamic references to directories)
+
+The dynamic directory naming system is described in the subsection
+em(Dynamic named directories) of
+ifzman(the section em(Filename Expansion) in zmanref(expn))\
+ifnzman(noderef(Filename Expansion)). In this, a reference to
+tt(~[)var(...)tt(]) is expanded by a function found by the hooks
+mechanism.
+
+The contributed function tt(zsh_directory_name_generic) provides a
+system allowing the user to refer to directories with only a limited
+amount of new code. It supports all three of the standard interfaces
+for directory naming: converting from a name to a directory, converting
+in the reverse direction to find a short name, and completion of names.
+
+The main feature of this function is a path-like syntax,
+combining abbreviations at multiple levels separated by ":".
+As an example, ~[g:p:s] might specify:
+startitem()
+item(tt(g))(
+The top level directory for your git area. This first component
+has to match, or the function will retrun indicating another
+directory name hook function should be tried.
+)
+item(tt(p))(
+The name of a project within your git area.
+)
+item(tt(s))(
+The source area within that project.
+)
+enditem()
+This allows you to collapse references to long hierarchies to a very
+compact form, particularly if the hierarchies are similar across different
+areas of the disk.
+
+Name components may be completed: if a description is shown at the top
+of the list of completions, it includes the path to which previous
+components expand, while the description for an individual completion
+shows the path segment it would add. No additional configuration is
+needed for this as the completion system is aware of the dynamic
+directory name mechanism.
+
+subsect(Usage)
+
+To use the function, first define a wrapper function for your specific
+case. We'll assume it's to be autoloaded. This can have any name but
+we'll refer to it as zdn_mywrapper. This wrapper function will define
+various variables and then call this function with the same arguments
+that the wrapper function gets. This configuration is described below.
+
+Then arrange for the wrapper to be run as a zsh_directory_name hook:
+
+example(autoload -Uz add-zsh-hook zsh_diretory_name_generic zdn_mywrapper
+add-zsh-hook -U zsh_directory_name zdn_mywrapper)
+
+subsect(Configuration)
+
+The wrapper function should define a local associative array zdn_top.
+Alternatively, this can be set with a style called tt(mapping). The
+context for the style is tt(:zdn:)var(wrapper-name) where
+var(wrapper-name) is the function calling zsh_directory_name_generic;
+for example:
+
+example(zstyle :zdn:zdn_mywrapper: mapping zdn_mywrapper_top)
+
+The keys in this associative array correspond to the first component of
+the name. The values are matching directories. They may have an
+optional suffix with a slash followed by a colon and the name of a
+variable in the same format to give the next component. (The slash
+before the colon is to disambiguate the case where a colon is needed in
+the path for a drive. There is otherwise no syntax for escaping this,
+so path components whose names start with a colon are not supported.) A
+special component tt(:default:) specifies a variable in the form
+tt(/:)var(var) (the path section is ignored and so is usually empty)
+that will be used for the next component if no variable is given for the
+path. Variables referred to within tt(zdn_top) have the same format as
+tt(zdn_top) itself, but contain relative paths.
+
+For example,
+
+example(local -A zdn_top=(
+ g ~/git
+ ga ~/alternate/git
+ gs /scratch/$USER/git/:second2
+ :default: /:second1
+))
+
+This specifies the behaviour of a directory referred to as tt(~[g:...])
+or tt(~[ga:...]) or tt(~[gs:...]). Later path components are optional;
+in that case tt(~[g]) expands to tt(~/git), and so on. tt(gs) expands
+to tt(/scratch/$USER/git) and uses the associative array tt(second2) to
+match the second component; tt(g) and tt(ga) use the associative array
+tt(second1) to match the second component.
+
+When expanding a name to a directory, if the first component is not tt(g) or
+tt(ga) or tt(gs), it is not an error; the function simply returns 1 so that a
+later hook function can be tried. However, matching the first component
+commits the function, so if a later component does not match, an error
+is printed (though this still does not stop later hooks from being
+executed).
+
+For components after the first, a relative path is expected, but note that
+multiple levels may still appear. Here is an example of tt(second1):
+
+example(local -A second1=(
+ p myproject
+ s somproject
+ os otherproject/subproject/:third
+))
+
+The path as found from tt(zdn_top) is extended with the matching
+directory, so tt(~[g:p]) becomes tt(~/git/myproject). The slash between
+is added automatically (it's not possible to have a later component
+modify the name of a directory already matched). Only tt(os) specifies
+a variable for a third component, and there's no tt(:default:), so it's
+an error to use a name like tt(~[g:p:x]) or tt(~[ga:s:y]) because
+there's nowhere to look up the tt(x) or tt(y).
+
+The associative arrays need to be visible within this function; the
+generic function therefore uses internal variable names beginning
+tt(_zdn_) in order to avoid clashes. Note that the variable tt(reply)
+needs to be passed back to the shell, so should not be local in the
+calling function.
+
+The function does not test whether directories assembled by component
+actually exist; this allows the system to work across automounted
+file systems. The error from the command trying to use a non-existent
+directory should be sufficient to indicate the problem.
+
+subsect(Complete example)
+
+Here is a full fictitious but usable autoloadable definition of the
+example function defined by the code above. So tt(~[gs:p:s]) expands
+to tt(/scratch/$USER/git/myscratchproject/top/srcdir) (with tt($USER)
+also expanded).
+
+example(local -A zdn_top=(
+ g ~/git
+ ga ~/alternate/git
+ gs /scratch/$USER/git/:second2
+ :default: /:second1
+)
+
+local -A second1=(
+ p myproject
+ s somproject
+ os otherproject/subproject/:third
+)
+
+local -A second2=(
+ p myscratchproject
+ s somescratchproject
+)
+
+local -A third=(
+ s top/srcdir
+ d top/documentation
+)
+
+# autoload not needed if you did this at initialisation...
+autoload -Uz zsh_directory_name_generic
+zsh_directory_name_generic "$@)
+
+It is also possible to use global associative arrays, suitably named,
+and set the style for the context of your wrapper function to
+refer to this. Then your set up code would contain the following:
+
+example(typeset -A zdn_mywrapper_top=(...)
+# ... and so on for other associative arrays ...
+zstyle ':zdn:zdn_mywrapper:' mapping zdn_mywrapper_top
+autoload -Uz add-zsh-hook zsh_directory_name_generic zdn_mywrapper
+add-zsh-hook -U zsh_directory_name zdn_mywrapper)
+
+and the function tt(zdn_mywrapper) would contain only the following:
+
+example(zsh_directory_name_generic "$@")
+
+texinode(Version Control Information)(Prompt Themes)(Other Directory Functions)(User Contributions)
sect(Gathering information from version control systems)
cindex(version control utility)
diff --git a/Doc/Zsh/manual.yo b/Doc/Zsh/manual.yo
index 86c72c0ff..119849e4c 100644
--- a/Doc/Zsh/manual.yo
+++ b/Doc/Zsh/manual.yo
@@ -164,6 +164,7 @@ User Contributions
menu(Utilities)
menu(Recent Directories)
+menu(Other Directory Functions)
menu(Version Control Information)
menu(Prompt Themes)
menu(ZLE Functions)
diff --git a/Functions/Chpwd/zsh_directory_name_generic b/Functions/Chpwd/zsh_directory_name_generic
new file mode 100644
index 000000000..9430c95e4
--- /dev/null
+++ b/Functions/Chpwd/zsh_directory_name_generic
@@ -0,0 +1,151 @@
+## zsh_directory_name_generic
+#
+# This function is useful as a hook function for the zsh_directory_name
+# facility.
+#
+# See the zsh-contrib manual page for more.
+
+emulate -L zsh
+setopt extendedglob
+local -a match mbegin mend
+
+# The variable containing the top level mapping.
+local _zdn_topvar
+
+zmodload -i zsh/parameter
+zstyle -s ":zdn:${funcstack[2]}:" mapping _zdn_topvar || _zdn_topvar=zdn_top
+
+if (( ! ${(P)#_zdn_topvar} )); then
+ print -r -- "$0: $_zdn_topver is not set" >&2
+ return 1
+fi
+
+local _zdn_var=$_zdn_topvar
+local -A _zdn_assoc
+
+if [[ $1 = n ]]; then
+ # Turning a name into a directory.
+ local _zdn_name=$2
+ local -a _zdn_words
+ local _zdn_dir _zdn_cpt
+
+ _zdn_words=(${(s.:.)_zdn_name})
+ while (( ${#_zdn_words} )); do
+ if [[ -z ${_zdn_var} ]]; then
+ print -r -- "$0: too many components in directory name \`$_zdn_name'" >&2
+ return 1
+ fi
+
+ # Subscripting (P)_zdn_var directly seems not to work.
+ _zdn_assoc=(${(Pkv)_zdn_var})
+ _zdn_cpt=${_zdn_assoc[${_zdn_words[1]}]}
+ shift _zdn_words
+
+ if [[ -z $_zdn_cpt ]]; then
+ # If top level component, just try another expansion
+ if [[ $_zdn_var != $_zdn_top ]]; then
+ # Committed to this expansion, so report failure.
+ print -r -- "$0: no expansion for directory name \`$_zdn_name'" >&2
+ fi
+ return 1
+ fi
+ if [[ $_zdn_cpt = (#b)(*)/:([[:IDENT:]]##) ]]; then
+ _zdn_cpt=$match[1]
+ _zdn_var=$match[2]
+ else
+ # may be empty
+ _zdn_var=${${_zdn_assoc[:default:]}##*/:}
+ fi
+ _zdn_dir=${_zdn_dir:+$_zdn_dir/}$_zdn_cpt
+ done
+ if (( ${#_zdn_dir} )); then
+ typeset -ag reply
+ reply=($_zdn_dir)
+ return 0
+ fi
+elif [[ $1 = d ]]; then
+ # Turning a directory into a name.
+ local _zdn_dir=$2
+ local _zdn_rest=$_zdn_dir
+ local -a _zdn_cpts
+ local _zdn_pref _zdn_pref_raw _zdn_matched _zdn_cpt _zdn_name
+
+ while [[ -n $_zdn_var && -n $_zdn_rest ]]; do
+ _zdn_assoc=(${(Pkv)_zdn_var})
+ # Sorting in descending order will ensure prefixes
+ # come after longer strings with that perfix, so
+ # we match more specific directory names preferentially.
+ _zdn_cpts=(${(Ov)_zdn_assoc})
+ _zdn_cpt=''
+ for _zdn_pref_raw in $_zdn_cpts; do
+ _zdn_pref=${_zdn_pref_raw%/:*}
+ [[ -z $_zdn_pref ]] && continue
+ if [[ $_zdn_rest = $_zdn_pref(#b)(/|)(*) ]]; then
+ _zdn_cpt=${(k)_zdn_assoc[(r)$_zdn_pref_raw]}
+ # if we matched a /, too, add it...
+ _zdn_matched+=$_zdn_pref$match[1]
+ _zdn_rest=$match[2]
+ break
+ fi
+ done
+ if [[ -n $_zdn_cpt ]]; then
+ _zdn_name+=${_zdn_name:+${_zdh_name}:}$_zdn_cpt
+ if [[ ${_zdn_assoc[$_zdn_cpt]} = (#b)*/:([[:IDENT:]]##) ]]; then
+ _zdn_var=$match[1]
+ else
+ _zdn_var=${${_zdn_assoc[:default:]}##*/:}
+ fi
+ else
+ break
+ fi
+ done
+ if [[ -n $_zdn_name ]]; then
+ # matched something, so report that.
+ integer _zdn_len=${#_zdn_matched}
+ [[ $_zdn_matched[-1] = / ]] && (( _zdn_len-- ))
+ typeset -ag reply
+ reply=($_zdn_name $_zdn_len)
+ return 0
+ fi
+ # else let someone else have a go.
+elif [[ $1 = c ]]; then
+ # Completion
+
+ if [[ -n $SUFFIX ]]; then
+ _message "Can't complete in the middle of a dynamic directory name"
+ else
+ local -a _zdn_cpts
+ local _zdn_word _zdn_cpt _zdn_desc _zdn_sofar expl
+
+ while [[ -n ${_zdn_var} && ${PREFIX} = (#b)([^:]##):* ]]; do
+ _zdn_word=$match[1]
+ compset -P '[^:]##:'
+ _zdn_assoc=(${(Pkv)_zdn_var})
+ _zdn_cpt=${_zdn_assoc[$_zdn_word]}
+ # We only complete at the end so must match here
+ [[ -z $_zdn_cpt ]] && return 1
+ if [[ $_zdn_cpt = (#b)(*)/:([[:IDENT:]]##) ]]; then
+ _zdn_cpt=$match[1]
+ _zdn_var=$match[2]
+ else
+ _zdn_var=${${_zdn_assoc[:default:]}##*/:}
+ fi
+ _zdn_sofar+=${_zdn_sofar:+${_zdn_sofar}/}$_zdn_cpt
+ done
+ if [[ -n $_zdn_var ]]; then
+ _zdn_assoc=(${(Pkv)_zdn_var})
+ local -a _zdn_cpts
+ for _zdn_cpt _zdn_desc in ${(kv)_zdn_assoc}; do
+ [[ $_zdn_cpt = :* ]] && continue
+ _zdn_cpts+=(${_zdn_cpt}:${_zdn_desc%/:[[:IDENT:]]##})
+ done
+ _describe -t dirnames "directory name under ${_zdn_sofar%%/}" \
+ _zdn_cpts -S: -r ':]'
+ return
+ fi
+ fi
+fi
+
+# Failed
+return 1
+## end
--
cgit v1.2.3
From 61fa5f66f05c85e290d50df860708e80221011c9 Mon Sep 17 00:00:00 2001
From: Christoph Mathys
Date: Fri, 25 Sep 2015 23:19:44 +0000
Subject: 36626: _hg: completion for 'hg bookmarks'
---
ChangeLog | 5 +++++
Completion/Unix/Command/_hg | 10 ++++++++++
2 files changed, 15 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 7055836fa..71788378d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-25 Christoph Mathys
+
+ * 36626: Completion/Unix/Command/_hg: _hg: completion for
+ 'hg bookmarks'
+
2015-09-25 Peter Stephenson
* 36630: Doc/Zsh/contrib.yo, Doc/Zsh/manual.yo,
diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg
index 9dd023653..5d4c9852b 100644
--- a/Completion/Unix/Command/_hg
+++ b/Completion/Unix/Command/_hg
@@ -460,6 +460,16 @@ _hg_cmd_bisect() {
'(--command -c --noupdate -U)'{-U,--noupdate}'[do not update to target]'
}
+_hg_cmd_bookmarks() {
+ _arguments -s : $_hg_global_opts \
+ '(--force -f)'{-f,--force}'[force]' \
+ '(--rev -r)'{-r+,--rev=}'[set bookmark at revision]:revision:_hg_tags' \
+ '(--delete -d)'{-d,--delete}'[delete a given bookmark]' \
+ '(--rename -m)'{-m+,--rename}'[rename given bookmark]:bookmark:_hg_bookmarks_internal' \
+ '(--inactive -i)'{-i,--inactive}'[mark a bookmark inactive]' \
+ ':bookmark:_hg_bookmarks_internal'
+}
+
_hg_cmd_branch() {
_arguments -s -w : $_hg_global_opts \
'(--force -f)'{-f,--force}'[set branch name even if it shadows an existing branch]' \
--
cgit v1.2.3
From 8165b488cb223ac58629d99f8df1bda930dd29c0 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf
Date: Fri, 25 Sep 2015 23:38:39 +0000
Subject: unposted: zle: Document the C helper function processcmd().
Also, tweak the docstring of zlelineasstring().
---
ChangeLog | 5 +++++
Src/Zle/zle_tricky.c | 3 +++
Src/Zle/zle_utils.c | 4 ++--
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 71788378d..fbd7c3a00 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-25 Daniel Shahaf
+
+ * unposted: Src/Zle/zle_tricky.c Src/Zle/zle_utils.c: zle:
+ Document the C helper function processcmd().
+
2015-09-25 Christoph Mathys
* 36626: Completion/Unix/Command/_hg: _hg: completion for
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index b1a6f9e7e..e26f66379 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -2952,6 +2952,9 @@ getcurcmd(void)
return s;
}
+/* Run '$WIDGET $commandword' and then restore the command-line using push-line.
+ */
+
/**/
int
processcmd(UNUSED(char **args))
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 9751f7a1f..714d911a6 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -166,13 +166,13 @@ zlecharasstring(ZLE_CHAR_T inchar, char *buf)
}
/*
- * Input a line in internal zle format, possibly using wide characters,
+ * Input: a line in internal zle format, possibly using wide characters,
* possibly not, together with its length and the cursor position.
* The length must be accurate and includes all characters (no NULL
* termination is expected). The input cursor position is only
* significant if outcs is non-NULL.
*
- * Output an ordinary NULL-terminated string, using multibyte characters
+ * Output: an ordinary NULL-terminated string, using multibyte characters
* instead of wide characters where appropriate and with the contents
* metafied.
*
--
cgit v1.2.3
From 92584634d3d39e9ca64475ae5af8010e2ccebe24 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf
Date: Sat, 26 Sep 2015 00:19:59 +0000
Subject: unposted (see 36633): _hg: Enable --option=value syntax and disable
'-xy Xarg Yarg' syntax
This simply removes the '-w' argument to _arguments and changes
{-x+,--foo} to {-x+,--foo=} throughout the file.
---
ChangeLog | 5 +
Completion/Unix/Command/_hg | 252 ++++++++++++++++++++++----------------------
2 files changed, 131 insertions(+), 126 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index fbd7c3a00..f700ec067 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-26 Daniel Shahaf
+
+ * unposted (see 36633): Completion/Unix/Command/_hg: _hg:
+ Enable --option=value syntax and disable '-xy Xarg Yarg' syntax
+
2015-09-25 Daniel Shahaf
* unposted: Src/Zle/zle_tricky.c Src/Zle/zle_utils.c: zle:
diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg
index 5d4c9852b..8d31cd377 100644
--- a/Completion/Unix/Command/_hg
+++ b/Completion/Unix/Command/_hg
@@ -359,7 +359,7 @@ _hg_clone_dest() {
# Common options
_hg_global_opts=(
- '(--repository -R)'{-R+,--repository}'[repository root directory]:repository:_files -/'
+ '(--repository -R)'{-R+,--repository=}'[repository root directory]:repository:_files -/'
'--cwd[change working directory]:new working directory:_files -/'
'(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, assume yes for any required answers]'
'(--verbose -v)'{-v,--verbose}'[enable additional output]'
@@ -378,8 +378,8 @@ _hg_global_opts=(
)
_hg_pat_opts=(
- '*'{-I+,--include}'[include names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/'
- '*'{-X+,--exclude}'[exclude names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/')
+ '*'{-I+,--include=}'[include names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/'
+ '*'{-X+,--exclude=}'[exclude names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/')
_hg_diff_opts=(
'(--text -a)'{-a,--text}'[treat all files as text]'
@@ -395,11 +395,11 @@ _hg_style_opts=(
_hg_commit_opts=(
'(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]'
- '(-e --edit -l --logfile --message -m)'{-m+,--message}'[use as commit message]:message:'
- '(-e --edit -m --message --logfile -l)'{-l+,--logfile}'[read the commit message from ]:log file:_files')
+ '(-e --edit -l --logfile --message -m)'{-m+,--message=}'[use as commit message]:message:'
+ '(-e --edit -m --message --logfile -l)'{-l+,--logfile=}'[read the commit message from ]:log file:_files')
_hg_remote_opts=(
- '(--ssh -e)'{-e+,--ssh}'[specify ssh command to use]:'
+ '(--ssh -e)'{-e+,--ssh=}'[specify ssh command to use]:'
'--remotecmd[specify hg command to run on the remote side]:')
_hg_cmd() {
@@ -408,19 +408,19 @@ _hg_cmd() {
}
_hg_cmd_add() {
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
'*:unknown files:_hg_unknown'
}
_hg_cmd_addremove() {
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
- '(--similarity -s)'{-s+,--similarity}'[guess renamed files by similarity (0<=s<=100)]:' \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
+ '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:' \
'*:unknown or missing files:_hg_addremove'
}
_hg_cmd_annotate() {
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
- '(--rev -r)'{-r+,--rev}'[annotate the specified revision]:revision:_hg_tags' \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts \
+ '(--rev -r)'{-r+,--rev=}'[annotate the specified revision]:revision:_hg_tags' \
'(--follow -f)'{-f,--follow}'[follow file copies and renames]' \
'(--text -a)'{-a,--text}'[treat all files as text]' \
'(--user -u)'{-u,--user}'[list the author]' \
@@ -431,32 +431,32 @@ _hg_cmd_annotate() {
}
_hg_cmd_archive() {
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts \
'--no-decode[do not pass files through decoders]' \
- '(--prefix -p)'{-p+,--prefix}'[directory prefix for files in archive]:' \
- '(--rev -r)'{-r+,--rev}'[revision to distribute]:revision:_hg_tags' \
- '(--type -t)'{-t+,--type}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \
+ '(--prefix -p)'{-p+,--prefix=}'[directory prefix for files in archive]:' \
+ '(--rev -r)'{-r+,--rev=}'[revision to distribute]:revision:_hg_tags' \
+ '(--type -t)'{-t+,--type=}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \
'*:destination:_files'
}
_hg_cmd_backout() {
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts \
'--merge[merge with old dirstate parent after backout]' \
- '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
+ '(--date -d)'{-d+,--date=}'[record datecode as commit date]:date code:' \
'--parent[parent to choose when backing out merge]' \
- '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
- '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \
- '(--message -m)'{-m+,--message}'[specify commit message]:text' \
- '(--logfile -l)'{-l+,--logfile}'[read commit message from specified file]:log file:_files'
+ '(--user -u)'{-u+,--user=}'[record user as commiter]:user:' \
+ '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_tags' \
+ '(--message -m)'{-m+,--message=}'[specify commit message]:text' \
+ '(--logfile -l)'{-l+,--logfile=}'[read commit message from specified file]:log file:_files'
}
_hg_cmd_bisect() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'(-)'{-r,--reset}'[reset bisect state]' \
'(--good -g --bad -b --skip -s --reset -r)'{-g,--good}'[mark changeset good]'::revision:_hg_tags \
'(--good -g --bad -b --skip -s --reset -r)'{-b,--bad}'[mark changeset bad]'::revision:_hg_tags \
'(--good -g --bad -b --skip -s --reset -r)'{-s,--skip}'[skip testing changeset]' \
- '(--command -c --noupdate -U)'{-c+,--command}'[use command to check changeset state]':commands:_command_names \
+ '(--command -c --noupdate -U)'{-c+,--command=}'[use command to check changeset state]':commands:_command_names \
'(--command -c --noupdate -U)'{-U,--noupdate}'[do not update to target]'
}
@@ -465,24 +465,24 @@ _hg_cmd_bookmarks() {
'(--force -f)'{-f,--force}'[force]' \
'(--rev -r)'{-r+,--rev=}'[set bookmark at revision]:revision:_hg_tags' \
'(--delete -d)'{-d,--delete}'[delete a given bookmark]' \
- '(--rename -m)'{-m+,--rename}'[rename given bookmark]:bookmark:_hg_bookmarks_internal' \
+ '(--rename -m)'{-m+,--rename=}'[rename given bookmark]:bookmark:_hg_bookmarks_internal' \
'(--inactive -i)'{-i,--inactive}'[mark a bookmark inactive]' \
':bookmark:_hg_bookmarks_internal'
}
_hg_cmd_branch() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'(--force -f)'{-f,--force}'[set branch name even if it shadows an existing branch]' \
'(--clean -C)'{-C,--clean}'[reset branch name to parent branch name]'
}
_hg_cmd_branches() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'(--active -a)'{-a,--active}'[show only branches that have unmerge heads]'
}
_hg_cmd_bundle() {
- _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
+ _arguments -s : $_hg_global_opts $_hg_remote_opts \
'(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \
'(2)*--base[a base changeset to specify instead of a destination]:revision:_hg_tags' \
':output file:_files' \
@@ -490,33 +490,33 @@ _hg_cmd_bundle() {
}
_hg_cmd_cat() {
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
- '(--output -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
- '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts \
+ '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:filespec:' \
+ '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_tags' \
'*:file:_hg_files'
}
_hg_cmd_clone() {
- _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
+ _arguments -s : $_hg_global_opts $_hg_remote_opts \
'(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]' \
- '(--rev -r)'{-r+,--rev}'[a changeset you would like to have after cloning]:' \
+ '(--rev -r)'{-r+,--rev=}'[a changeset you would like to have after cloning]:' \
'--uncompressed[use uncompressed transfer (fast over LAN)]' \
':source repository:_hg_remote' \
':destination:_hg_clone_dest'
}
_hg_cmd_commit() {
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts \
'(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
- '(--message -m)'{-m+,--message}'[specify commit message]:text' \
- '(--logfile -l)'{-l+,--logfile}'[read commit message from specified file]:log file:_files' \
- '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
- '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
+ '(--message -m)'{-m+,--message=}'[specify commit message]:text' \
+ '(--logfile -l)'{-l+,--logfile=}'[read commit message from specified file]:log file:_files' \
+ '(--date -d)'{-d+,--date=}'[record datecode as commit date]:date code:' \
+ '(--user -u)'{-u+,--user=}'[record user as commiter]:user:' \
'*:file:_hg_committable'
}
_hg_cmd_copy() {
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
'(--after -A)'{-A,--after}'[record a copy that has already occurred]' \
'(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
'*:file:_hg_files'
@@ -524,8 +524,8 @@ _hg_cmd_copy() {
_hg_cmd_diff() {
typeset -A opt_args
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \
- '*'{-r,--rev}'+[revision]:revision:_hg_revrange' \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \
+ '*'{-r+,--rev=}'[revision]:revision:_hg_revrange' \
'(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \
'(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]' \
'(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]' \
@@ -544,99 +544,99 @@ _hg_cmd_diff() {
}
_hg_cmd_export() {
- _arguments -s -w : $_hg_global_opts $_hg_diff_opts \
+ _arguments -s : $_hg_global_opts $_hg_diff_opts \
'(--outout -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
'--switch-parent[diff against the second parent]' \
'*:revision:_hg_tags'
}
_hg_cmd_grep() {
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts \
'(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
'--all[print all revisions with matches]' \
'(--follow -f)'{-f,--follow}'[follow changeset or file history]' \
'(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \
'(--files-with-matches -l)'{-l,--files-with-matches}'[print only filenames and revs that match]' \
'(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \
- '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
+ '*'{-r+,--rev=}'[search in given revision range]:revision:_hg_revrange' \
'(--user -u)'{-u,--user}'[print user who committed change]' \
'1:search pattern:' \
'*:files:_hg_files'
}
_hg_cmd_heads() {
- _arguments -s -w : $_hg_global_opts $_hg_style_opts \
- '(--rev -r)'{-r+,--rev}'[show only heads which are descendants of rev]:revision:_hg_tags'
+ _arguments -s : $_hg_global_opts $_hg_style_opts \
+ '(--rev -r)'{-r+,--rev=}'[show only heads which are descendants of rev]:revision:_hg_tags'
}
_hg_cmd_help() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'*:mercurial command:_hg_commands'
}
_hg_cmd_identify() {
- _arguments -s -w : $_hg_global_opts \
- '(--rev -r)'{-r+,--rev}'[identify the specified rev]:revision:_hg_tags' \
- '(--num -n)'{-n+,--num}'[show local revision number]' \
- '(--id -i)'{-i+,--id}'[show global revision id]' \
- '(--branch -b)'{-b+,--branch}'[show branch]' \
- '(--tags -t)'{-t+,--tags}'[show tags]'
+ _arguments -s : $_hg_global_opts \
+ '(--rev -r)'{-r+,--rev=}'[identify the specified rev]:revision:_hg_tags' \
+ '(--num -n)'{-n+,--num=}'[show local revision number]' \
+ '(--id -i)'{-i+,--id=}'[show global revision id]' \
+ '(--branch -b)'{-b+,--branch=}'[show branch]' \
+ '(--tags -t)'{-t+,--tags=}'[show tags]'
}
_hg_cmd_import() {
- _arguments -s -w : $_hg_global_opts \
- '(--strip -p)'{-p+,--strip}'[directory strip option for patch (default: 1)]:count:' \
- '(--message -m)'{-m+,--message}'[use as commit message]:text:' \
+ _arguments -s : $_hg_global_opts \
+ '(--strip -p)'{-p+,--strip=}'[directory strip option for patch (default: 1)]:count:' \
+ '(--message -m)'{-m+,--message=}'[use as commit message]:text:' \
'(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
'*:patch:_files'
}
_hg_cmd_incoming() {
- _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
+ _arguments -s : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
'(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
'(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
'(--patch -p)'{-p,--patch}'[show patch]' \
- '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:_hg_tags' \
+ '(--rev -r)'{-r+,--rev=}'[a specific revision up to which you would like to pull]:revision:_hg_tags' \
'(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
'--bundle[file to store the bundles into]:bundle file:_files' \
':source:_hg_remote'
}
_hg_cmd_init() {
- _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
+ _arguments -s : $_hg_global_opts $_hg_remote_opts \
':dir:_files -/'
}
_hg_cmd_locate() {
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
- '(--rev -r)'{-r+,--rev}'[search repository as it stood at revision]:revision:_hg_tags' \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts \
+ '(--rev -r)'{-r+,--rev=}'[search repository as it stood at revision]:revision:_hg_tags' \
'(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
'(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \
'*:search pattern:_hg_files'
}
_hg_cmd_log() {
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_style_opts \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_style_opts \
'(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
'(-f --follow)--follow-first[only follow the first parent of merge changesets]' \
'(--copies -C)'{-C,--copies}'[show copied files]' \
- '(--keyword -k)'{-k+,--keyword}'[search for a keyword]:' \
- '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
+ '(--keyword -k)'{-k+,--keyword=}'[search for a keyword]:' \
+ '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:' \
'*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \
'(--no-merges -M)'{-M,--no-merges}'[do not show merges]' \
'(--only-merges -m)'{-m,--only-merges}'[show only merges]' \
'(--patch -p)'{-p,--patch}'[show patch]' \
- '(--prune -P)'{-P+,--prune}'[do not display revision or any of its ancestors]:revision:_hg_tags' \
+ '(--prune -P)'{-P+,--prune=}'[do not display revision or any of its ancestors]:revision:_hg_tags' \
'*:files:_hg_files'
}
_hg_cmd_manifest() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
':revision:_hg_tags'
}
_hg_cmd_merge() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \
'(--rev -r 1)'{-r,--rev}'[revision to merge]:revision:_hg_mergerevs' \
'(--preview -P)'{-P,--preview}'[review revisions to merge (no merge is performed)]' \
@@ -644,38 +644,38 @@ _hg_cmd_merge() {
}
_hg_cmd_outgoing() {
- _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
+ _arguments -s : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
'(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
'(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
'(--patch -p)'{-p,--patch}'[show patch]' \
- '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]' \
+ '(--rev -r)'{-r+,--rev=}'[a specific revision you would like to push]' \
'(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
':destination:_hg_remote'
}
_hg_cmd_parents() {
- _arguments -s -w : $_hg_global_opts $_hg_style_opts \
- '(--rev -r)'{-r+,--rev}'[show parents of the specified rev]:revision:_hg_tags' \
+ _arguments -s : $_hg_global_opts $_hg_style_opts \
+ '(--rev -r)'{-r+,--rev=}'[show parents of the specified rev]:revision:_hg_tags' \
':last modified file:_hg_files'
}
_hg_cmd_paths() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
':path:_hg_paths'
}
_hg_cmd_pull() {
- _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
+ _arguments -s : $_hg_global_opts $_hg_remote_opts \
'(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
'(--update -u)'{-u,--update}'[update to new tip if changesets were pulled]' \
- '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:' \
+ '(--rev -r)'{-r+,--rev=}'[a specific revision up to which you would like to pull]:revision:' \
':source:_hg_remote'
}
_hg_cmd_push() {
- _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
+ _arguments -s : $_hg_global_opts $_hg_remote_opts \
'(--force -f)'{-f,--force}'[force push]' \
- '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]:revision:_hg_tags' \
+ '(--rev -r)'{-r+,--rev=}'[a specific revision you would like to push]:revision:_hg_tags' \
'*'{-B,--bookmark=}'[bookmark to push]:bookmark:_hg_bookmarks_internal' \
'*'{-b,--branch=}'[branch to push]:branch:_hg_branches_internal' \
'--insecure[do not verify server certificate]' \
@@ -684,14 +684,14 @@ _hg_cmd_push() {
}
_hg_cmd_remove() {
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts \
'(--after -A)'{-A,--after}'[record remove that has already occurred]' \
'(--force -f)'{-f,--force}'[remove file even if modified]' \
'*:file:_hg_files'
}
_hg_cmd_rename() {
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
'(--after -A)'{-A,--after}'[record a rename that has already occurred]' \
'(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
'*:file:_hg_files'
@@ -701,7 +701,7 @@ _hg_cmd_resolve() {
local context state line
typeset -A opt_args
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing merge]:*:merged files:->resolve_files' \
'(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as resolved]:*:unresolved files:_hg_unresolved' \
'(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as resolved]:*:resolved files:_hg_resolved' \
@@ -718,9 +718,9 @@ _hg_cmd_revert() {
local context state line
typeset -A opt_args
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
'(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
- '(--rev -r)'{-r+,--rev}'[revision to revert to]:revision:_hg_tags' \
+ '(--rev -r)'{-r+,--rev=}'[revision to revert to]:revision:_hg_tags' \
'--no-backup[do not save backup copies of files]' \
'*:file:->diff_files'
@@ -738,13 +738,13 @@ _hg_cmd_revert() {
}
_hg_cmd_serve() {
- _arguments -s -w : $_hg_global_opts \
- '(--accesslog -A)'{-A+,--accesslog}'[name of access log file]:log file:_files' \
- '(--errorlog -E)'{-E+,--errorlog}'[name of error log file]:log file:_files' \
+ _arguments -s : $_hg_global_opts \
+ '(--accesslog -A)'{-A+,--accesslog=}'[name of access log file]:log file:_files' \
+ '(--errorlog -E)'{-E+,--errorlog=}'[name of error log file]:log file:_files' \
'(--daemon -d)'{-d,--daemon}'[run server in background]' \
- '(--port -p)'{-p+,--port}'[listen port]:listen port:' \
- '(--address -a)'{-a+,--address}'[interface address]:interface address:' \
- '(--name -n)'{-n+,--name}'[name to show in web pages]:repository name:' \
+ '(--port -p)'{-p+,--port=}'[listen port]:listen port:' \
+ '(--address -a)'{-a+,--address=}'[interface address]:interface address:' \
+ '(--name -n)'{-n+,--name=}'[name to show in web pages]:repository name:' \
'(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \
'--style[web template style]:style' \
'--stdio[for remote clients]' \
@@ -752,13 +752,13 @@ _hg_cmd_serve() {
}
_hg_cmd_showconfig() {
- _arguments -s -w : $_hg_global_opts \
- '(--untrusted -u)'{-u+,--untrusted}'[show untrusted configuration options]' \
+ _arguments -s : $_hg_global_opts \
+ '(--untrusted -u)'{-u+,--untrusted=}'[show untrusted configuration options]' \
':config item:_hg_config'
}
_hg_cmd_status() {
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts \
'(--all -A)'{-A,--all}'[show status of all files]' \
'(--modified -m)'{-m,--modified}'[show only modified files]' \
'(--added -a)'{-a,--added}'[show only added files]' \
@@ -775,37 +775,37 @@ _hg_cmd_status() {
}
_hg_cmd_tag() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'(--local -l)'{-l,--local}'[make the tag local]' \
- '(--message -m)'{-m+,--message}'[message for tag commit log entry]:message:' \
- '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
- '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
- '(--rev -r)'{-r+,--rev}'[revision to tag]:revision:_hg_tags' \
+ '(--message -m)'{-m+,--message=}'[message for tag commit log entry]:message:' \
+ '(--date -d)'{-d+,--date=}'[record datecode as commit date]:date code:' \
+ '(--user -u)'{-u+,--user=}'[record user as commiter]:user:' \
+ '(--rev -r)'{-r+,--rev=}'[revision to tag]:revision:_hg_tags' \
':tag name:'
}
_hg_cmd_tip() {
- _arguments -s -w : $_hg_global_opts $_hg_style_opts \
+ _arguments -s : $_hg_global_opts $_hg_style_opts \
'(--patch -p)'{-p,--patch}'[show patch]'
}
_hg_cmd_unbundle() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \
':files:_files'
}
_hg_cmd_update() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \
- '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \
+ '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_tags' \
':revision:_hg_tags'
}
# HGK
_hg_cmd_view() {
- _arguments -s -w : $_hg_global_opts \
- '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
+ _arguments -s : $_hg_global_opts \
+ '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:' \
':revision range:_hg_tags'
}
@@ -859,35 +859,35 @@ _hg_qseries_opts=(
'(--summary -s)'{-s,--summary}'[print first line of patch header]')
_hg_cmd_qapplied() {
- _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
+ _arguments -s : $_hg_global_opts $_hg_qseries_opts
}
_hg_cmd_qdelete() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'(--keep -k)'{-k,--keep}'[keep patch file]' \
- '*'{-r+,--rev}'[stop managing a revision]:applied patch:_hg_revrange' \
+ '*'{-r+,--rev=}'[stop managing a revision]:applied patch:_hg_revrange' \
'*:unapplied patch:_hg_qdeletable'
}
_hg_cmd_qdiff() {
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts \
'*:pattern:_hg_files'
}
_hg_cmd_qfold() {
- _arguments -s -w : $_hg_global_opts $_h_commit_opts \
+ _arguments -s : $_hg_global_opts $_h_commit_opts \
'(--keep,-k)'{-k,--keep}'[keep folded patch files]' \
'*:unapplied patch:_hg_qunapplied'
}
_hg_cmd_qgoto() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'(--force -f)'{-f,--force}'[overwrite any local changes]' \
':patch:_hg_qseries'
}
_hg_cmd_qguard() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'(--list -l)'{-l,--list}'[list all patches and guards]' \
'(--none -n)'{-n,--none}'[drop all guards]' \
':patch:_hg_qseries' \
@@ -895,66 +895,66 @@ _hg_cmd_qguard() {
}
_hg_cmd_qheader() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
':patch:_hg_qseries'
}
_hg_cmd_qimport() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'(--existing -e)'{-e,--existing}'[import file in patch dir]' \
- '(--name -n 2)'{-n+,--name}'[patch file name]:name:' \
+ '(--name -n 2)'{-n+,--name=}'[patch file name]:name:' \
'(--force -f)'{-f,--force}'[overwrite existing files]' \
- '*'{-r+,--rev}'[place existing revisions under mq control]:revision:_hg_revrange' \
+ '*'{-r+,--rev=}'[place existing revisions under mq control]:revision:_hg_revrange' \
'*:patch:_files'
}
_hg_cmd_qnew() {
- _arguments -s -w : $_hg_global_opts $_hg_commit_opts \
+ _arguments -s : $_hg_global_opts $_hg_commit_opts \
'(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \
':patch:'
}
_hg_cmd_qnext() {
- _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
+ _arguments -s : $_hg_global_opts $_hg_qseries_opts
}
_hg_cmd_qpop() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'(--all -a :)'{-a,--all}'[pop all patches]' \
- '(--name -n)'{-n+,--name}'[queue name to pop]:' \
+ '(--name -n)'{-n+,--name=}'[queue name to pop]:' \
'(--force -f)'{-f,--force}'[forget any local changes]' \
':patch:_hg_qapplied'
}
_hg_cmd_qprev() {
- _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
+ _arguments -s : $_hg_global_opts $_hg_qseries_opts
}
_hg_cmd_qpush() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'(--all -a :)'{-a,--all}'[apply all patches]' \
'(--list -l)'{-l,--list}'[list patch name in commit text]' \
- '(--merge -m)'{-m+,--merge}'[merge from another queue]:' \
- '(--name -n)'{-n+,--name}'[merge queue name]:' \
+ '(--merge -m)'{-m+,--merge=}'[merge from another queue]:' \
+ '(--name -n)'{-n+,--name=}'[merge queue name]:' \
'(--force -f)'{-f,--force}'[apply if the patch has rejects]' \
':patch:_hg_qunapplied'
}
_hg_cmd_qrefresh() {
- _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \
+ _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \
'(--git -g)'{-g,--git}'[use git extended diff format]' \
'(--short -s)'{-s,--short}'[short refresh]' \
'*:files:_hg_files'
}
_hg_cmd_qrename() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
':patch:_hg_qseries' \
':destination:'
}
_hg_cmd_qselect() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'(--none -n :)'{-n,--none}'[disable all guards]' \
'(--series -s :)'{-s,--series}'[list all guards in series file]' \
'--pop[pop to before first guarded applied patch]' \
@@ -963,20 +963,20 @@ _hg_cmd_qselect() {
}
_hg_cmd_qseries() {
- _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
+ _arguments -s : $_hg_global_opts $_hg_qseries_opts \
'(--missing -m)'{-m,--missing}'[print patches not in series]'
}
_hg_cmd_qunapplied() {
- _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
+ _arguments -s : $_hg_global_opts $_hg_qseries_opts
}
_hg_cmd_qtop() {
- _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
+ _arguments -s : $_hg_global_opts $_hg_qseries_opts
}
_hg_cmd_strip() {
- _arguments -s -w : $_hg_global_opts \
+ _arguments -s : $_hg_global_opts \
'(--force -f)'{-f,--force}'[force multi-head removal]' \
'(--backup -b)'{-b,--backup}'[bundle unrelated changesets]' \
'(--nobackup -n)'{-n,--nobackup}'[no backups]' \
--
cgit v1.2.3
From 50721a1986a3637e923ccc4531135b8aa39c8e70 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sat, 26 Sep 2015 13:46:20 -0700
Subject: 36641: fix multibyte handling in incremental search during menu
selection
---
ChangeLog | 5 +++++
Src/Zle/complist.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index f700ec067..964e340f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-26 Barton E. Schaefer
+
+ * 36641: Src/Modules/complist.c: fix multibyte handling in
+ incremental search during menu selection
+
2015-09-26 Daniel Shahaf
* unposted (see 36633): Completion/Unix/Command/_hg: _hg:
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 01bcb7cf8..433701514 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -3300,7 +3300,7 @@ domenuselect(Hookdef dummy, Chdata dat)
int len;
memset(&mbs, 0, sizeof(mbs));
- len = wcrtomb(s, lastchar_wide, &mbs);
+ len = wcrtomb(toins, lastchar_wide, &mbs);
if (len < 0)
len = 0;
insert[len] = '\0';
--
cgit v1.2.3
From 0cfa2dcfc424667f7fc29cf9a13c68883f3ffc28 Mon Sep 17 00:00:00 2001
From: Jun-ichi Takimoto
Date: Mon, 28 Sep 2015 00:09:03 +0900
Subject: 36631: separate _zsh from _sh
Do all the completion for zsh by _arguments
---
ChangeLog | 5 +++++
Completion/Unix/Command/_sh | 17 +----------------
Completion/Unix/Command/_zsh | 8 ++++++++
3 files changed, 14 insertions(+), 16 deletions(-)
create mode 100644 Completion/Unix/Command/_zsh
diff --git a/ChangeLog b/ChangeLog
index 964e340f0..05c163014 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-28 Jun-ichi Takimoto
+
+ * 36631: Completion/Unix/Command/_sh,
+ Completion/Unix/Command/_zsh: separate _zsh from _sh
+
2015-09-26 Barton E. Schaefer
* 36641: Src/Modules/complist.c: fix multibyte handling in
diff --git a/Completion/Unix/Command/_sh b/Completion/Unix/Command/_sh
index 1b5112212..2afb46621 100644
--- a/Completion/Unix/Command/_sh
+++ b/Completion/Unix/Command/_sh
@@ -1,13 +1,4 @@
-#compdef sh ksh bash zsh csh tcsh rc
-
-if [[ $service == zsh ]]; then
- # try a bit harder
- if [[ ${words[CURRENT-1]} == -o ]]; then
- _options
- # no other possibilities
- return
- fi
-fi
+#compdef sh ksh bash csh tcsh rc
if (( CURRENT == ${words[(i)-c]} + 1 )); then
_cmdstring
@@ -21,9 +12,3 @@ else
fi
_default
fi
-
-local ret=$?
-
-[[ $service == zsh ]] && _arguments -S -s -- && ret=0
-
-return ret
diff --git a/Completion/Unix/Command/_zsh b/Completion/Unix/Command/_zsh
new file mode 100644
index 000000000..3b6d7ad4f
--- /dev/null
+++ b/Completion/Unix/Command/_zsh
@@ -0,0 +1,8 @@
+#compdef zsh
+
+_arguments -S -s : \
+ '*-o+[set named option]:option:_options' \
+ '*+o+[unset named option]:option:_options' \
+ '(1 -)-c[run a command]:command:_cmdstring' \
+ '(-)1:script file:_files' \
+ '*:command arguments' --
--
cgit v1.2.3
From c2254cfe2c9b4bace38035ec95e4bad4ef46c9f5 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sun, 27 Sep 2015 12:43:03 -0700
Subject: 36661: replace obsolete "autobins" setting with "autofeatures"
---
ChangeLog | 5 +++++
Src/Modules/curses.mdd | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 05c163014..13a62fdfa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-27 Barton E. Schaefer
+
+ * 36661: Src/Modules/curses.mdd: replace obsolete "autobins"
+ setting with "autofeatures"
+
2015-09-28 Jun-ichi Takimoto
* 36631: Completion/Unix/Command/_sh,
diff --git a/Src/Modules/curses.mdd b/Src/Modules/curses.mdd
index 669c4f5c7..80c8f867b 100644
--- a/Src/Modules/curses.mdd
+++ b/Src/Modules/curses.mdd
@@ -2,7 +2,7 @@ name=zsh/curses
link='if test "x$ac_cv_func_initscr" = xyes && test "x$zsh_cv_path_curses_header" != x; then echo dynamic; else echo no; fi'
load=no
-autobins="zcurses"
+autofeatures="b:zcurses"
objects="curses.o"
--
cgit v1.2.3
From 7e4784f90105a21af3f5e0a52aa8d2465919e635 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sun, 27 Sep 2015 12:43:25 -0700
Subject: 36663: replace obsolete "autobins" commentary with "autofeatures"
---
ChangeLog | 3 +++
Src/mkmakemod.sh | 10 +++-------
Src/zsh.mdd | 2 +-
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 13a62fdfa..3562b1379 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2015-09-27 Barton E. Schaefer
+ * 36663: Src/mkmakemod.sh, Src/zsh.mdd: replace obsolete
+ "autobins" commentary with "autofeatures"
+
* 36661: Src/Modules/curses.mdd: replace obsolete "autobins"
setting with "autofeatures"
diff --git a/Src/mkmakemod.sh b/Src/mkmakemod.sh
index 002160910..3ccf9c5e5 100644
--- a/Src/mkmakemod.sh
+++ b/Src/mkmakemod.sh
@@ -21,12 +21,8 @@
# moddeps modules on which this module depends (default none)
# nozshdep non-empty indicates no dependence on the `zsh/main' pseudo-module
# alwayslink if non-empty, always link the module into the executable
-# autobins builtins defined by the module, for autoloading
-# autoinfixconds infix condition codes defined by the module, for
-# autoloading (without the leading `-')
-# autoprefixconds like autoinfixconds, but for prefix condition codes
-# autoparams parameters defined by the module, for autoloading
-# automathfuncs math functions defined by the module, for autoloading
+# autofeatures features defined by the module, for autoloading
+# autofeatures_emu As autofeatures, but for non-zsh emulation modes
# objects .o files making up this module (*must* be defined)
# proto .syms files for this module (default generated from $objects)
# headers extra headers for this module (default none)
@@ -189,7 +185,7 @@ if $first_stage; then
for mddname in $here_mddnames; do
unset name moddeps nozshdep alwayslink hasexport
- unset autobins autoinfixconds autoprefixconds autoparams automathfuncs
+ unset autofeatures autofeatures_emu
unset objects proto headers hdrdeps otherincs
. $top_srcdir/$the_subdir/${mddname}.mdd
q_name=`echo $name | sed 's,Q,Qq,g;s,_,Qu,g;s,/,Qs,g'`
diff --git a/Src/zsh.mdd b/Src/zsh.mdd
index c2e59c910..86dd58866 100644
--- a/Src/zsh.mdd
+++ b/Src/zsh.mdd
@@ -7,7 +7,7 @@ functions='Functions/Chpwd/* Functions/Exceptions/* Functions/Misc/* Functions/M
nozshdep=1
alwayslink=1
-# autobins not specified because of alwayslink
+# autofeatures not specified because of alwayslink
objects="builtin.o compat.o cond.o context.o \
exec.o glob.o hashtable.o hashnameddir.o \
--
cgit v1.2.3
From 36abe20c0f53015b816d5f3bdd1eeed713614233 Mon Sep 17 00:00:00 2001
From: Matthew Martin
Date: Sun, 27 Sep 2015 01:03:16 -0500
Subject: 36653: OpenBSD's usermod has no -a flag
---
ChangeLog | 5 +++++
Completion/Unix/Command/_user_admin | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 3562b1379..b1fe74da4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-27 Matthew Martin
+
+ * 36653: Completion/Unix/Command/_user_admin: OpenBSD's usermod
+ has no -a flag
+
2015-09-27 Barton E. Schaefer
* 36663: Src/mkmakemod.sh, Src/zsh.mdd: replace obsolete
diff --git a/Completion/Unix/Command/_user_admin b/Completion/Unix/Command/_user_admin
index 31ccbf1c2..3653308a1 100644
--- a/Completion/Unix/Command/_user_admin
+++ b/Completion/Unix/Command/_user_admin
@@ -44,8 +44,8 @@ if [[ $service = user* ]]; then
"(-U -p)-L[lock user's password]"
"(-L -p)-U[unlock user's password]"
)
+ [[ $OSTYPE = openbsd* ]] || args+=('-a[append groups]')
args+=(
- '-a[append groups]'
'-l[specify new user name]:new username'
':username:_users'
)
--
cgit v1.2.3
From 2654cb43f63349cff06b3dd26932dd76f53aed4c Mon Sep 17 00:00:00 2001
From: Daniel Shahaf
Date: Sat, 26 Sep 2015 01:59:48 +0000
Subject: 36651: WARN_CREATE_GLOBAL += math expressions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Without this, '() { (( x=42 )) }' and '() { for (( i=0; … )) }' wouldn't warn
about $x and $i, respectively, being created global.
---
ChangeLog | 5 +++++
Doc/Zsh/options.yo | 3 ++-
Src/exec.c | 3 ++-
Src/math.c | 25 +++++++++++++++++++++++++
Test/E01options.ztst | 4 ++++
5 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b1fe74da4..2cd07ffa3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-27 Daniel Shahaf
+
+ * 36651: Doc/Zsh/options.yo Src/exec.c Src/math.c
+ Test/E01options.ztst: WARN_CREATE_GLOBAL += math expressions
+
2015-09-27 Matthew Martin
* 36653: Completion/Unix/Command/_user_admin: OpenBSD's usermod
diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index abd0f8715..fbf65abbc 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -746,7 +746,8 @@ pindex(NOWARNCREATEGLOBAL)
cindex(parameters, warning when created globally)
item(tt(WARN_CREATE_GLOBAL))(
Print a warning message when a global parameter is created in a function
-by an assignment. This often indicates that a parameter has not been
+by an assignment or in math context.
+This often indicates that a parameter has not been
declared local when it should have been. Parameters explicitly declared
global from within a function using tt(typeset -g) do not cause a warning.
Note that there is no warning when a local parameter is assigned to in
diff --git a/Src/exec.c b/Src/exec.c
index 109a04a26..da808d6f1 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -176,7 +176,8 @@ mod_export int sfcontext;
/**/
struct execstack *exstack;
-/* Stack with names of functions currently active. */
+/* Stack with names of function calls, 'source' calls, and 'eval' calls
+ * currently active. */
/**/
mod_export Funcstack funcstack;
diff --git a/Src/math.c b/Src/math.c
index 977e92345..56565a629 100644
--- a/Src/math.c
+++ b/Src/math.c
@@ -894,6 +894,24 @@ getcvar(char *s)
}
+/* If script execution is inside a function call that hasn't returned,
+ * return the name of that function. Else return NULL.
+ */
+
+/**/
+static const char *
+in_function_call(void)
+{
+ Funcstack i;
+ for (i = funcstack; i; i = i->prev)
+ if (i->tp == FS_FUNC) {
+ DPUTS(!i->name, "funcstack entry with no name");
+ return i->name;
+ }
+
+ return NULL;
+}
+
/**/
static mnumber
setmathvar(struct mathvalue *mvp, mnumber v)
@@ -929,6 +947,13 @@ setmathvar(struct mathvalue *mvp, mnumber v)
if (noeval)
return v;
untokenize(mvp->lval);
+ if (isset(WARNCREATEGLOBAL)) {
+ const char *function_name;
+ if (!paramtab->getnode(paramtab, mvp->lval) &&
+ (function_name = in_function_call()))
+ zwarn("math parameter %s created globally in function %s",
+ mvp->lval, function_name);
+ }
pm = setnparam(mvp->lval, v);
if (pm) {
/*
diff --git a/Test/E01options.ztst b/Test/E01options.ztst
index 2b91b21fa..1caee8d24 100644
--- a/Test/E01options.ztst
+++ b/Test/E01options.ztst
@@ -1110,11 +1110,15 @@
foo3=bar6
}
foo4=bar7 =true
+ (( foo5=8 ))
+ integer foo6=9
+ (( foo6=10 ))
}
fn
0:WARN_CREATE_GLOBAL option
?fn:3: scalar parameter foo1 created globally in function
?fn:5: scalar parameter foo1 created globally in function
+?fn:15: math parameter foo5 created globally in function fn
# This really just tests if XTRACE is egregiously broken.
# To test it properly would need a full set of its own.
--
cgit v1.2.3
From d85a1fcd888198d0212d7bec615751e8fe715fdd Mon Sep 17 00:00:00 2001
From: Mikael Magnusson
Date: Mon, 28 Sep 2015 02:18:49 +0200
Subject: unposted: Fix broken case condition and "qualifer" typo
---
ChangeLog | 15 ++++++++++-----
Completion/Zsh/Context/_brace_parameter | 6 +++---
Completion/Zsh/Type/_delimiters | 2 +-
Completion/Zsh/Type/_globquals | 2 +-
Functions/Calendar/age | 2 +-
5 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2cd07ffa3..7af8a07c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,17 @@
+2015-09-28 Mikael Magnusson
+
+ * unposted: Completion/Zsh/Context/_brace_parameter,
+ Completion/Zsh/Type/_delimiters, Completion/Zsh/Type/_globquals,
+ Functions/Calendar/age: Fix broken case condition and "qualifer"
+ typo
+
2015-09-27 Daniel Shahaf
- * 36651: Doc/Zsh/options.yo Src/exec.c Src/math.c
+ * 36651: Doc/Zsh/options.yo, Src/exec.c, Src/math.c,
Test/E01options.ztst: WARN_CREATE_GLOBAL += math expressions
-2015-09-27 Matthew Martin
-
- * 36653: Completion/Unix/Command/_user_admin: OpenBSD's usermod
- has no -a flag
+ * Matthew Martin: 36653: Completion/Unix/Command/_user_admin:
+ OpenBSD's usermod has no -a flag
2015-09-27 Barton E. Schaefer
diff --git a/Completion/Zsh/Context/_brace_parameter b/Completion/Zsh/Context/_brace_parameter
index 9eb3465ae..e77d4c58b 100644
--- a/Completion/Zsh/Context/_brace_parameter
+++ b/Completion/Zsh/Context/_brace_parameter
@@ -31,7 +31,7 @@ if [[ $PREFIX = *'${('[^\)]# ]]; then
([gIjsZ_])
# Single delimited argument.
if [[ -z $PREFIX ]]; then
- _delimiters qualifer-$char
+ _delimiters qualifier-$char
return
elif ! _globqual_delims; then
# still completing argument
@@ -46,7 +46,7 @@ if [[ $PREFIX = *'${('[^\)]# ]]; then
_message 'integer expression'
;;
- (js)
+ ([js])
_message "separator"
;;
@@ -71,7 +71,7 @@ if [[ $PREFIX = *'${('[^\)]# ]]; then
([lr])
# One compulsory argument, two optional.
if [[ -z $PREFIX ]]; then
- _delimiters qualifer-$char
+ _delimiters qualifier-$char
return
else
delim=$PREFIX[1]
diff --git a/Completion/Zsh/Type/_delimiters b/Completion/Zsh/Type/_delimiters
index bb5bba8d0..d98d5a766 100644
--- a/Completion/Zsh/Type/_delimiters
+++ b/Completion/Zsh/Type/_delimiters
@@ -1,6 +1,6 @@
#autoload
-# Simple function to offer delimiters for modifiers and qualifers.
+# Simple function to offer delimiters for modifiers and qualifiers.
# Single argument is tag to use.
local expl
diff --git a/Completion/Zsh/Type/_globquals b/Completion/Zsh/Type/_globquals
index 5cdb8f7c4..2523eb333 100644
--- a/Completion/Zsh/Type/_globquals
+++ b/Completion/Zsh/Type/_globquals
@@ -47,7 +47,7 @@ while [[ -n $PREFIX ]]; do
(e)
# complete/skip delimited command line
if [[ -z $PREFIX ]]; then
- _delimiters qualifer-e
+ _delimiters qualifier-e
return
elif ! _globqual_delims; then
# still completing command to eval
diff --git a/Functions/Calendar/age b/Functions/Calendar/age
index 17cf4d13e..50755d610 100644
--- a/Functions/Calendar/age
+++ b/Functions/Calendar/age
@@ -1,4 +1,4 @@
-# Match the age of a file, for use as a glob qualifer. Can
+# Match the age of a file, for use as a glob qualifier. Can
# take one or two arguments, which can be supplied by one of two
# ways (always the same for both arguments):
#
--
cgit v1.2.3
From 6d6b63c884a7484334a22671d2bd6ca138bb8751 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf
Date: Mon, 28 Sep 2015 01:20:44 +0000
Subject: unposted: Update link to my ChangeLog generator script, on account of
patching it to handle commas properly (thanks Mikael).
---
ChangeLog | 6 ++++++
Etc/zsh-development-guide | 2 ++
2 files changed, 8 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 7af8a07c9..f5b1a073f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-28 Daniel Shahaf
+
+ * unposted: Etc/zsh-development-guide: Update link to my
+ ChangeLog generator script, on account of patching it to handle
+ commas properly (thanks Mikael).
+
2015-09-28 Mikael Magnusson
* unposted: Completion/Zsh/Context/_brace_parameter,
diff --git a/Etc/zsh-development-guide b/Etc/zsh-development-guide
index cbbc798d3..9ca441bd8 100644
--- a/Etc/zsh-development-guide
+++ b/Etc/zsh-development-guide
@@ -77,7 +77,9 @@ avoided further changes to our workflow.
X-Seq: 33835, 33872, 34912
http://www.zsh.org/mla/workers/2014/msg01622.html
http://www.zsh.org/mla/workers/2014/msg01659.html
+ -> https://github.com/ft/zsh-am
http://www.zsh.org/mla/workers/2015/msg00836.html
+ -> https://github.com/danielshahaf/zsh-dev
Subject: Re: _git commit object name completion
X-Seq: 35414
--
cgit v1.2.3
From 4bed2cf256cf79f8e17093d54a67f75dfa54794a Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sun, 27 Sep 2015 23:56:38 -0700
Subject: 36669: fix ${(z)...} of an an incomplete math expression by restoring
"((" at the front of the token
---
ChangeLog | 5 +++++
Src/lex.c | 9 +++++++++
2 files changed, 14 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index f5b1a073f..bebc97b53 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-28 Barton E. Schaefer
+
+ * 36669: Src/lex.c: fix ${(z)...} of an an incomplete math
+ expression by restoring "((" at the front of the token
+
2015-09-28 Daniel Shahaf
* unposted: Etc/zsh-development-guide: Update link to my
diff --git a/Src/lex.c b/Src/lex.c
index 70f3d142a..89af96123 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -783,6 +783,15 @@ gettok(void)
*/
tokstr = NULL;
return INPAR;
+
+ case CMD_OR_MATH_ERR:
+ /*
+ * LEXFLAGS_ACTIVE means we came from bufferwords(),
+ * so we treat as an incomplete math expression
+ */
+ if (lexflags & LEXFLAGS_ACTIVE)
+ tokstr = dyncat("((", tokstr ? tokstr : "");
+ /* fall through */
default:
return LEXERR;
--
cgit v1.2.3
From 45bdc87a1f4058f9a8cd5eaceda704284d4a89a1 Mon Sep 17 00:00:00 2001
From: Daniel Hahler
Date: Wed, 23 Sep 2015 20:55:40 +0200
Subject: 36601: vcs_info: handle missing .git/rebase-apply/{next,msg-clean}
When pressing Ctrl-C after `git am`, only `last` exists in
`.git/rebase-apply/`, which is empty.
This patch fixes it to fall back to "no patch applied" then.
---
ChangeLog | 5 +++++
Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 25 +++++++++++++----------
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index bebc97b53..5a4db9010 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-28 Daniel Hahler
+
+ * 36601: Functions/VCS_Info/Backends/VCS_INFO_get_data_git:
+ vcs_info: handle missing .git/rebase-apply/{next,msg-clean}
+
2015-09-28 Barton E. Schaefer
* 36669: Src/lex.c: fix ${(z)...} of an an incomplete math
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 638ea4572..8ecc7c7f7 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -217,18 +217,21 @@ elif [[ -d "${gitdir}/rebase-merge" ]]; then
elif [[ -d "${gitdir}/rebase-apply" ]]; then
# Fake patch names for all but current patch
patchdir="${gitdir}/rebase-apply"
- local cur=$(< "${patchdir}/next")
- local p subject
- for p in $(seq $(($cur - 1))); do
- git_patches_applied+=("$(printf "%04d" $p) ?")
- done
- subject="${$(< "${patchdir}/msg-clean")[(f)1]}"
- if [[ -f "${patchdir}/original-commit" ]]; then
- git_patches_applied+=("$(< ${patchdir}/original-commit) $subject")
- else
- git_patches_applied+=("? $subject")
+ local next="${patchdir}/next"
+ if [[ -f $next ]]; then
+ local cur=$(< $next)
+ local p subject
+ for p in $(seq $(($cur - 1))); do
+ git_patches_applied+=("$(printf "%04d" $p) ?")
+ done
+ subject="${$(< "${patchdir}/msg-clean")[(f)1]}"
+ if [[ -f "${patchdir}/original-commit" ]]; then
+ git_patches_applied+=("$(< ${patchdir}/original-commit) $subject")
+ else
+ git_patches_applied+=("? $subject")
+ fi
+ git_patches_unapplied=($(seq $cur $(< "${patchdir}/last")))
fi
- git_patches_unapplied=($(seq $cur $(< "${patchdir}/last")))
VCS_INFO_git_handle_patches
elif [[ -f "${gitdir}/MERGE_HEAD" ]]; then
--
cgit v1.2.3
From a5cb918d4018bbd5cdc8751e5c9f4f55f0a211be Mon Sep 17 00:00:00 2001
From: Daniel Shahaf
Date: Mon, 28 Sep 2015 18:13:49 +0000
Subject: unposted: Test for 36669
---
ChangeLog | 4 ++++
Test/D04parameter.ztst | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 5a4db9010..546620d6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-09-28 Daniel Shahaf
+
+ * unposted: Test/D04parameter.ztst: Test for 36669
+
2015-09-28 Daniel Hahler
* 36601: Functions/VCS_Info/Backends/VCS_INFO_get_data_git:
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index e380e19b8..f1cc23e7c 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -572,6 +572,12 @@
>echo
>three
+ print -rl - ${(z):-":;(( echo 42 "}
+0:${(z)} with incomplete math expressions
+>:
+>;
+>(( echo 42
+
psvar=(dog)
setopt promptsubst
foo='It shouldn'\''t $(happen) to a %1v.'
--
cgit v1.2.3
From f9d7651c2554bb5db0373f63185ff358f795ab3c Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Mon, 28 Sep 2015 20:31:51 +0100
Subject: 36682: expand pattern interface to optimise unmetafication
---
ChangeLog | 6 +
Src/Zle/complist.c | 5 +-
Src/Zle/zle_hist.c | 4 +-
Src/glob.c | 56 +++++----
Src/pattern.c | 337 +++++++++++++++++++++++++++++++++++++----------------
Src/zsh.h | 10 ++
6 files changed, 288 insertions(+), 130 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 546620d6b..38e0e4627 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-28 Peter Stephenson
+
+ * 36682: Src/glob.c, Src/pattern.c, Src/zsh.h,
+ Src/Zle/complist,c, Src/Zle/zle_hist.c: expand pattern interface
+ to allow unmetafying trial string once for reuse.
+
2015-09-28 Daniel Shahaf
* unposted: Test/D04parameter.ztst: Test for 36669
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 433701514..986ad31ea 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -868,7 +868,7 @@ putmatchcol(char *group, char *n)
nrefs = MAX_POS - 1;
if ((!pc->prog || !group || pattry(pc->prog, group)) &&
- pattryrefs(pc->pat, n, -1, -1, 0, &nrefs, begpos, endpos)) {
+ pattryrefs(pc->pat, n, -1, -1, NULL, 0, &nrefs, begpos, endpos)) {
if (pc->cols[1]) {
patcols = pc->cols;
@@ -900,7 +900,8 @@ putfilecol(char *group, char *filename, mode_t m, int special)
nrefs = MAX_POS - 1;
if ((!pc->prog || !group || pattry(pc->prog, group)) &&
- pattryrefs(pc->pat, filename, -1, -1, 0, &nrefs, begpos, endpos)) {
+ pattryrefs(pc->pat, filename, -1, -1, NULL,
+ 0, &nrefs, begpos, endpos)) {
if (pc->cols[1]) {
patcols = pc->cols;
diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c
index 0cff0391a..95d96c95c 100644
--- a/Src/Zle/zle_hist.c
+++ b/Src/Zle/zle_hist.c
@@ -1306,8 +1306,8 @@ doisearch(char **args, int dir, int pattern)
* this mode.
*/
if (!skip_pos &&
- pattryrefs(patprog, zt, -1, -1, 0, NULL, NULL,
- &end_pos))
+ pattryrefs(patprog, zt, -1, -1, NULL, 0,
+ NULL, NULL, &end_pos))
t = zt;
} else {
if (!matchlist && !skip_pos) {
diff --git a/Src/glob.c b/Src/glob.c
index fa3ce25f4..8bf73520f 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2780,7 +2780,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
p->flags &= ~(PAT_NOTSTART|PAT_NOTEND);
if (fl & SUB_ALL) {
- int i = matched && pattry(p, s);
+ int i = matched && pattrylen(p, s, -1, -1, NULL, 0);
*sp = get_match_ret(*sp, 0, i ? l : 0, fl, i ? replstr : 0, NULL);
if (! **sp && (((fl & SUB_MATCH) && !i) || ((fl & SUB_REST) && i)))
return 0;
@@ -2809,7 +2809,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
* Largest/smallest possible match at head of string.
* First get the longest match...
*/
- if (pattry(p, s)) {
+ if (pattrylen(p, s, -1, -1, NULL, 0)) {
/* patmatchlen returns metafied length, as we need */
int mlen = patmatchlen();
if (!(fl & SUB_LONG) && !(p->flags & PAT_PURES)) {
@@ -2820,7 +2820,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
mb_charinit();
for (t = s, umlen = 0; t < s + mlen; ) {
set_pat_end(p, *t);
- if (pattrylen(p, s, t - s, umlen, 0)) {
+ if (pattrylen(p, s, t - s, umlen, NULL, 0)) {
mlen = patmatchlen();
break;
}
@@ -2847,7 +2847,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
tmatch = NULL;
for (ioff = 0, t = s, umlen = umltot; t < s + l; ioff++) {
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, ioff))
+ if (pattrylen(p, t, s + l - t, umlen, NULL, ioff))
tmatch = t;
if (fl & SUB_START)
break;
@@ -2857,7 +2857,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
*sp = get_match_ret(*sp, tmatch - s, l, fl, replstr, NULL);
return 1;
}
- if (!(fl & SUB_START) && pattrylen(p, s + l, 0, 0, ioff)) {
+ if (!(fl & SUB_START) && pattrylen(p, s + l, 0, 0, NULL, ioff)) {
*sp = get_match_ret(*sp, l, l, fl, replstr, NULL);
return 1;
}
@@ -2870,7 +2870,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
mb_charinit();
for (ioff = 0, t = s, umlen = umltot; t < s + l; ioff++) {
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, ioff)) {
+ if (pattrylen(p, t, s + l - t, umlen, NULL, ioff)) {
*sp = get_match_ret(*sp, t-s, l, fl, replstr, NULL);
return 1;
}
@@ -2878,7 +2878,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
break;
umlen -= iincchar(&t);
}
- if (!(fl & SUB_START) && pattrylen(p, s + l, 0, 0, ioff)) {
+ if (!(fl & SUB_START) && pattrylen(p, s + l, 0, 0, NULL, ioff)) {
*sp = get_match_ret(*sp, l, l, fl, replstr, NULL);
return 1;
}
@@ -2887,7 +2887,8 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
case SUB_SUBSTR:
/* Smallest at start, but matching substrings. */
set_pat_start(p, l);
- if (!(fl & SUB_GLOBAL) && pattry(p, s + l) && !--n) {
+ if (!(fl & SUB_GLOBAL) && pattrylen(p, s + l, -1, -1, NULL, 0) &&
+ !--n) {
*sp = get_match_ret(*sp, 0, 0, fl, replstr, NULL);
return 1;
} /* fall through */
@@ -2908,7 +2909,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
for (; t < s + l; ioff++) {
/* Find the longest match from this position. */
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, ioff)) {
+ if (pattrylen(p, t, s + l - t, umlen, NULL, ioff)) {
char *mpos = t + patmatchlen();
if (!(fl & SUB_LONG) && !(p->flags & PAT_PURES)) {
char *ptr;
@@ -2922,7 +2923,8 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
*/
for (ptr = t, umlen2 = 0; ptr < mpos;) {
set_pat_end(p, *ptr);
- if (pattrylen(p, t, ptr - t, umlen2, ioff)) {
+ if (pattrylen(p, t, ptr - t, umlen2,
+ NULL, ioff)) {
mpos = t + patmatchlen();
break;
}
@@ -2970,7 +2972,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
*/
set_pat_start(p, l);
if ((fl & (SUB_LONG|SUB_GLOBAL)) == SUB_LONG &&
- pattry(p, s + l) && !--n) {
+ pattrylen(p, s + l, -1, -1, NULL, 0) && !--n) {
*sp = get_match_ret(*sp, 0, 0, fl, replstr, repllist);
return 1;
}
@@ -2981,7 +2983,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
/* Longest/shortest at end, matching substrings. */
if (!(fl & SUB_LONG)) {
set_pat_start(p, l);
- if (pattrylen(p, s + l, 0, 0, umltot) && !--n) {
+ if (pattrylen(p, s + l, 0, 0, NULL, umltot) && !--n) {
*sp = get_match_ret(*sp, l, l, fl, replstr, NULL);
return 1;
}
@@ -3001,7 +3003,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
mb_charinit();
for (ioff = 0, t = s, umlen = umltot; t < s + l; ioff++) {
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, ioff)) {
+ if (pattrylen(p, t, s + l - t, umlen, NULL, ioff)) {
nmatches++;
tmatch = t;
}
@@ -3017,7 +3019,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
mb_charinit();
for (ioff = 0, t = s, umlen = umltot; t < s + l; ioff++) {
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, ioff) &&
+ if (pattrylen(p, t, s + l - t, umlen, NULL, ioff) &&
!n--) {
tmatch = t;
break;
@@ -3030,7 +3032,8 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
if (!(fl & SUB_LONG) && !(p->flags & PAT_PURES)) {
for (t = tmatch, umlen = 0; t < mpos; ) {
set_pat_end(p, *t);
- if (pattrylen(p, tmatch, t - tmatch, umlen, ioff)) {
+ if (pattrylen(p, tmatch, t - tmatch, umlen,
+ NULL, ioff)) {
mpos = tmatch + patmatchlen();
break;
}
@@ -3042,7 +3045,8 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
return 1;
}
set_pat_start(p, l);
- if ((fl & SUB_LONG) && pattrylen(p, s + l, 0, 0, umltot) && !--n) {
+ if ((fl & SUB_LONG) && pattrylen(p, s + l, 0, 0, NULL, umltot) &&
+ !--n) {
*sp = get_match_ret(*sp, l, l, fl, replstr, NULL);
return 1;
}
@@ -3167,7 +3171,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
*/
for (t = s, umlen = 0; t < s + mlen; METAINC(t), umlen++) {
set_pat_end(p, *t);
- if (pattrylen(p, s, t - s, umlen, 0)) {
+ if (pattrylen(p, s, t - s, umlen, NULL, 0)) {
mlen = patmatchlen();
break;
}
@@ -3187,7 +3191,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
if (t > s && t[-1] == Meta)
t--;
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, ioff)) {
+ if (pattrylen(p, t, s + l - t, umlen, NULL, ioff)) {
*sp = get_match_ret(*sp, t - s, l, fl, replstr, NULL);
return 1;
}
@@ -3203,7 +3207,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
for (ioff = 0, t = s, umlen = uml; t < s + l;
ioff++, METAINC(t), umlen--) {
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, ioff)) {
+ if (pattrylen(p, t, s + l - t, umlen, NULL, ioff)) {
*sp = get_match_ret(*sp, t-s, l, fl, replstr, NULL);
return 1;
}
@@ -3235,7 +3239,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
for (; t < s + l; METAINC(t), ioff++, umlen--) {
/* Find the longest match from this position. */
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, ioff)) {
+ if (pattrylen(p, t, s + l - t, umlen, NULL, ioff)) {
char *mpos = t + patmatchlen();
if (!(fl & SUB_LONG) && !(p->flags & PAT_PURES)) {
char *ptr;
@@ -3243,7 +3247,8 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
for (ptr = t, umlen2 = 0; ptr < mpos;
METAINC(ptr), umlen2++) {
set_pat_end(p, *ptr);
- if (pattrylen(p, t, ptr - t, umlen2, ioff)) {
+ if (pattrylen(p, t, ptr - t, umlen2,
+ NULL, ioff)) {
mpos = t + patmatchlen();
break;
}
@@ -3300,7 +3305,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
/* Longest/shortest at end, matching substrings. */
if (!(fl & SUB_LONG)) {
set_pat_start(p, l);
- if (pattrylen(p, s + l, 0, 0, uml) && !--n) {
+ if (pattrylen(p, s + l, 0, 0, NULL, uml) && !--n) {
*sp = get_match_ret(*sp, l, l, fl, replstr, NULL);
return 1;
}
@@ -3310,7 +3315,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
if (t > s && t[-1] == Meta)
t--;
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, ioff) && !--n) {
+ if (pattrylen(p, t, s + l - t, umlen, NULL, ioff) && !--n) {
/* Found the longest match */
char *mpos = t + patmatchlen();
if (!(fl & SUB_LONG) && !(p->flags & PAT_PURES)) {
@@ -3319,7 +3324,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
for (ptr = t, umlen2 = 0; ptr < mpos;
METAINC(ptr), umlen2++) {
set_pat_end(p, *ptr);
- if (pattrylen(p, t, ptr - t, umlen2, ioff)) {
+ if (pattrylen(p, t, ptr - t, umlen2, NULL, ioff)) {
mpos = t + patmatchlen();
break;
}
@@ -3331,7 +3336,8 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
}
}
set_pat_start(p, l);
- if ((fl & SUB_LONG) && pattrylen(p, s + l, 0, 0, uml) && !--n) {
+ if ((fl & SUB_LONG) && pattrylen(p, s + l, 0, 0, NULL, uml) &&
+ !--n) {
*sp = get_match_ret(*sp, l, l, fl, replstr, NULL);
return 1;
}
diff --git a/Src/pattern.c b/Src/pattern.c
index af56bd9cc..03ba37d92 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -2022,6 +2022,131 @@ pattrystart(void)
errsfound = 0;
}
+/*
+ * Allocate memeory for pattern match. Note this is specific to use
+ * of pattern *and* trial string.
+ *
+ * Unmetafy a trial string for use in pattern matching, if needed.
+ *
+ * If it is needed, returns a zalloc()'d string; if not needed, returns
+ * NULL.
+ *
+ * prog is the pattern to be executed.
+ * string is the metafied trial string.
+ * stringlen is it's length; it will be calculated if it's negative
+ * (this is a simple strlen()).
+ * unmetalen is the unmetafied length of the string, may be -1.
+ * force is 1 if we always unmetafy: this is useful if we are going
+ * to try again with different versions of the string. If this is
+ * called from pattryrefs() we don't force unmetafication as it won't
+ * be optimal.
+ * In patstralloc (supplied by caller, must last until last pattry is done)
+ * unmetalen is the unmetafied length of the string; it will be
+ * calculated if the input value is negative.
+ * unmetalenp is the umetafied length of a path segment preceeding
+ * the trial string needed for file mananagement; it is calculated as
+ * needed so does not need to be initialised.
+ * alloced is the memory allocated --- same as return value from
+ * function.
+ */
+/**/
+mod_export
+char *patallocstr(Patprog prog, char *string, int stringlen, int unmetalen,
+ int force, Patstralloc patstralloc)
+{
+ int needfullpath;
+
+ /*
+ * For a top-level ~-exclusion, we will need the full
+ * path to exclude, so copy the path so far and append the
+ * current test string.
+ */
+ needfullpath = (prog->flags & PAT_HAS_EXCLUDP) && pathpos;
+
+ /* Get the length of the full string when unmetafied. */
+ if (unmetalen < 0)
+ patstralloc->unmetalen = ztrsub(string + stringlen, string);
+ else
+ patstralloc->unmetalen = unmetalen;
+ if (needfullpath) {
+ patstralloc->unmetalenp = ztrsub(pathbuf + pathpos, pathbuf);
+ if (!patstralloc->unmetalenp)
+ needfullpath = 0;
+ } else
+ patstralloc->unmetalenp = 0;
+ /* Initialise cache area */
+ patstralloc->progstrunmeta = NULL;
+ patstralloc->progstrunmetalen = 0;
+
+ DPUTS(needfullpath && (prog->flags & (PAT_PURES|PAT_ANY)),
+ "rum sort of file exclusion");
+ /*
+ * Partly for efficiency, and partly for the convenience of
+ * globbing, we don't unmetafy pure string patterns, and
+ * there's no reason to if the pattern is just a *.
+ */
+ if (force ||
+ (!(prog->flags & (PAT_PURES|PAT_ANY))
+ && (needfullpath || patstralloc->unmetalen != stringlen))) {
+ /*
+ * We need to copy if we need to prepend the path so far
+ * (in which case we copy both chunks), or if we have
+ * Meta characters.
+ */
+ char *dst, *ptr;
+ int i, icopy, ncopy;
+
+ dst = patstralloc->alloced =
+ zalloc(patstralloc->unmetalen + patstralloc->unmetalenp);
+
+ if (needfullpath) {
+ /* loop twice, copy path buffer first time */
+ ptr = pathbuf;
+ ncopy = patstralloc->unmetalenp;
+ } else {
+ /* just loop once, copy string with unmetafication */
+ ptr = string;
+ ncopy = patstralloc->unmetalen;
+ }
+ for (icopy = 0; icopy < 2; icopy++) {
+ for (i = 0; i < ncopy; i++) {
+ if (*ptr == Meta) {
+ ptr++;
+ *dst++ = *ptr++ ^ 32;
+ } else {
+ *dst++ = *ptr++;
+ }
+ }
+ if (!needfullpath)
+ break;
+ /* next time append test string to path so far */
+ ptr = string;
+ ncopy = patstralloc->unmetalen;
+ }
+ }
+ else
+ {
+ patstralloc->alloced = NULL;
+ }
+
+ return patstralloc->alloced;
+}
+
+
+/*
+ * Free memory allocated by patallocstr().
+ */
+
+/**/
+mod_export
+void patfreestr(Patstralloc patstralloc)
+{
+ if (patstralloc->alloced)
+ zfree(patstralloc->alloced,
+ patstralloc->unmetalen + patstralloc->unmetalenp);
+}
+
+
/*
* Test prog against null-terminated, metafied string.
*/
@@ -2030,7 +2155,7 @@ pattrystart(void)
mod_export int
pattry(Patprog prog, char *string)
{
- return pattryrefs(prog, string, -1, -1, 0, NULL, NULL, NULL);
+ return pattryrefs(prog, string, -1, -1, NULL, 0, NULL, NULL, NULL);
}
/*
@@ -2041,9 +2166,11 @@ pattry(Patprog prog, char *string)
/**/
mod_export int
-pattrylen(Patprog prog, char *string, int len, int unmetalen, int offset)
+pattrylen(Patprog prog, char *string, int len, int unmetalen,
+ Patstralloc patstralloc, int offset)
{
- return pattryrefs(prog, string, len, unmetalen, offset, NULL, NULL, NULL);
+ return pattryrefs(prog, string, len, unmetalen, patstralloc, offset,
+ NULL, NULL, NULL);
}
/*
@@ -2055,14 +2182,32 @@ pattrylen(Patprog prog, char *string, int len, int unmetalen, int offset)
* there may be a severe penalty for this if a lot of matching is done
* on one string.
*
- * offset is the position in the original string (not seen by
+ * If patstralloc is not NULL it is used to optimise unmetafication
+ * of a trial string that may be passed (or any substring may be passed) to
+ * pattryrefs multiple times or the same pattern (N.B. so patstralloc
+ * depends on both prog *and* the trial string). This should only be
+ * done if there is no path prefix (pathpos == 0) as otherwise the path
+ * buffer and unmetafied string may not match. To do this,
+ * patallocstr() is callled (use force = 1 to ensure it is alway
+ * unmetafied); paststralloc points to existing storage. When all
+ * pattern matching is done, patfreestr() is called.
+ * patstralloc->alloced and patstralloc->unmetalen contain the
+ * unmetafied string and its length. In that case, the rules for the
+ * earlier arguments change:
+ * - string is an unmetafied string
+ * - stringlen is its unmetafied (i.e. actual) length
+ * - unmetalenin is not used.
+ * string and stringlen may refer to arbitrary substrings of
+ * patstralloc->alloced without any internal modification to patstralloc.
+ *
+ * patoffset is the position in the original string (not seen by
* the pattern module) at which we are trying to match.
* This is added in to the positions recorded in patbeginp and patendp
* when we are looking for substrings. Currently this only happens
* in the parameter substitution code.
*
- * Note this is a character offset, i.e. a metafied character
- * counts as 1.
+ * Note this is a character offset, i.e. a single possibly metafied and
+ * possibly multibyte character counts as 1.
*
* The last three arguments are used to report the positions for the
* backreferences. On entry, *nump should contain the maximum number
@@ -2075,14 +2220,15 @@ pattrylen(Patprog prog, char *string, int len, int unmetalen, int offset)
/**/
mod_export int
-pattryrefs(Patprog prog, char *string, int stringlen, int unmetalen,
- int patoffset,
+pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
+ Patstralloc patstralloc, int patoffset,
int *nump, int *begp, int *endp)
{
- int i, maxnpos = 0, ret, needfullpath, unmetalenp;
+ int i, maxnpos = 0, ret;
int origlen;
- char **sp, **ep, *tryalloced, *ptr;
+ char **sp, **ep, *ptr;
char *progstr = (char *)prog + prog->startoff;
+ struct patstralloc patstralloc_struct;
if (nump) {
maxnpos = *nump;
@@ -2091,86 +2237,38 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalen,
/* inherited from domatch, but why, exactly? */
if (*string == Nularg) {
string++;
- unmetalen--;
+ if (unmetalenin > 0)
+ unmetalenin--;
+ if (stringlen > 0)
+ stringlen--;
}
if (stringlen < 0)
stringlen = strlen(string);
origlen = stringlen;
- patflags = prog->flags;
- /*
- * For a top-level ~-exclusion, we will need the full
- * path to exclude, so copy the path so far and append the
- * current test string.
- */
- needfullpath = (patflags & PAT_HAS_EXCLUDP) && pathpos;
-
- /* Get the length of the full string when unmetafied. */
- if (unmetalen < 0)
- unmetalen = ztrsub(string + stringlen, string);
- if (needfullpath)
- unmetalenp = ztrsub(pathbuf + pathpos, pathbuf);
- else
- unmetalenp = 0;
-
- DPUTS(needfullpath && (patflags & (PAT_PURES|PAT_ANY)),
- "rum sort of file exclusion");
- /*
- * Partly for efficiency, and partly for the convenience of
- * globbing, we don't unmetafy pure string patterns, and
- * there's no reason to if the pattern is just a *.
- */
- if (!(patflags & (PAT_PURES|PAT_ANY))
- && (needfullpath || unmetalen != stringlen)) {
- /*
- * We need to copy if we need to prepend the path so far
- * (in which case we copy both chunks), or if we have
- * Meta characters.
- */
- char *dst;
- int icopy, ncopy;
-
- dst = tryalloced = zalloc(unmetalen + unmetalenp);
-
- if (needfullpath) {
- /* loop twice, copy path buffer first time */
- ptr = pathbuf;
- ncopy = unmetalenp;
- } else {
- /* just loop once, copy string with unmetafication */
- ptr = string;
- ncopy = unmetalen;
- }
- for (icopy = 0; icopy < 2; icopy++) {
- for (i = 0; i < ncopy; i++) {
- if (*ptr == Meta) {
- ptr++;
- *dst++ = *ptr++ ^ 32;
- } else {
- *dst++ = *ptr++;
- }
- }
- if (!needfullpath)
- break;
- /* next time append test string to path so far */
- ptr = string;
- ncopy = unmetalen;
- }
-
- if (needfullpath) {
- patinstart = tryalloced + unmetalenp;
- patinpath = tryalloced;
- } else {
- patinstart = tryalloced;
- patinpath = NULL;
- }
- stringlen = unmetalen;
- } else {
+ if (patstralloc) {
+ DPUTS(!patstralloc->alloced,
+ "External unmetafy didn't actually unmetafy.");
+ DPUTS(patstralloc->unmetalenp,
+ "Ooh-err: pathpos with external unmetafy. I have bad vibes.");
+ patinpath = NULL;
patinstart = string;
- tryalloced = patinpath = NULL;
+ /* stringlen is unmetafied length; unmetalenin is ignored */
+ } else {
+ patstralloc = &patstralloc_struct;
+ if (patallocstr(prog, string, stringlen, unmetalenin, 0, patstralloc)) {
+ patinstart = patstralloc->alloced + patstralloc->unmetalenp;
+ stringlen = patstralloc->unmetalen;
+ } else
+ patinstart = string;
+ if (patstralloc->unmetalenp)
+ patinpath = patstralloc->alloced;
+ else
+ patinpath = NULL;
}
+ patflags = prog->flags;
patinend = patinstart + stringlen;
/*
* From now on we do not require NULL termination of
@@ -2183,7 +2281,30 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalen,
* Either we are testing against a pure string,
* or we can match anything at all.
*/
- int ret;
+ int ret, pstrlen;
+ char *pstr;
+ if (patstralloc->alloced)
+ {
+ /*
+ * Unmetafied; we need pattern sring that's also unmetafied.
+ * We'll cache it in the patstralloc structure.
+ * Note it's on the heap.
+ */
+ if (!patstralloc->progstrunmeta)
+ {
+ patstralloc->progstrunmeta = dupstring(progstr);
+ unmetafy(patstralloc->progstrunmeta,
+ &patstralloc->progstrunmetalen);
+ }
+ pstr = patstralloc->progstrunmeta;
+ pstrlen = patstralloc->progstrunmetalen;
+ }
+ else
+ {
+ /* Metafied. */
+ pstr = progstr;
+ pstrlen = (int)prog->patmlen;
+ }
if (prog->flags & PAT_ANY) {
/*
* Optimisation for a single "*": always matches
@@ -2195,11 +2316,11 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalen,
* Testing a pure string. See if initial
* components match.
*/
- int lendiff = stringlen - prog->patmlen;
+ int lendiff = stringlen - pstrlen;
if (lendiff < 0) {
/* No, the pattern string is too long. */
ret = 0;
- } else if (!memcmp(progstr, patinstart, prog->patmlen)) {
+ } else if (!memcmp(pstr, patinstart, pstrlen)) {
/*
* Initial component matches. Matches either
* if lengths are the same or we are not anchored
@@ -2221,7 +2342,9 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalen,
} else {
/*
* Remember the length in case used for ${..#..} etc.
- * In this case, we didn't unmetafy the string.
+ * In this case, we didn't unmetafy the pattern string
+ * In the orignal structure, but it might be unmetafied
+ * for use with an unmetafied test string.
*/
patinlen = (int)prog->patmlen;
/* if matching files, must update globbing flags */
@@ -2229,16 +2352,26 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalen,
if ((patglobflags & GF_MATCHREF) &&
!(patflags & PAT_FILE)) {
- char *str = ztrduppfx(patinstart, patinlen);
+ char *str;
int mlen;
- /*
- * Count the characters. We're not using CHARSUB()
- * because the string is still metafied.
- */
- MB_METACHARINIT();
- mlen = MB_METASTRLEN2END(patinstart, 0,
- patinstart + patinlen);
+ if (patstralloc->alloced) {
+ /*
+ * Unmetafied: pstrlen contains unmetafied
+ * length in bytes.
+ */
+ str = metafy(patinstart, pstrlen, META_ALLOC);
+ mlen = CHARSUB(patinstart, patinstart + pstrlen);
+ } else {
+ str = ztrduppfx(patinstart, patinlen);
+ /*
+ * Count the characters. We're not using CHARSUB()
+ * because the string is still metafied.
+ */
+ MB_METACHARINIT();
+ mlen = MB_METASTRLEN2END(patinstart, 0,
+ patinstart + patinlen);
+ }
setsparam("MATCH", str);
setiparam("MBEGIN",
@@ -2250,9 +2383,8 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalen,
}
}
- if (tryalloced)
- zfree(tryalloced, unmetalen + unmetalenp);
-
+ if (patstralloc == &patstralloc_struct)
+ patfreestr(patstralloc);
return ret;
} else {
int q = queue_signal_level();
@@ -2289,8 +2421,8 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalen,
}
}
if (!ret) {
- if (tryalloced)
- zfree(tryalloced, unmetalen + unmetalenp);
+ if (patstralloc == &patstralloc_struct)
+ patfreestr(patstralloc);
return 0;
}
@@ -2322,8 +2454,11 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalen,
/*
* Optimization: if we didn't find any Meta characters
* to begin with, we don't need to look for them now.
+ * Only do this if we did the unmetfication internally,
+ * since otherwise it's too hard to work out.
*/
- if (unmetalen != origlen) {
+ if (patstralloc == &patstralloc_struct &&
+ patstralloc->unmetalen != origlen) {
for (ptr = patinstart; ptr < patinput; ptr++)
if (imeta(*ptr))
patinlen++;
@@ -2444,8 +2579,8 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalen,
restore_queue_signals(q);
- if (tryalloced)
- zfree(tryalloced, unmetalen + unmetalenp);
+ if (patstralloc == &patstralloc_struct)
+ patfreestr(patstralloc);
return ret;
}
diff --git a/Src/zsh.h b/Src/zsh.h
index dd0596116..32f2e0cb2 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -491,6 +491,7 @@ typedef struct options *Options;
typedef struct optname *Optname;
typedef struct param *Param;
typedef struct paramdef *Paramdef;
+typedef struct patstralloc *Patstralloc;
typedef struct patprog *Patprog;
typedef struct prepromptfn *Prepromptfn;
typedef struct process *Process;
@@ -1470,6 +1471,15 @@ struct patprog {
char patstartch;
};
+struct patstralloc {
+ int unmetalen; /* Unmetafied length of trial string */
+ int unmetalenp; /* Unmetafied length of path prefix.
+ If 0, no path prefix. */
+ char *alloced; /* Allocated string, may be NULL */
+ char *progstrunmeta; /* Unmetafied pure string in pattern, cached */
+ int progstrunmetalen; /* Length of the foregoing */
+};
+
/* Flags used in pattern matchers (Patprog) and passed down to patcompile */
#define PAT_FILE 0x0001 /* Pattern is a file name */
--
cgit v1.2.3
From d07783628e935daab518509db123141ceb535a28 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Tue, 29 Sep 2015 19:06:43 +0100
Subject: 36700: unmetafy early for parameter match
---
Src/glob.c | 436 ++++++++++++++++++++++++++++++++++------------------------
Src/pattern.c | 20 ++-
Src/zsh.h | 26 ++++
3 files changed, 294 insertions(+), 188 deletions(-)
diff --git a/Src/glob.c b/Src/glob.c
index 8bf73520f..0594f0a82 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2450,29 +2450,46 @@ matchpat(char *a, char *b)
/* please do not laugh at this code. */
/* Having found a match in getmatch, decide what part of string
- * to return. The matched part starts b characters into string s
- * and finishes e characters in: 0 <= b <= e <= strlen(s)
+ * to return. The matched part starts b characters into string imd->ustr
+ * and finishes e characters in: 0 <= b <= e <= imd->ulen on input
* (yes, empty matches should work).
- * fl is a set of the SUB_* matches defined in zsh.h from SUB_MATCH onwards;
- * the lower parts are ignored.
- * replstr is the replacement string for a substitution
+ *
+ * imd->flags is a set of the SUB_* matches defined in zsh.h from
+ * SUB_MATCH onwards; the lower parts are ignored.
+ *
+ * imd->replstr is the replacement string for a substitution
+ *
+ * imd->replstr is metafied and the values put in imd->repllist are metafied.
*/
/**/
static char *
-get_match_ret(char *s, int b, int e, int fl, char *replstr,
- LinkList repllist)
+get_match_ret(Imatchdata imd, int b, int e)
{
- char buf[80], *r, *p, *rr;
- int ll = 0, l = strlen(s), bl = 0, t = 0, i;
-
+ char buf[80], *r, *p, *rr, *replstr = imd->replstr;
+ int ll = 0, bl = 0, t = 0, add = 0, fl = imd->flags, i;
+
+ /* Account for b and e referring to unmetafied string */
+ for (p = imd->ustr; p < imd->ustr + b; p++)
+ if (imeta(*p))
+ add++;
+ b += add;
+ for (; p < imd->ustr + e; p++)
+ if (imeta(*p))
+ add++;
+ e += add;
+ for (; p < imd->ustr + imd->ulen; p++)
+ if (imeta(*p))
+ add++;
+
+ /* Everything now refers to meatfied lengths. */
if (replstr || (fl & SUB_LIST)) {
if (fl & SUB_DOSUBST) {
replstr = dupstring(replstr);
singsub(&replstr);
untokenize(replstr);
}
- if ((fl & (SUB_GLOBAL|SUB_LIST)) && repllist) {
+ if ((fl & (SUB_GLOBAL|SUB_LIST)) && imd->repllist) {
/* We are replacing the chunk, just add this to the list */
Repldata rd = (Repldata)
((fl & SUB_LIST) ? zalloc(sizeof(*rd)) : zhalloc(sizeof(*rd)));
@@ -2480,30 +2497,32 @@ get_match_ret(char *s, int b, int e, int fl, char *replstr,
rd->e = e;
rd->replstr = replstr;
if (fl & SUB_LIST)
- zaddlinknode(repllist, rd);
+ zaddlinknode(imd->repllist, rd);
else
- addlinknode(repllist, rd);
- return s;
+ addlinknode(imd->repllist, rd);
+ return imd->mstr;
}
ll += strlen(replstr);
}
if (fl & SUB_MATCH) /* matched portion */
ll += 1 + (e - b);
if (fl & SUB_REST) /* unmatched portion */
- ll += 1 + (l - (e - b));
+ ll += 1 + (imd->mlen - (e - b));
if (fl & SUB_BIND) {
/* position of start of matched portion */
- sprintf(buf, "%d ", MB_METASTRLEN2END(s, 0, s+b) + 1);
+ sprintf(buf, "%d ", MB_METASTRLEN2END(imd->mstr, 0, imd->mstr+b) + 1);
ll += (bl = strlen(buf));
}
if (fl & SUB_EIND) {
/* position of end of matched portion */
- sprintf(buf + bl, "%d ", MB_METASTRLEN2END(s, 0, s+e) + 1);
+ sprintf(buf + bl, "%d ",
+ MB_METASTRLEN2END(imd->mstr, 0, imd->mstr+e) + 1);
ll += (bl = strlen(buf));
}
if (fl & SUB_LEN) {
/* length of matched portion */
- sprintf(buf + bl, "%d ", MB_METASTRLEN2END(s+b, 0, s+e));
+ sprintf(buf + bl, "%d ", MB_METASTRLEN2END(imd->mstr+b, 0,
+ imd->mstr+e));
ll += (bl = strlen(buf));
}
if (bl)
@@ -2513,7 +2532,7 @@ get_match_ret(char *s, int b, int e, int fl, char *replstr,
if (fl & SUB_MATCH) {
/* copy matched portion to new buffer */
- for (i = b, p = s + b; i < e; i++)
+ for (i = b, p = imd->mstr + b; i < e; i++)
*rr++ = *p++;
t = 1;
}
@@ -2523,12 +2542,12 @@ get_match_ret(char *s, int b, int e, int fl, char *replstr,
if (t)
*rr++ = ' ';
/* there may be unmatched bits at both beginning and end of string */
- for (i = 0, p = s; i < b; i++)
+ for (i = 0, p = imd->mstr; i < b; i++)
*rr++ = *p++;
if (replstr)
for (p = replstr; *p; )
*rr++ = *p++;
- for (i = e, p = s + e; i < l; i++)
+ for (i = e, p = imd->mstr + e; i < imd->mlen; i++)
*rr++ = *p++;
t = 1;
}
@@ -2710,26 +2729,18 @@ set_pat_end(Patprog p, char null_me)
/*
* Increment *tp over character which may be multibyte.
- * Return number of bytes that remain in the character after unmetafication.
+ * Return number of bytes.
+ * All unmetafied here.
*/
/**/
-static int iincchar(char **tp)
+static int iincchar(char **tp, int left)
{
char *t = *tp;
- int mbclen = mb_metacharlenconv(t, NULL);
- int umlen = 0;
-
- while (mbclen--) {
- umlen++;
- if (*t++ == Meta) {
- t++;
- mbclen--;
- }
- }
- *tp = t;
+ int mbclen = mb_charlenconv(t, left, NULL);
+ *tp = t + mbclen;
- return umlen;
+ return mbclen;
}
/**/
@@ -2737,7 +2748,7 @@ static int
igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
LinkList *repllistp)
{
- char *s = *sp, *t, *tmatch;
+ char *s = *sp, *t, *tmatch, *send;
/*
* Note that ioff counts (possibly multibyte) characters in the
* character set (Meta's are not included), while l counts characters in
@@ -2752,36 +2763,52 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
*/
int ioff, l = strlen(*sp), matched = 1, umltot = ztrlen(*sp);
int umlen, nmatches;
- /*
- * List of bits of matches to concatenate with replacement string.
- * The data is a struct repldata. It is not used in cases like
- * ${...//#foo/bar} even though SUB_GLOBAL is set, since the match
- * is anchored. It goes on the heap.
- */
- LinkList repllist = NULL;
+ struct patstralloc patstralloc;
+ struct imatchdata imd;
+
+ (void)patallocstr(p, s, l, umltot, 1, &patstralloc);
+ s = patstralloc.alloced;
+ DPUTS(!s, "forced patallocstr failed");
+ send = s + umltot;
+
+ imd.mstr = *sp;
+ imd.mlen = l;
+ imd.ustr = s;
+ imd.ulen = umltot;
+ imd.flags = fl;
+ imd.replstr = replstr;
+ imd.repllist = NULL;
/* perform must-match test for complex closures */
if (p->mustoff)
{
- /*
- * Yuk. Probably we should rewrite this whole function to
- * use an unmetafied test string.
- *
- * Use META_HEAPDUP because we need a terminating NULL.
- */
- char *muststr = metafy((char *)p + p->mustoff,
- p->patmlen, META_HEAPDUP);
+ char *muststr = (char *)p + p->mustoff;
- if (!strstr(s, muststr))
- matched = 0;
+ matched = 0;
+ if (p->patmlen <= umltot)
+ {
+ for (t = s; t <= send - p->patmlen; t++)
+ {
+ if (!memcmp(muststr, t, p->patmlen)) {
+ matched = 1;
+ break;
+ }
+ }
+ }
}
/* in case we used the prog before... */
p->flags &= ~(PAT_NOTSTART|PAT_NOTEND);
if (fl & SUB_ALL) {
- int i = matched && pattrylen(p, s, -1, -1, NULL, 0);
- *sp = get_match_ret(*sp, 0, i ? l : 0, fl, i ? replstr : 0, NULL);
+ int i = matched && pattrylen(p, s, umltot, 0, &patstralloc, 0);
+ if (!i) {
+ /* Perform under no-match conditions */
+ umltot = 0;
+ imd.replstr = NULL;
+ }
+ *sp = get_match_ret(&imd, 0, umltot);
+ patfreestr(&patstralloc);
if (! **sp && (((fl & SUB_MATCH) && !i) || ((fl & SUB_REST) && i)))
return 0;
return 1;
@@ -2809,25 +2836,27 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
* Largest/smallest possible match at head of string.
* First get the longest match...
*/
- if (pattrylen(p, s, -1, -1, NULL, 0)) {
- /* patmatchlen returns metafied length, as we need */
+ if (pattrylen(p, s, umltot, 0, &patstralloc, 0)) {
+ /* patmatchlen returns unmetafied length in this case */
int mlen = patmatchlen();
if (!(fl & SUB_LONG) && !(p->flags & PAT_PURES)) {
+ send = s + mlen;
/*
* ... now we know whether it's worth looking for the
* shortest, which we do by brute force.
*/
mb_charinit();
- for (t = s, umlen = 0; t < s + mlen; ) {
+ for (t = s, umlen = 0; t < send; ) {
set_pat_end(p, *t);
- if (pattrylen(p, s, t - s, umlen, NULL, 0)) {
+ if (pattrylen(p, s, umlen, 0, &patstralloc, 0)) {
mlen = patmatchlen();
break;
}
- umlen += iincchar(&t);
+ umlen += iincchar(&t, send - t);
}
}
- *sp = get_match_ret(*sp, 0, mlen, fl, replstr, NULL);
+ *sp = get_match_ret(&imd, 0, mlen);
+ patfreestr(&patstralloc);
return 1;
}
break;
@@ -2845,20 +2874,23 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
*/
mb_charinit();
tmatch = NULL;
- for (ioff = 0, t = s, umlen = umltot; t < s + l; ioff++) {
+ for (ioff = 0, t = s, umlen = umltot; t < send; ioff++) {
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, NULL, ioff))
+ if (pattrylen(p, t, umlen, 0, &patstralloc, ioff))
tmatch = t;
if (fl & SUB_START)
break;
- umlen -= iincchar(&t);
+ umlen -= iincchar(&t, send - t);
}
if (tmatch) {
- *sp = get_match_ret(*sp, tmatch - s, l, fl, replstr, NULL);
+ *sp = get_match_ret(&imd, tmatch - s, umltot);
+ patfreestr(&patstralloc);
return 1;
}
- if (!(fl & SUB_START) && pattrylen(p, s + l, 0, 0, NULL, ioff)) {
- *sp = get_match_ret(*sp, l, l, fl, replstr, NULL);
+ if (!(fl & SUB_START) && pattrylen(p, s + umltot, 0, 0,
+ &patstralloc, ioff)) {
+ *sp = get_match_ret(&imd, umltot, umltot);
+ patfreestr(&patstralloc);
return 1;
}
break;
@@ -2868,18 +2900,21 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
* move forward along string until we get a match. *
* Again there's no optimisation. */
mb_charinit();
- for (ioff = 0, t = s, umlen = umltot; t < s + l; ioff++) {
+ for (ioff = 0, t = s, umlen = umltot; t < send ; ioff++) {
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, NULL, ioff)) {
- *sp = get_match_ret(*sp, t-s, l, fl, replstr, NULL);
+ if (pattrylen(p, t, umlen, 0, &patstralloc, ioff)) {
+ *sp = get_match_ret(&imd, t-s, umltot);
+ patfreestr(&patstralloc);
return 1;
}
if (fl & SUB_START)
break;
- umlen -= iincchar(&t);
+ umlen -= iincchar(&t, send - t);
}
- if (!(fl & SUB_START) && pattrylen(p, s + l, 0, 0, NULL, ioff)) {
- *sp = get_match_ret(*sp, l, l, fl, replstr, NULL);
+ if (!(fl & SUB_START) && pattrylen(p, send, 0, 0,
+ &patstralloc, ioff)) {
+ *sp = get_match_ret(&imd, umltot, umltot);
+ patfreestr(&patstralloc);
return 1;
}
break;
@@ -2887,18 +2922,20 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
case SUB_SUBSTR:
/* Smallest at start, but matching substrings. */
set_pat_start(p, l);
- if (!(fl & SUB_GLOBAL) && pattrylen(p, s + l, -1, -1, NULL, 0) &&
+ if (!(fl & SUB_GLOBAL) &&
+ pattrylen(p, send, 0, 0, &patstralloc, 0) &&
!--n) {
- *sp = get_match_ret(*sp, 0, 0, fl, replstr, NULL);
+ *sp = get_match_ret(&imd, 0, 0);
+ patfreestr(&patstralloc);
return 1;
} /* fall through */
case (SUB_SUBSTR|SUB_LONG):
/* longest or smallest at start with substrings */
t = s;
if (fl & SUB_GLOBAL) {
- repllist = (fl & SUB_LIST) ? znewlinklist() : newlinklist();
+ imd.repllist = (fl & SUB_LIST) ? znewlinklist() : newlinklist();
if (repllistp)
- *repllistp = repllist;
+ *repllistp = imd.repllist;
}
ioff = 0; /* offset into string */
umlen = umltot;
@@ -2906,10 +2943,10 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
do {
/* loop over all matches for global substitution */
matched = 0;
- for (; t < s + l; ioff++) {
+ for (; t < send; ioff++) {
/* Find the longest match from this position. */
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, NULL, ioff)) {
+ if (pattrylen(p, t, umlen, 0, &patstralloc, ioff)) {
char *mpos = t + patmatchlen();
if (!(fl & SUB_LONG) && !(p->flags & PAT_PURES)) {
char *ptr;
@@ -2923,19 +2960,18 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
*/
for (ptr = t, umlen2 = 0; ptr < mpos;) {
set_pat_end(p, *ptr);
- if (pattrylen(p, t, ptr - t, umlen2,
- NULL, ioff)) {
+ if (pattrylen(p, t, umlen2, 0,
+ &patstralloc, ioff)) {
mpos = t + patmatchlen();
break;
}
- umlen2 += iincchar(&ptr);
+ umlen2 += iincchar(&ptr, mpos - ptr);
}
}
if (!--n || (n <= 0 && (fl & SUB_GLOBAL))) {
- *sp = get_match_ret(*sp, t-s, mpos-s, fl,
- replstr, repllist);
+ *sp = get_match_ret(&imd, t-s, mpos-s);
if (mpos == t)
- mpos += mb_metacharlenconv(mpos, NULL);
+ mpos += mb_charlenconv(mpos, send - mpos, NULL);
}
if (!(fl & SUB_GLOBAL)) {
if (n) {
@@ -2945,9 +2981,10 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
* the next character, even if it overlaps
* with what we just found.
*/
- umlen -= iincchar(&t);
+ umlen -= iincchar(&t, send - t);
continue;
} else {
+ patfreestr(&patstralloc);
return 1;
}
}
@@ -2958,11 +2995,11 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
matched = 1;
while (t < mpos) {
ioff++;
- umlen -= iincchar(&t);
+ umlen -= iincchar(&t, send - t);
}
break;
}
- umlen -= iincchar(&t);
+ umlen -= iincchar(&t, send - t);
}
} while (matched);
/*
@@ -2972,8 +3009,9 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
*/
set_pat_start(p, l);
if ((fl & (SUB_LONG|SUB_GLOBAL)) == SUB_LONG &&
- pattrylen(p, s + l, -1, -1, NULL, 0) && !--n) {
- *sp = get_match_ret(*sp, 0, 0, fl, replstr, repllist);
+ pattrylen(p, send, 0, 0, &patstralloc, 0) && !--n) {
+ *sp = get_match_ret(&imd, 0, 0);
+ patfreestr(&patstralloc);
return 1;
}
break;
@@ -2983,8 +3021,10 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
/* Longest/shortest at end, matching substrings. */
if (!(fl & SUB_LONG)) {
set_pat_start(p, l);
- if (pattrylen(p, s + l, 0, 0, NULL, umltot) && !--n) {
- *sp = get_match_ret(*sp, l, l, fl, replstr, NULL);
+ if (pattrylen(p, send, 0, 0, &patstralloc, umltot) &&
+ !--n) {
+ *sp = get_match_ret(&imd, umltot, umltot);
+ patfreestr(&patstralloc);
return 1;
}
}
@@ -3001,13 +3041,13 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
nmatches = 0;
tmatch = NULL;
mb_charinit();
- for (ioff = 0, t = s, umlen = umltot; t < s + l; ioff++) {
+ for (ioff = 0, t = s, umlen = umltot; t < send; ioff++) {
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, NULL, ioff)) {
+ if (pattrylen(p, t, umlen, 0, &patstralloc, ioff)) {
nmatches++;
tmatch = t;
}
- umlen -= iincchar(&t);
+ umlen -= iincchar(&t, send - t);
}
if (nmatches) {
char *mpos;
@@ -3017,14 +3057,14 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
*/
n = nmatches - n;
mb_charinit();
- for (ioff = 0, t = s, umlen = umltot; t < s + l; ioff++) {
+ for (ioff = 0, t = s, umlen = umltot; t < send; ioff++) {
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, NULL, ioff) &&
+ if (pattrylen(p, t, umlen, 0, &patstralloc, ioff) &&
!n--) {
tmatch = t;
break;
}
- umlen -= iincchar(&t);
+ umlen -= iincchar(&t, send - t);
}
}
mpos = tmatch + patmatchlen();
@@ -3032,29 +3072,31 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
if (!(fl & SUB_LONG) && !(p->flags & PAT_PURES)) {
for (t = tmatch, umlen = 0; t < mpos; ) {
set_pat_end(p, *t);
- if (pattrylen(p, tmatch, t - tmatch, umlen,
- NULL, ioff)) {
+ if (pattrylen(p, tmatch, umlen, 0,
+ &patstralloc, ioff)) {
mpos = tmatch + patmatchlen();
break;
}
- umlen += iincchar(&t);
+ umlen += iincchar(&t, mpos - t);
}
}
- *sp = get_match_ret(*sp, tmatch-s, mpos-s, fl,
- replstr, NULL);
+ *sp = get_match_ret(&imd, tmatch-s, mpos-s);
+ patfreestr(&patstralloc);
return 1;
}
set_pat_start(p, l);
- if ((fl & SUB_LONG) && pattrylen(p, s + l, 0, 0, NULL, umltot) &&
+ if ((fl & SUB_LONG) && pattrylen(p, send, 0, 0,
+ &patstralloc, umltot) &&
!--n) {
- *sp = get_match_ret(*sp, l, l, fl, replstr, NULL);
+ *sp = get_match_ret(&imd, umltot, umltot);
+ patfreestr(&patstralloc);
return 1;
}
break;
}
}
- if (repllist && nonempty(repllist)) {
+ if (imd.repllist && nonempty(imd.repllist)) {
/* Put all the bits of a global search and replace together. */
LinkNode nd;
Repldata rd;
@@ -3062,10 +3104,15 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
char *ptr, *start;
int i;
+ /*
+ * Use metafied string again.
+ * Results from get_match_ret in repllist are all metafied.
+ */
+ s = *sp;
if (!(fl & SUB_LIST)) {
lleft = 0; /* size of returned string */
- i = 0; /* start of last chunk we got from *sp */
- for (nd = firstnode(repllist); nd; incnode(nd)) {
+ i = 0; /* start of last chunk we got from *sp */
+ for (nd = firstnode(imd.repllist); nd; incnode(nd)) {
rd = (Repldata) getdata(nd);
lleft += rd->b - i; /* previous chunk of *sp */
lleft += strlen(rd->replstr); /* the replaced bit */
@@ -3074,7 +3121,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
lleft += l - i; /* final chunk from *sp */
start = t = zhalloc(lleft+1);
i = 0;
- for (nd = firstnode(repllist); nd; incnode(nd)) {
+ for (nd = firstnode(imd.repllist); nd; incnode(nd)) {
rd = (Repldata) getdata(nd);
memcpy(t, s + i, rd->b - i);
t += rd->b - i;
@@ -3087,13 +3134,19 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
start[lleft] = '\0';
*sp = (char *)start;
}
+ patfreestr(&patstralloc);
return 1;
}
- if (fl & SUB_LIST) /* safety: don't think this can happen */
+ if (fl & SUB_LIST) { /* safety: don't think this can happen */
+ patfreestr(&patstralloc);
return 0;
+ }
/* munge the whole string: no match, so no replstr */
- *sp = get_match_ret(*sp, 0, 0, fl, 0, 0);
+ imd.replstr = NULL;
+ imd.repllist = NULL;
+ *sp = get_match_ret(&imd, 0, 0);
+ patfreestr(&patstralloc);
return (fl & SUB_RETFAIL) ? 0 : 1;
}
@@ -3111,7 +3164,7 @@ static int
igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
LinkList *repllistp)
{
- char *s = *sp, *t;
+ char *s = *sp, *t, *send;
/*
* Note that ioff and uml count characters in the character
* set (Meta's are not included), while l counts characters in the
@@ -3119,36 +3172,48 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
* lengths.
*/
int ioff, l = strlen(*sp), uml = ztrlen(*sp), matched = 1, umlen;
- /*
- * List of bits of matches to concatenate with replacement string.
- * The data is a struct repldata. It is not used in cases like
- * ${...//#foo/bar} even though SUB_GLOBAL is set, since the match
- * is anchored. It goes on the heap.
- */
- LinkList repllist = NULL;
+ struct patstralloc patstralloc;
+ struct imatchdata imd;
+
+ (void)patallocstr(p, s, l, uml, 1, &patstralloc);
+ s = patstralloc.alloced;
+ DPUTS(!s, "forced patallocstr failed");
+ send = s + uml;
+
+ imd.mstr = *sp;
+ imd.mlen = l;
+ imd.ustr = s;
+ imd.ulen = uml;
+ imd.flags = fl;
+ imd.replstr = replstr;
+ imd.repllist = NULL;
/* perform must-match test for complex closures */
if (p->mustoff)
{
- /*
- * Yuk. Probably we should rewrite this whole function to
- * use an unmetafied test string.
- *
- * Use META_HEAPDUP because we need a terminating NULL.
- */
- char *muststr = metafy((char *)p + p->mustoff,
- p->patmlen, META_HEAPDUP);
+ char *muststr = (char *)p + p->mustoff;
- if (!strstr(s, muststr))
- matched = 0;
+ matched = 0;
+ if (p->patmlen <= uml)
+ {
+ for (t = s; t <= send - p->patmlen; t++)
+ {
+ if (!memcmp(muststr, t, p->patmlen)) {
+ matched = 1;
+ break;
+ }
+ }
+ }
}
/* in case we used the prog before... */
p->flags &= ~(PAT_NOTSTART|PAT_NOTEND);
if (fl & SUB_ALL) {
- int i = matched && pattry(p, s);
- *sp = get_match_ret(*sp, 0, i ? l : 0, fl, i ? replstr : 0, NULL);
+ int i = matched && pattrylen(p, s, uml, 0, &patstralloc, 0);
+ if (!i)
+ imd.replstr = NULL;
+ *sp = get_match_ret(&imd, 0, i ? l : 0);
if (! **sp && (((fl & SUB_MATCH) && !i) || ((fl & SUB_REST) && i)))
return 0;
return 1;
@@ -3161,23 +3226,25 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
* Largest/smallest possible match at head of string.
* First get the longest match...
*/
- if (pattry(p, s)) {
+ if (pattrylen(p, s, uml, 0, &patstralloc, 0)) {
/* patmatchlen returns metafied length, as we need */
int mlen = patmatchlen();
if (!(fl & SUB_LONG) && !(p->flags & PAT_PURES)) {
+ send = s + mlen;
/*
* ... now we know whether it's worth looking for the
* shortest, which we do by brute force.
*/
for (t = s, umlen = 0; t < s + mlen; METAINC(t), umlen++) {
set_pat_end(p, *t);
- if (pattrylen(p, s, t - s, umlen, NULL, 0)) {
+ if (pattrylen(p, s, umlen, 0, &patstralloc, 0)) {
mlen = patmatchlen();
break;
}
}
}
- *sp = get_match_ret(*sp, 0, mlen, fl, replstr, NULL);
+ *sp = get_match_ret(&imd, 0, mlen);
+ patfreestr(&patstralloc);
return 1;
}
break;
@@ -3186,17 +3253,13 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
/* Smallest possible match at tail of string: *
* move back down string until we get a match. *
* There's no optimization here. */
- for (ioff = uml, t = s + l, umlen = 0; t >= s;
+ for (ioff = uml, t = send, umlen = 0; t >= s;
t--, ioff--, umlen++) {
- if (t > s && t[-1] == Meta)
- t--;
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, NULL, ioff)) {
- *sp = get_match_ret(*sp, t - s, l, fl, replstr, NULL);
+ if (pattrylen(p, t, umlen, 0, &patstralloc, ioff)) {
+ *sp = get_match_ret(&imd, t - s, uml);
return 1;
}
- if (t > s+1 && t[-2] == Meta)
- t--;
}
break;
@@ -3204,61 +3267,59 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
/* Largest possible match at tail of string: *
* move forward along string until we get a match. *
* Again there's no optimisation. */
- for (ioff = 0, t = s, umlen = uml; t < s + l;
- ioff++, METAINC(t), umlen--) {
+ for (ioff = 0, t = s, umlen = uml; t < send;
+ ioff++, t++, umlen--) {
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, NULL, ioff)) {
- *sp = get_match_ret(*sp, t-s, l, fl, replstr, NULL);
+ if (pattrylen(p, t, send - t, umlen, &patstralloc, ioff)) {
+ *sp = get_match_ret(&imd, t-s, uml);
return 1;
}
- if (*t == Meta)
- t++;
}
break;
case SUB_SUBSTR:
/* Smallest at start, but matching substrings. */
set_pat_start(p, l);
- if (!(fl & SUB_GLOBAL) && pattry(p, s + l) && !--n) {
- *sp = get_match_ret(*sp, 0, 0, fl, replstr, NULL);
+ if (!(fl & SUB_GLOBAL) &&
+ pattrylen(p, send, 0, 0, &patstralloc, 0) && !--n) {
+ *sp = get_match_ret(&imd, 0, 0);
return 1;
} /* fall through */
case (SUB_SUBSTR|SUB_LONG):
/* longest or smallest at start with substrings */
t = s;
if (fl & SUB_GLOBAL) {
- repllist = newlinklist();
+ imd.repllist = newlinklist();
if (repllistp)
- *repllistp = repllist;
+ *repllistp = imd.repllist;
}
ioff = 0; /* offset into string */
umlen = uml;
do {
/* loop over all matches for global substitution */
matched = 0;
- for (; t < s + l; METAINC(t), ioff++, umlen--) {
+ for (; t < send; t++, ioff++, umlen--) {
/* Find the longest match from this position. */
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, NULL, ioff)) {
+ if (pattrylen(p, t, send - t, umlen, &patstralloc, ioff)) {
char *mpos = t + patmatchlen();
if (!(fl & SUB_LONG) && !(p->flags & PAT_PURES)) {
char *ptr;
int umlen2;
for (ptr = t, umlen2 = 0; ptr < mpos;
- METAINC(ptr), umlen2++) {
+ ptr++, umlen2++) {
set_pat_end(p, *ptr);
if (pattrylen(p, t, ptr - t, umlen2,
- NULL, ioff)) {
+ &patstralloc, ioff)) {
mpos = t + patmatchlen();
break;
}
}
}
if (!--n || (n <= 0 && (fl & SUB_GLOBAL))) {
- *sp = get_match_ret(*sp, t-s, mpos-s, fl,
- replstr, repllist);
+ *sp = get_match_ret(&imd, t-s, mpos-s);
if (mpos == t)
- METAINC(mpos);
+ mpos++;
}
if (!(fl & SUB_GLOBAL)) {
if (n) {
@@ -3278,13 +3339,13 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
* which is already marked for replacement.
*/
matched = 1;
- for ( ; t < mpos; t++, ioff++, umlen--)
- if (*t == Meta)
- t++;
+ while (t < mpos) {
+ ioff++;
+ umlen--;
+ t++;
+ }
break;
}
- if (*t == Meta)
- t++;
}
} while (matched);
/*
@@ -3294,8 +3355,9 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
*/
set_pat_start(p, l);
if ((fl & (SUB_LONG|SUB_GLOBAL)) == SUB_LONG &&
- pattry(p, s + l) && !--n) {
- *sp = get_match_ret(*sp, 0, 0, fl, replstr, repllist);
+ pattrylen(p, send, 0, 0, &patstralloc, 0) && !--n) {
+ *sp = get_match_ret(&imd, 0, 0);
+ patfreestr(&patstralloc);
return 1;
}
break;
@@ -3305,47 +3367,50 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
/* Longest/shortest at end, matching substrings. */
if (!(fl & SUB_LONG)) {
set_pat_start(p, l);
- if (pattrylen(p, s + l, 0, 0, NULL, uml) && !--n) {
- *sp = get_match_ret(*sp, l, l, fl, replstr, NULL);
+ if (pattrylen(p, send, 0, 0, &patstralloc, uml) && !--n) {
+ *sp = get_match_ret(&imd, uml, uml);
+ patfreestr(&patstralloc);
return 1;
}
}
- for (ioff = uml - 1, t = s + l - 1, umlen = 1; t >= s;
+ for (ioff = uml - 1, t = send - 1, umlen = 1; t >= s;
t--, ioff--, umlen++) {
- if (t > s && t[-1] == Meta)
- t--;
set_pat_start(p, t-s);
- if (pattrylen(p, t, s + l - t, umlen, NULL, ioff) && !--n) {
+ if (pattrylen(p, t, send - t, umlen, &patstralloc, ioff) &&
+ !--n) {
/* Found the longest match */
char *mpos = t + patmatchlen();
if (!(fl & SUB_LONG) && !(p->flags & PAT_PURES)) {
char *ptr;
int umlen2;
for (ptr = t, umlen2 = 0; ptr < mpos;
- METAINC(ptr), umlen2++) {
+ ptr++, umlen2++) {
set_pat_end(p, *ptr);
- if (pattrylen(p, t, ptr - t, umlen2, NULL, ioff)) {
+ if (pattrylen(p, t, umlen2, 0, &patstralloc,
+ ioff)) {
mpos = t + patmatchlen();
break;
}
}
}
- *sp = get_match_ret(*sp, t-s, mpos-s, fl,
- replstr, NULL);
+ *sp = get_match_ret(&imd, t-s, mpos-s);
+ patfreestr(&patstralloc);
return 1;
}
}
set_pat_start(p, l);
- if ((fl & SUB_LONG) && pattrylen(p, s + l, 0, 0, NULL, uml) &&
+ if ((fl & SUB_LONG) && pattrylen(p, send, 0, 0,
+ &patstralloc, uml) &&
!--n) {
- *sp = get_match_ret(*sp, l, l, fl, replstr, NULL);
+ *sp = get_match_ret(&imd, uml, uml);
+ patfreestr(&patstralloc);
return 1;
}
break;
}
}
- if (repllist && nonempty(repllist)) {
+ if (imd.repllist && nonempty(imd.repllist)) {
/* Put all the bits of a global search and replace together. */
LinkNode nd;
Repldata rd;
@@ -3353,8 +3418,13 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
char *ptr, *start;
int i;
+ /*
+ * Use metafied string again.
+ * Results from get_match_ret in repllist are all metafied.
+ */
+ s = *sp;
i = 0; /* start of last chunk we got from *sp */
- for (nd = firstnode(repllist); nd; incnode(nd)) {
+ for (nd = firstnode(imd.repllist); nd; incnode(nd)) {
rd = (Repldata) getdata(nd);
lleft += rd->b - i; /* previous chunk of *sp */
lleft += strlen(rd->replstr); /* the replaced bit */
@@ -3363,7 +3433,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
lleft += l - i; /* final chunk from *sp */
start = t = zhalloc(lleft+1);
i = 0;
- for (nd = firstnode(repllist); nd; incnode(nd)) {
+ for (nd = firstnode(imd.repllist); nd; incnode(nd)) {
rd = (Repldata) getdata(nd);
memcpy(t, s + i, rd->b - i);
t += rd->b - i;
@@ -3375,11 +3445,15 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
memcpy(t, s + i, l - i);
start[lleft] = '\0';
*sp = (char *)start;
+ patfreestr(&patstralloc);
return 1;
}
/* munge the whole string: no match, so no replstr */
- *sp = get_match_ret(*sp, 0, 0, fl, 0, 0);
+ imd.replstr = NULL;
+ imd.repllist = NULL;
+ *sp = get_match_ret(&imd, 0, 0);
+ patfreestr(&patstralloc);
return 1;
}
diff --git a/Src/pattern.c b/Src/pattern.c
index 03ba37d92..8de372c9e 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -2204,7 +2204,10 @@ pattrylen(Patprog prog, char *string, int len, int unmetalen,
* the pattern module) at which we are trying to match.
* This is added in to the positions recorded in patbeginp and patendp
* when we are looking for substrings. Currently this only happens
- * in the parameter substitution code.
+ * in the parameter substitution code. It refers to a real character
+ * offset, i.e. is already in the form ready for presentation to the
+ * general public --- this is necessary as we don't have the
+ * information to convert it down here.
*
* Note this is a character offset, i.e. a single possibly metafied and
* possibly multibyte character counts as 1.
@@ -2292,7 +2295,8 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
*/
if (!patstralloc->progstrunmeta)
{
- patstralloc->progstrunmeta = dupstring(progstr);
+ patstralloc->progstrunmeta =
+ dupstrpfx(progstr, (int)prog->patmlen);
unmetafy(patstralloc->progstrunmeta,
&patstralloc->progstrunmetalen);
}
@@ -2346,7 +2350,7 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
* In the orignal structure, but it might be unmetafied
* for use with an unmetafied test string.
*/
- patinlen = (int)prog->patmlen;
+ patinlen = pstrlen;
/* if matching files, must update globbing flags */
patglobflags = prog->globend;
@@ -2360,7 +2364,7 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
* Unmetafied: pstrlen contains unmetafied
* length in bytes.
*/
- str = metafy(patinstart, pstrlen, META_ALLOC);
+ str = metafy(patinstart, pstrlen, META_DUP);
mlen = CHARSUB(patinstart, patinstart + pstrlen);
} else {
str = ztrduppfx(patinstart, patinlen);
@@ -2454,8 +2458,8 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
/*
* Optimization: if we didn't find any Meta characters
* to begin with, we don't need to look for them now.
- * Only do this if we did the unmetfication internally,
- * since otherwise it's too hard to work out.
+ *
+ * For patstralloc pased in, we want the unmetafied length.
*/
if (patstralloc == &patstralloc_struct &&
patstralloc->unmetalen != origlen) {
@@ -2588,7 +2592,9 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
/*
* Return length of previous succesful match. This is
- * in metafied bytes, i.e. includes a count of Meta characters.
+ * in metafied bytes, i.e. includes a count of Meta characters,
+ * unless the match was done on an unmetafied string using
+ * a patstralloc stuct, in which case it, too is unmetafed.
* Unusual and futile attempt at modular encapsulation.
*/
diff --git a/Src/zsh.h b/Src/zsh.h
index 32f2e0cb2..15fa5e417 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -480,6 +480,7 @@ typedef struct heap *Heap;
typedef struct heapstack *Heapstack;
typedef struct histent *Histent;
typedef struct hookdef *Hookdef;
+typedef struct imatchdata *Imatchdata;
typedef struct jobfile *Jobfile;
typedef struct job *Job;
typedef struct linkedmod *Linkedmod;
@@ -1593,6 +1594,31 @@ typedef struct zpc_disables_save *Zpc_disables_save;
/* Range: token followed by the (possibly multibyte) start and end */
#define PP_RANGE 21
+/*
+ * Argument to get_match_ret() in glob.c
+ */
+struct imatchdata {
+ /* Metafied trial string */
+ char *mstr;
+ /* Its length */
+ int mlen;
+ /* Unmetafied string */
+ char *ustr;
+ /* Its length */
+ int ulen;
+ /* Flags (SUB_*) */
+ int flags;
+ /* Replacement string (metafied) */
+ char *replstr;
+ /*
+ * List of bits of matches to concatenate with replacement string.
+ * The data is a struct repldata. It is not used in cases like
+ * ${...//#foo/bar} even though SUB_GLOBAL is set, since the match
+ * is anchored. It goes on the heap.
+ */
+ LinkList repllist;
+};
+
/* Globbing flags: lower 8 bits gives approx count */
#define GF_LCMATCHUC 0x0100
#define GF_IGNCASE 0x0200
--
cgit v1.2.3
From a5a6c58ff883edc202bd0103af1e09848c9b8fe7 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Tue, 29 Sep 2015 13:36:43 -0700
Subject: unposted: fix typo in comment.
---
Src/glob.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Src/glob.c b/Src/glob.c
index 0594f0a82..d9986634a 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2482,7 +2482,7 @@ get_match_ret(Imatchdata imd, int b, int e)
if (imeta(*p))
add++;
- /* Everything now refers to meatfied lengths. */
+ /* Everything now refers to metafied lengths. */
if (replstr || (fl & SUB_LIST)) {
if (fl & SUB_DOSUBST) {
replstr = dupstring(replstr);
--
cgit v1.2.3
From 533658730745ae6261f9552aba01dc5346405d30 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Wed, 30 Sep 2015 10:19:16 +0100
Subject: 36711: Allocate unmetafied pattern trial string on the heap
---
ChangeLog | 5 +++++
Src/glob.c | 25 -------------------------
Src/pattern.c | 34 +++++++---------------------------
3 files changed, 12 insertions(+), 52 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 38e0e4627..56e725cf0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-30 Peter Stephenson
+
+ * 36711: Src/glob.c, Src/pattern.c: Memory for early unmetafied
+ pattern trial string is on the heap.
+
2015-09-28 Peter Stephenson
* 36682: Src/glob.c, Src/pattern.c, Src/zsh.h,
diff --git a/Src/glob.c b/Src/glob.c
index d9986634a..24e60d0c5 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2478,9 +2478,6 @@ get_match_ret(Imatchdata imd, int b, int e)
if (imeta(*p))
add++;
e += add;
- for (; p < imd->ustr + imd->ulen; p++)
- if (imeta(*p))
- add++;
/* Everything now refers to metafied lengths. */
if (replstr || (fl & SUB_LIST)) {
@@ -2808,7 +2805,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
imd.replstr = NULL;
}
*sp = get_match_ret(&imd, 0, umltot);
- patfreestr(&patstralloc);
if (! **sp && (((fl & SUB_MATCH) && !i) || ((fl & SUB_REST) && i)))
return 0;
return 1;
@@ -2856,7 +2852,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
}
}
*sp = get_match_ret(&imd, 0, mlen);
- patfreestr(&patstralloc);
return 1;
}
break;
@@ -2884,13 +2879,11 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
}
if (tmatch) {
*sp = get_match_ret(&imd, tmatch - s, umltot);
- patfreestr(&patstralloc);
return 1;
}
if (!(fl & SUB_START) && pattrylen(p, s + umltot, 0, 0,
&patstralloc, ioff)) {
*sp = get_match_ret(&imd, umltot, umltot);
- patfreestr(&patstralloc);
return 1;
}
break;
@@ -2904,7 +2897,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
set_pat_start(p, t-s);
if (pattrylen(p, t, umlen, 0, &patstralloc, ioff)) {
*sp = get_match_ret(&imd, t-s, umltot);
- patfreestr(&patstralloc);
return 1;
}
if (fl & SUB_START)
@@ -2914,7 +2906,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
if (!(fl & SUB_START) && pattrylen(p, send, 0, 0,
&patstralloc, ioff)) {
*sp = get_match_ret(&imd, umltot, umltot);
- patfreestr(&patstralloc);
return 1;
}
break;
@@ -2926,7 +2917,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
pattrylen(p, send, 0, 0, &patstralloc, 0) &&
!--n) {
*sp = get_match_ret(&imd, 0, 0);
- patfreestr(&patstralloc);
return 1;
} /* fall through */
case (SUB_SUBSTR|SUB_LONG):
@@ -2984,7 +2974,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
umlen -= iincchar(&t, send - t);
continue;
} else {
- patfreestr(&patstralloc);
return 1;
}
}
@@ -3011,7 +3000,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
if ((fl & (SUB_LONG|SUB_GLOBAL)) == SUB_LONG &&
pattrylen(p, send, 0, 0, &patstralloc, 0) && !--n) {
*sp = get_match_ret(&imd, 0, 0);
- patfreestr(&patstralloc);
return 1;
}
break;
@@ -3024,7 +3012,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
if (pattrylen(p, send, 0, 0, &patstralloc, umltot) &&
!--n) {
*sp = get_match_ret(&imd, umltot, umltot);
- patfreestr(&patstralloc);
return 1;
}
}
@@ -3081,7 +3068,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
}
}
*sp = get_match_ret(&imd, tmatch-s, mpos-s);
- patfreestr(&patstralloc);
return 1;
}
set_pat_start(p, l);
@@ -3089,7 +3075,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
&patstralloc, umltot) &&
!--n) {
*sp = get_match_ret(&imd, umltot, umltot);
- patfreestr(&patstralloc);
return 1;
}
break;
@@ -3134,11 +3119,9 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
start[lleft] = '\0';
*sp = (char *)start;
}
- patfreestr(&patstralloc);
return 1;
}
if (fl & SUB_LIST) { /* safety: don't think this can happen */
- patfreestr(&patstralloc);
return 0;
}
@@ -3146,7 +3129,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
imd.replstr = NULL;
imd.repllist = NULL;
*sp = get_match_ret(&imd, 0, 0);
- patfreestr(&patstralloc);
return (fl & SUB_RETFAIL) ? 0 : 1;
}
@@ -3244,7 +3226,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
}
}
*sp = get_match_ret(&imd, 0, mlen);
- patfreestr(&patstralloc);
return 1;
}
break;
@@ -3357,7 +3338,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
if ((fl & (SUB_LONG|SUB_GLOBAL)) == SUB_LONG &&
pattrylen(p, send, 0, 0, &patstralloc, 0) && !--n) {
*sp = get_match_ret(&imd, 0, 0);
- patfreestr(&patstralloc);
return 1;
}
break;
@@ -3369,7 +3349,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
set_pat_start(p, l);
if (pattrylen(p, send, 0, 0, &patstralloc, uml) && !--n) {
*sp = get_match_ret(&imd, uml, uml);
- patfreestr(&patstralloc);
return 1;
}
}
@@ -3394,7 +3373,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
}
}
*sp = get_match_ret(&imd, t-s, mpos-s);
- patfreestr(&patstralloc);
return 1;
}
}
@@ -3403,7 +3381,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
&patstralloc, uml) &&
!--n) {
*sp = get_match_ret(&imd, uml, uml);
- patfreestr(&patstralloc);
return 1;
}
break;
@@ -3445,7 +3422,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
memcpy(t, s + i, l - i);
start[lleft] = '\0';
*sp = (char *)start;
- patfreestr(&patstralloc);
return 1;
}
@@ -3453,7 +3429,6 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
imd.replstr = NULL;
imd.repllist = NULL;
*sp = get_match_ret(&imd, 0, 0);
- patfreestr(&patstralloc);
return 1;
}
diff --git a/Src/pattern.c b/Src/pattern.c
index 8de372c9e..68a340919 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -2028,8 +2028,8 @@ pattrystart(void)
*
* Unmetafy a trial string for use in pattern matching, if needed.
*
- * If it is needed, returns a zalloc()'d string; if not needed, returns
- * NULL.
+ * If it is needed, returns a heap allocated string; if not needed,
+ * returns NULL.
*
* prog is the pattern to be executed.
* string is the metafied trial string.
@@ -2046,7 +2046,7 @@ pattrystart(void)
* unmetalenp is the umetafied length of a path segment preceeding
* the trial string needed for file mananagement; it is calculated as
* needed so does not need to be initialised.
- * alloced is the memory allocated --- same as return value from
+ * alloced is the memory allocated on the heap --- same as return value from
* function.
*/
/**/
@@ -2097,7 +2097,7 @@ char *patallocstr(Patprog prog, char *string, int stringlen, int unmetalen,
int i, icopy, ncopy;
dst = patstralloc->alloced =
- zalloc(patstralloc->unmetalen + patstralloc->unmetalenp);
+ zhalloc(patstralloc->unmetalen + patstralloc->unmetalenp);
if (needfullpath) {
/* loop twice, copy path buffer first time */
@@ -2133,20 +2133,6 @@ char *patallocstr(Patprog prog, char *string, int stringlen, int unmetalen,
}
-/*
- * Free memory allocated by patallocstr().
- */
-
-/**/
-mod_export
-void patfreestr(Patstralloc patstralloc)
-{
- if (patstralloc->alloced)
- zfree(patstralloc->alloced,
- patstralloc->unmetalen + patstralloc->unmetalenp);
-}
-
-
/*
* Test prog against null-terminated, metafied string.
*/
@@ -2189,8 +2175,9 @@ pattrylen(Patprog prog, char *string, int len, int unmetalen,
* done if there is no path prefix (pathpos == 0) as otherwise the path
* buffer and unmetafied string may not match. To do this,
* patallocstr() is callled (use force = 1 to ensure it is alway
- * unmetafied); paststralloc points to existing storage. When all
- * pattern matching is done, patfreestr() is called.
+ * unmetafied); paststralloc points to existing storage. Memory is
+ * on the heap.
+ *
* patstralloc->alloced and patstralloc->unmetalen contain the
* unmetafied string and its length. In that case, the rules for the
* earlier arguments change:
@@ -2387,8 +2374,6 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
}
}
- if (patstralloc == &patstralloc_struct)
- patfreestr(patstralloc);
return ret;
} else {
int q = queue_signal_level();
@@ -2425,8 +2410,6 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
}
}
if (!ret) {
- if (patstralloc == &patstralloc_struct)
- patfreestr(patstralloc);
return 0;
}
@@ -2583,9 +2566,6 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
restore_queue_signals(q);
- if (patstralloc == &patstralloc_struct)
- patfreestr(patstralloc);
-
return ret;
}
}
--
cgit v1.2.3
From 007f249a8e190306a9ef6bca2317e79004ace871 Mon Sep 17 00:00:00 2001
From: Matthew Martin
Date: Tue, 29 Sep 2015 00:06:39 -0500
Subject: 36693: arithmetic rounds towards zero, document
---
ChangeLog | 3 +++
Doc/Zsh/arith.yo | 10 +++++-----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 56e725cf0..ea7bd2e98 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2015-09-30 Peter Stephenson
+ * Matthew Martin: 36693: Doc/Zsh/arith.yo: arithmetic rounds
+ towards zero.
+
* 36711: Src/glob.c, Src/pattern.c: Memory for early unmetafied
pattern trial string is on the heap.
diff --git a/Doc/Zsh/arith.yo b/Doc/Zsh/arith.yo
index 1dcd18cad..c152bf48d 100644
--- a/Doc/Zsh/arith.yo
+++ b/Doc/Zsh/arith.yo
@@ -215,7 +215,7 @@ findex(integer, use of)
Arithmetic evaluation is performed on the value of each
assignment to a named parameter declared integer
in this manner. Assigning a floating point number to an integer results in
-rounding down to the next integer.
+rounding towards zero.
cindex(parameters, floating point)
cindex(floating point parameters)
@@ -230,16 +230,16 @@ format.
Promotion of integer to floating point values is performed where
necessary. In addition, if any operator which requires an integer
-(`tt(~)', `tt(&)', `tt(|)', `tt(^)', `tt(%)', `tt(<<)', `tt(>>)' and their
-equivalents with assignment) is given a floating point argument, it will be
-silently rounded down to the next integer.
+(`tt(&)', `tt(|)', `tt(^)', `tt(<<)', `tt(>>)' and their equivalents with
+assignment) is given a floating point argument, it will be silently rounded
+towards zero except for `tt(~)' which rounds down.
Users should beware that, in common with many other programming
languages but not software designed for calculation, the evaluation of
an expression in zsh is taken a term at a time and promotion of integers
to floating point does not occur in terms only containing integers. A
typical result of this is that a division such as tt(6/8) is truncated,
-in this being rounded down to 0. The tt(FORCE_FLOAT) shell option can
+in this being rounded towards 0. The tt(FORCE_FLOAT) shell option can
be used in scripts or functions where floating point evaluation is
required throughout.
--
cgit v1.2.3
From 756526eef3e064c3ffb023ae5e5e6df42e6e9162 Mon Sep 17 00:00:00 2001
From: Jun-ichi Takimoto
Date: Wed, 30 Sep 2015 23:56:14 +0900
Subject: 36697: handle options of _arguments correctly
---
ChangeLog | 5 +++++
Completion/Base/Utility/_arguments | 45 +++++++++++++++++++-------------------
2 files changed, 28 insertions(+), 22 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 56e725cf0..498ad7c87 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-30 Jun-ichi Takimoto
+
+ * 36697: Completion/Base/Utility/_arguments: handle options
+ of _arguments correctly
+
2015-09-30 Peter Stephenson
* 36711: Src/glob.c, Src/pattern.c: Memory for early unmetafied
diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments
index 1f35e8d43..87fb20e6b 100644
--- a/Completion/Base/Utility/_arguments
+++ b/Completion/Base/Utility/_arguments
@@ -8,15 +8,33 @@ local oldcontext="$curcontext" hasopts rawret optarg singopt alwopt
local setnormarg start rest
local -a match mbegin mend
+subopts=()
+singopt=()
+while [[ "$1" = -([AMO]*|[CRSWnsw]) ]]; do
+ case "$1" in
+ -C) usecc=yes; shift ;;
+ -O) subopts=( "${(@P)2}" ); shift 2 ;;
+ -O*) subopts=( "${(@P)${1[3,-1]}}" ); shift ;;
+ -R) rawret=yes; shift;;
+ -n) setnormarg=yes; NORMARG=-1; shift;;
+ -w) optarg=yes; shift;;
+ -W) alwopt=arg; shift;;
+ -[Ss]) singopt+=( $1 ); shift;;
+ -[AM]) singopt+=( $1 $2 ); shift 2 ;;
+ -[AM]*) singopt+=( $1 ); shift ;;
+ esac
+done
+
+[[ $1 = ':' ]] && shift
+singopt+=( ':' ) # always end with ':' to indicate the end of options
+
+[[ "$PREFIX" = [-+] ]] && alwopt=arg
+
long=$argv[(I)--]
if (( long )); then
local name tmp tmpargv
- if [[ long -eq 1 ]]; then
- tmpargv=()
- else
- tmpargv=( "${(@)argv[1,long-1]}" )
- fi
+ tmpargv=( "${(@)argv[1,long-1]}" ) # optspec's before --, if any
name=${~words[1]}
[[ "$name" = [^/]*/* ]] && name="$PWD/$name"
@@ -290,23 +308,6 @@ if (( long )); then
set -- "$tmpargv[@]" "${(@P)name}"
fi
-subopts=()
-singopt=()
-while [[ "$1" = -(O*|[CRWnsw]) ]]; do
- case "$1" in
- -C) usecc=yes; shift ;;
- -O) subopts=( "${(@P)2}" ); shift 2 ;;
- -O*) subopts=( "${(@P)${1[3,-1]}}" ); shift ;;
- -R) rawret=yes; shift;;
- -n) setnormarg=yes; NORMARG=-1; shift;;
- -w) optarg=yes; shift;;
- -s) singopt=(-s); shift;;
- -W) alwopt=arg; shift;;
- esac
-done
-
-[[ "$PREFIX" = [-+] ]] && alwopt=arg
-
zstyle -s ":completion:${curcontext}:options" auto-description autod
if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then
--
cgit v1.2.3
From 7ac34a3055d87b88d8b1b28ddfe68982f6550a08 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf
Date: Wed, 30 Sep 2015 14:21:59 +0000
Subject: 36725: vcs_info git: Compute %b correctly when merging to detached
heads.
The %b expando should be the hash prior to the merge. The hash of the merge
result is available as the %i expando and via the gen-applied-string hook.
---
ChangeLog | 6 ++++++
Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 498ad7c87..9a755434a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-30 Daniel Shahaf
+
+ * 36725: Functions/VCS_Info/Backends/VCS_INFO_get_data_git:
+ vcs_info git: Compute %b correctly when merging to detached
+ heads.
+
2015-09-30 Jun-ichi Takimoto
* 36697: Completion/Base/Utility/_arguments: handle options
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 8ecc7c7f7..312f17c33 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -90,7 +90,7 @@ VCS_INFO_git_getbranch () {
elif [[ -f "${gitdir}/MERGE_HEAD" ]] ; then
gitbranch="$(${(z)gitsymref} 2> /dev/null)"
- [[ -z ${gitbranch} ]] && gitbranch="$(< ${gitdir}/MERGE_HEAD)"
+ [[ -z ${gitbranch} ]] && gitbranch="$(< ${gitdir}/ORIG_HEAD)"
elif [[ -d "${gitdir}/rebase-merge" ]] ; then
gitbranch="$(< ${gitdir}/rebase-merge/head-name)"
--
cgit v1.2.3
From cd1cda9d57ff9f44d285bcd867721c4024500837 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf
Date: Wed, 30 Sep 2015 14:21:59 +0000
Subject: 36725: vcs_info git: Compute %b correctly when rebasing detached
heads.
This sets the %b expando to the hash of the before-the-merge HEAD, rather
than to the literal string "detached HEAD". That hash is already available
via the gen-applied-string hook.
---
ChangeLog | 3 +++
Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 4 ++++
2 files changed, 7 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 9a755434a..f45b414c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2015-09-30 Daniel Shahaf
+ * 36725: Functions/VCS_Info/Backends/VCS_INFO_get_data_git:
+ vcs_info git: Compute %b correctly when rebasing detached heads.
+
* 36725: Functions/VCS_Info/Backends/VCS_INFO_get_data_git:
vcs_info git: Compute %b correctly when merging to detached
heads.
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 312f17c33..0a2a8bc37 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -94,6 +94,10 @@ VCS_INFO_git_getbranch () {
elif [[ -d "${gitdir}/rebase-merge" ]] ; then
gitbranch="$(< ${gitdir}/rebase-merge/head-name)"
+ if [[ $gitbranch == 'detached HEAD' ]]; then
+ # get a sha1
+ gitbranch="$(< ${gitdir}/rebase-merge/orig-head)"
+ fi
elif [[ -d "${gitdir}/.dotest-merge" ]] ; then
gitbranch="$(< ${gitdir}/.dotest-merge/head-name)"
--
cgit v1.2.3
From a90cf551efc92184ab25da25b837296d1c4edc8a Mon Sep 17 00:00:00 2001
From: Daniel Shahaf
Date: Wed, 30 Sep 2015 14:21:59 +0000
Subject: 36725: vcs_info git: Compute %b correctly when "git am"-ing onto
detached heads.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Before this patch, $gitbranch would be set to empty, which caused
VCS_INFO_get_data_git to early out with a failure status¹, consequently
$vcs_info_msg_0_ would be empty.
¹ via the 'if [[ -z ]]' block around line 170.
---
ChangeLog | 4 ++++
Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 1 +
2 files changed, 5 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index f45b414c0..20860a1f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2015-09-30 Daniel Shahaf
+ * 36725: Functions/VCS_Info/Backends/VCS_INFO_get_data_git:
+ vcs_info git: Compute %b correctly when "git am"-ing onto
+ detached heads.
+
* 36725: Functions/VCS_Info/Backends/VCS_INFO_get_data_git:
vcs_info git: Compute %b correctly when rebasing detached heads.
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 0a2a8bc37..8664d510e 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -87,6 +87,7 @@ VCS_INFO_git_getbranch () {
gitbranch="$(${(z)gitsymref} 2> /dev/null)"
[[ -z ${gitbranch} ]] && [[ -r ${actiondir}/head-name ]] \
&& gitbranch="$(< ${actiondir}/head-name)"
+ [[ -z ${gitbranch} ]] && gitbranch="$(< ${gitdir}/ORIG_HEAD)"
elif [[ -f "${gitdir}/MERGE_HEAD" ]] ; then
gitbranch="$(${(z)gitsymref} 2> /dev/null)"
--
cgit v1.2.3
From a855d7bd246ef44d5393c3088aae8214d41d2b85 Mon Sep 17 00:00:00 2001
From: Mikael Magnusson
Date: Tue, 29 Sep 2015 06:11:24 +0200
Subject: 36709: zle -f from inside widget to set flags and make yank start/end
zle params writable
---
ChangeLog | 7 +++++++
Doc/Zsh/zle.yo | 29 ++++++++++++++++++++++++-----
Src/Zle/zle_main.c | 5 +++--
Src/Zle/zle_params.c | 24 +++++++++++++++++++-----
Src/Zle/zle_thingy.c | 39 +++++++++++++++++++++++++++++++++++++++
5 files changed, 92 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 20860a1f6..eaa565870 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-10-01 Mikael Magnusson
+
+ * 36709: Doc/Zsh/zle.yo, Functions/Zle/bracketed-paste-url-magic,
+ Src/Zle/zle_main.c, Src/Zle/zle_params.c, Src/Zle/zle_thingy.c:
+ zle -f from inside widget to set flags and make yank start/end
+ zle params writable.
+
2015-09-30 Daniel Shahaf
* 36725: Functions/VCS_Info/Backends/VCS_INFO_get_data_git:
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index 7d95eb377..05bb14829 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -404,6 +404,7 @@ xitem(tt(zle) tt(-l) [ tt(-L) | tt(-a) ] [ var(string) ... ])
xitem(tt(zle) tt(-D) var(widget) ...)
xitem(tt(zle) tt(-A) var(old-widget) var(new-widget))
xitem(tt(zle) tt(-N) var(widget) [ var(function) ])
+xitem(tt(zle) tt(-f) var(flag) [ var(flag)... ])
xitem(tt(zle) tt(-C) var(widget) var(completion-widget) var(function))
xitem(tt(zle) tt(-R) [ tt(-c) ] [ var(display-string) ] [ var(string) ... ])
xitem(tt(zle) tt(-M) var(string))
@@ -464,6 +465,21 @@ ifzman(the section `Widgets' below)\
ifnzman(noderef(Zle Widgets))\
.
)
+item(tt(-f) var(flag) [ var(flag)... ])(
+Set various flags on the running widget. Possible values for var(flag) are:
+
+tt(yank) for indicating that the widget has yanked text into the buffer.
+If the widget is wrapping an existing internal widget, no further
+action is necessary, but if it has inserted the text manually, then it
+should also take care to set tt(YANK_START) and tt(YANK_END) correctly.
+tt(yankbefore) does the same but is used when the yanked text appears
+after the cursor.
+
+tt(kill) for indicating that text has been killed into the cutbuffer.
+When repeatedly invoking a kill widget, text is appended to the cutbuffer
+instead of replacing it, but when wrapping such widgets, it is necessary
+to call `tt(zle -f kill)' to retain this effect.
+)
cindex(completion widgets, creating)
item(tt(-C) var(widget) var(completion-widget) var(function))(
Create a user-defined completion widget named var(widget). The
@@ -1011,11 +1027,14 @@ vindex(YANK_END)
xitem(tt(YANK_ACTIVE) (integer))
xitem(tt(YANK_START) (integer))
item(tt(YANK_END) (integer))(
-These three parameters indicate whether text has just been yanked (pasted)
-into the buffer. tt(YANK_START) and tt(YANK_END) are in the same units as
-tt(CURSOR), and are only valid when tt(YANK_ACTIVE) is non-zero.
-
-All three are read-only.
+tt(YANK_ACTIVE) indicates whether text has just been yanked (pasted)
+into the buffer. tt(YANK_START) and tt(YANK_END) give the location of
+the pasted text and are in the same units as tt(CURSOR). They are only
+valid for reading when tt(YANK_ACTIVE) is non-zero. They can also be
+assigned by widgets that insert text in a yank-like fashion, for example
+wrappers of tt(bracketed-paste). See also tt(zle -f).
+
+tt(YANK_ACTIVE) is read-only.
)
vindex(ZLE_STATE)
item(tt(ZLE_STATE) (scalar))(
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 992f152df..593d636cc 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1402,7 +1402,8 @@ execzlefunc(Thingy func, char **args, int set_bindk)
opts[XTRACE] = oxt;
sfcontext = osc;
endparamscope();
- lastcmd = 0;
+ lastcmd = w->flags;
+ w->flags = 0;
r = 1;
redup(osi, 0);
}
@@ -1981,7 +1982,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("zle", 0, bin_zle, 0, -1, 0, "aAcCDFgGIKlLmMNrRTUw", NULL),
+ BUILTIN("zle", 0, bin_zle, 0, -1, 0, "aAcCDfFgGIKlLmMNrRTUw", NULL),
};
/* The order of the entries in this table has to match the *HOOK
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index 000bc388c..b5bb288f1 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -98,9 +98,9 @@ static const struct gsu_integer undo_change_no_gsu =
static const struct gsu_integer undo_limit_no_gsu =
{ get_undo_limit_change, set_undo_limit_change, zleunsetfn };
static const struct gsu_integer yankstart_gsu =
-{ get_yankstart, NULL, zleunsetfn };
+{ get_yankstart, set_yankstart, zleunsetfn };
static const struct gsu_integer yankend_gsu =
-{ get_yankend, NULL, zleunsetfn };
+{ get_yankend, set_yankend, zleunsetfn };
static const struct gsu_integer yankactive_gsu =
{ get_yankactive, NULL, zleunsetfn };
@@ -149,8 +149,8 @@ static struct zleparam {
{ "WIDGET", PM_SCALAR | PM_READONLY, GSU(widget_gsu), NULL },
{ "WIDGETFUNC", PM_SCALAR | PM_READONLY, GSU(widgetfunc_gsu), NULL },
{ "WIDGETSTYLE", PM_SCALAR | PM_READONLY, GSU(widgetstyle_gsu), NULL },
- { "YANK_START", PM_INTEGER | PM_READONLY, GSU(yankstart_gsu), NULL },
- { "YANK_END", PM_INTEGER | PM_READONLY, GSU(yankend_gsu), NULL },
+ { "YANK_START", PM_INTEGER, GSU(yankstart_gsu), NULL },
+ { "YANK_END", PM_INTEGER, GSU(yankend_gsu), NULL },
{ "YANK_ACTIVE", PM_INTEGER | PM_READONLY, GSU(yankactive_gsu), NULL },
{ "ZLE_STATE", PM_SCALAR | PM_READONLY, GSU(zle_state_gsu), NULL },
{ NULL, 0, NULL, NULL }
@@ -503,7 +503,21 @@ get_yankend(UNUSED(Param pm))
static zlong
get_yankactive(UNUSED(Param pm))
{
- return lastcmd & ZLE_YANK;
+ return !!(lastcmd & ZLE_YANK) + !!(lastcmd & ZLE_YANKAFTER);
+}
+
+/**/
+static void
+set_yankstart(UNUSED(Param pm), zlong i)
+{
+ yankb = i;
+}
+
+/**/
+static void
+set_yankend(UNUSED(Param pm), zlong i)
+{
+ yanke = i;
}
/**/
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index da3a6d458..3963d7eaf 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -352,6 +352,7 @@ bin_zle(char *name, char **args, Options ops, UNUSED(int func))
{ 'U', bin_zle_unget, 1, 1 },
{ 'K', bin_zle_keymap, 1, 1 },
{ 'I', bin_zle_invalidate, 0, 0 },
+ { 'f', bin_zle_flags, 1, -1 },
{ 'F', bin_zle_fd, 0, 2 },
{ 'T', bin_zle_transform, 0, 2},
{ 0, bin_zle_call, 0, -1 },
@@ -623,6 +624,44 @@ bin_zle_complete(char *name, char **args, UNUSED(Options ops), UNUSED(char func)
return 0;
}
+/**/
+static int
+bin_zle_flags(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
+{
+ char **flag;
+
+ if (!zle_usable()) {
+ zwarnnam(name, "can only set flags from a widget");
+ return 1;
+ }
+
+ if (bindk) {
+ Widget w = bindk->widget;
+ if (w) {
+ for (flag = args; *flag; flag++) {
+ if (!strcmp(*flag, "yank")) {
+ w->flags |= ZLE_YANKAFTER;
+ } else if (!strcmp(*flag, "yankbefore"))
+ w->flags |= ZLE_YANKBEFORE;
+ else if (!strcmp(*flag, "kill"))
+ w->flags |= ZLE_KILL;
+ /*
+ * These won't do anything yet, because of how execzlefunc
+ * handles user widgets
+ } else if (!strcmp(*flag, "menucmp"))
+ w->flags |= ZLE_MENUCMP;
+ else if (!strcmp(*flag, "linemove"))
+ w->flags |= ZLE_LINEMOVE;
+ else if (!strcmp(*flag, "keepsuffix"))
+ w->flags |= ZLE_KEEPSUFFIX;
+ */
+ else
+ zwarnnam(name, "invalid flag `%s' given to zle -f", *flag);
+ }
+ }
+ }
+}
+
/**/
static int
zle_usable()
--
cgit v1.2.3
From 76da752fd75955cd6240c1daa026cc34dea1e010 Mon Sep 17 00:00:00 2001
From: Mikael Magnusson
Date: Thu, 1 Oct 2015 03:52:16 +0200
Subject: 36692: bracketed-paste-url-magic: simpler alternative for handling
pasted urls
---
ChangeLog | 3 +++
Functions/Zle/bracketed-paste-url-magic | 42 +++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+)
create mode 100644 Functions/Zle/bracketed-paste-url-magic
diff --git a/ChangeLog b/ChangeLog
index eaa565870..b003b9a71 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,9 @@
zle -f from inside widget to set flags and make yank start/end
zle params writable.
+ * 36692: Functions/Zle/bracketed-paste-url-magic: simpler
+ alternative for handling pasted urls
+
2015-09-30 Daniel Shahaf
* 36725: Functions/VCS_Info/Backends/VCS_INFO_get_data_git:
diff --git a/Functions/Zle/bracketed-paste-url-magic b/Functions/Zle/bracketed-paste-url-magic
new file mode 100644
index 000000000..e1bea60d6
--- /dev/null
+++ b/Functions/Zle/bracketed-paste-url-magic
@@ -0,0 +1,42 @@
+# bracketed-paste-url-magic quotes pasted urls automatically, if the
+# paste exactly starts with a url, eg no spaces or other characters precede it
+#
+# If the numeric argument is provided (eg, pressing alt-0 or alt-1 in emacs mode,
+# or just the number by itself in vi command mode), then override the url detection
+# and if it was 0, never quote, and if it was 1, always quote.
+#
+# To use this widget, put this in your startup files (eg, .zshrc)
+#
+# autoload -Uz bracketed-paste-url-magic
+# zle -N bracketed-paste bracketed-paste-url-magic
+#
+# You can customize which schemas are to be quoted by using
+#
+# zstyle :bracketed-paste-url-magic schema http https ftp
+#
+# The default can be seen just below.
+
+local -a schema
+zstyle -a :bracketed-paste-url-magic schema schema || schema=(http https ftp ftps file ssh sftp)
+
+local wantquote=${NUMERIC:-0}
+local content
+local start=$#LBUFFER
+
+zle .$WIDGET -N content
+
+if ! (( $wantquote )); then
+ if [[ $content = (${(~j:|:)schema})://* ]]; then
+ wantquote=1
+ fi
+fi
+
+if (( $wantquote )); then
+ content=${(q-)content}
+fi
+
+LBUFFER+=$content
+
+YANK_START=$start
+YANK_END=$#LBUFFER
+zle -f yank
--
cgit v1.2.3
From d1a810b000296bac43b114af526b0787068ae3ba Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Wed, 30 Sep 2015 19:58:43 -0700
Subject: remove sentence fragment
---
ChangeLog | 4 ++++
Doc/Zsh/builtins.yo | 3 +--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b003b9a71..018585611 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,10 @@
* 36692: Functions/Zle/bracketed-paste-url-magic: simpler
alternative for handling pasted urls
+2015-09-30 Barton E. Schaefer
+
+ * cf. 36690: Doc/Zsh/builtins.yo: remove sentence fragment
+
2015-09-30 Daniel Shahaf
* 36725: Functions/VCS_Info/Backends/VCS_INFO_get_data_git:
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 97c337071..85d1742f0 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -174,8 +174,7 @@ pattern are loaded.
With the tt(-w) flag, the var(name)s are taken as names of files compiled
with the tt(zcompile) builtin, and all functions defined in them are
-marked for autoloading. Note this does not otherwise change the search
-order for
+marked for autoloading.
The flags tt(-z) and tt(-k) mark the function to be autoloaded using the
zsh or ksh style, as if the option tt(KSH_AUTOLOAD) were unset or were
--
cgit v1.2.3
From 2bf4f667fb41a8aba139e3ef93b1ebcd9f3e016d Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Wed, 30 Sep 2015 20:01:13 -0700
Subject: 36707: distinguish ERR_RETURN value of retflag so that execif() can
ignore it in the test sublist
---
ChangeLog | 3 +++
Src/exec.c | 2 +-
Src/loop.c | 8 ++++++--
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 018585611..3f54075f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,9 @@
2015-09-30 Barton E. Schaefer
+ * 36707: Src/exec.c, Src/loop.c: distinguish ERR_RETURN value
+ of retflag so that execif() can ignore it in the test sublist
+
* cf. 36690: Doc/Zsh/builtins.yo: remove sentence fragment
2015-09-30 Daniel Shahaf
diff --git a/Src/exec.c b/Src/exec.c
index da808d6f1..154bbb8db 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1408,7 +1408,7 @@ sublist_done:
exit(lastval);
}
if (errreturn) {
- retflag = 1;
+ retflag = 2;
breaks = loops;
}
}
diff --git a/Src/loop.c b/Src/loop.c
index 4def9b652..7d1528efe 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -552,8 +552,12 @@ execif(Estate state, int do_exec)
run = 1;
break;
}
- if (retflag)
- break;
+ if (retflag) {
+ if (retflag == 2)
+ retflag = 0; /* Never ERR_RETURN here */
+ else
+ break;
+ }
s = 1;
state->pc = next;
}
--
cgit v1.2.3
From bc2e73ba4c27a220a6f122cb7b9b5c6fa9996941 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Wed, 30 Sep 2015 20:02:53 -0700
Subject: users/20672: missing "do" in gettext2() for "select"
---
ChangeLog | 2 ++
Src/text.c | 4 +++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 3f54075f8..bb7717692 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,8 @@
2015-09-30 Barton E. Schaefer
+ * users/20672: Src/text.c: missing "do" in gettext2() for "select"
+
* 36707: Src/exec.c, Src/loop.c: distinguish ERR_RETURN value
of retflag so that execif() can ignore it in the test sublist
diff --git a/Src/text.c b/Src/text.c
index 7e65f43a4..9421d70ce 100644
--- a/Src/text.c
+++ b/Src/text.c
@@ -632,8 +632,10 @@ gettext2(Estate state)
taddstr(" in ");
taddlist(state, *state->pc++);
}
- tindent++;
taddnl(0);
+ taddstr("do");
+ taddnl(0);
+ tindent++;
tpush(code, 1);
} else {
dec_tindent();
--
cgit v1.2.3
From 9064483b6c73286cd892acd5d30366db14a77371 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Thu, 1 Oct 2015 09:47:15 +0100
Subject: 36722: allow git range to complete after ^.
Take account of backslash quoting.
---
ChangeLog | 5 +++++
Completion/Unix/Command/_git | 9 ++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index b3a0a649f..80edc8fdf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-01 Peter Stephenson
+
+ * 36722: Completion/Unix/Command/_git: allow range to complete
+ after ^, taking acoount of backslash quoting.
+
2015-10-01 Mikael Magnusson
* 36709: Doc/Zsh/zle.yo, Functions/Zle/bracketed-paste-url-magic,
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 40a9fb63b..1fcde9015 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5753,7 +5753,14 @@ __git_commit_ranges () {
if compset -P '*..(.|)'; then
expl=( $* )
else
- compset -S '..*' || suf=( -S .. -r '.@~ ^:\t\n\-' )
+ if ! compset -S '..*'; then
+ local match mbegin mend
+ if [[ ${PREFIX} = (#b)((\\|)\^)* ]]; then
+ compset -p ${#match[1]}
+ else
+ suf=( -S .. -r '.@~ ^:\t\n\-' )
+ fi
+ fi
expl=( $* $suf )
fi
--
cgit v1.2.3
From 8bf72dd65b00ffd223d0705c8fde952ff129eafa Mon Sep 17 00:00:00 2001
From: Andrew Janke
Date: Wed, 30 Sep 2015 21:14:05 -0400
Subject: 36729: fix some typos in distro docs
---
ChangeLog | 2 ++
MACHINES | 4 ++--
NEWS | 6 +++---
README | 4 ++--
4 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 80edc8fdf..4a9d1cebc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2015-10-01 Peter Stephenson
+ * Andrew Janke: 36729: MACHINES, NEWS, README: fix some typos.
+
* 36722: Completion/Unix/Command/_git: allow range to complete
after ^, taking acoount of backslash quoting.
diff --git a/MACHINES b/MACHINES
index ddbf69ac6..73f80c7d1 100644
--- a/MACHINES
+++ b/MACHINES
@@ -162,8 +162,8 @@ Other machines
Zsh has previously been compiled on the following machines, but the
developers do not have direct access to them and the reports may be out
-of date. Some of these OS's are now very long in the tooth. We would
-be glad to receive any reports of success or failure on these OS's ---
+of date. Some of these OSes are now very long in the tooth. We would
+be glad to receive any reports of success or failure on these OSes ---
and, of course, any others not mentioned in this file.
Apple/NeXT OpenStep 4.2 for i386.
diff --git a/NEWS b/NEWS
index 7b2994b6b..bc14a8beb 100644
--- a/NEWS
+++ b/NEWS
@@ -47,7 +47,7 @@ and an array "array" containing the words "several"
- Improved (though still not perfect) POSIX compatibility for getopts
builtin when POSIX_BUILTINS is set.
-- New setopt APPEND_CREATE for POSIX-compatible NO_CLOBBER behavior.
+- New setopt APPEND_CREATE for POSIX-compatible NO_CLOBBER behaviour.
- Completion of date values now displays in a calendar format when
the complist module is available. Controllable by zstyle.
@@ -929,7 +929,7 @@ Parameter and expansion changes:
- expansion of ~ and other globbing flags via ${~param} do not depend
upon EXTENDED_GLOB (bug fix).
- nested parameter substitutions require braces (this was always the
- documented behavior, but previous parsers didn't enforce it).
+ documented behaviour, but previous parsers didn't enforce it).
- quote only nested expansion, e.g. ${(f)"$(
Date: Thu, 1 Oct 2015 15:55:01 +0100
Subject: 36735: add ~/.zcalcrc handling to zcalc
---
ChangeLog | 2 ++
Doc/Zsh/contrib.yo | 8 ++++++++
Functions/Misc/zcalc | 4 ++++
3 files changed, 14 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 4a9d1cebc..a51dc4795 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2015-10-01 Peter Stephenson
+ * 36735: Doc/Zsh/contrib.yo, Functions/Misc/zcalc: ~/.zcalcrc.
+
* Andrew Janke: 36729: MACHINES, NEWS, README: fix some typos.
* 36722: Completion/Unix/Command/_git: allow range to complete
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index 330c6f588..635f9b010 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -3657,6 +3657,14 @@ integer arithmetic, which is not how an ordinary desk calculator
operates. To force floating point operation, pass the option tt(-f);
see further notes below.
+If the file tt(~/.zcalcrc) exists it will be sourced inside the function
+once it is set up and about to process the command line. This
+can be used, for example, to set shell options; tt(emulate -L zsh)
+and tt(setopt extendedglob) are in effect at this point. Any
+failure to source the file if it exists is treated as fatal.
+As with other initialisation files, the directory tt($ZDOTDIR) is used
+instead of tt($HOME) if it is set.
+
The mathematical library tt(zsh/mathfunc) will be loaded if it is
available; see
ifzman(the section `The zsh/mathfunc Module' in zmanref(zshmodules))\
diff --git a/Functions/Misc/zcalc b/Functions/Misc/zcalc
index 63f67adb0..17700e48b 100644
--- a/Functions/Misc/zcalc
+++ b/Functions/Misc/zcalc
@@ -120,6 +120,10 @@ autoload -Uz zmathfuncdef
float PI E
(( PI = 4 * atan(1), E = exp(1) ))
+if [[ -f "${ZDOTDIR:-$HOME}/.zcalcrc" ]]; then
+ . "${ZDOTDIR:-$HOME}/.zcalcrc" || return 1
+fi
+
# Process command line
while [[ -n $1 && $1 = -(|[#-]*|f|e) ]]; do
optlist=${1[2,-1]}
--
cgit v1.2.3
From 807a8338a3be8127dd23c69971668b7b0c6b79a2 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Thu, 1 Oct 2015 16:21:18 +0100
Subject: 36737: Ensure we don't dreference unterminated zero-length string
---
ChangeLog | 3 +++
Src/pattern.c | 10 +++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a51dc4795..14749d9ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2015-10-01 Peter Stephenson
+ * 36737: Src/pattern.c: Ensure we are not dereferencing
+ zero-length unterminated string.
+
* 36735: Doc/Zsh/contrib.yo, Functions/Misc/zcalc: ~/.zcalcrc.
* Andrew Janke: 36729: MACHINES, NEWS, README: fix some typos.
diff --git a/Src/pattern.c b/Src/pattern.c
index 68a340919..04d3e3dfb 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -2224,8 +2224,10 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
maxnpos = *nump;
*nump = 0;
}
- /* inherited from domatch, but why, exactly? */
- if (*string == Nularg) {
+ /*
+ * Special signalling of empty tokenised string.
+ */
+ if ((!patstralloc || stringlen > 0) && *string == Nularg) {
string++;
if (unmetalenin > 0)
unmetalenin--;
@@ -2233,8 +2235,10 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
stringlen--;
}
- if (stringlen < 0)
+ if (stringlen < 0) {
+ DPUTS(patstralloc != NULL, "length needed with patstralloc");
stringlen = strlen(string);
+ }
origlen = stringlen;
if (patstralloc) {
--
cgit v1.2.3
From 99aff5bb0cad712b0e24e76ff2ba1ea3d2214769 Mon Sep 17 00:00:00 2001
From: Mikael Magnusson
Date: Thu, 1 Oct 2015 20:14:55 +0200
Subject: unposted: bracketed-paste-url-magic: actually do what the comment
says
---
Functions/Zle/bracketed-paste-url-magic | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/Functions/Zle/bracketed-paste-url-magic b/Functions/Zle/bracketed-paste-url-magic
index e1bea60d6..06dee2657 100644
--- a/Functions/Zle/bracketed-paste-url-magic
+++ b/Functions/Zle/bracketed-paste-url-magic
@@ -2,8 +2,10 @@
# paste exactly starts with a url, eg no spaces or other characters precede it
#
# If the numeric argument is provided (eg, pressing alt-0 or alt-1 in emacs mode,
-# or just the number by itself in vi command mode), then override the url detection
-# and if it was 0, never quote, and if it was 1, always quote.
+# or just the number by itself in vi command mode), then
+# 0 is the default and means auto detect urls
+# 1 means always quote
+# any other value means never quote
#
# To use this widget, put this in your startup files (eg, .zshrc)
#
@@ -25,13 +27,13 @@ local start=$#LBUFFER
zle .$WIDGET -N content
-if ! (( $wantquote )); then
+if (( $wantquote == 0 )); then
if [[ $content = (${(~j:|:)schema})://* ]]; then
wantquote=1
fi
fi
-if (( $wantquote )); then
+if (( $wantquote == 1 )); then
content=${(q-)content}
fi
--
cgit v1.2.3
From fa72e547120581cdbff1b1695a47c2c19fed3487 Mon Sep 17 00:00:00 2001
From: Mikael Magnusson
Date: Thu, 1 Oct 2015 20:24:09 +0200
Subject: unposted: zle_thingy: return a value in bin_zle_flags
---
Src/Zle/zle_thingy.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index 3963d7eaf..ba89e00a8 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -628,6 +628,7 @@ bin_zle_complete(char *name, char **args, UNUSED(Options ops), UNUSED(char func)
static int
bin_zle_flags(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
{
+ int ret = 0;
char **flag;
if (!zle_usable()) {
@@ -655,11 +656,14 @@ bin_zle_flags(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
else if (!strcmp(*flag, "keepsuffix"))
w->flags |= ZLE_KEEPSUFFIX;
*/
- else
+ else {
zwarnnam(name, "invalid flag `%s' given to zle -f", *flag);
+ ret = 1;
+ }
}
}
}
+ return ret;
}
/**/
--
cgit v1.2.3
From e3bc9aa22843cb55912b909e00f54972eab5b2c5 Mon Sep 17 00:00:00 2001
From: Jun-ichi Takimoto
Date: Fri, 2 Oct 2015 22:11:43 +0900
Subject: 36732: _zsh now complets script args; also support -s, -b
---
ChangeLog | 5 +++++
Completion/Unix/Command/_zsh | 17 ++++++++++++++++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 14749d9ff..87a2ce490 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-02 Jun-ichi Takimoto
+
+ * 36732: Completion/Unix/Command/_zsh: support -s and -b,
+ and complete script arguments
+
2015-10-01 Peter Stephenson
* 36737: Src/pattern.c: Ensure we are not dereferencing
diff --git a/Completion/Unix/Command/_zsh b/Completion/Unix/Command/_zsh
index 3b6d7ad4f..a5414670b 100644
--- a/Completion/Unix/Command/_zsh
+++ b/Completion/Unix/Command/_zsh
@@ -1,8 +1,23 @@
#compdef zsh
+local curcontext=$curcontext state state_descr line expl
+typeset -A opt_args
+
_arguments -S -s : \
'*-o+[set named option]:option:_options' \
'*+o+[unset named option]:option:_options' \
+ '(1 -s --shinstdin)'{-s,--shinstdin}'[read commands from standard input]' \
+ '(-)-b[end of option processing, like --]' \
'(1 -)-c[run a command]:command:_cmdstring' \
'(-)1:script file:_files' \
- '*:command arguments' --
+ '*::script arguments:->args' -- && return 0
+
+case $state in
+ (args)
+ if [[ -n ${opt_args[(I)-c|-s|--shinstdin]} ]]; then
+ _files
+ else
+ _normal
+ fi
+ ;;
+esac
--
cgit v1.2.3
From 0626be9e3c02ca9171cd4e0975c208e0c3d6ec2b Mon Sep 17 00:00:00 2001
From: Mikael Magnusson
Date: Fri, 2 Oct 2015 20:41:49 +0200
Subject: unposted: define zle_usable before using it (reported in 36741)
---
Src/Zle/zle_thingy.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index ba89e00a8..c6ef8e6a0 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -624,6 +624,23 @@ bin_zle_complete(char *name, char **args, UNUSED(Options ops), UNUSED(char func)
return 0;
}
+/**/
+static int
+zle_usable()
+{
+ return zleactive && !incompctlfunc && !incompfunc
+#if 0
+ /*
+ * PWS experiment: commenting this out allows zle widgets
+ * in signals, hooks etc. I'm not sure if this has a down side;
+ * it ought to be that zleactive is good enough to test whether
+ * widgets are callable.
+ */
+ && sfcontext == SFC_WIDGET
+#endif
+ ;
+}
+
/**/
static int
bin_zle_flags(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
@@ -666,23 +683,6 @@ bin_zle_flags(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
return ret;
}
-/**/
-static int
-zle_usable()
-{
- return zleactive && !incompctlfunc && !incompfunc
-#if 0
- /*
- * PWS experiment: commenting this out allows zle widgets
- * in signals, hooks etc. I'm not sure if this has a down side;
- * it ought to be that zleactive is good enough to test whether
- * widgets are callable.
- */
- && sfcontext == SFC_WIDGET
-#endif
- ;
-}
-
/**/
static int
bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
--
cgit v1.2.3
From 64061e504fe9145c34911622a9fec6ec43869cea Mon Sep 17 00:00:00 2001
From: Mikael Magnusson
Date: Sat, 3 Oct 2015 00:04:09 +0200
Subject: 36754: Functions/TCP: Tweak some usage output in the tcp_* functions
---
ChangeLog | 6 ++++++
Functions/TCP/tcp_open | 2 +-
Functions/TCP/tcp_read | 2 +-
Functions/TCP/tcp_send | 2 +-
Functions/TCP/tcp_shoot | 4 ++--
5 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 87a2ce490..1061d1d94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-10-03 Mikael Magnusson
+
+ * 36754: Functions/TCP/tcp_open, Functions/TCP/tcp_read,
+ Functions/TCP/tcp_send, Functions/TCP/tcp_shoot: Tweak some
+ usage output in the tcp_* functions
+
2015-10-02 Jun-ichi Takimoto
* 36732: Completion/Unix/Command/_zsh: support -s and -b,
diff --git a/Functions/TCP/tcp_open b/Functions/TCP/tcp_open
index 091217788..a04403c76 100644
--- a/Functions/TCP/tcp_open
+++ b/Functions/TCP/tcp_open
@@ -152,7 +152,7 @@ fi
if (( $# )); then
print "Usage: $0 [-z] [-a fd | -f fd | host port [ session ] ]
- $0 [-z] [ -s session | -l sesslist ] ..." >&2
+ $0 [-z] [ -s session | -l sesslist ] ..." >&2
return 1
fi
diff --git a/Functions/TCP/tcp_read b/Functions/TCP/tcp_read
index f880395dd..ba9185ed5 100644
--- a/Functions/TCP/tcp_read
+++ b/Functions/TCP/tcp_read
@@ -116,7 +116,7 @@ while getopts "abdl:qs:t:T:u:" opt; do
read_fds[$((read_fd))]=1
done
;;
- (*) [[ $opt != \? ]] && print Unhandled option, complain: $opt >&2
+ (*) [[ $opt != \? ]] && print "Unhandled option, complain: $opt" >&2
return 1
;;
esac
diff --git a/Functions/TCP/tcp_send b/Functions/TCP/tcp_send
index c976a2fb7..86dda6403 100644
--- a/Functions/TCP/tcp_send
+++ b/Functions/TCP/tcp_send
@@ -29,7 +29,7 @@ while getopts "acl:nqs:" opt; do
fi
sessions+=($OPTARG)
;;
- (*) [[ $opt != '?' ]] && print Unhandled option, complain: $opt >&2
+ (*) [[ $opt != '?' ]] && print "Unhandled option, complain: $opt" >&2
return 1
;;
esac
diff --git a/Functions/TCP/tcp_shoot b/Functions/TCP/tcp_shoot
index 8ff9866ba..c485c140a 100644
--- a/Functions/TCP/tcp_shoot
+++ b/Functions/TCP/tcp_shoot
@@ -4,8 +4,8 @@ setopt extendedglob
local REPLY tfd
if [[ $# -ne 2 ]]; then
- print "Usage: tcp_dump host port
-Connect to the given host and port; send standard input.">&2
+ print "Usage: $0 host port
+Connect to the given host and port; send standard input." >&2
return 1
fi
--
cgit v1.2.3
From faeb9555d3c853b019aa30ee1ca62bec3971ce9f Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Sat, 3 Oct 2015 20:25:57 +0100
Subject: 36760: more care with already unmetafied pattern trial strings
---
ChangeLog | 5 +++++
Src/pattern.c | 55 ++++++++++++++++++++++++++++++++++++++++---------------
2 files changed, 45 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1061d1d94..e45273e68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-03 Peter Stephenson
+
+ * 36760: Src/pattern.c: ensure we don't do anything untoward
+ with an already metafied pattern trial match.
+
2015-10-03 Mikael Magnusson
* 36754: Functions/TCP/tcp_open, Functions/TCP/tcp_read,
diff --git a/Src/pattern.c b/Src/pattern.c
index 04d3e3dfb..8b07cca92 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -2022,6 +2022,39 @@ pattrystart(void)
errsfound = 0;
}
+/*
+ * Fix up string length stuff.
+ *
+ * If we call patallocstr() with "force" to set things up early, it's
+ * done there, else it's done in pattryrefs(). The reason for the
+ * difference is in the latter case we may not be relying on
+ * patallocstr() having an effect.
+ */
+
+/**/
+static void
+patmungestring(char **string, int *stringlen, int *unmetalenin)
+{
+ /*
+ * Special signalling of empty tokenised string.
+ */
+ if (*stringlen > 0 && **string == Nularg) {
+ (*string)++;
+ /*
+ * If we don't have an unmetafied length
+ * and need it (we may not) we'll get it later.
+ */
+ if (*unmetalenin > 0)
+ (*unmetalenin)--;
+ if (*stringlen > 0)
+ (*stringlen)--;
+ }
+
+ /* Ensure we have a metafied length */
+ if (*stringlen < 0)
+ *stringlen = strlen(*string);
+}
+
/*
* Allocate memeory for pattern match. Note this is specific to use
* of pattern *and* trial string.
@@ -2039,7 +2072,8 @@ pattrystart(void)
* force is 1 if we always unmetafy: this is useful if we are going
* to try again with different versions of the string. If this is
* called from pattryrefs() we don't force unmetafication as it won't
- * be optimal.
+ * be optimal. This option should be used if the resulting
+ * patstralloc is going to be passed to pattrylen() / pattryrefs().
* In patstralloc (supplied by caller, must last until last pattry is done)
* unmetalen is the unmetafied length of the string; it will be
* calculated if the input value is negative.
@@ -2056,6 +2090,9 @@ char *patallocstr(Patprog prog, char *string, int stringlen, int unmetalen,
{
int needfullpath;
+ if (force)
+ patmungestring(&string, &stringlen, &unmetalen);
+
/*
* For a top-level ~-exclusion, we will need the full
* path to exclude, so copy the path so far and append the
@@ -2224,21 +2261,9 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
maxnpos = *nump;
*nump = 0;
}
- /*
- * Special signalling of empty tokenised string.
- */
- if ((!patstralloc || stringlen > 0) && *string == Nularg) {
- string++;
- if (unmetalenin > 0)
- unmetalenin--;
- if (stringlen > 0)
- stringlen--;
- }
- if (stringlen < 0) {
- DPUTS(patstralloc != NULL, "length needed with patstralloc");
- stringlen = strlen(string);
- }
+ if (!patstralloc)
+ patmungestring(&string, &stringlen, &unmetalenin);
origlen = stringlen;
if (patstralloc) {
--
cgit v1.2.3
From b581c3fece76c87ed86ae9fc704d0fcf208a79d3 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sat, 3 Oct 2015 19:40:14 -0700
Subject: 36766: fix incorrect reset of noerrexit during "if" conditions
---
ChangeLog | 5 +++++
Src/exec.c | 3 ++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index e45273e68..a5a235389 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-03 Barton E. Schaefer
+
+ * 36766: Src/exec.c: fix incorrect reset of noerrexit during
+ "if" conditions
+
2015-10-03 Peter Stephenson
* 36760: Src/pattern.c: ensure we don't do anything untoward
diff --git a/Src/exec.c b/Src/exec.c
index 154bbb8db..235faf3ba 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1364,7 +1364,8 @@ sublist_done:
* we hit execcmd on the way down. We're now
* on the way back up, so don't restore it.
*/
- noerrexit = (oldnoerrexit == 2) ? 0 : oldnoerrexit;
+ if (oldnoerrexit != 2)
+ noerrexit = oldnoerrexit;
if (sigtrapped[SIGDEBUG] && !isset(DEBUGBEFORECMD) && !donedebug) {
/*
--
cgit v1.2.3
From cb26e11c70f95c72e300e1f4f16b33e4e5f54d21 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sat, 3 Oct 2015 22:11:09 -0700
Subject: unposted: back out 36707, add test case for 36766
---
ChangeLog | 4 ++++
Src/exec.c | 2 +-
Src/loop.c | 8 ++------
Test/C03traps.ztst | 14 ++++++++++++++
4 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a5a235389..aa2253522 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2015-10-03 Barton E. Schaefer
+ * unposted (cf. 36696): Test/C03traps.ztst: test case for 36766
+
+ * unposted: Src/exec.c, Src/loop.c: back out 36707, fixed by 36766
+
* 36766: Src/exec.c: fix incorrect reset of noerrexit during
"if" conditions
diff --git a/Src/exec.c b/Src/exec.c
index 235faf3ba..bcc8065a2 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1409,7 +1409,7 @@ sublist_done:
exit(lastval);
}
if (errreturn) {
- retflag = 2;
+ retflag = 1;
breaks = loops;
}
}
diff --git a/Src/loop.c b/Src/loop.c
index 7d1528efe..4def9b652 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -552,12 +552,8 @@ execif(Estate state, int do_exec)
run = 1;
break;
}
- if (retflag) {
- if (retflag == 2)
- retflag = 0; /* Never ERR_RETURN here */
- else
- break;
- }
+ if (retflag)
+ break;
s = 1;
state->pc = next;
}
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index d179dc46d..4b2843a47 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -450,6 +450,20 @@
fn
1:ERRRETURN in "else" branch (regression test)
+ $ZTST_testdir/../Src/zsh -f =(<<<"
+ if false; then
+ :
+ else
+ if [[ -n '' ]]; then
+ a=2
+ fi
+ print Yes
+ fi
+ ")
+0:ERRRETURN when false "if" is the first statement in an "else" (regression)
+>Yes
+F:Must be tested with a top-level script rather than source or function
+
%clean
rm -f TRAPEXIT
--
cgit v1.2.3
From 3f9606333578384221948e285ed896738071b253 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sun, 4 Oct 2015 14:01:08 -0700
Subject: 36773: limit CORRECT / CORRECT_ALL to directory names in cases where
it is obvious that a directory is expected
---
ChangeLog | 5 +++++
Src/utils.c | 49 ++++++++++++++++++++++++++++++-------------------
2 files changed, 35 insertions(+), 19 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index aa2253522..e1f58c9ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-04 Barton E. Schaefer
+
+ * 36773: Src/utils.c: limit CORRECT / CORRECT_ALL to directory
+ names in cases where it is obvious that a directory is expected
+
2015-10-03 Barton E. Schaefer
* unposted (cf. 36696): Test/C03traps.ztst: test case for 36766
diff --git a/Src/utils.c b/Src/utils.c
index ab3b0c274..61cbe84aa 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -2812,7 +2812,7 @@ spckword(char **s, int hist, int cmd, int ask)
* as used in spscan(), so that an autocd is chosen *
* only when it is better than anything so far, and *
* so we prefer directories earlier in the cdpath. */
- if ((thisdist = mindist(*pp, *s, bestcd)) < d) {
+ if ((thisdist = mindist(*pp, *s, bestcd, 1)) < d) {
best = dupstring(bestcd);
d = thisdist;
}
@@ -4057,7 +4057,8 @@ spname(char *oldname)
thresh = 3;
else if (thresh > 100)
thresh = 100;
- if ((thisdist = mindist(newname, spnameguess, spnamebest)) >= thresh) {
+ thisdist = mindist(newname, spnameguess, spnamebest, *old == '/');
+ if (thisdist >= thresh) {
/* The next test is always true, except for the first path *
* component. We could initialize bestdist to some large *
* constant instead, and then compare to that constant here, *
@@ -4082,42 +4083,52 @@ spname(char *oldname)
/**/
static int
-mindist(char *dir, char *mindistguess, char *mindistbest)
+mindist(char *dir, char *mindistguess, char *mindistbest, int wantdir)
{
int mindistd, nd;
DIR *dd;
char *fn;
char *buf;
+ struct stat st;
+ size_t dirlen;
if (dir[0] == '\0')
dir = ".";
mindistd = 100;
- buf = zalloc(strlen(dir) + strlen(mindistguess) + 2);
+ if (!(buf = zalloc((dirlen = strlen(dir)) + strlen(mindistguess) + 2)))
+ return 0;
sprintf(buf, "%s/%s", dir, mindistguess);
- if (access(unmeta(buf), F_OK) == 0) {
+ if (stat(unmeta(buf), &st) == 0 && (!wantdir || S_ISDIR(st.st_mode))) {
strcpy(mindistbest, mindistguess);
free(buf);
return 0;
}
- free(buf);
- if (!(dd = opendir(unmeta(dir))))
- return mindistd;
- while ((fn = zreaddir(dd, 0))) {
- if (spnamepat && pattry(spnamepat, fn))
- continue;
- nd = spdist(fn, mindistguess,
- (int)strlen(mindistguess) / 4 + 1);
- if (nd <= mindistd) {
- strcpy(mindistbest, fn);
- mindistd = nd;
- if (mindistd == 0)
- break;
+ if ((dd = opendir(unmeta(dir)))) {
+ while ((fn = zreaddir(dd, 0))) {
+ if (spnamepat && pattry(spnamepat, fn))
+ continue;
+ nd = spdist(fn, mindistguess,
+ (int)strlen(mindistguess) / 4 + 1);
+ if (nd <= mindistd) {
+ if (wantdir) {
+ if (!(buf = zrealloc(buf, dirlen + strlen(fn) + 2)))
+ continue;
+ sprintf(buf, "%s/%s", dir, fn);
+ if (stat(unmeta(buf), &st) != 0 || !S_ISDIR(st.st_mode))
+ continue;
+ }
+ strcpy(mindistbest, fn);
+ mindistd = nd;
+ if (mindistd == 0)
+ break;
+ }
}
+ closedir(dd);
}
- closedir(dd);
+ free(buf);
return mindistd;
}
--
cgit v1.2.3
From 83a175795a444e8169fcb592a110d4d15a09b907 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Tue, 6 Oct 2015 09:28:07 +0100
Subject: 36780: Fix crash in ksh mode with -n and $HOME.
If home variable is NULL ensure HOME is unset.
---
ChangeLog | 5 +++++
Src/params.c | 13 +++++++------
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e1f58c9ae..6369cf6e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-06 Peter Stephenson
+
+ * 36780: Src/params.c: ensure HOME parameter is unset if
+ corresponding internal variable is null.
+
2015-10-04 Barton E. Schaefer
* 36773: Src/utils.c: limit CORRECT / CORRECT_ALL to directory
diff --git a/Src/params.c b/Src/params.c
index de151a4cd..a8abb289e 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -775,17 +775,18 @@ createparamtable(void)
#endif
opts[ALLEXPORT] = oae;
+ /*
+ * For native emulation we always set the variable home
+ * (see setupvals()).
+ */
+ pm = (Param) paramtab->getnode(paramtab, "HOME");
if (EMULATION(EMULATE_ZSH))
{
- /*
- * For native emulation we always set the variable home
- * (see setupvals()).
- */
- pm = (Param) paramtab->getnode(paramtab, "HOME");
pm->node.flags &= ~PM_UNSET;
if (!(pm->node.flags & PM_EXPORTED))
addenv(pm, home);
- }
+ } else if (!home)
+ pm->node.flags |= PM_UNSET;
pm = (Param) paramtab->getnode(paramtab, "LOGNAME");
if (!(pm->node.flags & PM_EXPORTED))
addenv(pm, pm->u.str);
--
cgit v1.2.3
From 7a1678767f44f200295d88dfea94902718275266 Mon Sep 17 00:00:00 2001
From: Frank Terbeck
Date: Sun, 11 Oct 2015 11:54:06 +0200
Subject: 36830: vcs_info: Silence an error message with new git versions
Mikael informs me on IRC, that in new versions of git (he used 2.6.1)
where the "am" subcommand is now a builtin, a file that is used by the
git backend of vcs_info (namely .git/rebase-apply/msg-clean) is not
available anymore, leading to an annoying error message:
VCS_INFO_get_data_git:232: no such file or directory: .git/rebase-apply/msg-clean
This patch checks for the availabiliy of the file before using it,
and adjusts the value of the dependant values accordingly.
---
ChangeLog | 5 ++++
Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 34 +++++++++++++++--------
2 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6369cf6e9..c8cad2adb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-11 Frank Terbeck
+
+ * 36830: Functions/VCS_Info/Backends/VCS_INFO_get_data_git:
+ vcs_info: Silence an error message with new git versions
+
2015-10-06 Peter Stephenson
* 36780: Src/params.c: ensure HOME parameter is unset if
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 8664d510e..7fc213916 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -224,18 +224,28 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then
patchdir="${gitdir}/rebase-apply"
local next="${patchdir}/next"
if [[ -f $next ]]; then
- local cur=$(< $next)
- local p subject
- for p in $(seq $(($cur - 1))); do
- git_patches_applied+=("$(printf "%04d" $p) ?")
- done
- subject="${$(< "${patchdir}/msg-clean")[(f)1]}"
- if [[ -f "${patchdir}/original-commit" ]]; then
- git_patches_applied+=("$(< ${patchdir}/original-commit) $subject")
- else
- git_patches_applied+=("? $subject")
- fi
- git_patches_unapplied=($(seq $cur $(< "${patchdir}/last")))
+ local cur=$(< $next)
+ local p subject
+ for p in $(seq $(($cur - 1))); do
+ git_patches_applied+=("$(printf "%04d" $p) ?")
+ done
+ if [[ -f "${patchdir}/msg-clean" ]]; then
+ subject="${$(< "${patchdir}/msg-clean")[(f)1]}"
+ fi
+ if [[ -f "${patchdir}/original-commit" ]]; then
+ if [[ -n $subject ]]; then
+ git_patches_applied+=("$(< ${patchdir}/original-commit) $subject")
+ else
+ git_patches_applied+=("$(< ${patchdir}/original-commit)")
+ fi
+ else
+ if [[ -n $subject ]]; then
+ git_patches_applied+=("? $subject")
+ else
+ git_patches_applied+=("?")
+ fi
+ fi
+ git_patches_unapplied=($(seq $cur $(< "${patchdir}/last")))
fi
VCS_INFO_git_handle_patches
--
cgit v1.2.3
From e245dd71936d1c22fce39f02c203ed2cdb43a548 Mon Sep 17 00:00:00 2001
From: Frank Terbeck
Date: Sun, 11 Oct 2015 12:39:56 +0200
Subject: 36832: vcs_info: Remove dependency on "seq"
The "seq" utility is usually available on GNU systems only. This
exchanges calls to seq with pure zsh features. Also: Less forks are
good.
---
ChangeLog | 3 +++
Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 5 +++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c8cad2adb..be49cf526 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@
* 36830: Functions/VCS_Info/Backends/VCS_INFO_get_data_git:
vcs_info: Silence an error message with new git versions
+ * 36832: Functions/VCS_Info/Backends/VCS_INFO_get_data_git:
+ vcs_info: Remove dependency on "seq"
+
2015-10-06 Peter Stephenson
* 36780: Src/params.c: ensure HOME parameter is unset if
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 7fc213916..fcee47c13 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -226,7 +226,7 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then
if [[ -f $next ]]; then
local cur=$(< $next)
local p subject
- for p in $(seq $(($cur - 1))); do
+ for ((p = 1; p < cur; p++)); do
git_patches_applied+=("$(printf "%04d" $p) ?")
done
if [[ -f "${patchdir}/msg-clean" ]]; then
@@ -245,7 +245,8 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then
git_patches_applied+=("?")
fi
fi
- git_patches_unapplied=($(seq $cur $(< "${patchdir}/last")))
+ local last="$(< "${patchdir}/last")"
+ git_patches_unapplied=( {$cur..$last} )
fi
VCS_INFO_git_handle_patches
--
cgit v1.2.3
From 9f8e3e82dd2c2bb98f72b6e026b72d9c47d5ad62 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sun, 11 Oct 2015 21:11:10 -0700
Subject: 36834: freeheap preserves last allocated heap
This is the first of two optimizations to improve heap performance when
there are a large number of mostly-filled heap arenas.
---
ChangeLog | 4 ++++
Src/mem.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------
2 files changed, 56 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index be49cf526..3adb1f159 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-10-11 Barton E. Schaefer
+
+ * 36834: Src/mem.c: freeheap preserves last allocated heap
+
2015-10-11 Frank Terbeck
* 36830: Functions/VCS_Info/Backends/VCS_INFO_get_data_git:
diff --git a/Src/mem.c b/Src/mem.c
index b9569ea0c..d49f685fe 100644
--- a/Src/mem.c
+++ b/Src/mem.c
@@ -294,7 +294,7 @@ pushheap(void)
#endif
for (h = heaps; h; h = h->next) {
- DPUTS(!h->used, "BUG: empty heap");
+ DPUTS(!h->used && h->next, "BUG: empty heap");
hs = (Heapstack) zalloc(sizeof(*hs));
hs->next = h->sp;
h->sp = hs;
@@ -334,17 +334,15 @@ freeheap(void)
*
* Whenever fheap is NULL here, the loop below sweeps back over the
* entire heap list again, resetting the free space in every arena to
- * the amount stashed by pushheap() and finding the first arena with
+ * the amount stashed by pushheap() and finding the arena with the most
* free space to optimize zhalloc()'s next search. When there's a lot
* of stuff already on the heap, this is an enormous amount of work,
* and performance goes to hell.
*
- * However, if the arena to which fheap points is unused, we want to
- * free it, so we have no choice but to do the sweep for a new fheap.
- */
- if (fheap && !fheap->sp)
- fheap = NULL; /* We used to do this unconditionally */
- /*
+ * Therefore, we defer freeing the most recently allocated arena until
+ * we reach popheap(). This may fail to reclaim some space in earlier
+ * arenas.
+ *
* In other cases, either fheap is already correct, or it has never
* been set and this loop will do it, or it'll be reset from scratch
* on the next popheap(). So all that's needed here is to pick up
@@ -361,7 +359,11 @@ freeheap(void)
memset(arena(h) + h->sp->used, 0xff, h->used - h->sp->used);
#endif
h->used = h->sp->used;
- if (!fheap && h->used < ARENA_SIZEOF(h))
+ if (!fheap) {
+ if (h->used < ARENA_SIZEOF(h))
+ fheap = h;
+ } else if (ARENA_SIZEOF(h) - h->used >
+ ARENA_SIZEOF(fheap) - fheap->used)
fheap = h;
hl = h;
#ifdef ZSH_HEAP_DEBUG
@@ -384,6 +386,26 @@ freeheap(void)
VALGRIND_MEMPOOL_TRIM((char *)h, (char *)arena(h), h->used);
#endif
} else {
+ if (h->next) {
+ /* We want to cut this out of the arena list if we can */
+ if (h == heaps)
+ hl = heaps = h->next;
+ else if (hl && hl->next == h)
+ hl->next = h->next;
+ else {
+ DPUTS(hl, "hl->next != h when freeing");
+ hl = h;
+ continue;
+ }
+ h->next = NULL;
+ } else {
+ /* Leave an empty arena at the end until popped */
+ h->used = 0;
+ fheap = hl = h;
+ break;
+ }
+ if (fheap == h)
+ fheap = NULL;
#ifdef USE_MMAP
munmap((void *) h, h->size);
#else
@@ -441,12 +463,29 @@ popheap(void)
#ifdef ZSH_VALGRIND
VALGRIND_MEMPOOL_TRIM((char *)h, (char *)arena(h), h->used);
#endif
- if (!fheap && h->used < ARENA_SIZEOF(h))
+ if (!fheap) {
+ if (h->used < ARENA_SIZEOF(h))
+ fheap = h;
+ } else if (ARENA_SIZEOF(h) - h->used >
+ ARENA_SIZEOF(fheap) - fheap->used)
fheap = h;
zfree(hs, sizeof(*hs));
hl = h;
} else {
+ if (h->next) {
+ /* We want to cut this out of the arena list if we can */
+ if (h == heaps)
+ hl = heaps = h->next;
+ else if (hl && hl->next == h)
+ hl->next = h->next;
+ else {
+ DPUTS(hl, "hl->next != h when popping");
+ hl = h;
+ continue;
+ }
+ h->next = NULL;
+ }
#ifdef USE_MMAP
munmap((void *) h, h->size);
#else
@@ -524,7 +563,7 @@ zheapptr(void *p)
mod_export void *
zhalloc(size_t size)
{
- Heap h;
+ Heap h, hp = NULL;
size_t n;
#ifdef ZSH_VALGRIND
size_t req_size = size;
@@ -546,6 +585,7 @@ zhalloc(size_t size)
for (h = ((fheap && ARENA_SIZEOF(fheap) >= (size + fheap->used))
? fheap : heaps);
h; h = h->next) {
+ hp = h;
if (ARENA_SIZEOF(h) >= (n = size + h->used)) {
void *ret;
@@ -566,7 +606,6 @@ zhalloc(size_t size)
}
}
{
- Heap hp;
/* not found, allocate new heap */
#if defined(ZSH_MEM) && !defined(USE_MMAP)
static int called = 0;
@@ -575,7 +614,6 @@ zhalloc(size_t size)
#endif
n = HEAP_ARENA_SIZE > size ? HEAPSIZE : size + sizeof(*h);
- for (hp = NULL, h = heaps; h; hp = h, h = h->next);
#ifdef USE_MMAP
h = mmap_heap_alloc(&n);
@@ -607,6 +645,7 @@ zhalloc(size_t size)
VALGRIND_MEMPOOL_ALLOC((char *)h, (char *)arena(h), req_size);
#endif
+ DPUTS(hp && hp->next, "failed to find end of chain in zhalloc");
if (hp)
hp->next = h;
else
--
cgit v1.2.3
From d77bf2ba88c289e28139ce36ac767447113ab95d Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sun, 11 Oct 2015 21:16:58 -0700
Subject: 36836: zhalloc() avoids re-scanning all heaps when the last known
heap with free space does not have enough space
This is the second of two performance optimizations for situations where
all heap arenas in the list are mostly full.
---
ChangeLog | 5 ++++-
Src/mem.c | 12 ++++++++----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3adb1f159..421da2f6f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
2015-10-11 Barton E. Schaefer
- * 36834: Src/mem.c: freeheap preserves last allocated heap
+ * 36836: Src/mem.c: zhalloc() avoids re-scanning all heaps when
+ the last known heap with free space does not have enough space
+
+ * 36834: Src/mem.c: freeheap() preserves last allocated heap
2015-10-11 Frank Terbeck
diff --git a/Src/mem.c b/Src/mem.c
index d49f685fe..191428323 100644
--- a/Src/mem.c
+++ b/Src/mem.c
@@ -582,10 +582,14 @@ zhalloc(size_t size)
/* find a heap with enough free space */
- for (h = ((fheap && ARENA_SIZEOF(fheap) >= (size + fheap->used))
- ? fheap : heaps);
- h; h = h->next) {
- hp = h;
+ /*
+ * This previously assigned:
+ * h = ((fheap && ARENA_SIZEOF(fheap) >= (size + fheap->used))
+ * ? fheap : heaps);
+ * but we think that nothing upstream of fheap has more free space,
+ * so why start over at heaps just because fheap has too little?
+ */
+ for (h = (fheap ? fheap : heaps); h; h = h->next) {
if (ARENA_SIZEOF(h) >= (n = size + h->used)) {
void *ret;
--
cgit v1.2.3
From ce929eb37e0a79d847dbfcaf1436c1a46bca55b2 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sun, 11 Oct 2015 21:23:38 -0700
Subject: 36841: factor out and update the patterns that filter "uninteresting"
functions out of the $funcstack display
---
ChangeLog | 5 +++++
Completion/Base/Widget/_complete_help | 9 ++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 421da2f6f..ae61df68d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2015-10-11 Barton E. Schaefer
+ * 36841: Completion/Base/Widget/_complete_help: factor out and
+ update the patterns that filter "uninteresting" functions out
+ of the $funcstack list when generating the call trace to show
+ where a tag is active.
+
* 36836: Src/mem.c: zhalloc() avoids re-scanning all heaps when
the last known heap with free space does not have enough space
diff --git a/Completion/Base/Widget/_complete_help b/Completion/Base/Widget/_complete_help
index 0563c618f..09637ecb9 100644
--- a/Completion/Base/Widget/_complete_help
+++ b/Completion/Base/Widget/_complete_help
@@ -6,12 +6,15 @@ _complete_help() {
local _sort_tags=_help_sort_tags text i j k tmp
typeset -A help_funcs help_tags help_sfuncs help_styles
+ local -H _help_scan_funcstack="main_complete|complete|approximate|normal"
+ local -H _help_filter_funcstack="alternative|call_function|describe|dispatch|wanted|requested|all_labels|next_label"
+
{
compadd() { return 1 }
zstyle() {
- local _f="${${(@)${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(dispatch|wanted|requested|all_labels|next_label)}% *}"
+ local _f="${${(@)${(@)funcstack[2,(i)_($~_help_scan_funcstack)]}:#(_($~_help_filter_funcstack)|\((eval|anon)\))}% *}"
- [[ -z "$_f" ]] && _f="${${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(dispatch|wanted|requested|all_labels|next_label)}"
+ [[ -z "$_f" ]] && _f="${${(@)funcstack[2,(i)_($~_help_scan_funcstack)]}:#(_($~_help_filter_funcstack)|\((eval|anon)\))}"
if [[ "$help_sfuncs[$2]" != *${_f}* ||
"$help_styles[${2}${_f}]" != *${3}* ]]; then
@@ -73,7 +76,7 @@ _complete_help() {
}
_help_sort_tags() {
- local f="${${(@)${(@)funcstack[3,(i)_(main_complete|complete|approximate|normal)]}:#(_(dispatch|wanted|requested|all_labels|next_label)|\(eval\))}% *}"
+ local f="${${(@)${(@)funcstack[3,(i)_($~_help_scan_funcstack)]}:#(_($~_help_filter_funcstack)|\((eval|anon)\))}% *}"
if [[ "$help_funcs[$curcontext]" != *${f}* ||
"$help_tags[${curcontext}${f}]" != *(${(j:|:)~argv})* ]]; then
--
cgit v1.2.3
From 643aca932aa30083246312eeddd2e0d6befa5861 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Sun, 11 Oct 2015 21:48:10 -0700
Subject: One crucial assignment accidentally lost from 36834 when merging
36836.
---
Src/mem.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Src/mem.c b/Src/mem.c
index 191428323..68bd76740 100644
--- a/Src/mem.c
+++ b/Src/mem.c
@@ -386,6 +386,8 @@ freeheap(void)
VALGRIND_MEMPOOL_TRIM((char *)h, (char *)arena(h), h->used);
#endif
} else {
+ if (fheap == h)
+ fheap = NULL;
if (h->next) {
/* We want to cut this out of the arena list if we can */
if (h == heaps)
@@ -404,8 +406,6 @@ freeheap(void)
fheap = hl = h;
break;
}
- if (fheap == h)
- fheap = NULL;
#ifdef USE_MMAP
munmap((void *) h, h->size);
#else
@@ -590,6 +590,7 @@ zhalloc(size_t size)
* so why start over at heaps just because fheap has too little?
*/
for (h = (fheap ? fheap : heaps); h; h = h->next) {
+ hp = h;
if (ARENA_SIZEOF(h) >= (n = size + h->used)) {
void *ret;
--
cgit v1.2.3
From bab1fc50436f23402696cd5236c0689c4d4dbd59 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Wed, 14 Oct 2015 14:23:16 +0100
Subject: 36856: cdr -p/-P to prune directory list
---
ChangeLog | 5 +++++
Doc/Zsh/contrib.yo | 12 ++++++++++++
Functions/Chpwd/cdr | 37 +++++++++++++++++++++++++++++++------
3 files changed, 48 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ae61df68d..2e31d243b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-14 Peter Stephenson
+
+ * 36856: Doc/Zsh/contrib.yo, Functions/Chpwd/cdr: add -p and -P
+ options to cdr for pruning the directory list.
+
2015-10-11 Barton E. Schaefer
* 36841: Completion/Base/Widget/_complete_help: factor out and
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index 635f9b010..d367d8b0f 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -415,6 +415,18 @@ newlines, where I have in any case no sympathy); directories are in
unabbreviated from and contain an absolute path, i.e. they start with tt(/).
Usually the first entry should be left as the current directory.
)
+item(tt(-p ')var(pattern)tt('))(
+Prunes any items in the directory list that match the given extended glob
+pattern; the pattern needs to be quoted from immediate expansion on the
+command line. The pattern is matched against each completely expanded
+file name in the list; the full string must match, so wildcards at the
+end (e.g. tt('*removeme*')) are needed to remove entries with a given
+substring.
+
+If output is to a terminal, then the function will print the new list
+after pruning and prompt for confirmation by the user. This output and
+confirmation step can be skipped by using tt(-P) instead of tt(-p).
+)
enditem()
subsect(Configuration)
diff --git a/Functions/Chpwd/cdr b/Functions/Chpwd/cdr
index 4f399106b..4bed88b13 100644
--- a/Functions/Chpwd/cdr
+++ b/Functions/Chpwd/cdr
@@ -51,6 +51,13 @@
# (and only /). Usually the first entry should be left as the current
# directory.
#
+# "cdr -p 'pattern'" prunes anything matching the given extended glob
+# pattern from the directory list. The match is against the fully
+# expanded directory path and the full string must match (use wildcards
+# at the ends if needed). If output is going to a terminal, the
+# function will print the new list for the user to confrim; this can be
+# skipped by giving -P instead of -p.
+#
# Details of directory handling
# =============================
#
@@ -217,11 +224,11 @@ setopt extendedglob
autoload -Uz chpwd_recent_filehandler chpwd_recent_add
-integer list set_reply i bad edit
-local opt dir
+integer list set_reply i bad edit force_prune
+local opt dir prune
local -aU dirs
-while getopts "elr" opt; do
+while getopts "elp:P:r" opt; do
case $opt in
(e)
edit=1
@@ -231,6 +238,12 @@ while getopts "elr" opt; do
list=1
;;
+ ([pP])
+ prune=$OPTARG
+ edit=1
+ [[ $opt = P ]] && force_prune=1
+ ;;
+
(r)
set_reply=1
;;
@@ -278,10 +291,22 @@ if [[ $PWD != $reply[1] ]]; then
fi
if (( edit )); then
- local compcontext='directories:directory:_path_files -/'
-IFS='
+ if [[ -n $prune ]]; then
+ reply=(${reply:#$~prune})
+ if [[ force_prune -eq 0 && -t 1 ]]; then
+ print -nrl "New list:" $reply 'Accept? '
+ if ! read -q; then
+ print
+ return 1
+ fi
+ print
+ fi
+ else
+ local compcontext='directories:directory:_path_files -/'
+ IFS='
' vared reply || return 1
-chpwd_recent_filehandler $reply
+ fi
+ chpwd_recent_filehandler $reply
fi
# Skip current directory if present (may have been pruned).
--
cgit v1.2.3
From 827d36077641ca87d1796b9c5cb05e7c44b01919 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer"
Date: Wed, 14 Oct 2015 21:46:26 -0700
Subject: 36853: replace pushheap/popheap by NEWHEAPS/OLDHEAPS in doshfunc() to
optimize memory management
Includes re-indentation that was not done in the posted patch.
---
ChangeLog | 5 +
Src/exec.c | 402 ++++++++++++++++++++++++++++++-------------------------------
2 files changed, 206 insertions(+), 201 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2e31d243b..f0c88c979 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-14 Barton E. Schaefer
+
+ * 36853: Src/exec.c: replace pushheap/popheap by NEWHEAPS/OLDHEAPS
+ in doshfunc() to optimize memory management
+
2015-10-14 Peter Stephenson
* 36856: Doc/Zsh/contrib.yo, Functions/Chpwd/cdr: add -p and -P
diff --git a/Src/exec.c b/Src/exec.c
index bcc8065a2..f0d1d2f70 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -5067,230 +5067,230 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
#ifdef MAX_FUNCTION_DEPTH
static int funcdepth;
#endif
+ Heap funcheap;
queue_signals(); /* Lots of memory and global state changes coming */
- pushheap();
+ NEWHEAPS(funcheap) {
+ oargv0 = NULL;
+ obreaks = breaks;
+ ocontflag = contflag;
+ oloops = loops;
+ if (trap_state == TRAP_STATE_PRIMED)
+ trap_return--;
+ oldlastval = lastval;
+ oldnumpipestats = numpipestats;
+ if (noreturnval) {
+ /*
+ * Easiest to use the heap here since we're bracketed
+ * immediately by a pushheap/popheap pair.
+ */
+ size_t bytes = sizeof(int)*numpipestats;
+ oldpipestats = (int *)zhalloc(bytes);
+ memcpy(oldpipestats, pipestats, bytes);
+ }
- oargv0 = NULL;
- obreaks = breaks;
- ocontflag = contflag;
- oloops = loops;
- if (trap_state == TRAP_STATE_PRIMED)
- trap_return--;
- oldlastval = lastval;
- oldnumpipestats = numpipestats;
- if (noreturnval) {
- /*
- * Easiest to use the heap here since we're bracketed
- * immediately by a pushheap/popheap pair.
- */
- size_t bytes = sizeof(int)*numpipestats;
- oldpipestats = (int *)zhalloc(bytes);
- memcpy(oldpipestats, pipestats, bytes);
- }
+ starttrapscope();
+ startpatternscope();
+
+ pptab = pparams;
+ if (!(flags & PM_UNDEFINED))
+ scriptname = dupstring(name);
+ oldzoptind = zoptind;
+ oldoptcind = optcind;
+ if (!isset(POSIXBUILTINS)) {
+ zoptind = 1;
+ optcind = 0;
+ }
- starttrapscope();
- startpatternscope();
-
- pptab = pparams;
- if (!(flags & PM_UNDEFINED))
- scriptname = dupstring(name);
- oldzoptind = zoptind;
- oldoptcind = optcind;
- if (!isset(POSIXBUILTINS)) {
- zoptind = 1;
- optcind = 0;
- }
+ /* We need to save the current options even if LOCALOPTIONS is *
+ * not currently set. That's because if it gets set in the *
+ * function we need to restore the original options on exit. */
+ memcpy(saveopts, opts, sizeof(opts));
+ saveemulation = emulation;
+ save_sticky = sticky;
- /* We need to save the current options even if LOCALOPTIONS is *
- * not currently set. That's because if it gets set in the *
- * function we need to restore the original options on exit. */
- memcpy(saveopts, opts, sizeof(opts));
- saveemulation = emulation;
- save_sticky = sticky;
+ if (sticky_emulation_differs(shfunc->sticky)) {
+ /*
+ * Function is marked for sticky emulation.
+ * Enable it now.
+ *
+ * We deliberately do not do this if the sticky emulation
+ * in effect is the same as that requested. This enables
+ * option setting naturally within emulation environments.
+ * Note that a difference in EMULATE_FULLY (emulate with
+ * or without -R) counts as a different environment.
+ *
+ * This propagates the sticky emulation to subfunctions.
+ */
+ sticky = sticky_emulation_dup(shfunc->sticky, 1);
+ emulation = sticky->emulation;
+ restore_sticky = 1;
+ installemulation(emulation, opts);
+ if (sticky->n_on_opts) {
+ OptIndex *onptr;
+ for (onptr = sticky->on_opts;
+ onptr < sticky->on_opts + sticky->n_on_opts;
+ onptr++)
+ opts[*onptr] = 1;
+ }
+ if (sticky->n_off_opts) {
+ OptIndex *offptr;
+ for (offptr = sticky->off_opts;
+ offptr < sticky->off_opts + sticky->n_off_opts;
+ offptr++)
+ opts[*offptr] = 0;
+ }
+ /* All emulations start with pattern disables clear */
+ clearpatterndisables();
+ } else
+ restore_sticky = 0;
- if (sticky_emulation_differs(shfunc->sticky)) {
+ if (flags & (PM_TAGGED|PM_TAGGED_LOCAL))
+ opts[XTRACE] = 1;
+ else if (oflags & PM_TAGGED_LOCAL)
+ opts[XTRACE] = 0;
+ ooflags = oflags;
/*
- * Function is marked for sticky emulation.
- * Enable it now.
- *
- * We deliberately do not do this if the sticky emulation
- * in effect is the same as that requested. This enables
- * option setting naturally within emulation environments.
- * Note that a difference in EMULATE_FULLY (emulate with
- * or without -R) counts as a different environment.
- *
- * This propagates the sticky emulation to subfunctions.
+ * oflags is static, because we compare it on the next recursive
+ * call. Hence also we maintain ooflags for restoring the previous
+ * value of oflags after the call.
*/
- sticky = sticky_emulation_dup(shfunc->sticky, 1);
- emulation = sticky->emulation;
- restore_sticky = 1;
- installemulation(emulation, opts);
- if (sticky->n_on_opts) {
- OptIndex *onptr;
- for (onptr = sticky->on_opts;
- onptr < sticky->on_opts + sticky->n_on_opts;
- onptr++)
- opts[*onptr] = 1;
- }
- if (sticky->n_off_opts) {
- OptIndex *offptr;
- for (offptr = sticky->off_opts;
- offptr < sticky->off_opts + sticky->n_off_opts;
- offptr++)
- opts[*offptr] = 0;
- }
- /* All emulations start with pattern disables clear */
- clearpatterndisables();
- } else
- restore_sticky = 0;
-
- if (flags & (PM_TAGGED|PM_TAGGED_LOCAL))
- opts[XTRACE] = 1;
- else if (oflags & PM_TAGGED_LOCAL)
- opts[XTRACE] = 0;
- ooflags = oflags;
- /*
- * oflags is static, because we compare it on the next recursive
- * call. Hence also we maintain ooflags for restoring the previous
- * value of oflags after the call.
- */
- oflags = flags;
- opts[PRINTEXITVALUE] = 0;
- if (doshargs) {
- LinkNode node;
-
- node = firstnode(doshargs);
- pparams = x = (char **) zshcalloc(((sizeof *x) *
- (1 + countlinknodes(doshargs))));
- if (isset(FUNCTIONARGZERO)) {
- oargv0 = argzero;
- argzero = ztrdup(getdata(node));
- }
- /* first node contains name regardless of option */
- node = node->next;
- for (; node; node = node->next, x++)
- *x = ztrdup(getdata(node));
- } else {
- pparams = (char **) zshcalloc(sizeof *pparams);
- if (isset(FUNCTIONARGZERO)) {
- oargv0 = argzero;
- argzero = ztrdup(argzero);
+ oflags = flags;
+ opts[PRINTEXITVALUE] = 0;
+ if (doshargs) {
+ LinkNode node;
+
+ node = firstnode(doshargs);
+ pparams = x = (char **) zshcalloc(((sizeof *x) *
+ (1 + countlinknodes(doshargs))));
+ if (isset(FUNCTIONARGZERO)) {
+ oargv0 = argzero;
+ argzero = ztrdup(getdata(node));
+ }
+ /* first node contains name regardless of option */
+ node = node->next;
+ for (; node; node = node->next, x++)
+ *x = ztrdup(getdata(node));
+ } else {
+ pparams = (char **) zshcalloc(sizeof *pparams);
+ if (isset(FUNCTIONARGZERO)) {
+ oargv0 = argzero;
+ argzero = ztrdup(argzero);
+ }
}
- }
#ifdef MAX_FUNCTION_DEPTH
- if(++funcdepth > MAX_FUNCTION_DEPTH)
- {
- zerr("maximum nested function level reached");
- goto undoshfunc;
- }
+ if(++funcdepth > MAX_FUNCTION_DEPTH)
+ {
+ zerr("maximum nested function level reached");
+ goto undoshfunc;
+ }
#endif
- fstack.name = dupstring(name);
- /*
- * The caller is whatever is immediately before on the stack,
- * unless we're at the top, in which case it's the script
- * or interactive shell name.
- */
- fstack.caller = funcstack ? funcstack->name :
- dupstring(oargv0 ? oargv0 : argzero);
- fstack.lineno = lineno;
- fstack.prev = funcstack;
- fstack.tp = FS_FUNC;
- funcstack = &fstack;
-
- fstack.flineno = shfunc->lineno;
- fstack.filename = dupstring(shfunc->filename);
-
- prog = shfunc->funcdef;
- if (prog->flags & EF_RUN) {
- Shfunc shf;
+ fstack.name = dupstring(name);
+ /*
+ * The caller is whatever is immediately before on the stack,
+ * unless we're at the top, in which case it's the script
+ * or interactive shell name.
+ */
+ fstack.caller = funcstack ? funcstack->name :
+ dupstring(oargv0 ? oargv0 : argzero);
+ fstack.lineno = lineno;
+ fstack.prev = funcstack;
+ fstack.tp = FS_FUNC;
+ funcstack = &fstack;
- prog->flags &= ~EF_RUN;
+ fstack.flineno = shfunc->lineno;
+ fstack.filename = dupstring(shfunc->filename);
- runshfunc(prog, NULL, fstack.name);
+ prog = shfunc->funcdef;
+ if (prog->flags & EF_RUN) {
+ Shfunc shf;
- if (!(shf = (Shfunc) shfunctab->getnode(shfunctab,
- (name = fname)))) {
- zwarn("%s: function not defined by file", name);
- if (noreturnval)
- errflag |= ERRFLAG_ERROR;
- else
- lastval = 1;
- goto doneshfunc;
+ prog->flags &= ~EF_RUN;
+
+ runshfunc(prog, NULL, fstack.name);
+
+ if (!(shf = (Shfunc) shfunctab->getnode(shfunctab,
+ (name = fname)))) {
+ zwarn("%s: function not defined by file", name);
+ if (noreturnval)
+ errflag |= ERRFLAG_ERROR;
+ else
+ lastval = 1;
+ goto doneshfunc;
+ }
+ prog = shf->funcdef;
}
- prog = shf->funcdef;
- }
- runshfunc(prog, wrappers, fstack.name);
- doneshfunc:
- funcstack = fstack.prev;
+ runshfunc(prog, wrappers, fstack.name);
+ doneshfunc:
+ funcstack = fstack.prev;
#ifdef MAX_FUNCTION_DEPTH
- undoshfunc:
- --funcdepth;
+ undoshfunc:
+ --funcdepth;
#endif
- if (retflag) {
- retflag = 0;
- breaks = obreaks;
- }
- freearray(pparams);
- if (oargv0) {
- zsfree(argzero);
- argzero = oargv0;
- }
- pparams = pptab;
- if (!isset(POSIXBUILTINS)) {
- zoptind = oldzoptind;
- optcind = oldoptcind;
- }
- scriptname = oldscriptname;
- oflags = ooflags;
+ if (retflag) {
+ retflag = 0;
+ breaks = obreaks;
+ }
+ freearray(pparams);
+ if (oargv0) {
+ zsfree(argzero);
+ argzero = oargv0;
+ }
+ pparams = pptab;
+ if (!isset(POSIXBUILTINS)) {
+ zoptind = oldzoptind;
+ optcind = oldoptcind;
+ }
+ scriptname = oldscriptname;
+ oflags = ooflags;
- endpatternscope(); /* before restoring old LOCALPATTERNS */
+ endpatternscope(); /* before restoring old LOCALPATTERNS */
- if (restore_sticky) {
- /*
- * If we switched to an emulation environment just for
- * this function, we interpret the option and emulation
- * switch as being a firewall between environments.
- */
- memcpy(opts, saveopts, sizeof(opts));
- emulation = saveemulation;
- sticky = save_sticky;
- } else if (isset(LOCALOPTIONS)) {
- /* restore all shell options except PRIVILEGED and RESTRICTED */
- saveopts[PRIVILEGED] = opts[PRIVILEGED];
- saveopts[RESTRICTED] = opts[RESTRICTED];
- memcpy(opts, saveopts, sizeof(opts));
- emulation = saveemulation;
- } else {
- /* just restore a couple. */
- opts[XTRACE] = saveopts[XTRACE];
- opts[PRINTEXITVALUE] = saveopts[PRINTEXITVALUE];
- opts[LOCALOPTIONS] = saveopts[LOCALOPTIONS];
- opts[LOCALLOOPS] = saveopts[LOCALLOOPS];
- }
+ if (restore_sticky) {
+ /*
+ * If we switched to an emulation environment just for
+ * this function, we interpret the option and emulation
+ * switch as being a firewall between environments.
+ */
+ memcpy(opts, saveopts, sizeof(opts));
+ emulation = saveemulation;
+ sticky = save_sticky;
+ } else if (isset(LOCALOPTIONS)) {
+ /* restore all shell options except PRIVILEGED and RESTRICTED */
+ saveopts[PRIVILEGED] = opts[PRIVILEGED];
+ saveopts[RESTRICTED] = opts[RESTRICTED];
+ memcpy(opts, saveopts, sizeof(opts));
+ emulation = saveemulation;
+ } else {
+ /* just restore a couple. */
+ opts[XTRACE] = saveopts[XTRACE];
+ opts[PRINTEXITVALUE] = saveopts[PRINTEXITVALUE];
+ opts[LOCALOPTIONS] = saveopts[LOCALOPTIONS];
+ opts[LOCALLOOPS] = saveopts[LOCALLOOPS];
+ }
- if (opts[LOCALLOOPS]) {
- if (contflag)
- zwarn("`continue' active at end of function scope");
- if (breaks)
- zwarn("`break' active at end of function scope");
- breaks = obreaks;
- contflag = ocontflag;
- loops = oloops;
- }
+ if (opts[LOCALLOOPS]) {
+ if (contflag)
+ zwarn("`continue' active at end of function scope");
+ if (breaks)
+ zwarn("`break' active at end of function scope");
+ breaks = obreaks;
+ contflag = ocontflag;
+ loops = oloops;
+ }
- endtrapscope();
+ endtrapscope();
- if (trap_state == TRAP_STATE_PRIMED)
- trap_return++;
- ret = lastval;
- if (noreturnval) {
- lastval = oldlastval;
- numpipestats = oldnumpipestats;
- memcpy(pipestats, oldpipestats, sizeof(int)*numpipestats);
- }
- popheap();
+ if (trap_state == TRAP_STATE_PRIMED)
+ trap_return++;
+ ret = lastval;
+ if (noreturnval) {
+ lastval = oldlastval;
+ numpipestats = oldnumpipestats;
+ memcpy(pipestats, oldpipestats, sizeof(int)*numpipestats);
+ }
+ } OLDHEAPS;
unqueue_signals();
--
cgit v1.2.3
From 21b6852b15c563c434ae053b71d109e4c6010479 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Thu, 15 Oct 2015 11:24:21 +0100
Subject: 36864: new objdump completion and tweak to nm completion
---
ChangeLog | 6 ++++++
Completion/Unix/Command/_nm | 2 +-
Completion/Unix/Command/_objdump | 8 ++++++++
3 files changed, 15 insertions(+), 1 deletion(-)
create mode 100644 Completion/Unix/Command/_objdump
diff --git a/ChangeLog b/ChangeLog
index f0c88c979..c84b643b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-10-15 Peter Stephenson
+
+ * 36864: Completion/Unix/Command/_nm,
+ Completion/Unix/Command/_objdump: new objdump completion plus
+ tweak to _nm.
+
2015-10-14 Barton E. Schaefer
* 36853: Src/exec.c: replace pushheap/popheap by NEWHEAPS/OLDHEAPS
diff --git a/Completion/Unix/Command/_nm b/Completion/Unix/Command/_nm
index 80136329d..d171ef5a3 100644
--- a/Completion/Unix/Command/_nm
+++ b/Completion/Unix/Command/_nm
@@ -6,7 +6,7 @@ _nm_object_file() {
[[ -x $REPLY || $REPLY = *.([ao]|so|elf) ]]
}
-files="*:object file:_files -g '*(-.e:_nm_object_file:)'"
+files="*:object file:_files -g '*(-.e,_nm_object_file,)'"
args=(
'(-A -o --print-file-name)'{-A,-o,--print-file-name}'[print name of input file on each line]'
'(--demangle)-C[decode symbol names]'
diff --git a/Completion/Unix/Command/_objdump b/Completion/Unix/Command/_objdump
new file mode 100644
index 000000000..607719a19
--- /dev/null
+++ b/Completion/Unix/Command/_objdump
@@ -0,0 +1,8 @@
+#compdef objdump
+
+# borrowed from _nm_object_file
+_objdump_object_file() {
+ [[ -x $REPLY || $REPLY = *.([ao]|so|elf) ]]
+}
+
+_arguments -- '*:object file:_files -g "*(-.e,_objdump_object_file,)"'
--
cgit v1.2.3
From 2e600b432a1a0167304ba5b57738b9f5c0af1cc3 Mon Sep 17 00:00:00 2001
From: Frank Terbeck
Date: Sun, 18 Oct 2015 20:27:55 +0200
Subject: 36888: vcs_info: Prevent warn_create_global warning with '-preinit-'
state
This is related to 33405. Turns out that not all other calls to
VCS_INFO_set are okay: With recent zsh versions the early call to that
function with the '-preinit-' argument causes a warning like this:
VCS_INFO_set:9: math parameter maxexports created globally
in function VCS_INFO_set
This fixes it.
---
ChangeLog | 5 +++++
Functions/VCS_Info/vcs_info | 2 ++
2 files changed, 7 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index c84b643b4..70a8d2e2e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-18 Frank Terbeck
+
+ * 36888: Functions/VCS_Info/vcs_info: vcs_info: Prevent
+ warn_create_global warning with '-preinit-' state
+
2015-10-15 Peter Stephenson