about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2001-11-15 18:42:31 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2001-11-15 18:42:31 +0000
commitf2e7cf4a05a5b74a16bf4f0280ef26f19b686925 (patch)
treedb9dcb3fa7ae92dfb0bd3baa18f29f969b3b1428
parent195d8c5ec6feb88847f11e96a10b20bb543233c1 (diff)
downloadzsh-f2e7cf4a05a5b74a16bf4f0280ef26f19b686925.tar.gz
zsh-f2e7cf4a05a5b74a16bf4f0280ef26f19b686925.tar.xz
zsh-f2e7cf4a05a5b74a16bf4f0280ef26f19b686925.zip
16254: complete map names after ypmatch
16255: options for default output base for zcalc
-rw-r--r--ChangeLog8
-rw-r--r--Completion/Unix/Command/_yp3
-rw-r--r--Functions/Misc/zcalc36
3 files changed, 45 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 7e1982ef6..249ecb77b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
 	* 16253: Src/Zle/complete.mdd: Add Mandrake completion directory to
diff --git a/Completion/Unix/Command/_yp b/Completion/Unix/Command/_yp
index 76c59fac7..96e50ebb4 100644
--- a/Completion/Unix/Command/_yp
+++ b/Completion/Unix/Command/_yp
@@ -19,7 +19,8 @@ ypcat)
   _arguments -C -s "$_yp_args[@]" ':map name:->map' && ret=0
   ;;
 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)
   _users
diff --git a/Functions/Misc/zcalc b/Functions/Misc/zcalc
index 78a48b9b0..5d0264922 100644
--- a/Functions/Misc/zcalc
+++ b/Functions/Misc/zcalc
@@ -74,6 +74,10 @@
 # also understood.  However, leading 0 for octal is not understood --- it's
 # 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:
 # - separate zcalc history from shell history using arrays --- or allow
@@ -84,7 +88,7 @@
 emulate -L zsh
 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
 
 zmodload -i zsh/mathfunc 2>/dev/null
@@ -95,6 +99,36 @@ zmodload -i zsh/mathfunc 2>/dev/null
 float PI E
 (( 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
   # Make sure all arguments have been evaluated.
   # The `$' before the second argv forces string rather than numeric