diff options
-rw-r--r-- | ChangeLog | 57 | ||||
-rw-r--r-- | Completion/Unix/Command/_git | 2 | ||||
-rw-r--r-- | Config/version.mk | 4 | ||||
-rw-r--r-- | Doc/Zsh/expn.yo | 14 | ||||
-rw-r--r-- | Doc/Zsh/zle.yo | 25 | ||||
-rw-r--r-- | Functions/Zle/bracketed-paste-magic | 16 | ||||
-rw-r--r-- | NEWS | 13 | ||||
-rw-r--r-- | README | 3 | ||||
-rw-r--r-- | Src/Modules/curses.c | 2 | ||||
-rw-r--r-- | Src/Zle/comp.h | 5 | ||||
-rw-r--r-- | Src/Zle/zle.h | 2 | ||||
-rw-r--r-- | Src/Zle/zle_main.c | 2 | ||||
-rw-r--r-- | Src/Zle/zle_params.c | 30 | ||||
-rw-r--r-- | Src/compat.c | 2 | ||||
-rw-r--r-- | Src/hist.c | 6 | ||||
-rw-r--r-- | Src/pattern.c | 43 | ||||
-rw-r--r-- | Src/zsh.h | 17 | ||||
-rw-r--r-- | Test/D07multibyte.ztst | 6 | ||||
-rw-r--r-- | Test/E01options.ztst | 2 |
19 files changed, 223 insertions, 28 deletions
@@ -1,3 +1,60 @@ +2015-09-11 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * unposted: Config/version.mk: 5.1.1 + + * Sebastian Gniazdowski: 36489: Src/Modules/curses.c: fix bug + with hash table for colours. + + * 36483: Functions/Zle/bracketed-paste-magic: use + [[:INCOMPLETE:]] to get rest of multibyte character. + +2015-09-11 Peter Stephenson <p.stephenson@samsung.com> + + * unposted: NEWS, README: update for minor new features that + have just appeared. + +2015-09-10 Daniel Shahaf <d.s@daniel.shahaf.name> + + * 36445: Doc/Zsh/zle.yo Src/Zle/zle_params.c: Expose yankb, + yanke, ZLE_YANK to widgets. + +2015-09-10 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * 36478: Src/pattern.c, Src/zsh.h, Src/Zle/comp.h, + Doc/Zsh/expn.yo, Test/D07multibyte.ztst: add [[:INCOMPLETE:]] and + [[:INVALID:]] pattern tests. + +2015-09-10 Barton E. Schaefer <schaefer@zsh.org> + + * 36470: Src/Zle/zle_main.c: Auxiliary to 36468, return an empty + buffer from zleread() if a widget exits + +2015-09-10 Peter Stephenson <p.stephenson@samsung.com> + + * 36468: Src/hist.c: Infinite loop if we tried to exit from a + Zle widget but the lexer thought the current lexical expression + needed finishing. + + * 36460: Test/E01options.ztst: Discard benign error on failure + to write to pipe with no one reading. + +2015-09-08 Oliver Kiddle <opk@zsh.org> + + 36422: Src/compat.c: add missing unmeta() + +2015-09-07 Daniel Shahaf <d.s@daniel.shahaf.name> + + * 36437: Doc/Zsh/zle.yo Src/Zle/zle.h: Document interaction of + $region_highlight and $zle_highlight. + + * unposted: Doc/Zsh/zle.yo: ZLE_STATE: fix obvious documentation + typo. + +2015-09-07 James Clarke <jrtc27@jrtc27.com> + + * 36441: Completion/Unix/Command/_git: _git: Fixed typo in + --author-date-order description + 2015-09-06 Peter Stephenson <p.w.stephenson@ntlworld.com> * unposted: Config/versiom.mk, Etc/FAQ.yo, NEWS, README: make diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 7f7c3ebc7..40a9fb63b 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -6436,7 +6436,7 @@ __git_setup_revision_options () { '(--full-history --dense --sparse --simplify-merges )--ancestry-path[only display commits that exists directly on ancestry chains]' '( --date-order --author-date-order)--topo-order[display commits in topological order]' '(--topo-order --author-date-order)--date-order[display commits in date order]' - '(--topo-order --date-order )--author-date-order[display commits in auhor date order]' + '(--topo-order --date-order )--author-date-order[display commits in author date order]' '(-g --walk-reflogs)--reverse[display commits in reverse order]' '( --objects-edge)--objects[display object ids of objects referenced by listed commits]' '(--objects )--objects-edge[display object ids of objects referenced by listed and excluded commits]' diff --git a/Config/version.mk b/Config/version.mk index 777a852d8..21577997b 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-test-1 -VERSION_DATE='September 6, 2015' +VERSION=5.1.1 +VERSION_DATE='September 11, 2015' diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index d44b40a3b..5ea8610f2 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -1956,6 +1956,20 @@ ifzman(the zmanref(zshparam) manual page)\ ifnzman(noderef(Parameters Used By The Shell))\ . ) +item(tt([:INCOMPLETE:]))( +Matches a byte that starts an incomplete multibyte character. +Note that there may be a sequence of more than one bytes that +taken together form the prefix of a multibyte character. To +test for a potentially incomplete byte sequence, use the pattern +`tt([[:INCOMPLETE:]]*)'. This will never match a sequence starting +with a valid multibyte character. +) +item(tt([:INVALID:]))( +Matches a byte that does not start a valid multibyte character. +Note this may be a continuation byte of an incomplete multibyte +character as any part of a multibyte string consisting of invalid and +incomplete multibyte characters is treated as single bytes. +) item(tt([:WORD:]))( The character is treated as part of a word; this test is sensitive to the value of the tt(WORDCHARS) parameter diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo index 4e9369508..2c539c460 100644 --- a/Doc/Zsh/zle.yo +++ b/Doc/Zsh/zle.yo @@ -955,6 +955,11 @@ any predisplay string should be highlighted in bold. Note that the effect of tt(region_highlight) is not saved and disappears as soon as the line is accepted. + +The final highlighting on the command line depends on both tt(region_highlight) +and tt(zle_highlight); see +ifzman(the section CHARACTER HIGHLIGHTING below)\ +ifnzman(noderef(Character Highlighting)) for details. ) vindex(UNDO_CHANGE_NO) item(tt(UNDO_CHANGE_NO) (integer))( @@ -1000,6 +1005,18 @@ executed; the second argument that followed tt(zle -C) when the widget was defined. This is the name of a builtin completion widget. For widgets defined with tt(zle -N) this is set to the empty string. Read-only. ) +vindex(YANK_ACTIVE) +vindex(YANK_START) +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 unit sas +tt(CURSOR), and are only valid when tt(YANK_ACTIVE) is non-zero. + +All three are read-only. +) vindex(ZLE_STATE) item(tt(ZLE_STATE) (scalar))( Contains a set of space-separated words that describe the current tt(zle) @@ -1018,7 +1035,7 @@ The substrings are sorted in alphabetical order so that if you want to test for two specific substrings in a future-proof way, you can do match by doing: -example(if [[ $ZLE_STATE == *insert*globalhistory* ]]; then ...; fi) +example(if [[ $ZLE_STATE == *globalhistory*insert* ]]; then ...; fi) ) enditem() @@ -2521,6 +2538,12 @@ Following a command to paste text, the characters that were inserted. ) enditem() +When tt(region_highlight) is set, the contexts that describe a region DASH()- +tt(isearch), tt(region), tt(suffix), and tt(paste) DASH()- +are applied first, then tt(region_highlight) is applied, then the remaining +tt(zle_highlight) contexts are applied. If a particular character is +affected by multiple specifications, the last specification wins. + tt(zle_highlight) may contain additional fields for controlling how terminal sequences to change colours are output. Each of the following is followed by a colon and a string in the same form as for key bindings. diff --git a/Functions/Zle/bracketed-paste-magic b/Functions/Zle/bracketed-paste-magic index 49f4b6620..464c6b339 100644 --- a/Functions/Zle/bracketed-paste-magic +++ b/Functions/Zle/bracketed-paste-magic @@ -164,17 +164,25 @@ 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 - PASTED=${PASTED#$KEYS} - if [[ $KEYS = ${(~j:|:)${(b)bpm_inactive}} ]]; then - zle .self-insert-unmeta + 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 else case $REPLY in (${~bpm_active}) function () { emulate -L $bpm_emulate; set -$bpm_opts zle $REPLY };; - (*) zle .self-insert-unmeta;; + (*) LBUFFER+=$mbchar; esac fi done @@ -4,7 +4,18 @@ CHANGES FROM PREVIOUS VERSIONS OF ZSH Note also the list of incompatibilities in the README file. -There are no significant changes between 5.1 and 5.1.1. +Changes from 5.1 to 5.1.1 +------------------------- + +5.1.1 is primarily a bug fix release; however, a few minor features were +added. + +The ZLE variables YANK_ACTIVE, YANK_START and YANK_END have been added +and are useful for managing highlighting. + +The zsh-specific pattern match range tests have been supplemented with +[:INCOMPLETE:] and [:INVALID:] to help detect the state of partially +read multibyte character strings. Changes from 5.0.8 to 5.1 ------------------------- @@ -10,7 +10,8 @@ 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 only bug fixes between 5.1 and 5.1.1. +There are mostly bug fixes between 5.1 and 5.1.1; however, a fewer minor +features useful in resolving problems with shell functions were added. Installing Zsh -------------- diff --git a/Src/Modules/curses.c b/Src/Modules/curses.c index 62dbd55ea..0054aef52 100644 --- a/Src/Modules/curses.c +++ b/Src/Modules/curses.c @@ -339,7 +339,7 @@ zcurses_colorget(const char *nam, char *colorpair) return NULL; if (zc_color_phase==1 || - !(cpn = (Colorpairnode) gethashnode(zcurses_colorpairs, colorpair))) { + !(cpn = (Colorpairnode) gethashnode2(zcurses_colorpairs, colorpair))) { zc_color_phase = 2; cp = ztrdup(colorpair); diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h index 34da2cabb..023c41814 100644 --- a/Src/Zle/comp.h +++ b/Src/Zle/comp.h @@ -202,8 +202,9 @@ struct cpattern { * TODO: this will change. */ #ifdef MULTIBYTE_SUPPORT -#define PATMATCHRANGE(r, c, ip, mtp) mb_patmatchrange(r, c, ip, mtp) -#define PATMATCHINDEX(r, i, cp, mtp) mb_patmatchindex(r, i, cp, mtp) +#define PATMATCHRANGE(r, c, ip, mtp) \ + mb_patmatchrange(r, c, ZMB_VALID, ip, mtp) +#define PATMATCHINDEX(r, i, cp, mtp) mb_patmatchindex(r, i, cp, mtp) #define CONVCAST(c) ((wchar_t)(c)) #define CHR_INVALID (WEOF) #else diff --git a/Src/Zle/zle.h b/Src/Zle/zle.h index 59f459185..2d672de3b 100644 --- a/Src/Zle/zle.h +++ b/Src/Zle/zle.h @@ -431,6 +431,8 @@ struct region_highlight { * 2: suffix * 3: pasted text */ +/* If you change this, update the documentation of zle_highlight/region_highlight + * interaction in Doc/Zsh/zle.yo. */ #define N_SPECIAL_HIGHLIGHTS (4) diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index e610ae1f3..ec3d2c354 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1276,7 +1276,7 @@ zleread(char **lp, char **rp, int flags, int context, char *init, char *finish) alarm(0); freeundo(); - if (eofsent || errflag) { + if (eofsent || errflag || exit_pending) { s = NULL; } else { zleline[zlell++] = ZWC('\n'); diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c index b84e72088..000bc388c 100644 --- a/Src/Zle/zle_params.c +++ b/Src/Zle/zle_params.c @@ -97,6 +97,12 @@ static const struct gsu_integer undo_change_no_gsu = { get_undo_current_change, NULL, zleunsetfn }; 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 }; +static const struct gsu_integer yankend_gsu = +{ get_yankend, NULL, zleunsetfn }; +static const struct gsu_integer yankactive_gsu = +{ get_yankactive, NULL, zleunsetfn }; static const struct gsu_array killring_gsu = { get_killring, set_killring, unset_killring }; @@ -143,6 +149,9 @@ 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_ACTIVE", PM_INTEGER | PM_READONLY, GSU(yankactive_gsu), NULL }, { "ZLE_STATE", PM_SCALAR | PM_READONLY, GSU(zle_state_gsu), NULL }, { NULL, 0, NULL, NULL } }; @@ -477,6 +486,27 @@ get_pending(UNUSED(Param pm)) } /**/ +static zlong +get_yankstart(UNUSED(Param pm)) +{ + return yankb; +} + +/**/ +static zlong +get_yankend(UNUSED(Param pm)) +{ + return yanke; +} + +/**/ +static zlong +get_yankactive(UNUSED(Param pm)) +{ + return lastcmd & ZLE_YANK; +} + +/**/ static char * get_cutbuffer(UNUSED(Param pm)) { diff --git a/Src/compat.c b/Src/compat.c index db468529a..9041c0bed 100644 --- a/Src/compat.c +++ b/Src/compat.c @@ -448,7 +448,7 @@ zgetcwd(void) } #endif /* HAVE_GETCWD */ if (!ret) - ret = pwd; + ret = unmeta(pwd); if (!ret) ret = dupstring("."); return ret; diff --git a/Src/hist.c b/Src/hist.c index 75e809c48..9c42d85c9 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -390,6 +390,12 @@ ihgetc(void) { int c = ingetc(); + if (exit_pending) + { + lexstop = 1; + errflag |= ERRFLAG_ERROR; + return ' '; + } qbang = 0; if (!stophist && !(inbufflags & INP_ALIAS)) { /* If necessary, expand history characters. */ diff --git a/Src/pattern.c b/Src/pattern.c index b4ba33e49..3b55ccf1c 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -145,7 +145,7 @@ typedef union upat *Upat; * * P_ANY, P_ANYOF: the operand is a null terminated * string. Normal characters match as expected. Characters - * in the range Meta+PP_ALPHA..Meta+PP_UNKNWN do the appropriate + * in the range Meta+PP_ALPHA..Meta+PP_UNKWN do the appropriate * Posix range tests. This relies on imeta returning true for these * characters. We treat unknown POSIX ranges as never matching. * PP_RANGE means the next two (possibly metafied) characters form @@ -1119,7 +1119,7 @@ patgetglobflags(char **strp, long *assertp, int *ignore) static const char *colon_stuffs[] = { "alpha", "alnum", "ascii", "blank", "cntrl", "digit", "graph", "lower", "print", "punct", "space", "upper", "xdigit", "IDENT", - "IFS", "IFSSPACE", "WORD", NULL + "IFS", "IFSSPACE", "WORD", "INCOMPLETE", "INVALID", NULL }; /* @@ -1870,9 +1870,9 @@ static int globdots; /* Glob initial dots? */ #ifdef MULTIBYTE_SUPPORT /* Get a character from the start point in a string */ -#define CHARREF(x, y) charref((x), (y)) +#define CHARREF(x, y) charref((x), (y), (int *)NULL) static wchar_t -charref(char *x, char *y) +charref(char *x, char *y, int *zmb_ind) { wchar_t wc; size_t ret; @@ -1886,9 +1886,13 @@ charref(char *x, char *y) /* Error. */ /* Reset the shift state for next time. */ memset(&shiftstate, 0, sizeof(shiftstate)); + if (zmb_ind) + *zmb_ind = (ret == MB_INVALID) ? ZMB_INVALID : ZMB_INCOMPLETE; return WCHAR_INVALID(*x); } + if (zmb_ind) + *zmb_ind = ZMB_VALID; return wc; } @@ -2580,10 +2584,11 @@ patmatch(Upat prog) fail = 1; else { #ifdef MULTIBYTE_SUPPORT - wchar_t cr = CHARREF(patinput, patinend); + int zmb_ind; + wchar_t cr = charref(patinput, patinend, &zmb_ind); char *scanop = (char *)P_OPERAND(scan); if (patglobflags & GF_MULTIBYTE) { - if (mb_patmatchrange(scanop, cr, NULL, NULL) ^ + if (mb_patmatchrange(scanop, cr, zmb_ind, NULL, NULL) ^ (P_OP(scan) == P_ANYOF)) fail = 1; else @@ -3351,6 +3356,9 @@ patmatch(Upat prog) * The null-terminated specification is in range; the test * character is in ch. * + * zmb is one of the enum defined above charref(), for indicating + * incomplete or invalid multibyte characters. + * * indptr is used by completion matching, which is why this * function is exported. If indptr is not NULL we set *indptr * to the index of the character in the range string, adjusted @@ -3367,7 +3375,7 @@ patmatch(Upat prog) /**/ mod_export int -mb_patmatchrange(char *range, wchar_t ch, wint_t *indptr, int *mtp) +mb_patmatchrange(char *range, wchar_t ch, int zmb_ind, wint_t *indptr, int *mtp) { wchar_t r1, r2; @@ -3476,6 +3484,14 @@ mb_patmatchrange(char *range, wchar_t ch, wint_t *indptr, int *mtp) *indptr += r2 - r1; } break; + case PP_INCOMPLETE: + if (zmb_ind == ZMB_INCOMPLETE) + return 1; + break; + case PP_INVALID: + if (zmb_ind == ZMB_INVALID) + return 1; + break; case PP_UNKWN: DPUTS(1, "BUG: unknown posix range passed through.\n"); break; @@ -3545,6 +3561,8 @@ mb_patmatchindex(char *range, wint_t ind, wint_t *chr, int *mtp) case PP_IFS: case PP_IFSSPACE: case PP_WORD: + case PP_INCOMPLETE: + case PP_INVALID: if (!ind) { *mtp = swtype; return 1; @@ -3698,6 +3716,10 @@ patmatchrange(char *range, int ch, int *indptr, int *mtp) if (indptr && r1 < r2) *indptr += r2 - r1; break; + case PP_INCOMPLETE: + case PP_INVALID: + /* Never true if not in multibyte mode */ + break; case PP_UNKWN: DPUTS(1, "BUG: unknown posix range passed through.\n"); break; @@ -3768,6 +3790,8 @@ patmatchindex(char *range, int ind, int *chr, int *mtp) case PP_IFS: case PP_IFSSPACE: case PP_WORD: + case PP_INCOMPLETE: + case PP_INVALID: if (!ind) { *mtp = swtype; return 1; @@ -3851,9 +3875,10 @@ static int patrepeat(Upat p, char *charstart) case P_ANYBUT: while (scan < patinend) { #ifdef MULTIBYTE_SUPPORT - wchar_t cr = CHARREF(scan, patinend); + int zmb_ind; + wchar_t cr = charref(scan, patinend, &zmb_ind); if (patglobflags & GF_MULTIBYTE) { - if (mb_patmatchrange(opnd, cr, NULL, NULL) ^ + if (mb_patmatchrange(opnd, cr, zmb_ind, NULL, NULL) ^ (P_OP(p) == P_ANYOF)) break; } else if (patmatchrange(opnd, (int)cr, NULL, NULL) ^ @@ -1562,13 +1562,15 @@ typedef struct zpc_disables_save *Zpc_disables_save; #define PP_IFS 15 #define PP_IFSSPACE 16 #define PP_WORD 17 +#define PP_INCOMPLETE 18 +#define PP_INVALID 19 /* Special value for last definition */ -#define PP_LAST 17 +#define PP_LAST 19 /* Unknown type. Not used in a valid token. */ -#define PP_UNKWN 18 +#define PP_UNKWN 20 /* Range: token followed by the (possibly multibyte) start and end */ -#define PP_RANGE 19 +#define PP_RANGE 21 /* Globbing flags: lower 8 bits gives approx count */ #define GF_LCMATCHUC 0x0100 @@ -1577,6 +1579,15 @@ typedef struct zpc_disables_save *Zpc_disables_save; #define GF_MATCHREF 0x0800 #define GF_MULTIBYTE 0x1000 /* Use multibyte if supported by build */ +enum { + /* Valid multibyte character from charref */ + ZMB_VALID, + /* Incomplete multibyte character from charref */ + ZMB_INCOMPLETE, + /* Invalid multibyte character charref */ + ZMB_INVALID +}; + /* Dummy Patprog pointers. Used mainly in executable code, but the * pattern code needs to know about it, too. */ diff --git a/Test/D07multibyte.ztst b/Test/D07multibyte.ztst index 3fadd8066..ace191f06 100644 --- a/Test/D07multibyte.ztst +++ b/Test/D07multibyte.ztst @@ -525,3 +525,9 @@ fi done 0:Invalid characters in pattern matching + + [[ $'\xe3' == [[:INCOMPLETE:]] ]] || print fail 1 + [[ $'\xe3\x83' == [[:INCOMPLETE:]][[:INVALID:]] ]] || print fail 2 + [[ $'\xe3\x83\x9b' != [[:INCOMPLETE:][:NVALID:]] ]] || print fail 3 + [[ $'\xe3\x83\x9b' = ? ]] || print fail 4 +0:Testing incomplete and invalid multibyte character components diff --git a/Test/E01options.ztst b/Test/E01options.ztst index 16279b88a..2b91b21fa 100644 --- a/Test/E01options.ztst +++ b/Test/E01options.ztst @@ -995,7 +995,7 @@ print this is bar >bar fn() { local NULLCMD=cat READNULLCMD=cat - echo hello | >foo + { echo hello | >foo } 2>/dev/null cat foo <bar } |