1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-26 16:40:29 +01:00

16254: complete map names after ypmatch

16255: options for default output base for zcalc
This commit is contained in:
Peter Stephenson 2001-11-15 18:42:31 +00:00
parent 195d8c5ec6
commit f2e7cf4a05
3 changed files with 45 additions and 2 deletions

View file

@ -1,3 +1,11 @@
2001-11-15 Peter Stephenson <pws@csr.com>
* 16255: Function/Misc/zcalc: allow -#base or -## base to
specify default output base.
* 16254: Completion/Unix/Command/_yp: allow completion of map
names after ypmatch.
2001-11-15 Chmouel Boudjnah <chmouel@mandrakesoft.com> 2001-11-15 Chmouel Boudjnah <chmouel@mandrakesoft.com>
* 16253: Src/Zle/complete.mdd: Add Mandrake completion directory to * 16253: Src/Zle/complete.mdd: Add Mandrake completion directory to

View file

@ -19,7 +19,8 @@ ypcat)
_arguments -C -s "$_yp_args[@]" ':map name:->map' && ret=0 _arguments -C -s "$_yp_args[@]" ':map name:->map' && ret=0
;; ;;
ypmatch) ypmatch)
_arguments -C -s "$_yp_args[@]" '*::key map:->keymap' && ret=0 _arguments -C -s "$_yp_args[@]" '::key map:->keymap' ':map name:->map' &&
ret=0
;; ;;
yppasswd) yppasswd)
_users _users

View file

@ -74,6 +74,10 @@
# also understood. However, leading 0 for octal is not understood --- it's # also understood. However, leading 0 for octal is not understood --- it's
# too confusing in a calculator. Use 8#777 etc. # too confusing in a calculator. Use 8#777 etc.
# #
# Options: -#<base> is the same as a line containing just `[#<base>],
# similarly -##<base>; they set the default output base, with and without
# a base discriminator in front, respectively.
#
# #
# To do: # To do:
# - separate zcalc history from shell history using arrays --- or allow # - separate zcalc history from shell history using arrays --- or allow
@ -84,7 +88,7 @@
emulate -L zsh emulate -L zsh
setopt extendedglob setopt extendedglob
local line latest base defbase match mbegin mend psvar local line latest base defbase match mbegin mend psvar optlist opt arg
integer num integer num
zmodload -i zsh/mathfunc 2>/dev/null zmodload -i zsh/mathfunc 2>/dev/null
@ -95,6 +99,36 @@ zmodload -i zsh/mathfunc 2>/dev/null
float PI E float PI E
(( PI = 4 * atan(1), E = exp(1) )) (( PI = 4 * atan(1), E = exp(1) ))
# Process command line
while [[ -n $1 && $1 = -(|[#-]*) ]]; do
optlist=${1[2,-1]}
shift
[[ $optlist = (|-) ]] && break
while [[ -n $optlist ]]; do
opt=${optlist[1]}
optlist=${optlist[2,-1]}
case $opt in
('#') # Default base
if [[ -n $optlist ]]; then
arg=$optlist
optlist=
elif [[ -n $1 ]]; then
arg=$1
shift
else
print "-# requires an argument" >&2
return 1
fi
if [[ $arg != (|\#)[[:digit:]]## ]]; then
print - "-# requires a decimal number as an argument" >&2
return 1
fi
defbase="[#${arg}]"
;;
esac
done
done
for (( num = 1; num <= $#; num++ )); do for (( num = 1; num <= $#; num++ )); do
# Make sure all arguments have been evaluated. # Make sure all arguments have been evaluated.
# The `$' before the second argv forces string rather than numeric # The `$' before the second argv forces string rather than numeric