This handles also newrole in the SELinux completion function. There are also a couple of other minor fixes. Module package files can be .cil instead of .pp files. There was one case where I must have used grep -L instead of -l when identifying commands for which an option applied because the case pattern was inverted. And for runcon, some detritus remained from copy/pasting the help output. Oliver diff --git a/Completion/Linux/Command/_selinux b/Completion/Linux/Command/_selinux index e7d4d3b2e..a7ba68952 100644 --- a/Completion/Linux/Command/_selinux +++ b/Completion/Linux/Command/_selinux @@ -1,4 +1,4 @@ -#compdef audit2allow audit2why avcstat chcon checkmodule checkpolicy fixfiles getpidprevcon getsebool matchpathcon restorecon runcon sealert secon sedta seinfo selinuxconlist selinuxdefcon selinuxexeccon semanage semodule semodule_unpackage sepolgen sepolicy sesearch sestatus setenforce setsebool validatetrans +#compdef audit2allow audit2why avcstat chcon checkmodule checkpolicy fixfiles getpidprevcon getsebool matchpathcon newrole restorecon runcon sealert secon sedta seinfo selinuxconlist selinuxdefcon selinuxexeccon semanage semodule semodule_unpackage sepolgen sepolicy sesearch sestatus setenforce setsebool validatetrans # encompasses checkpolicy libselinux-utils policycoreutils # policycoreutils-devel policycoreutils-python-utils setools-console @@ -251,6 +251,21 @@ case $service in ) ;; + newrole) + local cmd cpp + cmd="$words[1]" + cpp='_comp_priv_prefix=( $cmd ${(kv)opt_args[(I)-([rtl]|-role|-type|-level)]} )' + args=( + '(-r --role)'{-r+,--role=}'[specify role]: :_selinux_roles' + '(-t --type)'{-t+,--type=}'[specify type]: :_selinux_types' + '(-l --level)'{-l+,--range=}'[specify level]:level' + '(-p --preserve-environment)'{-p,--preserve-environment}"[don't create new minimal environment]" + "${ign}(-)"{-V,--version}'[display version information]' + "(-)1: :{ $cpp; _command_names -e }" \ + "*:: :{ $cpp; _normal }" + ) + ;; + restorecon) args=( '*-e+[exclude a directory]:directory:_directories' @@ -276,10 +291,10 @@ case $service in runcon) args=( '(1 -c --compute)'{-c,--compute}'[compute process transition context before modifying]' - '(1 -t --type=TYPE)'{-t+,--type=}'[specify type]: :_selinux_types' - '(1 -u --user=USER)'{-u+,--user=}'[specify user identity]: :_selinux_users' - '(1 -r --role=ROLE)'{-r+,--role=}'[specify role]: :_selinux_roles' - '(1 -l --range=RANGE)'{-l+,--range=}'[specify level range]:range' + '(1 -t --type)'{-t+,--type=}'[specify type]: :_selinux_types' + '(1 -u --user)'{-u+,--user=}'[specify user identity]: :_selinux_users' + '(1 -r --role)'{-r+,--role=}'[specify role]: :_selinux_roles' + '(1 -l --range)'{-l+,--range=}'[specify level range]:range' '(-)1:security context:_selinux_contexts' '*:::args:_normal' ) @@ -460,7 +475,7 @@ case $service in '(-E --extract)'{-E,--extract}'[extract customizable commands, for use within a transaction]' ) ;| - boolean|dontaudit|export|import) + fcontext|ibendport|ibpkey|interface|login|module|node|permissive|port|user) args+=( '(-a --add)'{-a,--add}'[add a record]' ) ;| boolean|fcontext|ibendport|ibpkey|interface|login|node|permissive|port|user) @@ -573,8 +588,8 @@ case $service in \*{-B,--build}'[build and reload policy]' \*'--refresh[like --build but reuse existing linked policy if module files unchanged]' \*{-D,--disable_dontaudit}'[remove dontaudits from policy]' - \*{-i+,--install=}'[install a new module]:module package:_files -g "*.pp(-.)"' - \!{-b,--base,-u,--upgrade}':module package:_files -g "*.pp(-.)"' + \*{-i+,--install=}'[install a new module]:module package:_files -g "*.(pp|cil)(-.)"' + \!{-b,--base,-u,--upgrade}':module package:_files -g "*.(pp|cil)(-.)"' \*{-r+,--remove=}'[remove existing module at desired priority]:module name:_selinux_modules' \*{-l+,--list-modules=-}'[display list of installed modules]::kind:(( standard\:highest\ priority,\ enabled\ modules
When listing available keywords, a trailing colon is included which is unwanted when passing a particular keyword to ansible-doc. This stips the trailing colon. Also, --step is valid for ansible-playbook and had got left out. Oliver diff --git a/Completion/Unix/Command/_ansible b/Completion/Unix/Command/_ansible index bf31819ad..e0d9fb9b6 100644 --- a/Completion/Unix/Command/_ansible +++ b/Completion/Unix/Command/_ansible @@ -69,6 +69,11 @@ case $service in "--skip-tags[only run plays and tasks whose tags don't match]" ) ;| + ansible-playbook|ansible-console) + args+=( + '--step[one-step-at-a-time: confirm each task before running]' + ) + ;| ansible|ansible-console) args+=( '--task-timeout[set the task timeout limit]:timeout (seconds)' @@ -97,11 +102,6 @@ case $service in '*::args:->config' ) ;; - ansible-console) - args+=( - '--step[one-step-at-a-time: confirm each task before running]' - ) - ;; ansible-doc) args+=( '!--metadata-dump' '!--no-fail-on-errors' # "internal use only" @@ -440,11 +440,11 @@ if [[ $state = plugins ]]; then typeset -ga ${plug} if zstyle -T ":completion:${curcontext}:plugins" verbose; then (( ${(P)#plugvar} )) || set -A ${plugvar} \ - ${${(f)"$(_call_program plugins ansible-doc -t $plug -l)"}/ ##/:} + ${${${(f)"$(_call_program plugins ansible-doc -t $plug -l)"}:# *}/(:|) ##/:} _describe -t plugins "${plug} plugin" $plugvar -M 'r:|.=* r:|=*' && ret=0 else (( ${(P)#plugvar} )) || set -A ${plugvar} \ - ${${(f)"$(_call_program plugins ansible-doc -t $plug -F)"}%% *} + ${${(f)"$(_call_program plugins ansible-doc -t $plug -F)"}%%(|:) *} _wanted plugins expl "${plug} plugin" compadd -M 'r:|.=* r:|=*' -a $plugvar && ret=0 fi fi
For example, a file called _foo;bar will cause this to happen: % hello [press tab]zsh: command not found: _foo zsh: command not found: bar I'll admit I'm not sure if adding the -r for compassocs at the end is correct, the array is empty for me and I don't know what it's for. --- Completion/compdump | 6 +++--- Completion/compinit | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Completion/compdump b/Completion/compdump index 6daf92f9ff..5af5174f12 100644 --- a/Completion/compdump +++ b/Completion/compdump @@ -113,7 +113,7 @@ integer _i=5 print -n autoload -Uz >& $_d_fd while (( $#_d_als )); do if (( ! $+_compautos[$_d_als[1]] )); then - print -n " $_d_als[1]" + print -rn " ${(q-)_d_als[1]}" if (( ! --_i && $#_d_als > 1 )); then _i=5 print -n ' \\\n ' @@ -126,13 +126,13 @@ print >& $_d_fd local _c for _c in "${(ok@)_compautos}"; do - print "autoload -Uz $_compautos[$_c] $_c" >& $_d_fd + print -r "autoload -Uz ${(q-)_compautos[$_c]} $_c" >& $_d_fd done print >& $_d_fd print "typeset -gUa _comp_assocs" >& $_d_fd -print "_comp_assocs=( ${(qq)_comp_assocs} )" >& $_d_fd +print -r "_comp_assocs=( ${(qq)_comp_assocs} )" >& $_d_fd exec {_d_fd}>&- mv -f $_d_file ${_d_file%.$HOST.$$} diff --git a/Completion/compinit b/Completion/compinit index 5cb527fac8..51e9d88b83 100644 --- a/Completion/compinit +++ b/Completion/compinit @@ -301,7 +301,7 @@ compdef() { if [[ -z "$eval" ]] && [[ "$1" = *\=* ]]; then while (( $# )); do if [[ "$1" = *\=* ]]; then - cmd="${1%%\=*}" + cmd="${(q)${1%%\=*}}" svc="${1#*\=}" func="$_comps[${_services[(r)$svc]:-$svc}]" [[ -n ${_services[$svc]} ]] && @@ -412,7 +412,7 @@ compdef() { svc= fi if [[ -z "$new" || -z "${_comps[$1]}" ]]; then - _comps[$cmd]="$func" + _comps[$cmd]="${(q)func}" [[ -n "$svc" ]] && _services[$cmd]="${1#*\=}" fi ;; -- 2.38.1
We've received a patch over on the sf.net bug tracker. diff here https://sourceforge.net/u/sring/zsh/ci/2c5d40d6c5404b94538bc0ad8168e571631c61e7/tree/Guide/zshguide/c4.yo?diff=22eb1e2187374f62fd8d535e5219a4b3527b345f [I'd paste it but webmail]. Daniel Stefan Ring wrote on Fri, 15 Mar 2024 22:54 +00:00: > Merge request: Tiny typos in guide > > > --- > > Stefan Ring has requested to merge changes from > `ssh://@git.code.sf.net/u/sring/zsh` at commit `[2c5d40]` into the > branch `master` > > > > > --- > > Sent from sourceforge.net because you indicated interest in > <https://sourceforge.net/p/zsh/web/merge-requests/1/>
Add zmemcpyz(), a memcpy() that nul-terminates the destination string. This is meant to be used when we have the strlen() of the string. We should prefer memcpy() when we know the length because it most libc implementations provide an assembly implementation of memcpy but maybe not strcpy(). Even if it is implemented in assembly, memcpy() is likely to be faster than strcpy() since as the loop condition strcpy() needs to check for zeros in SRC, whereas memcpy() can just decrement the size. --- Src/string.c | 56 +++++++++++++++++++++++++++++----------------------- Src/zsh.h | 10 ++++++++++ 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/Src/string.c b/Src/string.c index 5f439926e..12da19f72 100644 --- a/Src/string.c +++ b/Src/string.c @@ -33,11 +33,13 @@ mod_export char * dupstring(const char *s) { char *t; + size_t l; if (!s) return NULL; - t = (char *) zhalloc(strlen((char *)s) + 1); - strcpy(t, s); + l = strlen((char *)s); + t = (char *) zhalloc(l + 1); + zmemcpyz(t, s, l); return t; } @@ -68,7 +70,7 @@ dupstring_glen(const char *s, unsigned *len_ret) if (!s) return NULL; t = (char *) zhalloc((*len_ret = strlen((char *)s)) + 1); - strcpy(t, s); + zmemcpyz(t, s, *len_ret); return t; } @@ -77,11 +79,13 @@ mod_export char * ztrdup(const char *s) { char *t; + size_t l; if (!s) return NULL; - t = (char *)zalloc(strlen((char *)s) + 1); - strcpy(t, s); + l = strlen((char *)s); + t = (char *)zalloc(l + 1); + zmemcpyz(t, s, l); return t; } @@ -116,11 +120,12 @@ tricat(char const *s1, char const *s2, char const *s3) char *ptr; size_t l1 = strlen(s1); size_t l2 = strlen(s2); + size_t l3 = strlen(s3); - ptr = (char *)zalloc(l1 + l2 + strlen(s3) + 1); - strcpy(ptr, s1); - strcpy(ptr + l1, s2); - strcpy(ptr + l1 + l2, s3); + ptr = (char *)zalloc(l1 + l2 + l3 + 1); + memcpy(ptr, s1, l1); + memcpy(ptr + l1, s2, l2); + zmemcpyz(ptr + l1 + l2, s3, l3); return ptr; } @@ -131,11 +136,12 @@ zhtricat(char const *s1, char const *s2, char const *s3) char *ptr; size_t l1 = strlen(s1); size_t l2 = strlen(s2); + size_t l3 = strlen(s3); ptr = (char *)zhalloc(l1 + l2 + strlen(s3) + 1); - strcpy(ptr, s1); - strcpy(ptr + l1, s2); - strcpy(ptr + l1 + l2, s3); + memcpy(ptr, s1, l1); + memcpy(ptr + l1, s2, l2); + zmemcpyz(ptr + l1 + l2, s3, l3); return ptr; } @@ -148,10 +154,11 @@ dyncat(const char *s1, const char *s2) /* This version always uses space from the current heap. */ char *ptr; size_t l1 = strlen(s1); + size_t l2 = strlen(s2); - ptr = (char *)zhalloc(l1 + strlen(s2) + 1); - strcpy(ptr, s1); - strcpy(ptr + l1, s2); + ptr = (char *)zhalloc(l1 + l2 + 1); + memcpy(ptr, s1, l1); + zmemcpyz(ptr + l1, s2, l2); return ptr; } @@ -162,10 +169,11 @@ bicat(const char *s1, const char *s2) /* This version always uses permanently-allocated space. */ char *ptr; size_t l1 = strlen(s1); + size_t l2 = strlen(s2); - ptr = (char *)zalloc(l1 + strlen(s2) + 1); - strcpy(ptr, s1); - strcpy(ptr + l1, s2); + ptr = (char *)zalloc(l1 + l2 + 1); + memcpy(ptr, s1, l1); + zmemcpyz(ptr + l1, s2, l2); return ptr; } @@ -177,9 +185,7 @@ dupstrpfx(const char *s, int len) { char *r = zhalloc(len + 1); - memcpy(r, s, len); - r[len] = '\0'; - return r; + return zmemcpyz(r, s, len); } /**/ @@ -189,9 +195,7 @@ ztrduppfx(const char *s, int len) /* This version always uses permanently-allocated space. */ char *r = zalloc(len + 1); - memcpy(r, s, len); - r[len] = '\0'; - return r; + return zmemcpyz(r, s, len); } /* Append a string to an allocated string, reallocating to make room. */ @@ -200,7 +204,9 @@ ztrduppfx(const char *s, int len) mod_export char * appstr(char *base, char const *append) { - return strcat(realloc(base, strlen(base) + strlen(append) + 1), append); + size_t bl = strlen(base); + size_t al = strlen(append); + return zmemcpyz((char *)realloc(base, bl + al + 1) + bl, append, al); } /* Return a pointer to the last character of a string, diff --git a/Src/zsh.h b/Src/zsh.h index fae62b8d0..b10705356 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -3367,3 +3367,13 @@ typedef int convchar_t; #define ZWS(s) s #endif /* MULTIBYTE_SUPPORT */ + +#include <stddef.h> +#include <string.h> + +/* memcpy that nul-terminates DST. SRC need not be nul-terminated. */ +static inline char *zmemcpyz(char *dst, const char *src, size_t n) +{ + *((char *)memcpy(dst, src, n) + n) = '\0'; + return dst; +} -- 2.44.0
On Fri, Mar 15, 2024 at 5:53 AM Vincent Lefevre <vincent@vinc17.net> wrote: > > On 2024-03-13 22:13:09 -0700, Bart Schaefer wrote: > > Doing a full syntax analysis here would make it a lot more complicated > > and a lot slower. > > I don't think you need to do a full syntax analysis. Isn't this just > related to tokenization (something like that)? Tokenization is performed by lexical analysis. > Note that spelling correction, which occurs *before* the line is put > in the history, detects quoted text and won't try to correct it. Spelling correction is actually performed by the lexer, at the same time as alias expansion. > it seems that "quoted status" can be taken into account at that point. Not without separately storing both the original and lexed state of the text. Which is in fact done internally, but for hopefully obvious reasons is not done in the history file, which (during reading/writing) is where most duplicate elimination has to occur.
On Fri, Mar 15, 2024 at 5:47 AM Vincent Lefevre <vincent@vinc17.net> wrote:
>
> On 2024-03-13 21:52:44 -0700, Bart Schaefer wrote:
> > On Wed, Mar 13, 2024 at 8:05 AM Vincent Lefevre <vincent@vinc17.net> wrote:
> > > IMHO, HISTFILE should just be unset by default; but if the user sets
> > > this parameter, I suppose that the goal is to save the history.
> >
> > The goal might be to read the history, not to write it.
>
> To read the history? The zshparam(1) man page just says "to save":
>
> HISTFILE
> The file to save the history in when an interactive shell exits.
See also the part about "when exits" which is clearly also incorrect.
This entry is outdated. The shell also initializes the history from
this file at startup.
I was differentiating
zsh -f
% setopt RCS
from
zsh
% setopt no_RCS
In the former case, the history is not read, but it is written. In
the latter case it is read, but not written. The point being that
merely setting HISTFILE does not imply that the goal is to save to it.
Further, setting SAVEHIST=0 will truncate the file in the former case
and leave it alone in the latter case. There's no single setting that
covers all cases, which is part of the reason we've so far had trouble
agreeing on default behavior.
If anyone wants to have a go at cleaning up all these documentation
inaccuracies, please do.
On 2024-03-13 22:13:09 -0700, Bart Schaefer wrote: > On Wed, Mar 13, 2024 at 5:38 AM Vincent Lefevre <vincent@vinc17.net> wrote: > > > > With zsh 5.9, HIST_IGNORE_DUPS is buggy: it also ignores command lines > > that differ by a space between (single or double) quotes. > > With zsh back to at least April 1, 2000 and probably sooner. > Searching history with the ZLE widgets works the same way. > > Doing a full syntax analysis here would make it a lot more complicated > and a lot slower. I don't think you need to do a full syntax analysis. Isn't this just related to tokenization (something like that)? Note that spelling correction, which occurs *before* the line is put in the history, detects quoted text and won't try to correct it. So it seems that "quoted status" can be taken into account at that point. -- Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
On 2024-03-13 21:52:44 -0700, Bart Schaefer wrote: > On Wed, Mar 13, 2024 at 8:05 AM Vincent Lefevre <vincent@vinc17.net> wrote: > > IMHO, HISTFILE should just be unset by default; but if the user sets > > this parameter, I suppose that the goal is to save the history. > > The goal might be to read the history, not to write it. To read the history? The zshparam(1) man page just says "to save": HISTFILE The file to save the history in when an interactive shell exits. If unset, the history is not saved. And when I do cventin:~> zsh -f cventin% HISTFILE=~/.histfile I just get the "HISTFILE=~/.histfile" in the history, while ~/.histfile already contains various commands. > > Without INC_APPEND_HISTORY, the man page doesn't document when > > precisely the history is saved. For instance, what happens if one > > has a "print -s ..." in the .zlogout file? > > It'd expect it to be lost, because the history is saved before > .zlogout is read. Try it and let us know. Maybe it dumps core. It is added to the history, but not saved. With ls -l .histfile sleep 1 print -s foo1 print -s foo2 print -s foo3 history ls -l .histfile in my .zlogout file, I get -rw------- 1 vlefevre vlefevre 292 2024-03-15 13:17:11 .histfile [...] 27 foo1 28 foo2 29 foo3 -rw------- 1 vlefevre vlefevre 292 2024-03-15 13:17:11 .histfile and indeed, .histfile does not contain these lines. > > Moreover, with INC_APPEND_HISTORY, "print -s" does not put the entry > > in the history file immediately, only after the next accept-line. > > "print -s" doesn't write to the HISTFILE and isn't documented that > way. It explicitly says "Place the results in the history list". The > "history list" is the internal shell history, not the file. The file > is updated from the internal list either at shell exit or > (incappendhistory) when a line is entered (i.e., conceptually upon > accept-line, though in practice upon entering a complete command since > updating at PS2 would leave an incomplete entry). The documentation is not explicit. > You can use the zshaddhistory hook to confirm this. The documentation of the zshaddhistory hook is not clear. It says Executed when a history line has been read interactively, But this is the case for any (possibly empty!) command line, not just lines read from the history. Then but before it is executed. This is wrong. Empty command lines (which will not be executed) are also handled by the zshaddhistory hook (contrary to the preexec hook). And as a consequence, its example zshaddhistory() { print -sr -- ${1%%$'\n'} fc -p .zsh_local_history } has the effect to put empty command lines in the history, which is not the usual behavior. Moreover, the "fc -p .zsh_local_history" does not seem to work: no .zsh_local_history file is created. -- Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
On 2024-03-13 20:46:40 -0700, Bart Schaefer wrote: > On Wed, Mar 13, 2024 at 9:17 AM Vincent Lefevre <vincent@vinc17.net> wrote: > > Spelling correction is not done on any of the subsequent words > > of the full command line. [...] > > It also says "A simple command may be preceded ..." which is equally > inaccurate in this case, but there are a lot of bits of the doc that > colloquially assume that one interactive command line is the same as > one "simple command". No, this is really before a "simple command". For intance, "nocorrect" is not valid before "for", "if", "!" or "{": cventin% nocorrect for i in a b ; do echo $i ; done zsh: parse error near `for' Or is this a bug? (I do not see a reason to forbid it this case, and IMHO, "nocorrect" should be allowed as the first word of a complex command, the semantics being: just ignore "nocorrect", i.e. it is only used to enable spelling correction.) -- Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
I don't know if that could be done and it's probably too late anyway, but I thought I might throw in the idea anyway. What about, instead of adding ksh93's ${ cmd;} and mksh's ${|cmd} (in slightly diverging ways), we added just a | expansion flag whereby: ${(||)any zsh code} would expand to the output of the code without the fork and without the newline trimming. ${(|var|)any zsh code} would expand to the value of var as set by the zsh code Some advantages: - the flags can be cumulated as usual. So you can have ${(||.s[:])getconf PATH} to split the output of getconf PATH ("." to trim one newline, ".." to trim all) for example. - there's no extra rule as to how the expansion works and how it can be combined with others as it's the same syntax as other parameter expansions - as it's different syntax, it removes the potential surprises when ${ cmd;}, ${|cmd} behave differently than in ksh93/mksh/bash ============= Or (as a completely different idea), an alternative to mksh's ${|cmd} and ${|var|cmd} could be written ${REPLY<cmd} ${var<cmd}. That could be added as well as ${|cmd} if we wanted to add ${|cmd} for compatibility with mksh/bash. Or we could add neither of ${ cmd;} and ${|cmd} and have ${REPLY<cmd} as the (non-splitting, non-trimming) equivalent of ${|cmd} and ${<cmd} as the (non-splitting, non-trimming) equivalent of ${ cmd;} (though the latter would prevent adding ${ cmd; } in the future). And still allow flags there as in ${(.s[:])<getconf PATH} -- Stephane -
[-- Attachment #1: Type: text/plain, Size: 201 bytes --] Following on the discussion with Oliver. This still uses the ${|var|...} alternate syntax, I haven't yet looked closely enough at ${{var}...} as an alternative so that will have to follow separately. [-- Attachment #2: nofork-onenewline.txt --] [-- Type: text/plain, Size: 5817 bytes --] diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index 183ca6e03..0e121e784 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -1950,6 +1950,9 @@ the braces by whitespace, like `tt(${ )...tt( })', is replaced by its standard output. Like `tt(${|)...tt(})' and unlike `tt($LPAR())...tt(RPAR())', the command executes in the current shell context with function local behaviors and does not create a subshell. +Word splitting does not apply unless tt(SH_WORD_SPLIT) is set, but a +single trailing newline is stripped unless the substitution is enclosed +in double quotes. Note that because the `tt(${|)...tt(})' and `tt(${ )...tt( })' forms must be parsed at once as both string tokens and commands, all other diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo index 4a86050e6..4d71c8f30 100644 --- a/Etc/FAQ.yo +++ b/Etc/FAQ.yo @@ -1091,20 +1091,23 @@ sect(Comparisons of forking and non-forking command substitution) mytt(set -- pos1 pos2 etc). Nothing that happens within mytt($(command)) affects the caller. - mytt($(command)) removes trailing newlines from the output of mytt(command) - when substituting, whereas mytt(${ command }) and its variants do not. - The latter is consistent with mytt(${|...}) from mksh but differs from - bash and ksh, so in emulation modes, newlines are stripped from command - output (not from tt(REPLY) assignments). - When not enclosed in double quotes, the expansion of mytt($(command)) is split on tt(IFS) into an array of words. In contrast, and unlike both bash and ksh, unquoted non-forking substitutions behave like parameter expansions with respect to the tt(SH_WORD_SPLIT) option. - When mytt(command) is myem(not) a builtin, mytt(${ command }) does fork, and - typically forks the same number of times as mytt($(command)), because in - the latter case zsh usually optimizes the final fork into an exec. + Both of the mytt(${|...}) formats retain any trailing newlines, + except as handled by the tt(SH_WORD_SPLIT) option, consistent with + mytt(${|...}) from mksh. mytt(${ command }) removes a single final + newline, but mytt("${ command }") retains it. This differs from + bash and ksh, so in emulation modes, newlines are stripped even from + quoted command output. In all cases, mytt($(command)) removes all + trailing newlines from the output of mytt(command). + + When mytt(command) is myem(not) a builtin, mytt(${ command }) does + fork, and typically forks the same number of times as + mytt($(command)), because in the latter case zsh usually optimizes + the final fork into an exec. Redirecting input from files has subtle differences: itemization( diff --git a/Src/subst.c b/Src/subst.c index 49f7336bb..9d20a2d0e 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -1900,6 +1900,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, /* The command string to be run by ${|...;} */ char *cmdarg = NULL; size_t slen = 0; + int trim = (!EMULATION(EMULATE_ZSH)) ? 2 : !qt; inbrace = 1; s++; @@ -2005,10 +2006,13 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, int onoerrs = noerrs, rplylen; noerrs = 2; rplylen = zstuff(&cmdarg, rplytmp); - if (! EMULATION(EMULATE_ZSH)) { + if (trim) { /* bash and ksh strip trailing newlines here */ - while (rplylen > 0 && cmdarg[rplylen-1] == '\n') + while (rplylen > 0 && cmdarg[rplylen-1] == '\n') { rplylen--; + if (trim == 1) + break; + } cmdarg[rplylen] = 0; } noerrs = onoerrs; diff --git a/Test/D10nofork.ztst b/Test/D10nofork.ztst index d6a5588df..fc6b84613 100644 --- a/Test/D10nofork.ztst +++ b/Test/D10nofork.ztst @@ -86,9 +86,39 @@ F:setting option inside is too late for that substitution ?(eval):8: no matches found: f?* purr ${| REPLY=$'trailing newlines remain\n\n' } -0:newline removal should not occur +0:newline removal should not occur, part 1 >trailing newlines remain > +> + + purr ${ echo $'one trailing newline\nremoved\n\n\n' } +0:newline removal in ${ ... }, zsh mode +>one trailing newline +>removed +> +> +> + + () { + emulate -L ksh + purl ${ echo $'all trailing newlines\nremoved\n\n\n' } + purr "${ echo $'all trailing newlines\nremoved\n\n\n' }" + } +0:newline removal in ${ ... }, emulation mode, shwordsplit +>all +>trailing +>newlines +>removed +>all trailing newlines +>removed + + purr "${ echo $'no trailing newlines\nremoved\n\n\n' }" +0:newline removal should not occur, part 2 +>no trailing newlines +>removed +> +> +> > () { @@ -159,7 +189,7 @@ F:Why not use this error in the previous case as well? 1:unbalanced braces, part 4+ ?(eval):1: closing brace expected - purr ${ purr STDOUT } + purr "${ purr STDOUT }" 0:capture stdout >STDOUT > @@ -322,7 +352,7 @@ F:Fiddly here to get EOF past the test syntax 0:here-string behavior >in a here string - <<<${ purr $'stdout as a here string' } + <<<"${ purr $'stdout as a here string' }" 0:another capture stdout >stdout as a here string > @@ -331,7 +361,7 @@ F:Fiddly here to get EOF past the test syntax wrap=${ purr "capture in environment assignment" } typeset -p wrap 0:assignment context >typeset -g wrap='REPLY in environment assignment' ->typeset -g wrap=$'capture in environment assignment\n' +>typeset -g wrap='capture in environment assignment' # Repeat return and exit tests with stdout capture @@ -410,7 +440,7 @@ F:must do this before evaluating the next test block 0:ignored braces, part 1 >buried} - purr ${ purr ${REPLY:-buried}}} + purr "${ purr ${REPLY:-buried}}}" 0:ignored braces, part 2 >buried >} @@ -418,7 +448,6 @@ F:must do this before evaluating the next test block purr ${ { echo nested ;} } 0:ignored braces, part 3 >nested -> purr ${ { echo nested } } DONE 1:ignored braces, part 4
[-- Attachment #1: Type: text/plain, Size: 1751 bytes --] Oliver Kiddle <opk@zsh.org> on Thu, 2024/03/14 22:01: > Christian Hesse wrote: > > While zsh git master does support pcre2 already, this has not made it > > into a release and the current one still depends on the old library. > > Support is spread over several commits, which depend on even more > > commits. Thus cherry-picking is not that easy. > > If you cherry-pick 1b421e49 first then b62e9113 will also apply ... and 10bdbd8b5b0b43445aff23dcd412f25cf6aa328a - the module is not build without. Issue without is that Src/Modules/pcre.mdd still referenced pcre-config (and not pcre2-config). > without conflicts other than on ChangeLog. You shouldn't need any of > the subsequent patches related to PCRE. At least none of them are a > regression with respect to 5.9 - nor are any fixing bugs introduced with > the two cherry-picked patches. You don't necessarily need the first of > those two patches other than to make the second apply cleanly but it > doesn't do any harm. And you are right... Package built and it works. Ignoring Changelog in cherry-pick is pretty easy, just did that in every step before continue: git checkout tags/zsh-5.9 -- ChangeLog > > So wondering... It there any eta for a new release? Would be nice to have > > one any time soon... :) > > Not being the release manager, I can't answer this part with any > authority. Some of the newer developments are still in a state of > flux. Problem solved, so take your time. ;) Thanks a lot! -- main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];) putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);} [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 488 bytes --]
Bart Schaefer wrote: > like ${|REPLY=...} when of course piping to "read" etc. are also valid > ways to assign to REPLY. How often would there be a command name with > no arguments in that position? Probably not all that often. > I hesitate in suggesting this, but ... is there any existing case in > which "${{" is valid? If not, I think I can change ${|var|...} to be > ${{var}...} without too much violence (except to the doc, bleah). Inner `$' in nested parameter expansions are fairly superfluous in general. ${|var|...} is closer to the REPLY default with ${|...} but other than that, I marginally prefer ${{var}...} Certainly if it does involve much violence, what we currently have is working. > > That might look like a default value assignment to someone > > Would ${{=var}...} look better? The doubled braces do give me pause. Not as good as ${={var}...} but probably better. > This is the code diff to make emulation trim all, ${ ... } trim one, > "${ ... }" trim none ... not re-doing the doc diff yet. Looks good to me. Oliver
Christian Hesse wrote: > While zsh git master does support pcre2 already, this has not made it into a > release and the current one still depends on the old library. Support is > spread over several commits, which depend on even more commits. Thus > cherry-picking is not that easy. If you cherry-pick 1b421e49 first then b62e9113 will also apply without conflicts other than on ChangeLog. You shouldn't need any of the subsequent patches related to PCRE. At least none of them are a regression with respect to 5.9 - nor are any fixing bugs introduced with the two cherry-picked patches. You don't necessarily need the first of those two patches other than to make the second apply cleanly but it doesn't do any harm. > So wondering... It there any eta for a new release? Would be nice to have one > any time soon... :) Not being the release manager, I can't answer this part with any authority. Some of the newer developments are still in a state of flux. Oliver
On Wed, Mar 13, 2024 at 5:38 AM Vincent Lefevre <vincent@vinc17.net> wrote:
>
> With zsh 5.9, HIST_IGNORE_DUPS is buggy: it also ignores command lines
> that differ by a space between (single or double) quotes.
With zsh back to at least April 1, 2000 and probably sooner.
Searching history with the ZLE widgets works the same way.
Doing a full syntax analysis here would make it a lot more complicated
and a lot slower.
On Wed, Mar 13, 2024 at 8:05 AM Vincent Lefevre <vincent@vinc17.net> wrote: > > With zsh 5.9: > > cventin:~> zsh -f [set up history parameters and options] > cventin% exit > cventin:~> ls ~/.histfile > ls: cannot access '/home/vlefevre/.histfile': No such file or directory > > However, if I use INC_APPEND_HISTORY instead of APPEND_HISTORY, the > history is saved. This is because history is being incrementally saved (as the option name indicates) rather than being held only in memory until the shell is preparing to exit. APPEND_HISTORY just means that if the history is saved, it will be added to the history file (up to $SAVEHIST) instead of overwriting it. > According to the zsh(1) man page: > > Note also that the RCS option affects the saving of history files, > i.e. if RCS is unset when the shell exits, no history file will be > saved. > > But the difference between INC_APPEND_HISTORY and APPEND_HISTORY is > not documented concerning this point. Congratulations, you've found another place where documentation of feature X was not updated upon the introduction of newer feature Y. The doc for history is littered with these because it's been around longer than just about anything: HISTFILE is still documented as only being used at shell exit. Someone else can patch it this time. > Also, I do not see the point of not saving the history when RCS is set. It is saving when RCS is set, and not when RCS is not set (no_RCs). This is done because of the handling of $SAVEHIST, not to mention the various duplicate handling options. When no_RCs, the history has (presumably) not been read in at startup in the first place, so it won't have been merged with the interactive state. If written out when never read in, the $SAVEHIST size limit could cause contents to be lost that otherwise would not be. (Frobbing the RCs option during later shell operation is effectively undefined behavior, too difficult to keep track of.) > IMHO, HISTFILE should just be unset by default; but if the user sets > this parameter, I suppose that the goal is to save the history. The goal might be to read the history, not to write it. In any case we've had several go-rounds on this (and on the "right way" to set HISTSIZE vs. SAVEHIST) without coming to any consensus differing from the existing behavior. > Without INC_APPEND_HISTORY, the man page doesn't document when > precisely the history is saved. For instance, what happens if one > has a "print -s ..." in the .zlogout file? It'd expect it to be lost, because the history is saved before .zlogout is read. Try it and let us know. Maybe it dumps core. > Moreover, with INC_APPEND_HISTORY, "print -s" does not put the entry > in the history file immediately, only after the next accept-line. "print -s" doesn't write to the HISTFILE and isn't documented that way. It explicitly says "Place the results in the history list". The "history list" is the internal shell history, not the file. The file is updated from the internal list either at shell exit or (incappendhistory) when a line is entered (i.e., conceptually upon accept-line, though in practice upon entering a complete command since updating at PS2 would leave an incomplete entry). You can use the zshaddhistory hook to confirm this.
On Wed, Mar 13, 2024 at 9:17 AM Vincent Lefevre <vincent@vinc17.net> wrote: > > "nocorrect" is documented under "PRECOMMAND MODIFIERS". So it is > surprising that it can affect more than the corresponding command. It's documented there because there was no better place to put it, I vaguely recall. > Is this the expected behavior? It's the implemented behavior, at least. This is an effect of it being handled with a flag in the global parser state, which does not reset at subshell or command boundaries. This is hinted at by "with the exception of nocorrect which is a reserved word ... interpreted immediately, before any parsing". Conversely, as I think was discussed not that long ago, spelling correction is applied during parsing as soon as each full word is seen, just like alias expansion. > Spelling correction is not done on any of the subsequent words > of the full command line. [...] It also says "A simple command may be preceded ..." which is equally inaccurate in this case, but there are a lot of bits of the doc that colloquially assume that one interactive command line is the same as one "simple command". diff --git a/Doc/Zsh/grammar.yo b/Doc/Zsh/grammar.yo index 915b93bc0..b80f9750c 100644 --- a/Doc/Zsh/grammar.yo +++ b/Doc/Zsh/grammar.yo @@ -100,14 +100,15 @@ More generally, a list can be seen as a set of any shell commands whatsoever, including the complex commands below; this is implied wherever the word `list' appears in later descriptions. For example, the commands in a shell function form a special sort of list. + texinode(Precommand Modifiers)(Complex Commands)(Simple Commands & Pipelines)(Shell Grammar) sect(Precommand Modifiers) cindex(precommand modifiers) cindex(modifiers, precommand) -A simple command may be preceded by a em(precommand modifier), -which will alter how the command is interpreted. These modifiers are -shell builtin commands with the exception of tt(nocorrect) which is -a reserved word. +With the exception of tt(nocorrect), which is a reserved word that +affects further parsing when it is found in command position, each +of the following builtin commands is a em(precommand modifier) which +may precede a simple command to alter how that command is interpreted. startitem() findex(-)
[-- Attachment #1: Type: text/plain, Size: 2205 bytes --] On Tue, Mar 12, 2024 at 1:38 PM Bart Schaefer <schaefer@brasslantern.com> wrote: > > On Tue, Mar 12, 2024 at 1:26 PM Stephane Chazelas <stephane@chazelas.org> wrote: > > > > $ zsh -c 'a() { export a; a=3; typeset -p a; }; b() { local a=2; a; typeset -p a; }; a=1; b; typeset -p a' > > export -x a=3 > > typeset -x a=3 > > typeset a=1 > > > > That export -x seems bogus BTW as export doesn't accept the -x > > option. > > Indeed, that's a bug in the printparamnode() routine. That's not the only bug. As demonstrated by B02typeset.ztst in the test no array/hash in POSIX export/readonly -p with a declaration in a function of local -rx zsh_exported_readonly_scalar=1 the output of "export -p" is typeset -rx zsh_exported_readonly_scalar=1 However, "local" is supposed to supersede the GLOBAL_EXPORT option, so that should have output one of typeset +g -rx zsh_exported_readonly_scalar=1 or local -rx zsh_exported_readonly_scalar=1 The attached patch changes this (using "local"). The POSIX mode output -- export zsh_exported_readonly_scalar=1 -- is explained by a comment: * The zsh variants of export -p/readonly -p also report other * flags to indicate other attributes or scope. The POSIX variants * don't. There is also an AFAICT insurmountable problem: innie() { typeset -p $1 } outie() { local -x $1; innie $1 } outie var displays export var='' That is "correct" in that var is not local to outie, but that statement cannot be evaluated to restore the state of $var anywhere other than from functions called by innie. Conversely: innie() { print ${(tP)1} } outie var displays scalar-local-export Which is also "correct" but fibs about $var being local to innie. Finally we have innie() { typeset +m $1 } outie var which agrees with the (t) flag by reporting local exported var And innie() { typeset -m $1 } outie var yielding var='' No mention of export at all. These are all long-standing behaviors and haven't caused anyone a problem yet that I know of, so I'm not suggesting anything change, just pointing out that this patch doesn't address them. [-- Attachment #2: printparamflags.txt --] [-- Type: text/plain, Size: 2733 bytes --] diff --git a/Src/params.c b/Src/params.c index 973df3fe5..f65aa1e80 100644 --- a/Src/params.c +++ b/Src/params.c @@ -6044,6 +6044,7 @@ printparamnode(HashNode hn, int printflags) { Param p = (Param) hn; Param peer = NULL; + int altname = 0; if (!(p->node.flags & PM_HASHELEM) && !(printflags & PRINT_WITH_NAMESPACE) && *(p->node.nam) == '.') @@ -6089,16 +6090,26 @@ printparamnode(HashNode hn, int printflags) if (printflags & PRINT_POSIX_EXPORT) { if (!(p->node.flags & PM_EXPORTED)) return; + altname = 'x'; printf("export "); } else if (printflags & PRINT_POSIX_READONLY) { if (!(p->node.flags & PM_READONLY)) return; + altname = 'r'; printf("readonly "); - } else if (locallevel && p->level >= locallevel) { - printf("typeset "); /* printf("local "); */ } else if ((p->node.flags & PM_EXPORTED) && !(p->node.flags & (PM_ARRAY|PM_HASHED))) { - printf("export "); + if (p->level && p->level >= locallevel) + printf("local "); + else { + altname = 'x'; + printf("export "); + } + } else if (locallevel && p->level >= locallevel) { + if (p->node.flags & PM_EXPORTED) + printf("local "); + else + printf("typeset "); /* printf("local "); */ } else if (locallevel) { printf("typeset -g "); } else @@ -6112,6 +6123,10 @@ printparamnode(HashNode hn, int printflags) for (pmptr = pmtypes, i = 0; i < PMTYPES_SIZE; i++, pmptr++) { int doprint = 0; + + if (altname && altname == pmptr->typeflag) + continue; + if (pmptr->flags & PMTF_TEST_LEVEL) { if (p->level) { /* diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst index d90f17d13..914eea92b 100644 --- a/Test/B02typeset.ztst +++ b/Test/B02typeset.ztst @@ -311,7 +311,7 @@ print $OUTER 0:Export of tied parameters >i:n:n:e:r ->typeset -xT OUTER outer=( i n n e r ) +>local -xT OUTER outer=( i n n e r ) >typeset -aT OUTER outer=( i n n e r ) >OUTER=i:n:n:e:r >outer=( i n n e r ) @@ -1099,12 +1099,12 @@ } 0: no array/hash in POSIX export/readonly -p >zsh: ->typeset -arx zsh_exported_readonly_array=( 2 ) ->typeset -Arx zsh_exported_readonly_hash=( [3]=3 ) ->typeset -rx zsh_exported_readonly_scalar=1 ->typeset -arx zsh_exported_readonly_array=( 2 ) ->typeset -Arx zsh_exported_readonly_hash=( [3]=3 ) ->typeset -rx zsh_exported_readonly_scalar=1 +>local -arx zsh_exported_readonly_array=( 2 ) +>local -Arx zsh_exported_readonly_hash=( [3]=3 ) +>local -rx zsh_exported_readonly_scalar=1 +>local -arx zsh_exported_readonly_array=( 2 ) +>local -Arx zsh_exported_readonly_hash=( [3]=3 ) +>local -rx zsh_exported_readonly_scalar=1 >sh: >export zsh_exported_readonly_scalar=1 >readonly zsh_exported_readonly_scalar=1
[-- Attachment #1: Type: text/plain, Size: 807 bytes --] Dear zsh developers, I am writing in my role as Arch Linux downstream developer. We have started sorting pcre, replacing it with pcre2 [0]. While zsh git master does support pcre2 already, this has not made it into a release and the current one still depends on the old library. Support is spread over several commits, which depend on even more commits. Thus cherry-picking is not that easy. So wondering... It there any eta for a new release? Would be nice to have one any time soon... :) Thanks a lot! [0] https://archlinux.org/todo/move-to-pcre2/ -- main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];) putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);} [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 488 bytes --]
Bart Schaefer wrote: > On Tue, Mar 12, 2024 at 2:44 PM Clinton Bunch <cdb_zsh@zentaur.org> wrote: > > I propose that we update the development guide to remove the bit about the 1989 standard (much less K&R compatibility) since it is no longer true, and I personally question if it even makes sense as a goal 30+ years in to development. No objections from me. Replacement wording would be welcome. We're using string pasting (##) in quite a few places despite that being "not available". stdbool.h apparently already gets used in wcwidth9.h but --enable-unicode9 is also something whose time has passed and which should be removed. It may also be useful to consider things like whether stdbool.h should be included once from zsh_system.h > I think we pretty much agreed on that back in December (workers/51212 > anyone?) and just never edited that bit of the document. The sentiment there was similar but the legacy code removed at that point likely ceased to be relevant even before C99 was defined. I wouldn't draw too many conclusions from zsh failing to compile with c89. The errors mostly come from system header files. Often the standards options enforce a level of strictness that can be absent with default options. With the right vintage C compiler, you'll likely find that specifying the C99 standard also breaks the build, sometimes even with -std=gnu99. It was quite some time after 1999 before C99 became usable. C++ was higher priority for the compiler writers at that time. I think the K&R support continued to be relevant for long after the ANSI standard because some Unix vendors (HP?) included a basic K&R compiler with the OS but charged extra for the newer one. But I doubt anyone has needed ansi2knr in a long time. The attached patch strips out all the ansi2knr support. There's something for ._foo_ file extensions in Makemod.in.in that looks like someone's leftover debug from years back. Or does it have a strange purpose I couldn't fathom? It's possible that I've missed a use of the _(Args) macro buried somewhere in conditional code. We had logic in aclocal.m4 to select appropriate compiler options to select ansi form. Perhaps some of this is still actually relevant but it seemed better to clear it. From memory I was always forcing -xansi into CFLAGS on IRIX manually and the same approach would still be open. I also needed to mark a couple of #ifdefs for makepro.awk to keep them in utils.c where a function conditionally had a macro replacement. With different results from configure, similar problems may remain elsewhere. Oliver diff --git a/Config/defs.mk.in b/Config/defs.mk.in index 2bc17482a..116875fb9 100644 --- a/Config/defs.mk.in +++ b/Config/defs.mk.in @@ -75,7 +75,6 @@ IMPOPT = @IMPOPT@ # utilities AWK = @AWK@ -ANSI2KNR = @ANSI2KNR@ YODL = @YODL@ @YODL_OPTIONS@ YODL2TXT = @YODL@2txt YODL2HTML = @YODL@2html @@ -100,7 +99,7 @@ LDFLAGS='$(LDFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' \ DLCFLAGS='$(DLCFLAGS)' DLLDFLAGS='$(DLLDFLAGS)' \ LIBLDFLAGS='$(LIBLDFLAGS)' EXELDFLAGS='$(EXELDFLAGS)' \ LIBS='$(LIBS)' DL_EXT='$(DL_EXT)' DLLD='$(DLLD)' \ -AWK='$(AWK)' ANSI2KNR='$(ANSI2KNR)' \ +AWK='$(AWK)' \ YODL='$(YODL)' YODL2TXT='$(YODL2TXT)' YODL2HTML='$(YODL2HTML)' \ FUNCTIONS_INSTALL='$(FUNCTIONS_INSTALL)' tzsh='$(tzsh)' diff --git a/Etc/zsh-development-guide b/Etc/zsh-development-guide index 5cb542709..bdabe17d8 100644 --- a/Etc/zsh-development-guide +++ b/Etc/zsh-development-guide @@ -240,7 +240,7 @@ C coding style There must be an empty line, a line with "/**/", a line with the type of the function, and finally the name of the function with typed arguments. These lines must not be indented. The script generating - function prototypes and the ansi2knr program depend on this format. + function prototypes depends on this format. * Variable declarations must similarly be preceded by a line containing only "/**/", for the prototype generation script. diff --git a/Src/Makemod.in.in b/Src/Makemod.in.in index ea0cdc3a4..3343ae1d0 100644 --- a/Src/Makemod.in.in +++ b/Src/Makemod.in.in @@ -52,32 +52,17 @@ DLCOMPILE = $(CC) -c -I. -I$(dir_top)/Src -I$(sdir_top)/Src -I$(sdir_top)/Src/ LINK = $(CC) $(LDFLAGS) $(EXELDFLAGS) $(EXTRA_LDFLAGS) -o $@ DLLINK = $(DLLD) $(LDFLAGS) $(LIBLDFLAGS) $(DLLDFLAGS) -o $@ -KNR_OBJ=.o -KNROBJ=._foo_ +OBJ=.o -ANSIOBJ=.o -ANSI_OBJ=._foo_ +.SUFFIXES: .c .$(DL_EXT) ..o .o .syms .pro .epro -.SUFFIXES: .c .$(DL_EXT) ..o .._foo_ .o ._foo_ .syms .pro .epro - -.c$(ANSI@U@OBJ): +.c$(OBJ): $(COMPILE) -o $@ $< @rm -f $(dir_src)/stamp-modobjs -.c$(KNR@U@OBJ): - @ANSI2KNR@ $< > $@.c - $(COMPILE) -o $@ $@.c - rm -f $@.c - @rm -f $(dir_src)/stamp-modobjs - -.c.$(ANSI@U@OBJ): +.c.$(OBJ): $(DLCOMPILE) -o $@ $< -.c.$(KNR@U@OBJ): - @ANSI2KNR@ $< > $@.c - $(DLCOMPILE) -o $@ $@.c - rm -f $@.c - .c.syms: $(AWK) -f $(sdir_src)/makepro.awk $< $(subdir) > $@ diff --git a/Src/Modules/files.c b/Src/Modules/files.c index bf0e8f8a8..a3fec1daa 100644 --- a/Src/Modules/files.c +++ b/Src/Modules/files.c @@ -29,8 +29,8 @@ #include "files.mdh" -typedef int (*MoveFunc) _((char const *, char const *)); -typedef int (*RecurseFunc) _((char *, char *, struct stat const *, void *)); +typedef int (*MoveFunc) (char const *, char const *); +typedef int (*RecurseFunc) (char *, char *, struct stat const *, void *); struct recursivecmd; diff --git a/Src/Modules/watch.c b/Src/Modules/watch.c index ba17cf940..acc499518 100644 --- a/Src/Modules/watch.c +++ b/Src/Modules/watch.c @@ -584,7 +584,7 @@ readwtab(WATCH_STRUCT_UTMP **head, int initial_sz) if (sz) qsort((void *) *head, sz, sizeof(WATCH_STRUCT_UTMP), - (int (*) _((const void *, const void *)))ucmp); + (int (*) (const void *, const void *))ucmp); return sz; } diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c index 47a5e9de9..0c26828fd 100644 --- a/Src/Modules/zftp.c +++ b/Src/Modules/zftp.c @@ -127,7 +127,7 @@ typedef int (*readwrite_t)(int, char *, off_t, int); struct zftpcmd { const char *nam; - int (*fun) _((char *, char **, int)); + int (*fun) (char *, char **, int); int min, max, flags; }; diff --git a/Src/Modules/zprof.c b/Src/Modules/zprof.c index 56cdab888..171a15b90 100644 --- a/Src/Modules/zprof.c +++ b/Src/Modules/zprof.c @@ -163,9 +163,9 @@ bin_zprof(UNUSED(char *nam), UNUSED(char **args), Options ops, UNUSED(int func)) *ap = NULL; qsort(fs, ncalls, sizeof(f), - (int (*) _((const void *, const void *))) cmpsfuncs); + (int (*) (const void *, const void *)) cmpsfuncs); qsort(as, narcs, sizeof(a), - (int (*) _((const void *, const void *))) cmpparcs); + (int (*) (const void *, const void *)) cmpparcs); printf("num calls time self name\n-----------------------------------------------------------------------------------\n"); for (fp = fs, i = 1; *fp; fp++, i++) { @@ -179,7 +179,7 @@ bin_zprof(UNUSED(char *nam), UNUSED(char **args), Options ops, UNUSED(int func)) (*fp)->name); } qsort(fs, ncalls, sizeof(f), - (int (*) _((const void *, const void *))) cmptfuncs); + (int (*) (const void *, const void *)) cmptfuncs); for (fp = fs; *fp; fp++) { printf("\n-----------------------------------------------------------------------------------\n\n"); diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c index 9b87cad93..09282d42d 100644 --- a/Src/Zle/compcore.c +++ b/Src/Zle/compcore.c @@ -3253,7 +3253,7 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp) /* Now sort the array (it contains matches). */ matchorder = flags; qsort((void *) rp, n, sizeof(Cmatch), - (int (*) _((const void *, const void *)))matchcmp); + (int (*) (const void *, const void *))matchcmp); /* since the matches are sorted and the default is to remove * all duplicates, -1 (remove only consecutive dupes) is a no-op, @@ -3295,7 +3295,7 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp) sp = (Cmatch *) zhalloc((n + 1) * sizeof(Cmatch)); memcpy(sp, rp, (n + 1) * sizeof(Cmatch)); qsort((void *) sp, n, sizeof(Cmatch), - (int (*) _((const void *, const void *)))matchcmp); + (int (*) (const void *, const void *))matchcmp); for (asp = sp + 1; *asp; asp++) { Cmatch *ap = asp - 1, *bp = asp; if (matcheq(*ap, *bp)) { diff --git a/Src/Zle/zle.h b/Src/Zle/zle.h index 010ead3d2..5bb9e7a5e 100644 --- a/Src/Zle/zle.h +++ b/Src/Zle/zle.h @@ -186,7 +186,7 @@ typedef struct thingy *Thingy; /* widgets (ZLE functions) */ -typedef int (*ZleIntFunc) _((char **)); +typedef int (*ZleIntFunc) (char **); struct widget { int flags; /* flags (see below) */ @@ -319,7 +319,7 @@ struct vichange { typedef struct keymap *Keymap; -typedef void (*KeyScanFunc) _((char *, Thingy, char *, void *)); +typedef void (*KeyScanFunc) (char *, Thingy, char *, void *); #define invicmdmode() (!strcmp(curkeymapname, "vicmd")) diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c index 041682ee9..5012917f5 100644 --- a/Src/Zle/zle_keymap.c +++ b/Src/Zle/zle_keymap.c @@ -745,7 +745,7 @@ bin_bindkey(char *name, char **argv, Options ops, UNUSED(int func)) static struct opn { char o; char selp; - int (*func) _((char *, char *, Keymap, char **, Options, char)); + int (*func) (char *, char *, Keymap, char **, Options, char); int min, max; } const opns[] = { { 'l', 0, bin_bindkey_lsmaps, 0, -1 }, diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c index 1b036a8a0..f71435b01 100644 --- a/Src/Zle/zle_thingy.c +++ b/Src/Zle/zle_thingy.c @@ -344,7 +344,7 @@ bin_zle(char *name, char **args, Options ops, UNUSED(int func)) { static struct opn { char o; - int (*func) _((char *, char **, Options, char)); + int (*func) (char *, char **, Options, char); int min, max; } const opns[] = { { 'l', bin_zle_list, 0, -1 }, diff --git a/Src/exec.c b/Src/exec.c index 0231bc361..e955e85df 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -267,7 +267,7 @@ static char *blank_env[] = { NULL }; /* Execution functions. */ -static int (*execfuncs[WC_COUNT-WC_CURSH]) _((Estate, int)) = { +static int (*execfuncs[WC_COUNT-WC_CURSH]) (Estate, int) = { execcursh, exectime, NULL /* execfuncdef handled specially */, execfor, execselect, execwhile, execrepeat, execcase, execif, execcond, diff --git a/Src/glob.c b/Src/glob.c index bd199ace3..3e34f708e 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -133,7 +133,7 @@ typedef struct stat *Statptr; /* This makes the Ultrix compiler happy. Go figu #define TT_TERABYTES 5 -typedef int (*TestMatchFunc) _((char *, struct stat *, off_t, char *)); +typedef int (*TestMatchFunc) (char *, struct stat *, off_t, char *); struct qual { struct qual *next; /* Next qualifier, must match */ @@ -1264,7 +1264,7 @@ zglob(LinkList list, LinkNode np, int nountok) int sense, qualsfound; off_t data; char *sdata, *newcolonmod, *ptr; - int (*func) _((char *, Statptr, off_t, char *)); + int (*func) (char *, Statptr, off_t, char *); /* * Initialise state variables for current file pattern. @@ -1310,7 +1310,7 @@ zglob(LinkList list, LinkNode np, int nountok) if (*ptr == Dash) *ptr = '-'; while (*s && !newcolonmod) { - func = (int (*) _((char *, Statptr, off_t, char *)))0; + func = (int (*) (char *, Statptr, off_t, char *)) 0; if (*s == ',') { /* A comma separates alternative sets of qualifiers */ s++; @@ -1961,7 +1961,7 @@ zglob(LinkList list, LinkNode np, int nountok) /* Sort arguments in to lexical (and possibly numeric) order. * * This is reversed to facilitate insertion into the list. */ qsort((void *) & matchbuf[0], matchct, sizeof(struct gmatch), - (int (*) _((const void *, const void *)))gmatchcmp); + (int (*) (const void *, const void *)) gmatchcmp); } if (first < 0) { diff --git a/Src/hist.c b/Src/hist.c index 448dfddbc..1a00c30ed 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -34,25 +34,25 @@ * word control. */ /**/ -mod_export int (*hgetc) _((void)); +mod_export int (*hgetc) (void); /**/ -void (*hungetc) _((int)); +void (*hungetc) (int); /**/ -void (*hwaddc) _((int)); +void (*hwaddc) (int); /**/ -void (*hwbegin) _((int)); +void (*hwbegin) (int); /**/ -void (*hwabort) _((void)); +void (*hwabort) (void); /**/ -void (*hwend) _((void)); +void (*hwend) (void); /**/ -void (*addtoline) _((int)); +void (*addtoline) (int); /* != 0 means history substitution is turned off */ diff --git a/Src/makepro.awk b/Src/makepro.awk index 0d53c5850..56c4f4595 100644 --- a/Src/makepro.awk +++ b/Src/makepro.awk @@ -131,8 +131,8 @@ BEGIN { sub(/@-.*$/, "", dnam) # Put parens etc. back - gsub(/@[{]/, " _((", dcltor) - gsub(/@}/, "))", dcltor) + gsub(/@[{]/, " (", dcltor) + gsub(/@}/, ")", dcltor) gsub(/@</, "(", dcltor) gsub(/@>/, ")", dcltor) gsub(/@!/, ",", dcltor) diff --git a/Src/mem.c b/Src/mem.c index fb4be47bf..0b6f76e46 100644 --- a/Src/mem.c +++ b/Src/mem.c @@ -1057,17 +1057,17 @@ zrealloc(void *ptr, size_t size) #if !defined(__hpux) && !defined(DGUX) && !defined(__osf__) # if defined(_BSD) # ifndef HAVE_BRK_PROTO - extern int brk _((caddr_t)); + extern int brk (caddr_t); # endif # ifndef HAVE_SBRK_PROTO - extern caddr_t sbrk _((int)); + extern caddr_t sbrk (int); # endif # else # ifndef HAVE_BRK_PROTO - extern int brk _((void *)); + extern int brk (void *); # endif # ifndef HAVE_SBRK_PROTO - extern void *sbrk _((int)); + extern void *sbrk (int); # endif # endif #endif diff --git a/Src/mkbltnmlst.sh b/Src/mkbltnmlst.sh index 067ecdaf9..1994ace60 100644 --- a/Src/mkbltnmlst.sh +++ b/Src/mkbltnmlst.sh @@ -122,12 +122,12 @@ for bin_mod in $bin_mods; do esac done echo " {" - echo " extern int setup_${q_bin_mod} _((Module));" - echo " extern int boot_${q_bin_mod} _((Module));" - echo " extern int features_${q_bin_mod} _((Module,char***));" - echo " extern int enables_${q_bin_mod} _((Module,int**));" - echo " extern int cleanup_${q_bin_mod} _((Module));" - echo " extern int finish_${q_bin_mod} _((Module));" + echo " extern int setup_${q_bin_mod} (Module);" + echo " extern int boot_${q_bin_mod} (Module);" + echo " extern int features_${q_bin_mod} (Module,char***);" + echo " extern int enables_${q_bin_mod} (Module,int**);" + echo " extern int cleanup_${q_bin_mod} (Module);" + echo " extern int finish_${q_bin_mod} (Module);" echo echo " register_module(\"$bin_mod\"," echo " setup_${q_bin_mod}," diff --git a/Src/modentry.c b/Src/modentry.c index 4d8217f43..23c499d94 100644 --- a/Src/modentry.c +++ b/Src/modentry.c @@ -1,10 +1,10 @@ #include "zsh.mdh" -int setup_ _((Module)); -int boot_ _((Module)); -int cleanup_ _((Module)); -int finish_ _((Module)); -int modentry _((int boot, Module m, void *ptr)); +int setup_ (Module); +int boot_ (Module); +int cleanup_ (Module); +int finish_ (Module); +int modentry (int boot, Module m, void *ptr); /**/ int diff --git a/Src/parse.c b/Src/parse.c index 40eb0ee0b..334365649 100644 --- a/Src/parse.c +++ b/Src/parse.c @@ -2392,7 +2392,7 @@ par_nl_wordlist(void) */ /**/ -void (*condlex) _((void)) = zshlex; +void (*condlex) (void) = zshlex; /* * cond : cond_1 { SEPER } [ DBAR { SEPER } cond ] diff --git a/Src/prototypes.h b/Src/prototypes.h index e3db4f5ee..3578482d0 100644 --- a/Src/prototypes.h +++ b/Src/prototypes.h @@ -28,9 +28,9 @@ */ #ifndef HAVE_STDLIB_H -char *malloc _((size_t)); -char *realloc _((void *, size_t)); -char *calloc _((size_t, size_t)); +char *malloc (size_t); +char *realloc (void *, size_t); +char *calloc (size_t, size_t); #endif #if !(defined(USES_TERMCAP_H) || defined(USES_TERM_H)) @@ -45,11 +45,11 @@ char *calloc _((size_t, size_t)); #else #define TC_CONST #endif -extern int tgetent _((char *bp, TC_CONST char *name)); -extern int tgetnum _((char *id)); -extern int tgetflag _((char *id)); -extern char *tgetstr _((char *id, char **area)); -extern int tputs _((TC_CONST char *cp, int affcnt, int (*outc) (int))); +extern int tgetent (char *bp, TC_CONST char *name); +extern int tgetnum (char *id); +extern int tgetflag (char *id); +extern char *tgetstr (char *id, char **area); +extern int tputs (TC_CONST char *cp, int affcnt, int (*outc) (int)); #undef TC_CONST #endif @@ -70,30 +70,30 @@ char *tgoto(const char *cap, int col, int row); #endif #ifdef __osf__ -char *mktemp _((char *)); +char *mktemp (char *); #endif #if defined(__osf__) && defined(__alpha) && defined(__GNUC__) /* Digital cc does not need these prototypes, gcc does need them */ # ifndef HAVE_IOCTL_PROTO -int ioctl _((int d, unsigned long request, void *argp)); +int ioctl (int d, unsigned long request, void *argp); # endif # ifndef HAVE_MKNOD_PROTO -int mknod _((const char *pathname, int mode, dev_t device)); +int mknod (const char *pathname, int mode, dev_t device); # endif -int nice _((int increment)); -int select _((int nfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds, struct timeval *timeout)); +int nice (int increment); +int select (int nfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds, struct timeval *timeout); #endif #if defined(DGUX) && defined(__STDC__) /* Just plain missing. */ -extern int getrlimit _((int resource, struct rlimit *rlp)); -extern int setrlimit _((int resource, const struct rlimit *rlp)); -extern int getrusage _((int who, struct rusage *rusage)); -extern int gettimeofday _((struct timeval *tv, struct timezone *tz)); -extern int wait3 _((union wait *wait_status, int options, struct rusage *rusage)); -extern int getdomainname _((char *name, int maxlength)); -extern int select _((int nfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds, struct timeval *timeout)); +extern int getrlimit (int resource, struct rlimit *rlp); +extern int setrlimit (int resource, const struct rlimit *rlp); +extern int getrusage (int who, struct rusage *rusage); +extern int gettimeofday (struct timeval *tv, struct timezone *tz); +extern int wait3 (union wait *wait_status, int options, struct rusage *rusage); +extern int getdomainname (char *name, int maxlength); +extern int select (int nfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds, struct timeval *timeout); #endif /* DGUX and __STDC__ */ #ifdef __NeXT__ @@ -101,34 +101,34 @@ extern pid_t getppid(void); #endif #if defined(__sun__) && !defined(__SVR4) /* SunOS */ -extern char *strerror _((int errnum)); +extern char *strerror (int errnum); #endif /**************************************************/ /*** prototypes for functions built in compat.c ***/ #ifndef HAVE_STRSTR -extern char *strstr _((const char *s, const char *t)); +extern char *strstr (const char *s, const char *t); #endif #ifndef HAVE_GETHOSTNAME -extern int gethostname _((char *name, size_t namelen)); +extern int gethostname (char *name, size_t namelen); #endif #ifndef HAVE_GETTIMEOFDAY -extern int gettimeofday _((struct timeval *tv, struct timezone *tz)); +extern int gettimeofday (struct timeval *tv, struct timezone *tz); #endif #ifndef HAVE_DIFFTIME -extern double difftime _((time_t t2, time_t t1)); +extern double difftime (time_t t2, time_t t1); #endif #ifndef HAVE_STRERROR -extern char *strerror _((int errnum)); +extern char *strerror (int errnum); #endif /*** end of prototypes for functions in compat.c ***/ /***************************************************/ #ifndef HAVE_MEMMOVE -extern void bcopy _((const void *, void *, size_t)); +extern void bcopy (const void *, void *, size_t); #endif diff --git a/Src/signals.h b/Src/signals.h index 391f11fed..7910f6b79 100644 --- a/Src/signals.h +++ b/Src/signals.h @@ -27,7 +27,7 @@ * */ -#define SIGNAL_HANDTYPE void (*)_((int)) +#define SIGNAL_HANDTYPE void (*)(int) #ifndef HAVE_KILLPG # define killpg(pgrp,sig) kill(-(pgrp),sig) @@ -145,7 +145,7 @@ #ifdef BSD_SIGNALS #define signal_block(S) sigblock(S) #else -extern sigset_t signal_block _((sigset_t)); +extern sigset_t signal_block (sigset_t); #endif /* BSD_SIGNALS */ -extern sigset_t signal_unblock _((sigset_t)); +extern sigset_t signal_unblock (sigset_t); diff --git a/Src/utils.c b/Src/utils.c index c8831c85e..ce4e875fd 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -5277,6 +5277,7 @@ nicedupstring(char const *s) } +/**/ #ifndef MULTIBYTE_SUPPORT /* Unmetafy and output a string, displaying special characters readably. */ @@ -5311,8 +5312,9 @@ niceztrlen(char const *s) } return l; } -#endif +/**/ +#endif /**/ #ifdef MULTIBYTE_SUPPORT @@ -7633,6 +7635,7 @@ mode_to_octal(mode_t mode) return m; } +/**/ #ifdef MAILDIR_SUPPORT /* * Stat a file. If it's a maildir, check all messages @@ -7756,4 +7759,6 @@ mailstat(char *path, struct stat *st) *st = st_ret_last = st_ret; return 0; } + +/**/ #endif diff --git a/Src/zsh.h b/Src/zsh.h index fae62b8d0..090abf8f5 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -618,7 +618,7 @@ union linkroot { /* Specific elements of linked lists */ /*************************************/ -typedef void (*voidvoidfnptr_t) _((void)); +typedef void (*voidvoidfnptr_t) (void); /* * Element of the prepromptfns list. @@ -678,7 +678,7 @@ struct timedfn { #define COND_MOD 18 #define COND_MODI 19 -typedef int (*CondHandler) _((char **, int)); +typedef int (*CondHandler) (char **, int); struct conddef { Conddef next; /* next in list */ @@ -1164,28 +1164,28 @@ struct dirsav { /* Definitions for Hash Tables */ /*******************************/ -typedef void *(*VFunc) _((void *)); -typedef void (*FreeFunc) _((void *)); +typedef void *(*VFunc) (void *); +typedef void (*FreeFunc) (void *); -typedef unsigned (*HashFunc) _((const char *)); -typedef void (*TableFunc) _((HashTable)); +typedef unsigned (*HashFunc) (const char *); +typedef void (*TableFunc) (HashTable); /* * Note that this is deliberately "char *", not "const char *", * since the AddNodeFunc is passed a pointer to a string that * will be stored and later freed. */ -typedef void (*AddNodeFunc) _((HashTable, char *, void *)); -typedef HashNode (*GetNodeFunc) _((HashTable, const char *)); -typedef HashNode (*RemoveNodeFunc) _((HashTable, const char *)); -typedef void (*FreeNodeFunc) _((HashNode)); -typedef int (*CompareFunc) _((const char *, const char *)); +typedef void (*AddNodeFunc) (HashTable, char *, void *); +typedef HashNode (*GetNodeFunc) (HashTable, const char *); +typedef HashNode (*RemoveNodeFunc) (HashTable, const char *); +typedef void (*FreeNodeFunc) (HashNode); +typedef int (*CompareFunc) (const char *, const char *); /* type of function that is passed to * * scanhashtable or scanmatchtable */ -typedef void (*ScanFunc) _((HashNode, int)); -typedef void (*ScanTabFunc) _((HashTable, ScanFunc, int)); +typedef void (*ScanFunc) (HashNode, int); +typedef void (*ScanTabFunc) (HashTable, ScanFunc, int); -typedef void (*PrintTableStats) _((HashTable)); +typedef void (*PrintTableStats) (HashTable); /* Hash table for standard open hashing. Instances of struct hashtable can be * * created only by newhashtable(). In fact, this function creates an instance * @@ -1352,7 +1352,7 @@ struct funcstack { /* node in list of function call wrappers */ -typedef int (*WrapFunc) _((Eprog, FuncWrap, char *)); +typedef int (*WrapFunc) (Eprog, FuncWrap, char *); struct funcwrap { FuncWrap next; @@ -1428,8 +1428,8 @@ enum { * builtin structure. */ -typedef int (*HandlerFunc) _((char *, char **, Options, int)); -typedef int (*HandlerFuncAssign) _((char *, char **, LinkList, Options, int)); +typedef int (*HandlerFunc) (char *, char **, Options, int); +typedef int (*HandlerFuncAssign) (char *, char **, LinkList, Options, int); #define NULLBINCMD ((HandlerFunc) 0) struct builtin { @@ -1526,10 +1526,10 @@ struct module { /* Module record is an alias */ #define MOD_ALIAS (1<<6) -typedef int (*Module_generic_func) _((void)); -typedef int (*Module_void_func) _((Module)); -typedef int (*Module_features_func) _((Module, char ***)); -typedef int (*Module_enables_func) _((Module, int **)); +typedef int (*Module_generic_func) (void); +typedef int (*Module_void_func) (Module); +typedef int (*Module_features_func) (Module, char ***); +typedef int (*Module_enables_func) (Module, int **); struct linkedmod { char *name; @@ -1574,7 +1574,7 @@ struct feature_enables { /* C-function hooks */ -typedef int (*Hookfn) _((Hookdef, void *)); +typedef int (*Hookfn) (Hookdef, void *); struct hookdef { Hookdef next; @@ -1789,33 +1789,33 @@ typedef const struct gsu_array *GsuArray; typedef const struct gsu_hash *GsuHash; struct gsu_scalar { - char *(*getfn) _((Param)); - void (*setfn) _((Param, char *)); - void (*unsetfn) _((Param, int)); + char *(*getfn) (Param); + void (*setfn) (Param, char *); + void (*unsetfn) (Param, int); }; struct gsu_integer { - zlong (*getfn) _((Param)); - void (*setfn) _((Param, zlong)); - void (*unsetfn) _((Param, int)); + zlong (*getfn) (Param); + void (*setfn) (Param, zlong); + void (*unsetfn) (Param, int); }; struct gsu_float { - double (*getfn) _((Param)); - void (*setfn) _((Param, double)); - void (*unsetfn) _((Param, int)); + double (*getfn) (Param); + void (*setfn) (Param, double); + void (*unsetfn) (Param, int); }; struct gsu_array { - char **(*getfn) _((Param)); - void (*setfn) _((Param, char **)); - void (*unsetfn) _((Param, int)); + char **(*getfn) (Param); + void (*setfn) (Param, char **); + void (*unsetfn) (Param, int); }; struct gsu_hash { - HashTable (*getfn) _((Param)); - void (*setfn) _((Param, HashTable)); - void (*unsetfn) _((Param, int)); + HashTable (*getfn) (Param); + void (*setfn) (Param, HashTable); + void (*unsetfn) (Param, int); }; @@ -2984,7 +2984,7 @@ enum errflag_bits { /* Sorting */ /***********/ -typedef int (*CompareFn) _((const void *, const void *)); +typedef int (*CompareFn) (const void *, const void *); enum { SORTIT_ANYOLDHOW = 0, /* Defaults */ @@ -3042,13 +3042,13 @@ struct hist_stack { short *chwords; int chwordlen; int chwordpos; - int (*hgetc) _((void)); - void (*hungetc) _((int)); - void (*hwaddc) _((int)); - void (*hwbegin) _((int)); - void (*hwabort) _((void)); - void (*hwend) _((void)); - void (*addtoline) _((int)); + int (*hgetc) (void); + void (*hungetc) (int); + void (*hwaddc) (int); + void (*hwbegin) (int); + void (*hwabort) (void); + void (*hwend) (void); + void (*addtoline) (int); unsigned char *cstack; int csp; int hist_keep_comment; @@ -3218,7 +3218,7 @@ enum { /* compctl entry point pointers */ -typedef int (*CompctlReadFn) _((char *, char **, Options, char *)); +typedef int (*CompctlReadFn) (char *, char **, Options, char *); /* ZLE entry point pointer */ diff --git a/Src/zsh_system.h b/Src/zsh_system.h index 16f724401..5c004d53e 100644 --- a/Src/zsh_system.h +++ b/Src/zsh_system.h @@ -82,12 +82,6 @@ */ #define _STRPTIME_DONTZERO -#ifdef PROTOTYPES -# define _(Args) Args -#else -# define _(Args) () -#endif - #ifndef HAVE_ALLOCA # define alloca zhalloc #else @@ -101,7 +95,7 @@ # pragma alloca # else # ifndef alloca -char *alloca _((size_t)); +char *alloca (size_t); # endif # endif # endif diff --git a/aclocal.m4 b/aclocal.m4 index c26e2d834..792d533f2 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -2,56 +2,6 @@ # Copyright (C) 1992, 1994 Free Software Foundation, Inc. # Francois Pinard <pinard@iro.umontreal.ca>, 1992. -# @defmac fp_PROG_CC_STDC -# @maindex PROG_CC_STDC -# @ovindex CC -# If the C compiler in not in ANSI C mode by default, try to add an option -# to output variable @code{CC} to make it so. This macro tries various -# options that select ANSI C on some system or another. It considers the -# compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and -# handles function prototypes correctly. -# -# If you use this macro, you should check after calling it whether the C -# compiler has been set to accept ANSI C; if not, the shell variable -# @code{fp_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source -# code in ANSI C, you can make an un-ANSIfied copy of it by using the -# program @code{ansi2knr}, which comes with Ghostscript. -# @end defmac - -define(fp_PROG_CC_STDC, -[AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, -fp_cv_prog_cc_stdc, -[fp_cv_prog_cc_stdc=no -ac_save_CFLAGS="$CFLAGS" -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX -Ae or -Aa -D_HPUX_SOURCE -# SVR4 -Xc -# For HP-UX, we try -Ae first; this turns on ANSI but also extensions, -# as well as defining _HPUX_SOURCE, and we can then use long long. -# We keep the old version for backward compatibility. -for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" -Xc -do - CFLAGS="$ac_save_CFLAGS $ac_arg" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ -[#ifndef __STDC__ -choke me -#endif -]], [[int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);};]])], -[fp_cv_prog_cc_stdc="$ac_arg"; break],[]) -done -CFLAGS="$ac_save_CFLAGS" -]) -case "x$fp_cv_prog_cc_stdc" in - x|xno) ;; - *) CC="$CC $fp_cv_prog_cc_stdc" ;; -esac -]) - AC_DEFUN(AC_PROG_LN, [AC_MSG_CHECKING(whether ln works) AC_CACHE_VAL(ac_cv_prog_LN, diff --git a/configure.ac b/configure.ac index 175d90433..ba3f2fe90 100644 --- a/configure.ac +++ b/configure.ac @@ -273,11 +273,6 @@ fi], AC_DEFINE(CONFIG_LOCALE) ) -dnl Do you want to compile as K&R C. -AC_ARG_ENABLE(ansi2knr, -AS_HELP_STRING([--enable-ansi2knr],[translate source to K&R C before compiling]), -[ansi2knr="$enableval"], [ansi2knr=default]) - ifdef([runhelpdir],[undefine([runhelpdir])])dnl AC_ARG_ENABLE(runhelpdir, AS_HELP_STRING([--enable-runhelpdir=DIR],[the directory in which to install run-help files]), @@ -483,7 +478,7 @@ fi dnl if the user hasn't specified CFLAGS, then dnl if compiler is gcc, then use -O2 and some warning flags dnl else use -O -if test -n "$auto_cflags" && test ."$ansi2knr" != .yes; then +if test -n "$auto_cflags"; then if test "${enable_zsh_debug}" = yes; then if test -n "$GCC"; then CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -ggdb" @@ -558,28 +553,6 @@ case "$host_os" in esac fp_PROG_CC_STDC -AC_MSG_CHECKING([whether to use prototypes]) -if test ."$ansi2knr" = .yes || test ."$ansi2knr" = .no; then - msg="(overridden) " -else - msg= - if test ."$fp_cv_prog_cc_stdc" = .no; then - ansi2knr=yes - else - ansi2knr=no - fi -fi -AH_TEMPLATE([PROTOTYPES], -[Define to 1 if ANSI function prototypes are usable.]) -if test "$ansi2knr" = yes; then - AC_MSG_RESULT(${msg}no) - U=_ -else - AC_MSG_RESULT(${msg}yes) - AC_DEFINE(PROTOTYPES) - U= -fi -AC_SUBST(U) AC_FUNC_ALLOCA dnl Check how to get `alloca'. @@ -647,18 +620,6 @@ case "$LC_PAPER" in esac AC_SUBST(PAPERSIZE) -AC_CHECK_PROGS([ANSI2KNR], [ansi2knr], [: ansi2knr]) - -if test x"$ansi2knr" = xyes && test x"$ANSI2KNR" = x": ansi2knr"; then - echo "----------" - echo "configure fatal error:" - echo "ansi2knr was specified (--enable-ansi2knr) but the program could not be found." - echo "Either remove the configure option if it is not required or build the ansi2knr" - echo "program before reconfiguring Zsh. The source code for ansi2knr is also" - echo "available in the GPL directory on Zsh distribution sites." - exit 1 -fi - dnl ------------------ dnl CHECK HEADER FILES dnl ------------------
With zsh 5.9, consider: cventin% setopt CORRECT_ALL cventin% zsha && zshb && nocorrect zshc && zshd zsh: correct 'zsha' to 'zsh' [nyae]? n zsh: correct 'zshb' to 'zsh' [nyae]? n zsh: command not found: zsha while without "nocorrect", the 4 commands are proposed for correction. The following lines are handled in the same way: zsha ; zshb ; nocorrect zshc ; zshd zsha ; zshb ; echo $(nocorrect zshc) ; zshd "nocorrect" is documented under "PRECOMMAND MODIFIERS". So it is surprising that it can affect more than the corresponding command. Is this the expected behavior? Well, at least this is useful to be able to use "nocorrect" on the "for" words: nocorrect : ; for i in word1 word2 ; do echo $i ; done Given the context "PRECOMMAND MODIFIERS", the documentation is not explicit: nocorrect Spelling correction is not done on any of the words. This must appear before any other precommand modifier, as it is interpreted immediately, before any parsing is done. It has no effect in non-interactive shells. If this is the expected behavior, I suppose that the documentation should be something like Spelling correction is not done on any of the subsequent words of the full command line. [...] -- Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
With zsh 5.9: cventin:~> zsh -f cventin% HISTFILE=~/.histfile cventin% HISTSIZE=1000 cventin% SAVEHIST=1000 cventin% setopt APPEND_HISTORY cventin% true cventin% exit cventin:~> ls ~/.histfile ls: cannot access '/home/vlefevre/.histfile': No such file or directory However, if I use INC_APPEND_HISTORY instead of APPEND_HISTORY, the history is saved. According to the zsh(1) man page: Note also that the RCS option affects the saving of history files, i.e. if RCS is unset when the shell exits, no history file will be saved. But the difference between INC_APPEND_HISTORY and APPEND_HISTORY is not documented concerning this point. Also, I do not see the point of not saving the history when RCS is set. IMHO, HISTFILE should just be unset by default; but if the user sets this parameter, I suppose that the goal is to save the history. Without INC_APPEND_HISTORY, the man page doesn't document when precisely the history is saved. For instance, what happens if one has a "print -s ..." in the .zlogout file? Moreover, with INC_APPEND_HISTORY, "print -s" does not put the entry in the history file immediately, only after the next accept-line. -- Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
With zsh 5.9, HIST_IGNORE_DUPS is buggy: it also ignores command lines that differ by a space between (single or double) quotes. For instance, with setopt HIST_IGNORE_DUPS echo " " echo " " (the first echo with only 1 space character between the quotes, the second echo with 2 space characters between the quotes), zsh keeps only the second one in the history. Such spaces are significant, so that these command lines are not dups. However, if the spaces are quoted, this problem does not occur: echo \ . echo \ \ . -- Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
(Believe it or not, my cat stepped on the laptop while I was
drag-selecting and that hit the send button)
On Tue, Mar 12, 2024 at 2:44 PM Clinton Bunch <cdb_zsh@zentaur.org> wrote:
>
> I propose that we update the development guide to remove the bit about the 1989 standard (much less K&R compatibility) since it is no longer true, and I personally question if it even makes sense as a goal 30+ years in to development.
I think we pretty much agreed on that back in December (workers/51212
anyone?) and just never edited that bit of the document.