mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-27 04:40:59 +01:00
18278: remove zgprintf, zformat already does this
This commit is contained in:
parent
fcc7489b7e
commit
b1ae269e55
6 changed files with 9 additions and 92 deletions
|
|
@ -1,5 +1,9 @@
|
||||||
2003-02-23 Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
|
2003-02-23 Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
|
||||||
|
|
||||||
|
* 18278: Functions/TCP/tcp_output, Functions/TCP/tcp_spam,
|
||||||
|
Functions/TCP/zgprintf, Doc/Zsh/tcpsys.yo: zgprintf is already
|
||||||
|
implemented as zformat in the zsh/zutil module, so is unnecessary.
|
||||||
|
|
||||||
* unposted, see 18276: Completion/Unix/Command/_perforce:
|
* unposted, see 18276: Completion/Unix/Command/_perforce:
|
||||||
fix labels and clients after `@'; rationalise function and tag
|
fix labels and clients after `@'; rationalise function and tag
|
||||||
names; add date completion; add service=p4-<subcommand> support;
|
names; add date completion; add service=p4-<subcommand> support;
|
||||||
|
|
|
||||||
|
|
@ -495,24 +495,6 @@ files which are configured.
|
||||||
The tt(-S) and tt(-F) options are used to pass in the session name and file
|
The tt(-S) and tt(-F) options are used to pass in the session name and file
|
||||||
descriptor for possible replacement in the prompt.
|
descriptor for possible replacement in the prompt.
|
||||||
)
|
)
|
||||||
findex(zgprintf)
|
|
||||||
item(tt(zgprintf) tt(-rPR -%)var(X)tt(=)var(subst) var(fmt) tt([) var(val) tt(... ]))(
|
|
||||||
This function is used for performing tt(%)-replacement in prompts supplied
|
|
||||||
to tt(tcp_output). The var(fmt) string is printed to standard output.
|
|
||||||
The option tt(-%)var(X)tt(=)var(subst) specifies that any occurrence
|
|
||||||
of tt(%)var(X) in the var(fmt) string should be replaced by var(subst).
|
|
||||||
These arguments may be repeated for arbitrary var(X).
|
|
||||||
|
|
||||||
The option tt(-r) specifies that the normal tt(print) conventions are not
|
|
||||||
to be used, as with the corresponding argument to the tt(print) builtin.
|
|
||||||
|
|
||||||
The option tt(-R) specifies that the output is to be left in the parameter
|
|
||||||
tt($REPLY) instead of being printed.
|
|
||||||
|
|
||||||
The option tt(-P) specifies that unhandled tt(%)-escapes should be
|
|
||||||
formatted by a call to tt(printf). Each is assumed to consume exactly one
|
|
||||||
additional var(val) argument. This option is only minimally implemented.
|
|
||||||
)
|
|
||||||
enditem()
|
enditem()
|
||||||
|
|
||||||
texinode(TCP Parameters)(TCP Examples)(TCP Functions)(TCP Function System)
|
texinode(TCP Parameters)(TCP Examples)(TCP Functions)(TCP Function System)
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,8 @@ emulate -L zsh
|
||||||
setopt extendedglob cbases
|
setopt extendedglob cbases
|
||||||
|
|
||||||
zmodload -i zsh/net/tcp || return 1
|
zmodload -i zsh/net/tcp || return 1
|
||||||
autoload -U zgprintf tcp_alias tcp_close tcp_command tcp_expect tcp_fd_handler
|
zmodload -i zsh/zutil
|
||||||
|
autoload -U tcp_alias tcp_close tcp_command tcp_expect tcp_fd_handler
|
||||||
autoload -U tcp_log tcp_output tcp_proxy tcp_read tcp_rename tcp_send
|
autoload -U tcp_log tcp_output tcp_proxy tcp_read tcp_rename tcp_send
|
||||||
autoload -U tcp_sess tcp_spam tcp_talk tcp_wait
|
autoload -U tcp_sess tcp_spam tcp_talk tcp_wait
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ fi
|
||||||
# where data is coming from; also, it allows more predictable
|
# where data is coming from; also, it allows more predictable
|
||||||
# behaviour in tcp_expect.
|
# behaviour in tcp_expect.
|
||||||
if [[ -n $tprompt ]]; then
|
if [[ -n $tprompt ]]; then
|
||||||
zgprintf -R -%s=$sess -%f=$read_fd -- $tprompt
|
zformat -f REPLY $tprompt "s:$sess" "f:$read_fd"
|
||||||
# We will pass this back up.
|
# We will pass this back up.
|
||||||
REPLY="$REPLY$*"
|
REPLY="$REPLY$*"
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ for TCP_SESS in $sessions; do
|
||||||
tcp_on_spam $TCP_SESS $cmd $*
|
tcp_on_spam $TCP_SESS $cmd $*
|
||||||
[[ $REPLY = done ]] && continue
|
[[ $REPLY = done ]] && continue
|
||||||
fi
|
fi
|
||||||
[[ -n $verbose ]] && zgprintf -R -%s=$TCP_SESS \
|
[[ -n $verbose ]] && zformat REPLY $TCP_PROMPT "s:$TCP_SESS" \
|
||||||
-%f=${tcp_by_name[$TCP_SESS]} -- $TCP_PROMPT
|
"f:${tcp_by_name[$TCP_SESS]}"
|
||||||
eval $cmd '$*'
|
eval $cmd '$*'
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
# Generalised printf.
|
|
||||||
# Arguments of the form -%X=... give the output to be used with
|
|
||||||
# the directive %x.
|
|
||||||
#
|
|
||||||
# -P indicates that any unhandled directives are to be
|
|
||||||
# passed to printf. With this option, any %-escapes passed to printf
|
|
||||||
# are assumed to consume exactly one argument from the command line.
|
|
||||||
# Unused command line arguments are ignored. This is only minimally
|
|
||||||
# implemented.
|
|
||||||
#
|
|
||||||
# -R indicates the value is to be put into REPLY rather than printed.
|
|
||||||
#
|
|
||||||
# -r indicates that print formatting (backslash escapes etc.) should
|
|
||||||
# not be replied to the result. When using -R, no print formatting
|
|
||||||
# is applied in any case.
|
|
||||||
|
|
||||||
emulate -L zsh
|
|
||||||
setopt extendedglob
|
|
||||||
|
|
||||||
local opt printf fmt usereply match mbegin mend raw c
|
|
||||||
typeset -A chars
|
|
||||||
chars=(% %)
|
|
||||||
|
|
||||||
while getopts "%:PrR" opt; do
|
|
||||||
case $opt in
|
|
||||||
(%) if [[ $OPTARG != ?=* ]]; then
|
|
||||||
print -r "Bad % option: should be -%${OPTARG[1]}=..." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
chars[${OPTARG[1]}]=${OPTARG[3,-1]}
|
|
||||||
;;
|
|
||||||
(P) printf=1
|
|
||||||
;;
|
|
||||||
(r) raw=-r
|
|
||||||
;;
|
|
||||||
(R) usereply=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
|
|
||||||
|
|
||||||
[[ -z $usereply ]] && local REPLY
|
|
||||||
REPLY=
|
|
||||||
|
|
||||||
if (( $# )); then
|
|
||||||
fmt=$1
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
|
|
||||||
while [[ $fmt = (#b)([^%]#)%([-0-9.*]#?)(*) ]]; do
|
|
||||||
REPLY+=$match[1]
|
|
||||||
c=$match[2]
|
|
||||||
fmt=$match[3]
|
|
||||||
if [[ -n ${chars[$c]} ]]; then
|
|
||||||
REPLY+=${chars[$c]}
|
|
||||||
elif [[ -n $P ]]; then
|
|
||||||
# hmmm, we need sprintf...
|
|
||||||
# TODO: %ld etc.
|
|
||||||
REPLY+=`printf "%$c" $1`
|
|
||||||
(( $? )) && return 1
|
|
||||||
shift
|
|
||||||
else
|
|
||||||
print -r "Format not handled: %$c" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
REPLY+=$fmt
|
|
||||||
[[ -z $usereply ]] && print -n $raw - $REPLY
|
|
||||||
return 0
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue