From dd0ad1ac2310853e3d4963c5715de6a9c058479f Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 5 Jan 2011 18:22:08 +0000 Subject: 28568: buffer overflow examining paths --- Src/utils.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Src/utils.c') diff --git a/Src/utils.c b/Src/utils.c index b64530bcc..a1cac2537 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -3667,16 +3667,22 @@ mindist(char *dir, char *mindistguess, char *mindistbest) int mindistd, nd; DIR *dd; char *fn; - char buf[PATH_MAX]; + char *buf; if (dir[0] == '\0') dir = "."; mindistd = 100; + + buf = zalloc(strlen(dir) + strlen(mindistguess) + 2); sprintf(buf, "%s/%s", dir, mindistguess); + if (access(unmeta(buf), F_OK) == 0) { strcpy(mindistbest, mindistguess); + free(buf); return 0; } + free(buf); + if (!(dd = opendir(unmeta(dir)))) return mindistd; while ((fn = zreaddir(dd, 0))) { -- cgit v1.2.3 From 87d6527628583c355883cc997d54d337abae2a7a Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Thu, 6 Jan 2011 16:49:25 +0000 Subject: 28578: fix handling of numeric escapes that expand to "%" in printf format strings, so they are not treated as format introducers. --- ChangeLog | 8 +++++++- Src/utils.c | 3 ++- Src/zsh.h | 11 ++++++++--- Test/B03print.ztst | 5 ++--- 4 files changed, 19 insertions(+), 8 deletions(-) (limited to 'Src/utils.c') diff --git a/ChangeLog b/ChangeLog index 3eadca8f9..033e0b020 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-06 Barton E. Schaefer + + * 28578 (plus test): Src/utils.c, Src/zsh.h, Test/B03print.ztst: + fix handling of numeric escapes that expand to "%" in printf + format strings, so they are not treated as format introducers. + 2011-01-05 Peter Stephenson * 28568 c.f. 28549 (Ricky Zhou): Src/utils.c: buffer overflow @@ -14043,5 +14049,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5168 $ +* $Revision: 1.5169 $ ***************************************************** diff --git a/Src/utils.c b/Src/utils.c index a1cac2537..a4cd67812 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -1,4 +1,3 @@ - /* * utils.c - miscellaneous utilities * @@ -5523,6 +5522,8 @@ getkeystring(char *s, int *len, int how, int *misc) } *t++ = zstrtol(s + (*s == 'x'), &s, (*s == 'x') ? 16 : 8); + if ((how & GETKEY_PRINTF_PERCENT) && t[-1] == '%') + *t++ = '%'; if (svchar) { u[3] = svchar; svchar = '\0'; diff --git a/Src/zsh.h b/Src/zsh.h index 6dc918c09..6d8ac0353 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -2492,7 +2492,11 @@ enum { * Yes, I know that doesn't seem to make much sense. * It's for use in completion, comprenez? */ - GETKEY_UPDATE_OFFSET = (1 << 7) + GETKEY_UPDATE_OFFSET = (1 << 7), + /* + * When replacing numeric escapes for printf format strings, % -> %% + */ + GETKEY_PRINTF_PERCENT = (1 << 8) }; /* @@ -2501,8 +2505,9 @@ enum { */ /* echo builtin */ #define GETKEYS_ECHO (GETKEY_BACKSLASH_C) -/* printf format string: \123 -> S, \0123 -> NL 3 */ -#define GETKEYS_PRINTF_FMT (GETKEY_OCTAL_ESC|GETKEY_BACKSLASH_C) +/* printf format string: \123 -> S, \0123 -> NL 3, \045 -> %% */ +#define GETKEYS_PRINTF_FMT \ + (GETKEY_OCTAL_ESC|GETKEY_BACKSLASH_C|GETKEY_PRINTF_PERCENT) /* printf argument: \123 -> \123, \0123 -> S */ #define GETKEYS_PRINTF_ARG (GETKEY_BACKSLASH_C) /* Full print without -e */ diff --git a/Test/B03print.ztst b/Test/B03print.ztst index 92a24d6b6..48574c227 100644 --- a/Test/B03print.ztst +++ b/Test/B03print.ztst @@ -105,10 +105,9 @@ 0:numeric value of high numbered character >f0 -# code will probably be changed to print the literal `%s' in this case printf '\x25s\n' arg -0:using \x25 to introduce a format specifier ->arg +0:using \x25 to print a literal % in format +>%s printf '%3c\n' c 0:width specified in format specifier -- cgit v1.2.3 From 6318e041d17a3dc82589cf324afa115b6c907dfe Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 6 Jan 2011 21:31:06 +0000 Subject: unposted: fix argument type for write_loop() --- ChangeLog | 4 +++- Src/utils.c | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'Src/utils.c') diff --git a/ChangeLog b/ChangeLog index d0fd822d7..5bef8dc69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2011-01-06 Peter Stephenson + * unposted: Src/utils.c: fix argument type for write_loop(). + * 28588: Src/text.c, Test/C02cond.ztst: fix textual display after =~ test. @@ -14059,5 +14061,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5172 $ +* $Revision: 1.5173 $ ***************************************************** diff --git a/Src/utils.c b/Src/utils.c index a4cd67812..844a43e1b 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -2405,8 +2405,10 @@ getquery(char *valid_chars, int purge) } zbeep(); } - if (c >= 0) - write_loop(SHTTY, &c, 1); + if (c >= 0) { + char buf = (char)c; + write_loop(SHTTY, &buf, 1); + } if (nl) write_loop(SHTTY, "\n", 1); -- cgit v1.2.3 From f2dca9e155f25ee57f15df7dc2dc81489e1abbae Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 11 Mar 2011 16:32:07 +0000 Subject: users/15864: turn zsh_directory_name into a hook --- ChangeLog | 8 ++- Completion/Zsh/Context/_dynamic_directory_name | 12 +++- Doc/Zsh/contrib.yo | 52 +++++++---------- Doc/Zsh/expn.yo | 25 +++++++-- Functions/Chpwd/.distfiles | 1 + Functions/Chpwd/zsh_directory_name_cdr | 25 +++++++++ Functions/Misc/add-zsh-hook | 7 ++- Src/subst.c | 4 +- Src/utils.c | 78 ++++++++++++++++++++------ 9 files changed, 149 insertions(+), 63 deletions(-) create mode 100644 Functions/Chpwd/zsh_directory_name_cdr (limited to 'Src/utils.c') diff --git a/ChangeLog b/ChangeLog index 1a6a69d09..bdbc02d84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2011-03-11 Peter Stephenson + * users/15864: Completion/Zsh/Context/_dynamic_directory_name, + Doc/Zsh/contrib.yo, Doc/Zsh/expn.yo, Functions/Chpwd/.distfiles, + Functions/Chpwd/zsh_directory_name_cdr, + Functions/Misc/add-zsh-hook, Src/subst.c, Src/utils.c: + turn zsh_directory_name into a hook. + * 28886: Src/Zle/zle_utils.c: Fix 28772 for the case where regions have the "P" flag to include $PREDISPLAY in the offsets. @@ -14316,5 +14322,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5218 $ +* $Revision: 1.5219 $ ***************************************************** diff --git a/Completion/Zsh/Context/_dynamic_directory_name b/Completion/Zsh/Context/_dynamic_directory_name index 5f7fe9a90..fbea15a7a 100644 --- a/Completion/Zsh/Context/_dynamic_directory_name +++ b/Completion/Zsh/Context/_dynamic_directory_name @@ -1,7 +1,15 @@ #autoload -if [[ -n $functions[zsh_directory_name] ]]; then - zsh_directory_name c +local func +integer ret=1 + +if [[ -n $functions[zsh_directory_name] || \ + ${+zsh_directory_name_functions} -ne 0 ]] ; then + zsh_directory_name c && ret=0 + for func in $zsh_directory_name_functions; do + $func c && ret=0 + done + return ret else _message 'dynamic directory name: implemented as zsh_directory_name c' fi diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index c5808fbeb..5b9af12f3 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -302,10 +302,13 @@ called at the same point; these are so-called `hook functions'. The shell function tt(add-zsh-hook) provides a simple way of adding or removing functions from the array. -var(hook) is one of tt(chpwd), tt(periodic), tt(precmd) or tt(preexec), -the special functions in question. +var(hook) is one of tt(chpwd), tt(periodic), tt(precmd), tt(preexec), +tt(zshaddhistory), tt(zshexit), or tt(zsh_directory_name), +the special functions in question. Note that tt(zsh_directory_name) +is called in a different way from the other functions, but may +still be manipulated as a hook. -var(functions) is name of an ordinary shell function. If no options +var(function) is name of an ordinary shell function. If no options are given this will be added to the array of functions to be executed in the given context. @@ -315,6 +318,10 @@ the array of functions to be executed. If the option tt(-D) is given, the var(function) is treated as a pattern and any matching names of functions are removed from the array of functions to be executed. + +The options tt(-U), tt(-z) and tt(-k) are passed as arguments to +tt(autoload) for var(function). For functions contributed with zsh, the +options tt(-Uz) are appropriate. ) enditem() @@ -544,36 +551,15 @@ enditem() subsect(Use with dynamic directory naming) It is possible to refer to recent directories using the dynamic directory -name syntax that appeared in zsh version 4.3.7. If you create and -autoload a function tt(zsh_directory_name) containing the following code, -tt(~[1]) will refer to the most recent directory other than $PWD, and so on. -This also includes completion. - -example(if [[ $1 = n ]]; then - if [[ $2 = <-> ]]; then - # Recent directory - typeset -ga reply - autoload -Uz cdr - cdr -r - if [[ -n ${reply[$2]} ]]; then - reply=LPAR()${reply[$2]}RPAR() - return 0 - else - reply=LPAR()RPAR() - return 1 - fi - fi -elif [[ $1 = c ]]; then - if [[ $PREFIX = <-> || -z $PREFIX ]]; then - typeset -a keys values - values=LPAR()${${(f)"$+LPAR()cdr -l+RPAR()"}/ ##/:}RPAR() - keys=LPAR()${values%%:*}RPAR() - _describe -t dir-index 'recent directory index' \ - values keys -V unsorted -S']' - return - fi -fi -return 1) +name syntax by using the supplied function tt(zsh_directory_name_cdr) +a hook: + +example(autoload -Uz add-zsh-hook +add-zsh-hook -Uz zsh_directory_name zsh_directory_name_cdr) + +When this is done, tt(~[1]) will refer to the most recent +directory other than $PWD, and so on. Completion after tt(~[)var(...) +also works. subsect(Details of directory handling) diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index 9c4491386..1bace49c3 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -1517,8 +1517,12 @@ cindex(directories, named, dynamic) cindex(named directories, dynamic) cindex(dynamic named directories) -The feature described here is only available if the shell function -tt(zsh_directory_name) exists. +If the function tt(zsh_directory_name) exists, or the shell variable +tt(zsh_directory_name_functions) exists and contains an array of +function names, then the functions are used to implement dynamic +directory naming. The functions are tried in order until one returns +status zero, so it is important that functions test whether they can +handle the case in question and return an appropriate status. A `tt(~)' followed by a string var(namstr) in unquoted square brackets is treated specially as a dynamic directory name. Note that the first @@ -1529,11 +1533,12 @@ which is the directory corresponding to the name and return status zero (executing an assignment as the last statement is usually sufficient), or it should return status non-zero. In the former case the element of reply is used as the directory; in the latter case the substitution is deemed to -have failed and tt(NOMATCH) handling is applied if the option is set. +have failed. If all functions fail and the option tt(NOMATCH) is set, +an error results. -The function tt(zsh_directory_name) is also used to see if a directory can +The functions defined as above are also used to see if a directory can be turned into a name, for example when printing the directory stack or -when expanding tt(%~) in prompts. In this case the function is passed two +when expanding tt(%~) in prompts. In this case each function is passed two arguments: the string tt(d) (for directory) and the candidate for dynamic naming. The function should either return non-zero status, if the directory cannot be named by the function, or it should set the array reply @@ -1551,7 +1556,15 @@ parts of the directory path, as described below; it is used if the prefix length matched (16 in the example) is longer than that matched by any static name. -The completion system calls `tt(zsh_directory_name c)' in order to +It is not a requirement that a function implements both +tt(n) and tt(d) calls; for example, it might be appropriate for certain +dynamic forms of expansion not to be contracted to names. In that case +any call with the first argument tt(d) should cause a non-zero status to +be returned. + +The completion system calls `tt(zsh_directory_name c)' followed by +equivalent calls to elements of the array +tt(zsh_directory_name_functions), if it exists, in order to complete dynamic names for directories. The code for this should be as for any other completion function as described in ifnzman(noderef(Completion System))\ diff --git a/Functions/Chpwd/.distfiles b/Functions/Chpwd/.distfiles index 39ccd830c..89779a686 100644 --- a/Functions/Chpwd/.distfiles +++ b/Functions/Chpwd/.distfiles @@ -5,4 +5,5 @@ _cdr chpwd_recent_add chpwd_recent_dirs chpwd_recent_filehandler +zsh_directory_name_cdr ' diff --git a/Functions/Chpwd/zsh_directory_name_cdr b/Functions/Chpwd/zsh_directory_name_cdr new file mode 100644 index 000000000..09aa35a93 --- /dev/null +++ b/Functions/Chpwd/zsh_directory_name_cdr @@ -0,0 +1,25 @@ +if [[ $1 = n ]]; then + if [[ $2 = <-> ]]; then + # Recent directory + typeset -ga reply + autoload -Uz cdr + cdr -r + if [[ -n ${reply[$2]} ]]; then + reply=(${reply[$2]}) + return 0 + else + reply=() + return 1 + fi + fi +elif [[ $1 = c ]]; then + if [[ $PREFIX = <-> || -z $PREFIX ]]; then + typeset -a keys values + values=(${${(f)"$(cdr -l)"}/ ##/:}) + keys=(${values%%:*}) + _describe -t dir-index 'recent directory index' \ + values keys -V unsorted -S']' + return + fi +fi +return 1 diff --git a/Functions/Misc/add-zsh-hook b/Functions/Misc/add-zsh-hook index aedc1e754..c49688643 100644 --- a/Functions/Misc/add-zsh-hook +++ b/Functions/Misc/add-zsh-hook @@ -1,6 +1,6 @@ # Add to HOOK the given FUNCTION. # HOOK is one of chpwd, precmd, preexec, periodic, zshaddhistory, -# zshexit (the _functions subscript is not required). +# zshexit, zsh_directory_name (the _functions subscript is not required). # # With -d, remove the function from the hook instead; delete the hook # variable if it is empty. @@ -15,7 +15,10 @@ emulate -L zsh local -a hooktypes -hooktypes=(chpwd precmd preexec periodic zshaddhistory zshexit) +hooktypes=( + chpwd precmd preexec periodic zshaddhistory zshexit + zsh_directory_name +) local opt local -a autoopts diff --git a/Src/subst.c b/Src/subst.c index 37d63cabe..9b3699a47 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -579,7 +579,6 @@ filesubstr(char **namptr, int assign) char *str = *namptr; if (*str == Tilde && str[1] != '=' && str[1] != Equals) { - Shfunc dirfunc; char *ptr, *tmp, *res, *ptr2; int val; @@ -594,12 +593,11 @@ filesubstr(char **namptr, int assign) *namptr = dyncat((tmp = oldpwd) ? tmp : pwd, str + 2); return 1; } else if (str[1] == Inbrack && - (dirfunc = getshfunc("zsh_directory_name")) && (ptr2 = strchr(str+2, Outbrack))) { char **arr; untokenize(tmp = dupstrpfx(str+2, ptr2 - (str+2))); remnulargs(tmp); - arr = subst_string_by_func(dirfunc, "n", tmp); + arr = subst_string_by_hook("zsh_directory_name", "n", tmp); res = arr ? *arr : NULL; if (res) { *namptr = dyncat(res, ptr2+1); diff --git a/Src/utils.c b/Src/utils.c index 844a43e1b..9857303bb 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -890,7 +890,8 @@ finddir(char *s) { static struct nameddir homenode = { {NULL, "", 0}, NULL, 0 }; static int ffsz; - Shfunc func = getshfunc("zsh_directory_name"); + char **ares; + int len; /* Invalidate directory cache if argument is NULL. This is called * * whenever a node is added to or removed from the hash table, and * @@ -906,9 +907,16 @@ finddir(char *s) return finddir_last = NULL; } - /* It's not safe to use the cache while we have function transformations.*/ - if(!func && !strcmp(s, finddir_full) && *finddir_full) +#if 0 + /* + * It's not safe to use the cache while we have function + * transformations, and it's not clear it's worth the + * complexity of guessing here whether subst_string_by_hook + * is going to turn up the goods. + */ + if (!strcmp(s, finddir_full) && *finddir_full) return finddir_last; +#endif if ((int)strlen(s) >= ffsz) { free(finddir_full); @@ -920,18 +928,15 @@ finddir(char *s) finddir_scan(&homenode.node, 0); scanhashtable(nameddirtab, 0, 0, 0, finddir_scan, 0); - if (func) { - char **ares = subst_string_by_func(func, "d", finddir_full); - int len; - if (ares && arrlen(ares) >= 2 && - (len = (int)zstrtol(ares[1], NULL, 10)) > finddir_best) { - /* better duplicate this string since it's come from REPLY */ - finddir_last = (Nameddir)hcalloc(sizeof(struct nameddir)); - finddir_last->node.nam = zhtricat("[", dupstring(ares[0]), "]"); - finddir_last->dir = dupstrpfx(finddir_full, len); - finddir_last->diff = len - strlen(finddir_last->node.nam); - finddir_best = len; - } + ares = subst_string_by_hook("zsh_directory_name", "d", finddir_full); + if (ares && arrlen(ares) >= 2 && + (len = (int)zstrtol(ares[1], NULL, 10)) > finddir_best) { + /* better duplicate this string since it's come from REPLY */ + finddir_last = (Nameddir)hcalloc(sizeof(struct nameddir)); + finddir_last->node.nam = zhtricat("[", dupstring(ares[0]), "]"); + finddir_last->dir = dupstrpfx(finddir_full, len); + finddir_last->diff = len - strlen(finddir_last->node.nam); + finddir_best = len; } return finddir_last; @@ -3212,7 +3217,7 @@ getshfunc(char *nam) char ** subst_string_by_func(Shfunc func, char *arg1, char *orig) { - int osc = sfcontext; + int osc = sfcontext, osm = stopmsg; LinkList l = newlinklist(); char **ret; @@ -3228,6 +3233,47 @@ subst_string_by_func(Shfunc func, char *arg1, char *orig) ret = getaparam("reply"); sfcontext = osc; + stopmsg = osm; + return ret; +} + +/** + * Front end to subst_string_by_func to use hook-like logic. + * name can refer to a function, and name + "_hook" can refer + * to an array containing a list of functions. The functions + * are tried in order until one returns success. + */ +/**/ +char ** +subst_string_by_hook(char *name, char *arg1, char *orig) +{ + Shfunc func; + char **ret = NULL; + + if ((func = getshfunc(name))) { + ret = subst_string_by_func(func, arg1, orig); + } + + if (!ret) { + char **arrptr; + int namlen = strlen(name); + VARARR(char, arrnam, namlen + HOOK_SUFFIX_LEN); + memcpy(arrnam, name, namlen); + memcpy(arrnam + namlen, HOOK_SUFFIX, HOOK_SUFFIX_LEN); + + if ((arrptr = getaparam(arrnam))) { + /* Guard against internal modification of the array */ + arrptr = arrdup(arrptr); + for (; *arrptr; arrptr++) { + if ((func = getshfunc(*arrptr))) { + ret = subst_string_by_func(func, arg1, orig); + if (ret) + break; + } + } + } + } + return ret; } -- cgit v1.2.3 From 9e0b7684e578442f84d3983aad1e627bae87a4ce Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Wed, 6 Apr 2011 00:04:06 +0000 Subject: 28977: fix copying of uninitialized memory when trying to spell-correct a really long string. --- ChangeLog | 7 ++++++- Src/utils.c | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'Src/utils.c') diff --git a/ChangeLog b/ChangeLog index a8175b28f..e8c439bd3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-05 Wayne Davison + + * 28977: Src/utils.c: fix copying of uninitialized memory + when trying to spell-correct a really long string. + 2011-04-01 Peter Stephenson * Stef van Vlierberghe: 28965 (as posted in 28967): @@ -14420,5 +14425,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5240 $ +* $Revision: 1.5241 $ ***************************************************** diff --git a/Src/utils.c b/Src/utils.c index 9857303bb..22bffa276 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -3684,6 +3684,8 @@ spname(char *oldname) thresh = (int)(p - spnameguess) / 4 + 1; if (thresh < 3) thresh = 3; + else if (thresh > 100) + thresh = 100; if ((thisdist = mindist(newname, spnameguess, spnamebest)) >= thresh) { /* The next test is always true, except for the first path * * component. We could initialize bestdist to some large * -- cgit v1.2.3 From d89361739acdf07f0b0775c85f69abe89d57b600 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 9 May 2011 09:49:08 +0000 Subject: 29165: use term.h globally if needed at all. --- ChangeLog | 14 +++++- Src/Modules/files.c | 16 +++--- Src/Modules/termcap.c | 23 --------- Src/Modules/zpty.c | 4 +- Src/Zle/comp.h | 4 +- Src/Zle/complist.c | 132 ++++++++++++++++++++++++++------------------------ Src/Zle/compmatch.c | 6 +-- Src/Zle/compresult.c | 73 +++++++++++++++------------- Src/Zle/computil.c | 29 ++++++----- Src/Zle/zle_refresh.c | 12 ++--- Src/Zle/zle_tricky.c | 38 +++++++-------- Src/Zle/zle_utils.c | 6 +-- Src/builtin.c | 2 +- Src/exec.c | 6 +-- Src/glob.c | 4 +- Src/hashtable.c | 16 +++--- Src/init.c | 4 +- Src/jobs.c | 2 +- Src/loop.c | 6 +-- Src/params.c | 12 ++--- Src/prompt.c | 6 +-- Src/system.h | 24 +++++++++ Src/utils.c | 43 ++++++++-------- 23 files changed, 254 insertions(+), 228 deletions(-) (limited to 'Src/utils.c') diff --git a/ChangeLog b/ChangeLog index 51a07cbfe..42e9fbb5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2011-05-09 Peter Stephenson + + * 29165: Src/builtin.c, Src/exec.c, Src/glob.c, Src/hashtable.c, + Src/init.c, Src/jobs.c, Src/loop.c, Src/params.c, Src/prompt.c, + Src/system.h, Src/utils.c, Src/Modules/files.c, + Src/Modules/termcap.c, Src/Modules/zpty.c, Src/Zle/comp.h, + Src/Zle/complist.c, Src/Zle/compmatch.c, Src/Zle/compresult.c, + Src/Zle/computil.c, Src/Zle/zle_refresh.c, Src/Zle/zle_tricky.c, + Src/Zle/zle_utils.c: Use term.h globally if needed, instead of + just using in Modules and fudging the headers elsewhere. Fix + various name clashes. + 2011-05-08 Barton E. Schaefer * users/15986 (belated commit): Src/Modules/curses.c: handle @@ -14612,5 +14624,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5283 $ +* $Revision: 1.5284 $ ***************************************************** diff --git a/Src/Modules/files.c b/Src/Modules/files.c index 3fbccf576..f86b9c1e9 100644 --- a/Src/Modules/files.c +++ b/Src/Modules/files.c @@ -195,7 +195,7 @@ bin_rmdir(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) static int bin_ln(char *nam, char **args, Options ops, int func) { - MoveFunc move; + MoveFunc movefn; int flags, have_dir, err = 0; char **a, *ptr, *rp, *buf; struct stat st; @@ -203,7 +203,7 @@ bin_ln(char *nam, char **args, Options ops, int func) if(func == BIN_MV) { - move = (MoveFunc) rename; + movefn = (MoveFunc) rename; flags = OPT_ISSET(ops,'f') ? 0 : MV_ASKNW; flags |= MV_ATOMIC; } else { @@ -212,11 +212,11 @@ bin_ln(char *nam, char **args, Options ops, int func) if(OPT_ISSET(ops,'h') || OPT_ISSET(ops,'n')) flags |= MV_NOCHASETARGET; if(OPT_ISSET(ops,'s')) - move = (MoveFunc) symlink; + movefn = (MoveFunc) symlink; else #endif { - move = (MoveFunc) link; + movefn = (MoveFunc) link; if(!OPT_ISSET(ops,'d')) flags |= MV_NODIRS; } @@ -267,7 +267,7 @@ bin_ln(char *nam, char **args, Options ops, int func) else args[1] = args[0]; } - return domove(nam, move, args[0], args[1], flags); + return domove(nam, movefn, args[0], args[1], flags); havedir: buf = ztrdup(*a); *a = NULL; @@ -283,7 +283,7 @@ bin_ln(char *nam, char **args, Options ops, int func) buf[blen] = 0; buf = appstr(buf, ptr); - err |= domove(nam, move, *args, buf, flags); + err |= domove(nam, movefn, *args, buf, flags); } zsfree(buf); return err; @@ -291,7 +291,7 @@ bin_ln(char *nam, char **args, Options ops, int func) /**/ static int -domove(char *nam, MoveFunc move, char *p, char *q, int flags) +domove(char *nam, MoveFunc movefn, char *p, char *q, int flags) { struct stat st; char *pbuf, *qbuf; @@ -341,7 +341,7 @@ domove(char *nam, MoveFunc move, char *p, char *q, int flags) if(doit && !(flags & MV_ATOMIC)) unlink(qbuf); } - if(move(pbuf, qbuf)) { + if(movefn(pbuf, qbuf)) { zwarnnam(nam, "%s: %e", p, errno); zsfree(pbuf); return 1; diff --git a/Src/Modules/termcap.c b/Src/Modules/termcap.c index 7367dade7..cd0e85885 100644 --- a/Src/Modules/termcap.c +++ b/Src/Modules/termcap.c @@ -35,34 +35,11 @@ */ #include "../../config.h" -#ifdef HAVE_TGETENT -# if defined(ZSH_HAVE_CURSES_H) && defined(ZSH_HAVE_TERM_H) -# define USES_TERM_H 1 -# else -# ifdef HAVE_TERMCAP_H -# define USES_TERMCAP_H 1 -# endif -# endif -#endif - #include "termcap.mdh" #include "termcap.pro" /**/ #ifdef HAVE_TGETENT -# ifdef USES_TERM_H -# ifdef HAVE_TERMIO_H -# include -# endif -# ifdef ZSH_HAVE_CURSES_H -# include "../zshcurses.h" -# endif -# include "../zshterm.h" -# else -# ifdef USES_TERMCAP_H -# include -# endif -# endif #ifndef HAVE_BOOLCODES static char *boolcodes[] = { diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index 2a81e68cb..25ec7dfea 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -351,8 +351,8 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) struct ttyinfo info; if (ioctl(slave, TIOCGWINSZ, (char *) &info.winsize) == 0) { - info.winsize.ws_row = lines; - info.winsize.ws_col = columns; + info.winsize.ws_row = zterm_lines; + info.winsize.ws_col = zterm_columns; ioctl(slave, TIOCSWINSZ, (char *) &info.winsize); } } diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h index e96c4217c..a8be74d03 100644 --- a/Src/Zle/comp.h +++ b/Src/Zle/comp.h @@ -323,8 +323,8 @@ struct cadata { typedef struct cldata *Cldata; struct cldata { - int columns; /* screen width */ - int lines; /* screen height */ + int zterm_columns; /* screen width */ + int zterm_lines; /* screen height */ int menuacc; /* value of global menuacc */ int valid; /* no need to calculate anew */ int nlist; /* number of matches to list */ diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index c253daa4c..6d0da448c 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -656,7 +656,7 @@ clprintfmt(char *p, int ml) tcout(TCCLEAREOL); cc = 0; } - if (ml == mlend - 1 && (cc % columns) == columns - 1) + if (ml == mlend - 1 && (cc % zterm_columns) == zterm_columns - 1) return 0; if (*p == Meta) { @@ -664,9 +664,9 @@ clprintfmt(char *p, int ml) putc(*p ^ 32, shout); } else putc(*p, shout); - if ((beg = !(cc % columns))) + if ((beg = !(cc % zterm_columns))) ml++; - if (mscroll && !(cc % columns) && + if (mscroll && !(cc % zterm_columns) && !--mrestlines && (ask = asklistscroll(ml))) return ask; } @@ -765,7 +765,7 @@ clnicezputs(int do_colors, char *s, int ml) /* Input is metafied... */ int nc = (*t == Meta) ? STOUC(*++t ^ 32) : STOUC(*t); /* Is the screen full? */ - if (ml == mlend - 1 && col == columns - 1) { + if (ml == mlend - 1 && col == zterm_columns - 1) { mlprinted = ml - oml; return 0; } @@ -787,13 +787,13 @@ clnicezputs(int do_colors, char *s, int ml) * There might be problems with characters of printing width * greater than one here. */ - if (col > columns) { + if (col > zterm_columns) { ml++; if (mscroll && !--mrestlines && (ask = asklistscroll(ml))) { mlprinted = ml - oml; return ask; } - col -= columns; + col -= zterm_columns; if (do_colors) fputs(" \010", shout); } @@ -820,12 +820,12 @@ clnicezputs(int do_colors, char *s, int ml) for (t = nicechar(cc); *t; t++) { int nc = (*t == Meta) ? STOUC(*++t ^ 32) : STOUC(*t); - if (ml == mlend - 1 && col == columns - 1) { + if (ml == mlend - 1 && col == zterm_columns - 1) { mlprinted = ml - oml; return 0; } putc(nc, shout); - if (++col > columns) { + if (++col > zterm_columns) { ml++; if (mscroll && !--mrestlines && (ask = asklistscroll(ml))) { mlprinted = ml - oml; @@ -991,7 +991,7 @@ asklistscroll(int ml) !strcmp(cmd->nam, "expand-or-complete-prefix") || !strcmp(cmd->nam, "menu-complete") || !strcmp(cmd->nam, "menu-expand-or-complete")) - mrestlines = lines - 1; + mrestlines = zterm_lines - 1; else if (cmd == Th(z_acceptsearch)) ret = 1; else { @@ -1001,7 +1001,7 @@ asklistscroll(int ml) selectlocalmap(NULL); settyinfo(&shttyinfo); putc('\r', shout); - for (i = columns - 1; i-- > 0; ) + for (i = zterm_columns - 1; i-- > 0; ) putc(' ', shout); putc('\r', shout); @@ -1213,8 +1213,8 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop) /* nc only contains ASCII text */ int l = strlen(nc); - if (l + cc > columns - 2) - nc[l -= l + cc - (columns - 2)] = '\0'; + if (l + cc > zterm_columns - 2) + nc[l -= l + cc - (zterm_columns - 2)] = '\0'; fputs(nc, shout); cc += l; } else if (dopr && m == 1) { @@ -1230,16 +1230,17 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop) } else { cc += width; - if ((cc >= columns - 2 || cchar == ZWC('\n')) && stat) + if ((cc >= zterm_columns - 2 || cchar == ZWC('\n')) && stat) dopr = 2; if (cchar == ZWC('\n')) { if (dopr == 1 && mlbeg >= 0 && tccan(TCCLEAREOL)) tcout(TCCLEAREOL); - l += 1 + ((cc - 1) / columns); + l += 1 + ((cc - 1) / zterm_columns); cc = 0; } if (dopr == 1) { - if (ml == mlend - 1 && (cc % columns) == columns - 1) { + if (ml == mlend - 1 && (cc % zterm_columns) == + zterm_columns - 1) { dopr = 0; p += len; continue; @@ -1256,7 +1257,7 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop) * TODO: the following doesn't allow for * character widths greater than 1. */ - if ((beg = !(cc % columns)) && !stat) { + if ((beg = !(cc % zterm_columns)) && !stat) { ml++; fputs(" \010", shout); } @@ -1264,7 +1265,7 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop) *stop = 1; if (stat && n) mfirstl = -1; - mlprinted = l + (cc ? ((cc-1) / columns) : 0); + mlprinted = l + (cc ? ((cc-1) / zterm_columns) : 0); return mlprinted; } } @@ -1273,7 +1274,7 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop) } } if (dopr) { - if (!(cc % columns)) + if (!(cc % zterm_columns)) fputs(" \010", shout); if (mlbeg >= 0 && tccan(TCCLEAREOL)) tcout(TCCLEAREOL); @@ -1285,7 +1286,7 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop) * *Not* subtracting 1 from cc at this point appears to be * correct. C.f. printfmt in zle_tricky.c. */ - mlprinted = l + (cc / columns); + mlprinted = l + (cc / zterm_columns); return mlprinted; } @@ -1309,7 +1310,7 @@ compzputs(char const *s, int ml) putc(c, shout); if (c == '\n' && mlbeg >= 0 && tccan(TCCLEAREOL)) tcout(TCCLEAREOL); - if (mscroll && (++col == columns || c == '\n')) { + if (mscroll && (++col == zterm_columns || c == '\n')) { ml++; if (!--mrestlines && (ask = asklistscroll(ml))) return ask; @@ -1344,10 +1345,11 @@ compprintlist(int showall) lastml = 0; lastnlnct = -1; } - cl = (listdat.nlines > lines - nlnct - mhasstat ? - lines - nlnct - mhasstat : listdat.nlines) - (lastnlnct > nlnct); + cl = (listdat.nlines > zterm_lines - nlnct - mhasstat ? + zterm_lines - nlnct - mhasstat : + listdat.nlines) - (lastnlnct > nlnct); lastnlnct = nlnct; - mrestlines = lines - 1; + mrestlines = zterm_lines - 1; lastinvcount = invcount; if (cl < 2) { @@ -1643,20 +1645,20 @@ compprintlist(int showall) /* Move the cursor up to the prompt, if always_last_prompt * * is set and all that... */ if (mlbeg >= 0) { - if ((nl = listdat.nlines + nlnct) >= lines) { + if ((nl = listdat.nlines + nlnct) >= zterm_lines) { if (mhasstat) { putc('\n', shout); compprintfmt(NULL, 0, 1, 1, mline, NULL); mstatprinted = 1; } - nl = lines - 1; + nl = zterm_lines - 1; } else nl--; tcmultout(TCUP, TCMULTUP, nl); showinglist = -1; lastlistlen = listdat.nlines; - } else if ((nl = listdat.nlines + nlnct - 1) < lines) { + } else if ((nl = listdat.nlines + nlnct - 1) < zterm_lines) { if (mlbeg >= 0 && tccan(TCCLEAREOL)) tcout(TCCLEAREOL); tcmultout(TCUP, TCMULTUP, nl); @@ -1666,12 +1668,12 @@ compprintlist(int showall) } else { clearflag = 0; if (!asked) { - mrestlines = (ml + nlnct > lines); + mrestlines = (ml + nlnct > zterm_lines); compprintnl(ml); } } } else if (!asked) { - mrestlines = (ml + nlnct > lines); + mrestlines = (ml + nlnct > zterm_lines); compprintnl(ml); } listshown = (clearflag ? 1 : -1); @@ -1789,7 +1791,7 @@ clprintm(Cmgroup g, Cmatch *mp, int mc, int ml, int lastc, int width) if (!dolist(ml)) { int nc = ZMB_nicewidth(m->disp ? m->disp : m->str); if (nc) - mlprinted = (nc-1) / columns; + mlprinted = (nc-1) / zterm_columns; else mlprinted = 0; return 0; @@ -1831,7 +1833,7 @@ clprintm(Cmgroup g, Cmatch *mp, int mc, int ml, int lastc, int width) return 1; } len = ZMB_nicewidth(m->disp ? m->disp : m->str); - mlprinted = len ? (len-1) / columns : 0; + mlprinted = len ? (len-1) / zterm_columns : 0; modec = (mcolors.flags & LC_FOLLOW_SYMLINKS) ? m->fmodec : m->modec; if ((g->flags & CGF_FILES) && modec) { @@ -1864,9 +1866,11 @@ static int singlecalc(int *cp, int l, int *lcp) { int c = *cp, n, j, first = 1; - Cmatch **p, *op, *mp = mtab[l * columns + c]; + Cmatch **p, *op, *mp = mtab[l * zterm_columns + c]; - for (n = 0, j = c, p = mtab + l * columns + c, op = NULL; j >= 0; j--, p--) { + for (n = 0, j = c, p = mtab + l * zterm_columns + c, op = NULL; + j >= 0; + j--, p--) { if (*p == mp) c = j; if (!first && *p != op) @@ -1876,7 +1880,7 @@ singlecalc(int *cp, int l, int *lcp) } *cp = c; *lcp = 1; - for (p = mtab + l * columns + c; c < columns; c++, p++) + for (p = mtab + l * zterm_columns + c; c < zterm_columns; c++, p++) if (*p && mp != *p) *lcp = 0; @@ -1906,9 +1910,9 @@ singledraw() tc_downcurs(md1); if (mc1) tcmultout(TCRIGHT, TCMULTRIGHT, mc1); - DPUTS(ml1 * columns + mc1 >= mgtabsize, "BUG: invalid position"); - g = mgtab[ml1 * columns + mc1]; - clprintm(g, mtab[ml1 * columns + mc1], mcc1, ml1, lc1, + DPUTS(ml1 * zterm_columns + mc1 >= mgtabsize, "BUG: invalid position"); + g = mgtab[ml1 * zterm_columns + mc1]; + clprintm(g, mtab[ml1 * zterm_columns + mc1], mcc1, ml1, lc1, (g->widths ? g->widths[mcc1] : g->width)); if (mlprinted) (void) tcmultout(TCUP, TCMULTUP, mlprinted); @@ -1918,20 +1922,20 @@ singledraw() tc_downcurs(md2 - md1); if (mc2) tcmultout(TCRIGHT, TCMULTRIGHT, mc2); - DPUTS(ml2 * columns + mc2 >= mgtabsize, "BUG: invalid position"); - g = mgtab[ml2 * columns + mc2]; - clprintm(g, mtab[ml2 * columns + mc2], mcc2, ml2, lc2, + DPUTS(ml2 * zterm_columns + mc2 >= mgtabsize, "BUG: invalid position"); + g = mgtab[ml2 * zterm_columns + mc2]; + clprintm(g, mtab[ml2 * zterm_columns + mc2], mcc2, ml2, lc2, (g->widths ? g->widths[mcc2] : g->width)); if (mlprinted) (void) tcmultout(TCUP, TCMULTUP, mlprinted); putc('\r', shout); if (mstatprinted) { - int i = lines - md2 - nlnct; + int i = zterm_lines - md2 - nlnct; tc_downcurs(i - 1); compprintfmt(NULL, 0, 1, 1, mline, NULL); - tcmultout(TCUP, TCMULTUP, lines - 1); + tcmultout(TCUP, TCMULTUP, zterm_lines - 1); } else tcmultout(TCUP, TCMULTUP, md2 + nlnct); @@ -1951,7 +1955,7 @@ complistmatches(UNUSED(Hookdef dummy), Chdata dat) noselect = 0; - if ((minfo.asked == 2 && mselect < 0) || nlnct >= lines) { + if ((minfo.asked == 2 && mselect < 0) || nlnct >= zterm_lines) { showinglist = 0; amatches = oamatches; return (noselect = 1); @@ -1971,7 +1975,7 @@ complistmatches(UNUSED(Hookdef dummy), Chdata dat) getcols(); - mnew = ((calclist(mselect >= 0) || mlastcols != columns || + mnew = ((calclist(mselect >= 0) || mlastcols != zterm_columns || mlastlines != listdat.nlines) && mselect >= 0); if (!listdat.nlines || (mselect >= 0 && @@ -2006,7 +2010,7 @@ complistmatches(UNUSED(Hookdef dummy), Chdata dat) mscroll = 1; } else { clearflag = 1; - minfo.asked = (listdat.nlines + nlnct <= lines); + minfo.asked = (listdat.nlines + nlnct <= zterm_lines); } } else { unqueue_signals(); @@ -2019,7 +2023,7 @@ complistmatches(UNUSED(Hookdef dummy), Chdata dat) } } if (mlbeg >= 0) { - mlend = mlbeg + lines - nlnct - mhasstat; + mlend = mlbeg + zterm_lines - nlnct - mhasstat; while (mline >= mlend) mlbeg++, mlend++; } else @@ -2030,7 +2034,7 @@ complistmatches(UNUSED(Hookdef dummy), Chdata dat) mtab_been_reallocated = 1; - i = columns * listdat.nlines; + i = zterm_columns * listdat.nlines; free(mtab); mtab = (Cmatch **) zalloc(i * sizeof(Cmatch **)); memset(mtab, 0, i * sizeof(Cmatch **)); @@ -2040,7 +2044,7 @@ complistmatches(UNUSED(Hookdef dummy), Chdata dat) mgtabsize = i; #endif memset(mgtab, 0, i * sizeof(Cmgroup)); - mlastcols = mcols = columns; + mlastcols = mcols = zterm_columns; mlastlines = mlines = listdat.nlines; } last_cap = (char *) zhalloc(max_caplen + 1); @@ -2067,13 +2071,13 @@ complistmatches(UNUSED(Hookdef dummy), Chdata dat) static int adjust_mcol(int wish, Cmatch ***tabp, Cmgroup **grp) { - Cmatch **tab = *tabp; + Cmatch **matchtab = *tabp; int p, n, c; - tab -= mcol; + matchtab -= mcol; - for (p = wish; p >= 0 && (!tab[p] || mmarked(tab[p])); p--); - for (n = wish; n < mcols && (!tab[n] || mmarked(tab[n])); n++); + for (p = wish; p >= 0 && (!matchtab[p] || mmarked(matchtab[p])); p--); + for (n = wish; n < mcols && (!matchtab[n] || mmarked(matchtab[n])); n++); if (n == mcols) n = -1; @@ -2086,7 +2090,7 @@ adjust_mcol(int wish, Cmatch ***tabp, Cmgroup **grp) else c = ((mcol - p) < (n - mcol) ? p : n); - *tabp = tab + c; + *tabp = matchtab + c; if (grp) *grp = *grp + c - mcol; @@ -2177,7 +2181,7 @@ setmstatus(char *status, char *sline, int sll, int scs, } pl = strlen(p); sl = strlen(s); - max = (columns < MAX_STATUS ? columns : MAX_STATUS) - 14; + max = (zterm_columns < MAX_STATUS ? zterm_columns : MAX_STATUS) - 14; if (max > 12) { int h = (max - 2) >> 1; @@ -2394,9 +2398,9 @@ domenuselect(Hookdef dummy, Chdata dat) if ((s = getsparam("MENUSCROLL"))) { if (!(step = mathevali(s))) - step = (lines - nlnct) >> 1; + step = (zterm_lines - nlnct) >> 1; else if (step < 0) - if ((step += lines - nlnct) < 0) + if ((step += zterm_lines - nlnct) < 0) step = 1; } if ((s = getsparam("MENUMODE"))) { @@ -2473,34 +2477,34 @@ domenuselect(Hookdef dummy, Chdata dat) } if (mlbeg && lbeg != mlbeg) { - Cmatch **p = mtab + ((mlbeg - 1) * columns), **q; + Cmatch **p = mtab + ((mlbeg - 1) * zterm_columns), **q; int c; while (mlbeg) { - for (q = p, c = columns; c > 0; q++, c--) + for (q = p, c = zterm_columns; c > 0; q++, c--) if (*q && !mmarked(*q)) break; if (c) break; - p -= columns; + p -= zterm_columns; mlbeg--; } } - if ((space = lines - pl - mhasstat)) + if ((space = zterm_lines - pl - mhasstat)) while (mline >= mlbeg + space) if ((mlbeg += step) + space > mlines) mlbeg = mlines - space; if (lbeg != mlbeg) { - Cmatch **p = mtab + (mlbeg * columns), **q; + Cmatch **p = mtab + (mlbeg * zterm_columns), **q; int c; while (mlbeg < mlines) { - for (q = p, c = columns; c > 0; q++, c--) + for (q = p, c = zterm_columns; c > 0; q++, c--) if (*q) break; if (c) break; - p += columns; + p += zterm_columns; mlbeg++; } } @@ -2955,7 +2959,7 @@ domenuselect(Hookdef dummy, Chdata dat) cmd == Th(z_viforwardword) || cmd == Th(z_viforwardwordend) || cmd == Th(z_forwardword)) { - int i = lines - pl - 1, oi = i, ll = 0; + int i = zterm_lines - pl - 1, oi = i, ll = 0; Cmatch **lp = NULL; mode = 0; @@ -2983,7 +2987,7 @@ domenuselect(Hookdef dummy, Chdata dat) } else if (cmd == Th(z_emacsbackwardword) || cmd == Th(z_vibackwardword) || cmd == Th(z_backwardword)) { - int i = lines - pl - 1, oi = i, ll = 0; + int i = zterm_lines - pl - 1, oi = i, ll = 0; Cmatch **lp = NULL; mode = 0; diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c index b59f5a2e1..4cd3b9ffe 100644 --- a/Src/Zle/compmatch.c +++ b/Src/Zle/compmatch.c @@ -1268,7 +1268,7 @@ pattern_match_equivalence(Cpattern lp, convchar_t wind, int wmtp, /**/ static int pattern_match_restrict(Cpattern p, Cpattern wp, convchar_t *wsc, int wsclen, - Cpattern prestrict, ZLE_STRING_T newline) + Cpattern prestrict, ZLE_STRING_T new_line) { convchar_t c; convchar_t ind, wind; @@ -1356,7 +1356,7 @@ pattern_match_restrict(Cpattern p, Cpattern wp, convchar_t *wsc, int wsclen, } /* We need to assemble the line */ - *newline++ = (ZLE_CHAR_T)c; + *new_line++ = (ZLE_CHAR_T)c; prestrict = prestrict->next; wsc++; wsclen--; @@ -1393,7 +1393,7 @@ pattern_match_restrict(Cpattern p, Cpattern wp, convchar_t *wsc, int wsclen, if (!pattern_match1(p, c, &mt)) return 0; p = p->next; - *newline++ = (ZLE_CHAR_T)c; + *new_line++ = (ZLE_CHAR_T)c; prestrict = prestrict->next; } diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c index 0389b52a2..f2729a0fe 100644 --- a/Src/Zle/compresult.c +++ b/Src/Zle/compresult.c @@ -1473,13 +1473,14 @@ calclist(int showall) if (lastinvcount == invcount && listdat.valid && onlyexpl == listdat.onlyexpl && menuacc == listdat.menuacc && showall == listdat.showall && - lines == listdat.lines && columns == listdat.columns) + zterm_lines == listdat.zterm_lines && + zterm_columns == listdat.zterm_columns) return 0; lastinvcount = invcount; for (g = amatches; g; g = g->next) { char **pp = g->ylist; - int nl = 0, l, glong = 1, gshort = columns, ndisp = 0, totl = 0; + int nl = 0, l, glong = 1, gshort = zterm_columns, ndisp = 0, totl = 0; int hasf = 0; g->flags |= CGF_PACKED | CGF_ROWS; @@ -1495,7 +1496,7 @@ calclist(int showall) /* We have an ylist, lets see, if it contains newlines. */ hidden = 1; while (!nl && *pp) { - if (MB_METASTRWIDTH(*pp) >= columns) + if (MB_METASTRWIDTH(*pp) >= zterm_columns) nl = 1; else nl = !!strchr(*pp++, '\n'); @@ -1511,11 +1512,12 @@ calclist(int showall) while (*sptr) { if ((nlptr = strchr(sptr, '\n'))) { *nlptr = '\0'; - nlines += 1 + (MB_METASTRWIDTH(sptr)-1) / columns; + nlines += 1 + (MB_METASTRWIDTH(sptr)-1) / + zterm_columns; *nlptr = '\n'; sptr = nlptr + 1; } else { - nlines += (MB_METASTRWIDTH(sptr)-1) / columns; + nlines += (MB_METASTRWIDTH(sptr)-1) / zterm_columns; break; } } @@ -1607,7 +1609,7 @@ calclist(int showall) g->dcount = ndisp; g->width = glong + CM_SPACE; g->shortest = gshort + CM_SPACE; - if ((g->cols = columns / g->width) > g->dcount) + if ((g->cols = zterm_columns / g->width) > g->dcount) g->cols = g->dcount; if (g->cols) { i = g->cols * g->width - CM_SPACE; @@ -1636,9 +1638,10 @@ calclist(int showall) } else { g->cols = 1; g->width = 1; - + while (*pp) - glines += 1 + (MB_METASTRWIDTH(*pp++) / columns); + glines += 1 + (MB_METASTRWIDTH(*pp++) / + zterm_columns); } } } else { @@ -1650,15 +1653,17 @@ calclist(int showall) } else if (!(g->flags & CGF_LINES)) { g->cols = 1; g->width = 0; - + for (p = g->matches; (m = *p); p++) if (!(m->flags & CMF_HIDE)) { if (m->disp) { if (!(m->flags & CMF_DISPLINE)) - glines += 1 + ((mlens[m->gnum] - 1) / columns); + glines += 1 + ((mlens[m->gnum] - 1) / + zterm_columns); } else if (showall || !(m->flags & (CMF_NOLIST | CMF_MULT))) - glines += 1 + (((mlens[m->gnum]) - 1) / columns); + glines += 1 + (((mlens[m->gnum]) - 1) / + zterm_columns); } } } @@ -1669,8 +1674,8 @@ calclist(int showall) if (!(g->flags & CGF_PACKED)) continue; - ws = g->widths = (int *) zalloc(columns * sizeof(int)); - memset(ws, 0, columns * sizeof(int)); + ws = g->widths = (int *) zalloc(zterm_columns * sizeof(int)); + memset(ws, 0, zterm_columns * sizeof(int)); tlines = g->lins; tcols = g->cols; width = 0; @@ -1686,14 +1691,14 @@ calclist(int showall) if (g->flags & CGF_ROWS) { int nth, tcol, len; - for (tcols = columns / (g->shortest + CM_SPACE); + for (tcols = zterm_columns / (g->shortest + CM_SPACE); tcols > g->cols; tcols--) { memset(ws, 0, tcols * sizeof(int)); for (width = nth = tcol = 0, tlines = 1; - width < columns && nth < g->dcount; + width < zterm_columns && nth < g->dcount; nth++, tcol++) { m = *p; @@ -1709,13 +1714,13 @@ calclist(int showall) ws[tcol] = len; } } - if (width < columns) + if (width < zterm_columns) break; } } else { int nth, tcol, tline, len; - for (tcols = columns / (g->shortest + CM_SPACE); + for (tcols = zterm_columns / (g->shortest + CM_SPACE); tcols > g->cols; tcols--) { @@ -1725,7 +1730,7 @@ calclist(int showall) memset(ws, 0, tcols * sizeof(int)); for (width = nth = tcol = tline = 0; - width < columns && nth < g->dcount; + width < zterm_columns && nth < g->dcount; nth++, tline++) { m = *p; @@ -1745,7 +1750,7 @@ calclist(int showall) ws[tcol] = len; } } - if (width < columns) + if (width < zterm_columns) break; } } @@ -1754,7 +1759,7 @@ calclist(int showall) if (g->flags & CGF_ROWS) { int nth, tcol, len; - for (tcols = columns / (g->shortest + CM_SPACE); + for (tcols = zterm_columns / (g->shortest + CM_SPACE); tcols > g->cols; tcols--) { @@ -1762,7 +1767,7 @@ calclist(int showall) for (width = nth = tcol = 0, tlines = 1, p = skipnolist(g->matches, showall); - *p && width < columns && nth < g->dcount; + *p && width < zterm_columns && nth < g->dcount; nth++, p = skipnolist(p + 1, showall), tcol++) { m = *p; @@ -1779,13 +1784,13 @@ calclist(int showall) ws[tcol] = len; } } - if (width < columns) + if (width < zterm_columns) break; } } else { int nth, tcol, tline, len; - for (tcols = columns / (g->shortest + CM_SPACE); + for (tcols = zterm_columns / (g->shortest + CM_SPACE); tcols > g->cols; tcols--) { @@ -1796,7 +1801,7 @@ calclist(int showall) for (width = nth = tcol = tline = 0, p = skipnolist(g->matches, showall); - *p && width < columns && nth < g->dcount; + *p && width < zterm_columns && nth < g->dcount; nth++, p = skipnolist(p + 1, showall), tline++) { m = *p; @@ -1817,7 +1822,7 @@ calclist(int showall) ws[tcol] = len; } } - if (width < columns) { + if (width < zterm_columns) { if (++tcol < tcols) tcols = tcol; break; @@ -1828,7 +1833,7 @@ calclist(int showall) if (tcols <= g->cols) tlines = g->lins; if (tlines == g->lins) { - zfree(ws, columns * sizeof(int)); + zfree(ws, zterm_columns * sizeof(int)); g->widths = NULL; } else { nlines += tlines - g->lins; @@ -1862,8 +1867,8 @@ calclist(int showall) listdat.nlines = nlines; listdat.menuacc = menuacc; listdat.onlyexpl = onlyexpl; - listdat.columns = columns; - listdat.lines = lines; + listdat.zterm_columns = zterm_columns; + listdat.zterm_lines = zterm_lines; listdat.showall = showall; return 1; @@ -1884,7 +1889,7 @@ asklist(void) if ((!minfo.cur || !minfo.asked) && ((complistmax > 0 && listdat.nlist >= complistmax) || (complistmax < 0 && listdat.nlines <= -complistmax) || - (!complistmax && listdat.nlines >= lines))) { + (!complistmax && listdat.nlines >= zterm_lines))) { int qup, l; zsetterm(); @@ -1893,7 +1898,7 @@ asklist(void) listdat.nlist, listdat.nlines) : fprintf(shout, "zsh: do you wish to see all %d lines? ", listdat.nlines)); - qup = ((l + columns - 1) / columns) - 1; + qup = ((l + zterm_columns - 1) / zterm_columns) - 1; fflush(shout); if (!getzlequery()) { if (clearflag) { @@ -1987,7 +1992,7 @@ printlist(int over, CLPrintFunc printm, int showall) while ((p = *pp++)) { zputs(p, shout); if (*pp) { - if (MB_METASTRWIDTH(p) % columns) + if (MB_METASTRWIDTH(p) % zterm_columns) putc('\n', shout); else fputs(" \010", shout); @@ -2113,7 +2118,7 @@ printlist(int over, CLPrintFunc printm, int showall) if (clearflag) { /* Move the cursor up to the prompt, if always_last_prompt * * is set and all that... */ - if ((ml = listdat.nlines + nlnct - 1) < lines) { + if ((ml = listdat.nlines + nlnct - 1) < zterm_lines) { tcmultout(TCUP, TCMULTUP, ml); showinglist = -1; @@ -2134,8 +2139,8 @@ bld_all_str(Cmatch all) { Cmgroup g; Cmatch *mp, m; - int len = columns - 5, t, add = 0; - VARARR(char, buf, columns + 1); + int len = zterm_columns - 5, t, add = 0; + VARARR(char, buf, zterm_columns + 1); buf[0] = '\0'; diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index 0cc9d7400..e5a99485c 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -226,8 +226,8 @@ cd_prep() runp = &(cd_state.runs); if (cd_state.groups) { - int lines = cd_state.groups + cd_state.descs; - VARARR(Cdstr, grps, lines); + int preplines = cd_state.groups + cd_state.descs; + VARARR(Cdstr, grps, preplines); VARARR(int, wids, cd_state.maxg); Cdstr gs, gp, gn, *gpp; int i, j, d; @@ -275,7 +275,7 @@ cd_prep() if (cd_state.gprew > cd_state.maxmlen && cd_state.maxglen > 1) return 1; - for (i = 0; i < lines; i++) { + for (i = 0; i < preplines; i++) { Cdstr s = grps[i]; int dummy; @@ -283,9 +283,9 @@ cd_prep() unmetafy(s->sortstr, &dummy); } - qsort(grps, lines, sizeof(Cdstr), cd_sort); + qsort(grps, preplines, sizeof(Cdstr), cd_sort); - for (i = lines, strp = grps; i > 1; i--, strp++) { + for (i = preplines, strp = grps; i > 1; i--, strp++) { strp2 = strp + 1; if (!strcmp((*strp)->desc, (*strp2)->desc)) continue; @@ -303,9 +303,9 @@ cd_prep() expl = (Cdrun) zalloc(sizeof(*run)); expl->type = CRT_EXPL; expl->strs = grps[0]; - expl->count = lines; + expl->count = preplines; - for (i = lines, strp = grps, strp2 = NULL; i; i--, strp++) { + for (i = preplines, strp = grps, strp2 = NULL; i; i--, strp++) { str = *strp; *strp = str->other; if (strp2) @@ -321,7 +321,7 @@ cd_prep() *strp2 = NULL; for (i = cd_state.maxg - 1; i; i--) { - for (d = 0, j = lines, strp = grps; j; j--, strp++) { + for (d = 0, j = preplines, strp = grps; j; j--, strp++) { if ((str = *strp)) { if (d) { *runp = run = (Cdrun) zalloc(sizeof(*run)); @@ -465,7 +465,7 @@ cd_init(char *nam, char *hide, char *mlen, char *sep, cd_state.showd = disp; cd_state.maxg = cd_state.groups = cd_state.descs = 0; cd_state.maxmlen = atoi(mlen); - itmp = columns - cd_state.swidth - 4; + itmp = zterm_columns - cd_state.swidth - 4; if (cd_state.maxmlen > itmp) cd_state.maxmlen = itmp; if (cd_state.maxmlen < 4) @@ -545,7 +545,7 @@ cd_init(char *nam, char *hide, char *mlen, char *sep, args++; } if (disp && grp) { - int mg = columns; + int mg = zterm_columns; do { cd_group(mg); @@ -651,7 +651,8 @@ cd_get(char **params) * is available. Leave 1 character at the end of screen * as safety margin */ - remw = columns - cd_state.premaxw - cd_state.swidth - 3; + remw = zterm_columns - cd_state.premaxw - + cd_state.swidth - 3; d = str->desc; w = MB_METASTRWIDTH(d); if (w <= remw) @@ -727,7 +728,8 @@ cd_get(char **params) case CRT_EXPL: { /* add columns as safety margin */ - VARARR(char, dbuf, cd_state.suf + cd_state.slen + columns); + VARARR(char, dbuf, cd_state.suf + cd_state.slen + + zterm_columns); char buf[20], *p, *pp, *d; int i = run->count, remw, w, l; @@ -743,7 +745,8 @@ cd_get(char **params) } strcpy(dbuf, cd_state.sep); - remw = columns - cd_state.gprew - cd_state.swidth - CM_SPACE; + remw = zterm_columns - cd_state.gprew - + cd_state.swidth - CM_SPACE; p = pp = dbuf + cd_state.slen; d = str->desc; w = MB_METASTRWIDTH(d); diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index a78aef7db..797f86251 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -688,12 +688,12 @@ resetvideo(void) { int ln; - winw = columns; /* terminal width */ + winw = zterm_columns; /* terminal width */ if (termflags & TERM_SHORT) winh = 1; else - winh = (lines < 2) ? 24 : lines; - rwinh = lines; /* keep the real number of lines */ + winh = (zterm_lines < 2) ? 24 : zterm_lines; + rwinh = zterm_lines; /* keep the real number of lines */ vln = vmaxln = winprompt = 0; winpos = -1; if (winw_alloc != winw || winh_alloc != winh) { @@ -1082,7 +1082,7 @@ zrefresh(void) cleareol = 0; /* unset */ more_start = more_end = 0; /* unset */ - if (isset(SINGLELINEZLE) || lines < 3 + if (isset(SINGLELINEZLE) || zterm_lines < 3 || (termflags & (TERM_NOUP | TERM_BAD | TERM_UNKNOWN))) termflags |= TERM_SHORT; else @@ -1138,7 +1138,7 @@ zrefresh(void) } fflush(shout); clearf = clearflag; - } else if (winw != columns || rwinh != lines) + } else if (winw != zterm_columns || rwinh != zterm_lines) resetvideo(); /* now winw equals columns and winh equals lines @@ -2004,7 +2004,7 @@ refreshline(int ln) * last line lest undesired scrolling occurs due to `illegal' * characters on screen */ - if (tccan(TCINS) && (vln != lines - 1)) { + if (tccan(TCINS) && (vln != zterm_lines - 1)) { /* not on last line */ for (i = 1; nl[i].chr; i++) { if (tcinscost(i) < wpfxlen(ol, nl + i)) { diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index 74da24e6c..8f7c2aac1 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -2419,13 +2419,13 @@ printfmt(char *fmt, int n, int dopr, int doesc) if (tccan(TCCLEAREOL)) tcout(TCCLEAREOL); else { - int s = columns - 1 - (cc % columns); + int s = zterm_columns - 1 - (cc % zterm_columns); while (s-- > 0) putc(' ', shout); } } - l += 1 + ((cc - 1) / columns); + l += 1 + ((cc - 1) / zterm_columns); cc = 0; if (dopr) putc('\n', shout); @@ -2445,18 +2445,18 @@ printfmt(char *fmt, int n, int dopr, int doesc) } else p += clen; cc += WCWIDTH_WINT(cchar); - if (dopr && !(cc % columns)) + if (dopr && !(cc % zterm_columns)) fputs(" \010", shout); } } } if (dopr) { - if (!(cc % columns)) + if (!(cc % zterm_columns)) fputs(" \010", shout); if (tccan(TCCLEAREOL)) tcout(TCCLEAREOL); else { - int s = columns - 1 - (cc % columns); + int s = zterm_columns - 1 - (cc % zterm_columns); while (s-- > 0) putc(' ', shout); @@ -2467,7 +2467,7 @@ printfmt(char *fmt, int n, int dopr, int doesc) * cc is correct, i.e. if just misses wrapping we still add 1. * (Why?) */ - return l + (cc / columns); + return l + (cc / zterm_columns); } /* This is used to print expansions. */ @@ -2481,8 +2481,8 @@ listlist(LinkList l) LinkNode node; char **p; VARARR(int, lens, num); - VARARR(int, widths, columns); - int longest = 0, shortest = columns, totl = 0; + VARARR(int, widths, zterm_columns); + int longest = 0, shortest = zterm_columns, totl = 0; int len, ncols, nlines, tolast, col, i, max, pack = 0, *lenp; for (node = firstnode(l), p = data; node; incnode(node), p++) @@ -2500,7 +2500,7 @@ listlist(LinkList l) shortest = len; totl += len; } - if ((ncols = ((columns + 2) / longest))) { + if ((ncols = ((zterm_columns + 2) / longest))) { int tlines = 0, tline, tcols = 0, maxlen, nth, width; nlines = (num + ncols - 1) / ncols; @@ -2509,7 +2509,7 @@ listlist(LinkList l) if (isset(LISTROWSFIRST)) { int count, tcol, first, maxlines = 0, llines; - for (tcols = columns / shortest; tcols > ncols; + for (tcols = zterm_columns / shortest; tcols > ncols; tcols--) { for (nth = first = maxlen = width = maxlines = llines = tcol = 0, @@ -2522,7 +2522,7 @@ listlist(LinkList l) nth += tcols; tlines++; if (nth >= num) { - if ((width += maxlen) >= columns) + if ((width += maxlen) >= zterm_columns) break; widths[tcol++] = maxlen; maxlen = 0; @@ -2536,13 +2536,13 @@ listlist(LinkList l) widths[tcol++] = maxlen; width += maxlen; } - if (!count && width < columns) + if (!count && width < zterm_columns) break; } if (tcols > ncols) tlines = maxlines; } else { - for (tlines = ((totl + columns) / columns); + for (tlines = ((totl + zterm_columns) / zterm_columns); tlines < nlines; tlines++) { for (p = data, nth = tline = width = maxlen = tcols = 0; @@ -2550,7 +2550,7 @@ listlist(LinkList l) if (lens[nth] > maxlen) maxlen = lens[nth]; if (++tline == tlines) { - if ((width += maxlen) >= columns) + if ((width += maxlen) >= zterm_columns) break; widths[tcols++] = maxlen; maxlen = tline = 0; @@ -2560,7 +2560,7 @@ listlist(LinkList l) widths[tcols++] = maxlen; width += maxlen; } - if (nth == num && width < columns) + if (nth == num && width < zterm_columns) break; } } @@ -2572,7 +2572,7 @@ listlist(LinkList l) } else { nlines = 0; for (p = data; *p; p++) - nlines += 1 + (strlen(*p) / columns); + nlines += 1 + (strlen(*p) / zterm_columns); } /* Set the cursor below the prompt. */ trashzle(); @@ -2581,7 +2581,7 @@ listlist(LinkList l) clearflag = (isset(USEZLE) && !termflags && tolast); max = getiparam("LISTMAX"); - if ((max && num > max) || (!max && nlines > lines)) { + if ((max && num > max) || (!max && nlines > zterm_lines)) { int qup, l; zsetterm(); @@ -2589,7 +2589,7 @@ listlist(LinkList l) fprintf(shout, "zsh: do you wish to see all %d possibilities (%d lines)? ", num, nlines) : fprintf(shout, "zsh: do you wish to see all %d lines? ", nlines)); - qup = ((l + columns - 1) / columns) - 1; + qup = ((l + zterm_columns - 1) / zterm_columns) - 1; fflush(shout); if (!getzlequery()) { if (clearflag) { @@ -2656,7 +2656,7 @@ listlist(LinkList l) } } if (clearflag) { - if ((nlines += nlnct - 1) < lines) { + if ((nlines += nlnct - 1) < zterm_lines) { tcmultout(TCUP, TCMULTUP, nlines); showinglist = -1; } else diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c index e63f6a162..03a514cce 100644 --- a/Src/Zle/zle_utils.c +++ b/Src/Zle/zle_utils.c @@ -1257,7 +1257,7 @@ showmsg(char const *msg) p++; putc('\n', shout); - up += 1 + cc / columns; + up += 1 + cc / zterm_columns; cc = 0; } else { /* @@ -1308,7 +1308,7 @@ showmsg(char const *msg) c = *++p ^ 32; if(c == '\n') { putc('\n', shout); - up += 1 + cc / columns; + up += 1 + cc / zterm_columns; cc = 0; } else { char const *n = nicechar(c); @@ -1317,7 +1317,7 @@ showmsg(char const *msg) } } #endif - up += cc / columns; + up += cc / zterm_columns; if (clearflag) { putc('\r', shout); diff --git a/Src/builtin.c b/Src/builtin.c index 127d58bdb..fc98eb1b1 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -3903,7 +3903,7 @@ bin_print(char *name, char **args, Options ops, int func) * nc: number of columns (at least one) */ sc = l + 2; - nc = (columns + 1) / sc; + nc = (zterm_columns + 1) / sc; if (!nc) nc = 1; nr = (n + nc - 1) / nc; diff --git a/Src/exec.c b/Src/exec.c index a06f2f3ac..df0101853 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -4398,7 +4398,7 @@ loadautofn(Shfunc shf, int fksh, int autol) mod_export int doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval) { - char **tab, **x, *oargv0; + char **pptab, **x, *oargv0; int oldzoptind, oldlastval, oldoptcind, oldnumpipestats, ret; int *oldpipestats = NULL; char saveopts[OPT_SIZE], *oldscriptname = scriptname; @@ -4432,7 +4432,7 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval) starttrapscope(); - tab = pparams; + pptab = pparams; if (!(flags & PM_UNDEFINED)) scriptname = dupstring(name); oldzoptind = zoptind; @@ -4548,7 +4548,7 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval) zsfree(argzero); argzero = oargv0; } - pparams = tab; + pparams = pptab; optcind = oldoptcind; zoptind = oldzoptind; scriptname = oldscriptname; diff --git a/Src/glob.c b/Src/glob.c index b788ff38a..bfc7f0416 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -2000,7 +2000,7 @@ hasbraces(char *str) /**/ int -xpandredir(struct redir *fn, LinkList tab) +xpandredir(struct redir *fn, LinkList redirtab) { char *nam; struct redir *ff; @@ -2048,7 +2048,7 @@ xpandredir(struct redir *fn, LinkList tab) ff = (struct redir *) zhalloc(sizeof *ff); *ff = *fn; ff->name = nam; - addlinknode(tab, ff); + addlinknode(redirtab, ff); ret = 1; } } diff --git a/Src/hashtable.c b/Src/hashtable.c index 6d7179412..235beda1c 100644 --- a/Src/hashtable.c +++ b/Src/hashtable.c @@ -59,7 +59,7 @@ struct scanstatus { int sorted; union { struct { - HashNode *tab; + HashNode *hashtab; int ct; } s; HashNode u; @@ -187,11 +187,11 @@ addhashnode2(HashTable ht, char *nam, void *nodeptr) hn->next = hp->next; if(ht->scan) { if(ht->scan->sorted) { - HashNode *tab = ht->scan->u.s.tab; + HashNode *hashtab = ht->scan->u.s.hashtab; int i; for(i = ht->scan->u.s.ct; i--; ) - if(tab[i] == hp) - tab[i] = hn; + if(hashtab[i] == hp) + hashtab[i] = hn; } else if(ht->scan->u.u == hp) ht->scan->u.u = hn; } @@ -286,11 +286,11 @@ removehashnode(HashTable ht, const char *nam) ht->ct--; if(ht->scan) { if(ht->scan->sorted) { - HashNode *tab = ht->scan->u.s.tab; + HashNode *hashtab = ht->scan->u.s.hashtab; int i; for(i = ht->scan->u.s.ct; i--; ) - if(tab[i] == hp) - tab[i] = NULL; + if(hashtab[i] == hp) + hashtab[i] = NULL; } else if(ht->scan->u.u == hp) ht->scan->u.u = hp->next; } @@ -397,7 +397,7 @@ scanmatchtable(HashTable ht, Patprog pprog, int sorted, qsort((void *)hnsorttab, ct, sizeof(HashNode), hnamcmp); st.sorted = 1; - st.u.s.tab = hnsorttab; + st.u.s.hashtab = hnsorttab; st.u.s.ct = ct; ht->scan = &st; diff --git a/Src/init.c b/Src/init.c index 0fcecef1a..30cd40e6c 100644 --- a/Src/init.c +++ b/Src/init.c @@ -908,8 +908,8 @@ setupvals(void) /* columns and lines are normally zero, unless something different * * was inhereted from the environment. If either of them are zero * * the setiparam calls below set them to the defaults from termcap */ - setiparam("COLUMNS", columns); - setiparam("LINES", lines); + setiparam("COLUMNS", zterm_columns); + setiparam("LINES", zterm_lines); #endif #ifdef HAVE_GETRLIMIT diff --git a/Src/jobs.c b/Src/jobs.c index 9a8dc8fea..951f06d6e 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -893,7 +893,7 @@ printjob(Job jn, int lng, int synch) { Process pn; int job, len = 9, sig, sflag = 0, llen; - int conted = 0, lineleng = columns, skip = 0, doputnl = 0; + int conted = 0, lineleng = zterm_columns, skip = 0, doputnl = 0; int doneprint = 0, skip_print = 0; FILE *fout = (synch == 2 || !shout) ? stdout : shout; diff --git a/Src/loop.c b/Src/loop.c index 40dbe6f8f..90a0761b3 100644 --- a/Src/loop.c +++ b/Src/loop.c @@ -324,13 +324,13 @@ selectlist(LinkList l, size_t start) while (t0) t0 /= 10, longest++; /* to compensate for added ')' */ - fct = (columns - 1) / (longest + 3); + fct = (zterm_columns - 1) / (longest + 3); if (fct == 0) fct = 1; else - fw = (columns - 1) / fct; + fw = (zterm_columns - 1) / fct; colsz = (ct + fct - 1) / fct; - for (t1 = start; t1 != colsz && t1 - start < lines - 2; t1++) { + for (t1 = start; t1 != colsz && t1 - start < zterm_lines - 2; t1++) { ap = arr + t1; do { size_t t2 = strlen(*ap) + 2; diff --git a/Src/params.c b/Src/params.c index ba6cd6365..cdc05213d 100644 --- a/Src/params.c +++ b/Src/params.c @@ -94,8 +94,8 @@ mod_export zlong lastval, /* $? */ mypid, /* $$ */ lastpid, /* $! */ - columns, /* $COLUMNS */ - lines, /* $LINES */ + zterm_columns, /* $COLUMNS */ + zterm_lines, /* $LINES */ ppid, /* $PPID */ zsh_subshell; /* $ZSH_SUBSHELL */ /**/ @@ -312,8 +312,8 @@ IPDEF4("PPID", &ppid), IPDEF4("ZSH_SUBSHELL", &zsh_subshell), #define IPDEF5(A,B,F) {{NULL,A,PM_INTEGER|PM_SPECIAL},BR((void *)B),GSU(varinteger_gsu),10,0,NULL,NULL,NULL,0} -IPDEF5("COLUMNS", &columns, zlevar_gsu), -IPDEF5("LINES", &lines, zlevar_gsu), +IPDEF5("COLUMNS", &zterm_columns, zlevar_gsu), +IPDEF5("LINES", &zterm_lines, zlevar_gsu), IPDEF5("OPTIND", &zoptind, varinteger_gsu), IPDEF5("SHLVL", &shlvl, varinteger_gsu), IPDEF5("TRY_BLOCK_ERROR", &try_errflag, varinteger_gsu), @@ -3269,8 +3269,8 @@ zlevarsetfn(Param pm, zlong x) zlong *p = pm->u.valptr; *p = x; - if (p == &lines || p == &columns) - adjustwinsize(2 + (p == &columns)); + if (p == &zterm_lines || p == &zterm_columns) + adjustwinsize(2 + (p == &zterm_columns)); } /* Function to set value of generic special scalar * diff --git a/Src/prompt.c b/Src/prompt.c index 715f4b503..d15b7c0d4 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -1008,7 +1008,7 @@ countprompt(char *str, int *wp, int *hp, int overf) #endif for (; *str; str++) { - if (w >= columns && overf >= 0) { + if (w >= zterm_columns && overf >= 0) { w = 0; h++; } @@ -1092,8 +1092,8 @@ countprompt(char *str, int *wp, int *hp, int overf) * This isn't easy to handle generally; just assume there's no * output. */ - if(w >= columns && overf >= 0) { - if (!overf || w > columns) { + if(w >= zterm_columns && overf >= 0) { + if (!overf || w > zterm_columns) { w = 0; h++; } diff --git a/Src/system.h b/Src/system.h index 33b0af2f3..01c6738ca 100644 --- a/Src/system.h +++ b/Src/system.h @@ -850,3 +850,27 @@ extern short ospeed; #elif HAVE_STRUCT_STAT_ST_CTIMENSEC # define GET_ST_CTIME_NSEC(st) (st).st_ctimensec #endif + +#ifdef HAVE_TGETENT +# if defined(ZSH_HAVE_CURSES_H) && defined(ZSH_HAVE_TERM_H) +# define USES_TERM_H 1 +# else +# ifdef HAVE_TERMCAP_H +# define USES_TERMCAP_H 1 +# endif +# endif + +# ifdef USES_TERM_H +# ifdef HAVE_TERMIO_H +# include +# endif +# ifdef ZSH_HAVE_CURSES_H +# include "zshcurses.h" +# endif +# include "zshterm.h" +# else +# ifdef USES_TERMCAP_H +# include +# endif +# endif +#endif diff --git a/Src/utils.c b/Src/utils.c index 22bffa276..066710e1e 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -1296,7 +1296,8 @@ preprompt(void) countprompt(str, &w, 0, -1); opts[PROMPTPERCENT] = percents; zputs(str, shout); - fprintf(shout, "%*s\r%*s\r", (int)columns - w - !hasxn, "", w, ""); + fprintf(shout, "%*s\r%*s\r", (int)zterm_columns - w - !hasxn, + "", w, ""); fflush(shout); free(str); } @@ -1558,49 +1559,49 @@ mod_export int winchanged; static int adjustlines(int signalled) { - int oldlines = lines; + int oldlines = zterm_lines; #ifdef TIOCGWINSZ - if (signalled || lines <= 0) - lines = shttyinfo.winsize.ws_row; + if (signalled || zterm_lines <= 0) + zterm_lines = shttyinfo.winsize.ws_row; else - shttyinfo.winsize.ws_row = lines; + shttyinfo.winsize.ws_row = zterm_lines; #endif /* TIOCGWINSZ */ - if (lines <= 0) { + if (zterm_lines <= 0) { DPUTS(signalled, "BUG: Impossible TIOCGWINSZ rows"); - lines = tclines > 0 ? tclines : 24; + zterm_lines = tclines > 0 ? tclines : 24; } - if (lines > 2) + if (zterm_lines > 2) termflags &= ~TERM_SHORT; else termflags |= TERM_SHORT; - return (lines != oldlines); + return (zterm_lines != oldlines); } static int adjustcolumns(int signalled) { - int oldcolumns = columns; + int oldcolumns = zterm_columns; #ifdef TIOCGWINSZ - if (signalled || columns <= 0) - columns = shttyinfo.winsize.ws_col; + if (signalled || zterm_columns <= 0) + zterm_columns = shttyinfo.winsize.ws_col; else - shttyinfo.winsize.ws_col = columns; + shttyinfo.winsize.ws_col = zterm_columns; #endif /* TIOCGWINSZ */ - if (columns <= 0) { + if (zterm_columns <= 0) { DPUTS(signalled, "BUG: Impossible TIOCGWINSZ cols"); - columns = tccolumns > 0 ? tccolumns : 80; + zterm_columns = tccolumns > 0 ? tccolumns : 80; } - if (columns > 2) + if (zterm_columns > 2) termflags &= ~TERM_NARROW; else termflags |= TERM_NARROW; - return (columns != oldcolumns); + return (zterm_columns != oldcolumns); } /* check the size of the window and adjust if necessary. * @@ -1634,8 +1635,8 @@ adjustwinsize(int from) ttycols = shttyinfo.winsize.ws_col; } else { /* Set to value from environment on failure */ - shttyinfo.winsize.ws_row = lines; - shttyinfo.winsize.ws_col = columns; + shttyinfo.winsize.ws_row = zterm_lines; + shttyinfo.winsize.ws_col = zterm_columns; resetzle = (from == 1); } #else @@ -1655,9 +1656,9 @@ adjustwinsize(int from) * but I'm concerned about what happens on race conditions; e.g., * * suppose the user resizes his xterm during `eval $(resize)'? */ if (adjustlines(from) && zgetenv("LINES")) - setiparam("LINES", lines); + setiparam("LINES", zterm_lines); if (adjustcolumns(from) && zgetenv("COLUMNS")) - setiparam("COLUMNS", columns); + setiparam("COLUMNS", zterm_columns); getwinsz = 1; break; case 2: -- cgit v1.2.3