From d18476ce5c0a76831192df8ba2006536206c6646 Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Wed, 27 Jan 2016 21:57:45 -0800 Subject: 37819: zshaddhistory hook works for any history file write, even upon keyboard interrupt --- Src/hist.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'Src/hist.c') diff --git a/Src/hist.c b/Src/hist.c index 007366a49..7f9e4dbbb 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -1378,7 +1378,6 @@ should_ignore_line(Eprog prog) mod_export int hend(Eprog prog) { - LinkList hookargs = newlinklist(); int flag, hookret, stack_pos = histsave_stack_pos; /* * save: @@ -1418,9 +1417,17 @@ hend(Eprog prog) DPUTS(hptr < chline, "History end pointer off start of line"); *hptr = '\0'; } - addlinknode(hookargs, "zshaddhistory"); - addlinknode(hookargs, chline); - callhookfunc("zshaddhistory", hookargs, 1, &hookret); + { + LinkList hookargs = newlinklist(); + int save_errflag = errflag; + errflag = 0; + + addlinknode(hookargs, "zshaddhistory"); + addlinknode(hookargs, chline); + callhookfunc("zshaddhistory", hookargs, 1, &hookret); + + errflag |= save_errflag; + } /* For history sharing, lock history file once for both read and write */ hf = getsparam("HISTFILE"); if (isset(SHAREHISTORY) && !lockhistfile(hf, 0)) { -- cgit v1.2.3 From ca3bc0d95d7deab4f5381f12b15047de748c0814 Mon Sep 17 00:00:00 2001 From: Jun-ichi Takimoto Date: Sat, 30 Jan 2016 00:25:53 +0900 Subject: 37838: use UNUSED() consistently --- ChangeLog | 13 +++++++++++++ Src/Builtins/rlimits.c | 2 +- Src/Builtins/sched.c | 2 +- Src/Modules/curses.c | 10 +++++----- Src/Modules/datetime.c | 2 +- Src/Modules/db_gdbm.c | 2 +- Src/Modules/files.c | 2 +- Src/Modules/langinfo.c | 2 +- Src/Modules/mapfile.c | 2 +- Src/Modules/mathfunc.c | 2 +- Src/Modules/newuser.c | 4 ++-- Src/Modules/parameter.c | 2 +- Src/Modules/pcre.c | 2 +- Src/Modules/regex.c | 2 +- Src/Modules/socket.c | 2 +- Src/Modules/stat.c | 2 +- Src/Modules/system.c | 4 ++-- Src/Modules/tcp.c | 2 +- Src/Modules/termcap.c | 2 +- Src/Modules/terminfo.c | 2 +- Src/Modules/zpty.c | 2 +- Src/Modules/zselect.c | 2 +- Src/Modules/zutil.c | 2 +- Src/Zle/compctl.c | 2 +- Src/Zle/computil.c | 2 +- Src/Zle/zle_utils.c | 2 +- Src/Zle/zle_word.c | 2 +- Src/hashtable.c | 2 +- Src/hist.c | 2 +- 29 files changed, 47 insertions(+), 34 deletions(-) (limited to 'Src/hist.c') diff --git a/ChangeLog b/ChangeLog index 82ac489e6..f7f8b218e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2016-01-30 Jun-ichi Takimoto + + * 37838: Src/Builtins/rlimits.c, Src/Builtins/sched.c, + Src/Modules/curses.c, Src/Modules/datetime.c, Src/Modules/db_gdbm.c, + Src/Modules/files.c, Src/Modules/langinfo.c, Src/Modules/mapfile.c, + Src/Modules/mathfunc.c, Src/Modules/newuser.c, Src/Modules/parameter.c, + Src/Modules/pcre.c, Src/Modules/regex.c, Src/Modules/socket.c, + Src/Modules/stat.c, Src/Modules/system.c, Src/Modules/tcp.c, + Src/Modules/termcap.c, Src/Modules/terminfo.c, Src/Modules/zpty.c, + Src/Modules/zselect.c, Src/Modules/zutil.c, Src/Zle/compctl.c, + Src/Zle/computil.c, Src/Zle/zle_utils.c, Src/Zle/zle_word.c, + Src/hashtable.c, Src/hist.c: use UNUSED() consistently + 2016-01-29 Daniel Shahaf * 37833: README: Document 37804 in README. diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c index 85ec1811c..8b664e36a 100644 --- a/Src/Builtins/rlimits.c +++ b/Src/Builtins/rlimits.c @@ -1037,7 +1037,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { return 0; } diff --git a/Src/Builtins/sched.c b/Src/Builtins/sched.c index 5d5dac6b7..1b9c68ff4 100644 --- a/Src/Builtins/sched.c +++ b/Src/Builtins/sched.c @@ -411,7 +411,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { addprepromptfn(&checksched); return 0; diff --git a/Src/Modules/curses.c b/Src/Modules/curses.c index 64329f643..b8a79ed11 100644 --- a/Src/Modules/curses.c +++ b/Src/Modules/curses.c @@ -299,7 +299,7 @@ zcurses_free_window(ZCWin w) } static struct zcurses_namenumberpair * -zcurses_attrget(WINDOW *w, char *attr) +zcurses_attrget(UNUSED(WINDOW *w), char *attr) { struct zcurses_namenumberpair *zca; @@ -419,7 +419,7 @@ freecolorpairnode(HashNode hn) *************/ static int -zccmd_init(const char *nam, char **args) +zccmd_init(UNUSED(const char *nam), UNUSED(char **args)) { LinkNode stdscr_win = zcurses_getwindowbyname("stdscr"); @@ -808,7 +808,7 @@ zccmd_border(const char *nam, char **args) static int -zccmd_endwin(const char *nam, char **args) +zccmd_endwin(UNUSED(const char *nam), UNUSED(char **args)) { LinkNode stdscr_win = zcurses_getwindowbyname("stdscr"); @@ -1496,7 +1496,7 @@ zccmd_touch(const char *nam, char **args) /**/ static int -bin_zcurses(char *nam, char **args, Options ops, UNUSED(int func)) +bin_zcurses(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) { char **saargs; struct zcurses_subcommand *zcsc; @@ -1693,7 +1693,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { zcurses_windows = znewlinklist(); diff --git a/Src/Modules/datetime.c b/Src/Modules/datetime.c index 86c61cf1c..bb82c542f 100644 --- a/Src/Modules/datetime.c +++ b/Src/Modules/datetime.c @@ -292,7 +292,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { return 0; } diff --git a/Src/Modules/db_gdbm.c b/Src/Modules/db_gdbm.c index 032963262..8dd60fc0d 100644 --- a/Src/Modules/db_gdbm.c +++ b/Src/Modules/db_gdbm.c @@ -390,7 +390,7 @@ boot_(UNUSED(Module m)) /**/ int -cleanup_(UNUSED(Module m)) +cleanup_(Module m) { return setfeatureenables(m, &module_features, NULL); } diff --git a/Src/Modules/files.c b/Src/Modules/files.c index dbcff6307..6f816bac0 100644 --- a/Src/Modules/files.c +++ b/Src/Modules/files.c @@ -805,7 +805,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { return 0; } diff --git a/Src/Modules/langinfo.c b/Src/Modules/langinfo.c index eb45d161b..520b0370c 100644 --- a/Src/Modules/langinfo.c +++ b/Src/Modules/langinfo.c @@ -498,7 +498,7 @@ boot_(UNUSED(Module m)) /**/ int -cleanup_(UNUSED(Module m)) +cleanup_(Module m) { return setfeatureenables(m, &module_features, NULL); } diff --git a/Src/Modules/mapfile.c b/Src/Modules/mapfile.c index 422c7077c..2503b361e 100644 --- a/Src/Modules/mapfile.c +++ b/Src/Modules/mapfile.c @@ -306,7 +306,7 @@ boot_(UNUSED(Module m)) /**/ int -cleanup_(UNUSED(Module m)) +cleanup_(Module m) { return setfeatureenables(m, &module_features, NULL); } diff --git a/Src/Modules/mathfunc.c b/Src/Modules/mathfunc.c index efadd86ff..451b3cfeb 100644 --- a/Src/Modules/mathfunc.c +++ b/Src/Modules/mathfunc.c @@ -599,7 +599,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { return 0; } diff --git a/Src/Modules/newuser.c b/Src/Modules/newuser.c index efdb2abba..6f0d2e0aa 100644 --- a/Src/Modules/newuser.c +++ b/Src/Modules/newuser.c @@ -41,14 +41,14 @@ setup_(UNUSED(Module m)) /**/ int -features_(Module m, char ***features) +features_(UNUSED(Module m), UNUSED(char ***features)) { return 1; } /**/ int -enables_(Module m, int **enables) +enables_(UNUSED(Module m), UNUSED(int **enables)) { return 0; } diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index 04d448529..edb051785 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -2190,7 +2190,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { return 0; } diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c index aa5c8ed5b..e23ab57f5 100644 --- a/Src/Modules/pcre.c +++ b/Src/Modules/pcre.c @@ -479,7 +479,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { return 0; } diff --git a/Src/Modules/regex.c b/Src/Modules/regex.c index 16cc77f30..edb7234d4 100644 --- a/Src/Modules/regex.c +++ b/Src/Modules/regex.c @@ -248,7 +248,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { return 0; } diff --git a/Src/Modules/socket.c b/Src/Modules/socket.c index 7c3fb5ebe..c65b7dfce 100644 --- a/Src/Modules/socket.c +++ b/Src/Modules/socket.c @@ -310,7 +310,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { return 0; } diff --git a/Src/Modules/stat.c b/Src/Modules/stat.c index 396177149..66baa1292 100644 --- a/Src/Modules/stat.c +++ b/Src/Modules/stat.c @@ -659,7 +659,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { return 0; } diff --git a/Src/Modules/system.c b/Src/Modules/system.c index 1ab1fb17e..1ee61c00b 100644 --- a/Src/Modules/system.c +++ b/Src/Modules/system.c @@ -439,7 +439,7 @@ bin_sysseek(char *nam, char **args, Options ops, UNUSED(int func)) /**/ static mnumber -math_systell(UNUSED(char *name), int argc, mnumber *argv, UNUSED(int id)) +math_systell(UNUSED(char *name), UNUSED(int argc), mnumber *argv, UNUSED(int id)) { int fd = (argv->type == MN_INTEGER) ? argv->u.l : (int)argv->u.d; mnumber ret; @@ -834,7 +834,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { return 0; } diff --git a/Src/Modules/tcp.c b/Src/Modules/tcp.c index 9fc1b29a2..5af68834f 100644 --- a/Src/Modules/tcp.c +++ b/Src/Modules/tcp.c @@ -732,7 +732,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { ztcp_sessions = znewlinklist(); return 0; diff --git a/Src/Modules/termcap.c b/Src/Modules/termcap.c index cd0e85885..29c28360c 100644 --- a/Src/Modules/termcap.c +++ b/Src/Modules/termcap.c @@ -342,7 +342,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { #ifdef HAVE_TGETENT # ifdef HAVE_SETUPTERM diff --git a/Src/Modules/terminfo.c b/Src/Modules/terminfo.c index 88e326f63..e0439afca 100644 --- a/Src/Modules/terminfo.c +++ b/Src/Modules/terminfo.c @@ -335,7 +335,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { #ifdef USE_TERMINFO_MODULE # ifdef HAVE_SETUPTERM diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index 63ff7578c..0ef753915 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -891,7 +891,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { ptycmds = NULL; diff --git a/Src/Modules/zselect.c b/Src/Modules/zselect.c index 30a3f51a5..8c1267240 100644 --- a/Src/Modules/zselect.c +++ b/Src/Modules/zselect.c @@ -307,7 +307,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { return 0; } diff --git a/Src/Modules/zutil.c b/Src/Modules/zutil.c index 12a4c03e9..477575ccd 100644 --- a/Src/Modules/zutil.c +++ b/Src/Modules/zutil.c @@ -1995,7 +1995,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { return 0; } diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c index 8381867d0..ce4576297 100644 --- a/Src/Zle/compctl.c +++ b/Src/Zle/compctl.c @@ -3992,7 +3992,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { addhookfunc("compctl_make", (Hookfn) ccmakehookfn); addhookfunc("compctl_cleanup", (Hookfn) cccleanuphookfn); diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index 60fb096be..e8f0a6fe7 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -4994,7 +4994,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { return 0; } diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c index 6e9a98bde..a2c88102a 100644 --- a/Src/Zle/zle_utils.c +++ b/Src/Zle/zle_utils.c @@ -1678,7 +1678,7 @@ viundochange(char **args) /**/ int -splitundo(char **args) +splitundo(UNUSED(char **args)) { if (vistartchange >= 0) { mergeundo(); diff --git a/Src/Zle/zle_word.c b/Src/Zle/zle_word.c index 2e6d75e86..3c1f26c40 100644 --- a/Src/Zle/zle_word.c +++ b/Src/Zle/zle_word.c @@ -153,7 +153,7 @@ emacsforwardword(char **args) /**/ int -viforwardblankwordend(UNUSED(char **args)) +viforwardblankwordend(char **args) { int n = zmult; diff --git a/Src/hashtable.c b/Src/hashtable.c index 0664c3694..2d5af5be0 100644 --- a/Src/hashtable.c +++ b/Src/hashtable.c @@ -558,7 +558,7 @@ printhashtabinfo(HashTable ht) /**/ int -bin_hashinfo(char *nam, char **args, Options ops, int func) +bin_hashinfo(UNUSED(char *nam), UNUSED(char **args), UNUSED(Options ops), UNUSED(int func)) { HashTable ht; diff --git a/Src/hist.c b/Src/hist.c index 7f9e4dbbb..5fc40bd67 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -468,7 +468,7 @@ herrflush(void) /**/ static int -getsubsargs(char *subline, int *gbalp, int *cflagp) +getsubsargs(UNUSED(char *subline), int *gbalp, int *cflagp) { int del, follow; char *ptr1, *ptr2; -- cgit v1.2.3 From 4ab3fcc90d928d200f9e70c81189079c3316b42d Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 3 Oct 2016 13:43:20 +0100 Subject: 39545: Add some missing unqueue_signals(). All of these are added simply to fit existing logic in other branches. --- ChangeLog | 5 +++++ Src/Zle/computil.c | 1 + Src/Zle/zle_main.c | 1 + Src/builtin.c | 3 +++ Src/exec.c | 3 +++ Src/hist.c | 1 + Src/init.c | 4 +++- Src/mem.c | 8 ++++++-- Src/module.c | 1 + Src/params.c | 2 ++ Src/prompt.c | 4 +++- 11 files changed, 29 insertions(+), 4 deletions(-) (limited to 'Src/hist.c') diff --git a/ChangeLog b/ChangeLog index a1c4e60e3..a68dfaf59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2016-10-03 Peter Stephenson + * 39545: Src/builtin.c, Src/exec.c, Src/hist.c, Src/init.c, + Src/mem.c, Src/module.c, Src/params.c, Src/prompt.c, + Src/Zle/computil.c, Src/Zle/zle_main.c: Add some missing + unqueue_signals(). + * 39521: Src/exec.c, Src/zsh.h, Test/A01grammar.ztst: Refactor start of execcmd(). This allows execpline2() easier access to the state at the start of execuation. diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index 27b78cd61..e9bad1cab 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -4865,6 +4865,7 @@ bin_compfiles(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) } queue_signals(); if (!(tmp = getaparam(args[1]))) { + unqueue_signals(); zwarnnam(nam, "unknown parameter: %s", args[1]); return 0; } diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 0bdd82ba4..0b3b1fcf4 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1631,6 +1631,7 @@ bin_vared(char *name, char **args, Options ops, UNUSED(int func)) return 1; } else if (v) { if (*s) { + unqueue_signals(); zwarnnam(name, "not an identifier: `%s'", args[0]); return 1; } diff --git a/Src/builtin.c b/Src/builtin.c index 60dc07f25..a274ff791 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -1489,6 +1489,7 @@ bin_fc(char *nam, char **argv, Options ops, int func) } if (zleactive) { + unqueue_signals(); zwarnnam(nam, "no interactive history within ZLE"); return 1; } @@ -2808,6 +2809,7 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func) return 0; } if (off & PM_TIED) { + unqueue_signals(); zerrnam(name, "use unset to remove tied variables"); return 1; } @@ -3138,6 +3140,7 @@ bin_functions(char *name, char **argv, Options ops, int func) queue_signals(); for (q = mathfuncs; q; q = q->next) { if (!strcmp(q->name, funcname)) { + unqueue_signals(); zwarnnam(name, "-M %s: function already exists", funcname); zsfree(p->name); diff --git a/Src/exec.c b/Src/exec.c index a4294288b..9890286b2 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1795,6 +1795,8 @@ execpline(Estate state, wordcode slcode, int how, int last1) deletejob(jn, 0); thisjob = pj; } + else + unqueue_signals(); if ((slflags & WC_SUBLIST_NOT) && !errflag) lastval = !lastval; } @@ -5556,6 +5558,7 @@ runshfunc(Eprog prog, FuncWrap wrap, char *name) if (!cont) { if (ou) zfree(ou, ouu); + unqueue_signals(); return; } wrap = wrap->next; diff --git a/Src/hist.c b/Src/hist.c index 5fc40bd67..eebd7dcde 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -653,6 +653,7 @@ histsubchar(int c) (c == '}' || c == ';' || c == '\'' || c == '"' || c == '`')) { /* Neither event nor word designator, no expansion */ safeinungetc(c); + unqueue_signals(); return bangchar; } *ptr = 0; diff --git a/Src/init.c b/Src/init.c index 3dea179b9..c12043b88 100644 --- a/Src/init.c +++ b/Src/init.c @@ -1442,8 +1442,10 @@ sourcehome(char *s) queue_signals(); if (EMULATION(EMULATE_SH|EMULATE_KSH) || !(h = getsparam_u("ZDOTDIR"))) { h = home; - if (!h) + if (!h) { + unqueue_signals(); return; + } } { diff --git a/Src/mem.c b/Src/mem.c index 021dad573..db311efbd 100644 --- a/Src/mem.c +++ b/Src/mem.c @@ -903,11 +903,15 @@ memory_validate(Heapid heap_id) queue_signals(); for (h = heaps; h; h = h->next) { - if (h->heap_id == heap_id) + if (h->heap_id == heap_id) { + unqueue_signals(); return 0; + } for (hs = heaps->sp; hs; hs = hs->next) { - if (hs->heap_id == heap_id) + if (hs->heap_id == heap_id) { + unqueue_signals(); return 0; + } } } diff --git a/Src/module.c b/Src/module.c index 46a7d7746..41f142adb 100644 --- a/Src/module.c +++ b/Src/module.c @@ -2242,6 +2242,7 @@ load_module(char const *name, Feature_enables enablesarr, int silent) return 0; } if (m->node.flags & MOD_BUSY) { + unqueue_signals(); zerr("circular dependencies for module ;%s", name); return 1; } diff --git a/Src/params.c b/Src/params.c index e11510246..1418021aa 100644 --- a/Src/params.c +++ b/Src/params.c @@ -2803,6 +2803,7 @@ assignsparam(char *s, char *val, int flags) zerr("read-only variable: %s", v->pm->node.nam); *ss = '['; zsfree(val); + unqueue_signals(); return NULL; } flags &= ~ASSPM_WARN_CREATE; @@ -3117,6 +3118,7 @@ setnparam(char *s, mnumber val) if (!(v = getvalue(&vbuf, &t, 1))) { DPUTS(!v, "BUG: value not found for new parameter"); /* errflag |= ERRFLAG_ERROR; */ + unqueue_signals(); return NULL; } if (!was_unset && isset(WARNCREATEGLOBAL) && locallevel > forklevel) diff --git a/Src/prompt.c b/Src/prompt.c index d4f389809..ee77c8bc8 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -491,8 +491,10 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep) if (!arg) arg++; queue_signals(); - if (!(hostnam = getsparam("HOST"))) + if (!(hostnam = getsparam("HOST"))) { + unqueue_signals(); break; + } if (arg < 0) { for (ss = hostnam + strlen(hostnam); ss > hostnam; ss--) if (ss[-1] == '.' && !++arg) -- cgit v1.2.3 From a62e1640bcafbb82d86ea8d8ce057a83c4683d60 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 17 Nov 2016 19:49:17 +0000 Subject: 39958: Add extra byte to PATH_MAX allocations. This ensures we've got enough space for a null, although this isn't always needed. --- ChangeLog | 6 ++++++ Src/Zle/compctl.c | 2 +- Src/builtin.c | 2 +- Src/compat.c | 6 +++--- Src/exec.c | 16 ++++++++-------- Src/glob.c | 4 ++-- Src/hist.c | 2 +- Src/utils.c | 12 ++++++------ 8 files changed, 28 insertions(+), 22 deletions(-) (limited to 'Src/hist.c') diff --git a/ChangeLog b/ChangeLog index aa3b57bf0..f3dbffcc0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-11-17 Peter Stephenson + + * 39958: Src/Zle/compctl.c, Src/builtin.c, Src/compat.c, + Src/exec.c, Src/glob.c, Src/hist.c, Src/utils.c: Add spare byte + to PATH_MAX allocation to allow for possible null. + 2016-11-17 Daniel Shahaf * 39921: Completion/Unix/Command/_git: __git_recent_branches: diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c index 09e590569..52c6f1233 100644 --- a/Src/Zle/compctl.c +++ b/Src/Zle/compctl.c @@ -2135,7 +2135,7 @@ gen_matches_files(int dirs, int execs, int all) { DIR *d; struct stat buf; - char *n, p[PATH_MAX], *q = NULL, *e, *pathpref; + char *n, p[PATH_MAX+1], *q = NULL, *e, *pathpref; LinkList l = NULL; int ns = 0, ng = opts[NULLGLOB], test, aw = addwhat, pathpreflen; diff --git a/Src/builtin.c b/Src/builtin.c index 696971944..d3c628592 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -973,7 +973,7 @@ cd_do_chdir(char *cnam, char *dest, int hard) * Normalize path under Cygwin to avoid messing with * DOS style names with drives in them */ - static char buf[PATH_MAX]; + static char buf[PATH_MAX+1]; #ifdef HAVE_CYGWIN_CONV_PATH cygwin_conv_path(CCP_WIN_A_TO_POSIX | CCP_RELATIVE, dest, buf, PATH_MAX); diff --git a/Src/compat.c b/Src/compat.c index 9041c0bed..81afd4dfd 100644 --- a/Src/compat.c +++ b/Src/compat.c @@ -270,7 +270,7 @@ zgetdir(struct dirsav *d) int len; #endif - buf = zhalloc(bufsiz = PATH_MAX); + buf = zhalloc(bufsiz = PATH_MAX+1); pos = bufsiz - 1; buf[pos] = '\0'; strcpy(nbuf, "../"); @@ -439,11 +439,11 @@ zgetcwd(void) free(cwd); } #else - char *cwdbuf = zalloc(PATH_MAX); + char *cwdbuf = zalloc(PATH_MAX+1); ret = getcwd(cwdbuf, PATH_MAX); if (ret) ret = dupstring(ret); - zfree(cwdbuf, PATH_MAX); + zfree(cwdbuf, PATH_MAX+1); #endif /* GETCWD_CALLS_MALLOC */ } #endif /* HAVE_GETCWD */ diff --git a/Src/exec.c b/Src/exec.c index ad80dd059..f544a33e7 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -437,7 +437,7 @@ static int zexecve(char *pth, char **argv, char **newenvp) { int eno; - static char buf[PATH_MAX * 2]; + static char buf[PATH_MAX * 2+1]; char **eep; unmetafy(pth, NULL); @@ -620,7 +620,7 @@ static void execute(LinkList args, int flags, int defpath) { Cmdnam cn; - char buf[MAXCMDLEN], buf2[MAXCMDLEN]; + char buf[MAXCMDLEN+1], buf2[MAXCMDLEN+1]; char *s, *z, *arg0; char **argv, **pp, **newenvp = NULL; int eno = 0, ee; @@ -701,7 +701,7 @@ execute(LinkList args, int flags, int defpath) /* for command -p, search the default path */ if (defpath) { - char pbuf[PATH_MAX]; + char pbuf[PATH_MAX+1]; char *dptr; if (!search_defpath(arg0, pbuf, PATH_MAX)) { @@ -721,7 +721,7 @@ execute(LinkList args, int flags, int defpath) } else { if ((cn = (Cmdnam) cmdnamtab->getnode(cmdnamtab, arg0))) { - char nn[PATH_MAX], *dptr; + char nn[PATH_MAX+1], *dptr; if (cn->node.flags & HASHED) strcpy(nn, cn->u.cmd); @@ -814,7 +814,7 @@ findcmd(char *arg0, int docopy, int default_path) } } if (cn) { - char nn[PATH_MAX]; + char nn[PATH_MAX+1]; if (cn->node.flags & HASHED) strcpy(nn, cn->u.cmd); @@ -905,7 +905,7 @@ mod_export Cmdnam hashcmd(char *arg0, char **pp) { Cmdnam cn; - char *s, buf[PATH_MAX]; + char *s, buf[PATH_MAX+1]; char **pq; for (; *pp; pp++) @@ -5602,7 +5602,7 @@ runshfunc(Eprog prog, FuncWrap wrap, char *name) Eprog getfpfunc(char *s, int *ksh, char **fname) { - char **pp, buf[PATH_MAX]; + char **pp, buf[PATH_MAX+1]; off_t len; off_t rlen; char *d; @@ -5732,7 +5732,7 @@ cancd(char *s) char *t; if (*s != '/') { - char sbuf[PATH_MAX], **cp; + char sbuf[PATH_MAX+1], **cp; if (cancd2(s)) return s; diff --git a/Src/glob.c b/Src/glob.c index 50f6dceb3..33bf2ae18 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -283,7 +283,7 @@ addpath(char *s, int l) static int statfullpath(const char *s, struct stat *st, int l) { - char buf[PATH_MAX]; + char buf[PATH_MAX+1]; DPUTS(strlen(s) + !*s + pathpos - pathbufcwd >= PATH_MAX, "BUG: statfullpath(): pathname too long"); @@ -779,7 +779,7 @@ parsepat(char *str) /* Now there is no (#X) in front, we can check the path. */ if (!pathbuf) - pathbuf = zalloc(pathbufsz = PATH_MAX); + pathbuf = zalloc(pathbufsz = PATH_MAX+1); DPUTS(pathbufcwd, "BUG: glob changed directory"); if (*str == '/') { /* pattern has absolute path */ str++; diff --git a/Src/hist.c b/Src/hist.c index eebd7dcde..5be7d2524 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -1843,7 +1843,7 @@ chrealpath(char **junkptr) # ifdef REALPATH_ACCEPTS_NULL char *lastpos, *nonreal, *real; # else - char *lastpos, *nonreal, pathbuf[PATH_MAX]; + char *lastpos, *nonreal, pathbuf[PATH_MAX+1]; char *real = pathbuf; # endif #endif diff --git a/Src/utils.c b/Src/utils.c index 151e9e4eb..7bbd5887f 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -845,7 +845,7 @@ ispwd(char *s) return 0; } -static char xbuf[PATH_MAX*2]; +static char xbuf[PATH_MAX*2+1]; /**/ static char ** @@ -884,7 +884,7 @@ static int xsymlinks(char *s, int full) { char **pp, **opp; - char xbuf2[PATH_MAX*3], xbuf3[PATH_MAX*2]; + char xbuf2[PATH_MAX*3+1], xbuf3[PATH_MAX*2+1]; int t0, ret = 0; zulong xbuflen = strlen(xbuf); @@ -1003,7 +1003,7 @@ print_if_link(char *s, int all) *xbuf = '\0'; if (all) { char *start = s + 1; - char xbuflink[PATH_MAX]; + char xbuflink[PATH_MAX+1]; for (;;) { if (xsymlinks(start, 0) > 0) { printf(" -> "); @@ -1140,7 +1140,7 @@ finddir(char *s) if(homenode.diff==1) homenode.diff = 0; if(!finddir_full) - finddir_full = zalloc(ffsz = PATH_MAX); + finddir_full = zalloc(ffsz = PATH_MAX+1); finddir_full[0] = 0; return finddir_last = NULL; } @@ -1644,7 +1644,7 @@ checkmailpath(char **s) } else if (S_ISDIR(st.st_mode)) { LinkList l; DIR *lock = opendir(unmeta(*s)); - char buf[PATH_MAX * 2], **arr, **ap; + char buf[PATH_MAX * 2 + 1], **arr, **ap; int ct = 1; if (lock) { @@ -6916,7 +6916,7 @@ strsfx(char *s, char *t) static int upchdir(int n) { - char buf[PATH_MAX]; + char buf[PATH_MAX+1]; char *s; int err = -1; -- cgit v1.2.3 From 110ffae9fefa1367af4fdcc90a456de23b92436c Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Mon, 28 Nov 2016 22:53:24 -0800 Subject: 40035: Cosmetic fixes for comments and documentation. Mostly fixes to doubled words. --- ChangeLog | 7 +++++-- Completion/Base/Utility/_arguments | 2 +- Completion/Unix/Command/_git | 2 +- Completion/Unix/Type/_zfs_dataset | 2 +- Completion/Zsh/Command/_zstyle | 2 +- Completion/Zsh/Function/_zargs | 2 +- Doc/Zsh/builtins.yo | 2 +- Doc/Zsh/compsys.yo | 4 ++-- Doc/Zsh/contrib.yo | 2 +- Etc/ChangeLog-4.3 | 2 +- Src/Zle/zle_refresh.c | 2 +- Src/glob.c | 2 +- Src/hist.c | 2 +- Src/input.c | 2 +- Src/subst.c | 2 +- Src/zsh.h | 2 +- Util/helpfiles | 2 +- 17 files changed, 22 insertions(+), 19 deletions(-) (limited to 'Src/hist.c') diff --git a/ChangeLog b/ChangeLog index a016ce0e6..0d5f61198 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2016-11-29 Peter Stephenson + * 40035: Eitan Adler: Cosmetic fixes mostly for duplication in + comments and documentation. + * 40026: Src/Zle/zle_tricky.c: More care with redirection completion. Fixes for completion after > in "!> ." that should add to sanity. @@ -3523,7 +3526,7 @@ 2015-09-28 Barton E. Schaefer - * 36669: Src/lex.c: fix ${(z)...} of an an incomplete math + * 36669: Src/lex.c: fix ${(z)...} of an incomplete math expression by restoring "((" at the front of the token 2015-09-28 Daniel Shahaf @@ -9517,7 +9520,7 @@ 2013-07-20 Peter Stephenson * 31545: Src/exec.c, Src/parse.c: if FD_CLOEXEC is available, - so mark dump file file descriptors, avoiding possible + so mark dump file descriptors, avoiding possible multiple use of file descriptors. 2013-07-19 Peter Stephenson diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments index 82c969629..d2c0d33de 100644 --- a/Completion/Base/Utility/_arguments +++ b/Completion/Base/Utility/_arguments @@ -105,7 +105,7 @@ if (( long )); then continue else # Still no comment, add the previous options anyway. - # Add a ':' after the option anyways, to make the the matching of + # Add a ':' after the option anyways, to make the matching of # the options lateron work as intended. # It will be removed again later. lopts+=("${^tmp[@]}":) diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 283c50cc0..da049bd23 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -6114,7 +6114,7 @@ __git_recent_branches() { local -aU valid_ref_names_munged=( ${"${(f)"$(_call_program valid-ref-names 'git for-each-ref --format="%(refname)" refs/heads/')"}"#refs/heads/} ) # 1. Obtain names of recently-checked-out branches from the reflog. - # 2. Remove ref names that that no longer exist from the list. + # 2. Remove ref names that no longer exist from the list. # (We must do this because #3 would otherwise croak on them.) __git_recent_branches__names; branches=( ${(@)reply:*valid_ref_names_munged} ) diff --git a/Completion/Unix/Type/_zfs_dataset b/Completion/Unix/Type/_zfs_dataset index 6c625e9ec..6bef04e45 100644 --- a/Completion/Unix/Type/_zfs_dataset +++ b/Completion/Unix/Type/_zfs_dataset @@ -4,7 +4,7 @@ local -a type expl_type_arr rsrc rdst paths_allowed local -a typearg datasetlist expl mlist local expl_type -# -e takes an argument which is passed as as the "descr" argument to _wanted +# -e takes an argument which is passed as the "descr" argument to _wanted # -p indicates that filesystem paths, not just dataset names, are allowed # -r1 indicates that we're completing the source of a rename # -r2 indicates that we're completing the destination of a rename diff --git a/Completion/Zsh/Command/_zstyle b/Completion/Zsh/Command/_zstyle index d6f285271..0e828225e 100644 --- a/Completion/Zsh/Command/_zstyle +++ b/Completion/Zsh/Command/_zstyle @@ -266,7 +266,7 @@ while (( $#state )); do _wanted contexts expl "$state_descr" compadd -a patterns ;; - # 'metapatterns': patterns that are are matched not against contexts, but + # 'metapatterns': patterns that are matched not against contexts, but # against patterns. (metapatterns) zstyle -g patterns diff --git a/Completion/Zsh/Function/_zargs b/Completion/Zsh/Function/_zargs index c24b276f2..f974ab646 100644 --- a/Completion/Zsh/Function/_zargs +++ b/Completion/Zsh/Function/_zargs @@ -4,7 +4,7 @@ local arguments eofstr pos=$((CURRENT)) numeofs=0 ret=1 cmdpos=1 #this doesn't handle '--' on the command line, only -- #it also by extension doesn't handle eofstr being the empty string -#it also also doesn't handle eofstr being -e or --eof, and everything will +#it also doesn't handle eofstr being -e or --eof, and everything will # probably also be confused if the command at the end takes a -e, --eof= or -- eofstr=${${${${words[(r)(--eof=*|-e*)]}#--eof=}#-e}:---} while { diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index 169a31ea3..7b04d0648 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -570,7 +570,7 @@ with emulations to be set to their values in tt(sh). tt(fno) then calls tt(fni); because tt(fni) is also marked for sticky tt(sh) emulation, no option changes take place on entry to or exit from it. Hence the option tt(cshnullglob), turned off by tt(sh) emulation, will -be turned on within tt(fni) and remain on on return to tt(fno). On exit +be turned on within tt(fni) and remain on return to tt(fno). On exit from tt(fno), the emulation mode and all options will be restored to the state they were in before entry to the temporary emulation. diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index ceb98c7bc..60ef9ee2c 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -144,8 +144,8 @@ directory mentioned in the tt(fpath) parameter, and should be autoloaded few utility functions, arrange for all the necessary shell functions to be autoloaded, and will then re-define all widgets that do completion to use the new system. If you use the tt(menu-select) widget, which is part of the -tt(zsh/complist) module, you should make sure that that module is loaded -before the call to tt(compinit) so that that widget is also +tt(zsh/complist) module, you should make sure that the module is loaded +before the call to tt(compinit) so that the widget is also re-defined. If completion styles (see below) are set up to perform expansion as well as completion by default, and the TAB key is bound to tt(expand-or-complete), tt(compinit) will rebind it to tt(complete-word); diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 623507283..f764eb7c6 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -3854,7 +3854,7 @@ The expression tt(<) followed (with no space) by a shell identifier causes the value of the variable with that name to be pushed onto the stack. var(ident) may be an integer, in which case the previous result with that number (as shown before -the tt(>) in th standard standard tt(zcalc) prompt) is put on the stack. +the tt(>) in the standard tt(zcalc) prompt) is put on the stack. ) item(Exchange: tt(xy))( The pseudo-function tt(xy) causes the most recent two elements of diff --git a/Etc/ChangeLog-4.3 b/Etc/ChangeLog-4.3 index 1be618b48..6d85e40af 100644 --- a/Etc/ChangeLog-4.3 +++ b/Etc/ChangeLog-4.3 @@ -1182,7 +1182,7 @@ 2011-08-16 Wayne Davison - * 29650: Src/jobs.c: don't lose the the time info after a + * 29650: Src/jobs.c: don't lose the time info after a suspend+restore. 2011-08-15 Peter Stephenson diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index e78f1e562..8d173cda1 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -946,7 +946,7 @@ addmultiword(REFRESH_ELEMENT *base, ZLE_STRING_T tptr, int ichars) /* * Swap the old and new video buffers, plus any associated multiword - * buffers. The new buffer becomes the old one; the new new buffer + * buffers. The new buffer becomes the old one; the new buffer * will be filled with the command line next time. */ static void diff --git a/Src/glob.c b/Src/glob.c index 33bf2ae18..623e6f1d6 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -1174,7 +1174,7 @@ checkglobqual(char *str, int sl, int nobareglob, char **sp) } /* Main entry point to the globbing code for filename globbing. * - * np points to a node in the list list which will be expanded * + * np points to a node in the list which will be expanded * * into a series of nodes. */ /**/ diff --git a/Src/hist.c b/Src/hist.c index 5be7d2524..97fd34039 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -1038,7 +1038,7 @@ hbegin(int dohist) /* * pws: We used to test for "|| (inbufflags & INP_ALIAS)" * in this test, but at this point we don't have input - * set up up so this can trigger unnecessarily. + * set up so this can trigger unnecessarily. * I don't see how the test at this point could ever be * useful, since we only get here when we're initialising * the history mechanism, before we've done any input. diff --git a/Src/input.c b/Src/input.c index eb968ea72..fe94b8ef7 100644 --- a/Src/input.c +++ b/Src/input.c @@ -51,7 +51,7 @@ * Note that the input string is itself used as the input buffer: it is not * copied, nor is it every written back to, so using a constant string * should work. Consequently, when passing areas of memory from the heap - * it is necessary that that heap last as long as the operation of reading + * it is necessary that the heap last as long as the operation of reading * the string. After the string is read, the stack should be popped with * inpop(), which effectively flushes any unread input as well as restoring * the previous input state. diff --git a/Src/subst.c b/Src/subst.c index c7c552257..a26ebb1d6 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -2368,7 +2368,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, * This is the inner handling for the case referred to above * where we have something like ${${(P)name}...}. * - * Treat this as as a normal value here; all transformations on + * Treat this as a normal value here; all transformations on * result are in outer instance. */ aspar = 0; diff --git a/Src/zsh.h b/Src/zsh.h index a5d4455e3..63cada827 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -1589,7 +1589,7 @@ struct zpc_disables_save { /* * Bit vector of ZPC_COUNT disabled characters. * We'll live dangerously and assumed ZPC_COUNT is no greater - * than the number of bits an an unsigned int. + * than the number of bits an unsigned int. */ unsigned int disables; }; diff --git a/Util/helpfiles b/Util/helpfiles index 699ca8321..9e837fe2d 100755 --- a/Util/helpfiles +++ b/Util/helpfiles @@ -19,7 +19,7 @@ # This script is called automatically during `make install' # unless specified otherwise. -# For usage and and more information see zshcontrib(1). +# For usage and more information see zshcontrib(1). sub Usage { print(STDERR "Usage: helpfiles zshbuiltins.1 dest-dir [link-file]\n"); -- cgit v1.2.3