Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Re: Curiosity: zstyle -a vs. zstyle -h



Bart Schaefer wrote:

> I just did a little experiment.  It appears that `zstyle -h pat style name'
> is exactly equivalent to `typeset -A name; zstyle -a pat style name'.
> 
> This seems just a tad inconsistent; if `zstyle -h' is going to force the
> name to be an associative array, shouldn't `zstyle -a' force the name to
> be an ordinary array?  (And shouldn't it be -A rather than -h?  I thought
> we only used -h when -A was already taken, as with `stat' (and there it's
> -H).)
> 
> An equally good (perhaps even better) alternative would be to drop the -h
> option entirely and require the array to be declared if one wants it to be
> an assoc.

This patch does that.

Bye
 Sven

Index: Doc/Zsh/mod_zutil.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/mod_zutil.yo,v
retrieving revision 1.5
diff -u -r1.5 mod_zutil.yo
--- Doc/Zsh/mod_zutil.yo	2000/05/21 18:27:36	1.5
+++ Doc/Zsh/mod_zutil.yo	2000/05/22 09:29:31
@@ -11,7 +11,7 @@
 xitem(tt(zstyle) [ tt(-) | tt(-)tt(-) ] var(pattern) var(style) var(strings) ...)
 xitem(tt(zstyle -d) [ var(pattern) [ var(styles) ... ] ])
 xitem(tt(zstyle -g) var(name) [ var(pattern) [ var(style) ] ])
-xitem(tt(zstyle -abhs) var(context) var(style) var(name) [ var(sep) ])
+xitem(tt(zstyle -abs) var(context) var(style) var(name) [ var(sep) ])
 xitem(tt(zstyle -Tt) var(context) var(style) [ var(strings) ...])
 item(tt(zstyle -m) var(context) var(style) var(pattern))(
 This builtin command is used to define and lookup styles.  Styles are
@@ -67,11 +67,10 @@
 of `tt(yes)', `tt(true)', `tt(on)', or `tt(1)'. If the value is any other
 string or has more than one string, the parameter is set to `tt(no)'.
 )
-xitem(tt(zstyle -a) var(context) var(style) var(name))
-item(tt(zstyle -h) var(context) var(style) var(name))(
-With the tt(-a) option the value is stored in var(name) as an array and
-with tt(-h) as an associative array (with the first, third, etc. string
-being used as the keys and the other strings being used as the values).
+item(tt(zstyle -a) var(context) var(style) var(name))(
+The value is stored in var(name) as an array. If var(name) is declared 
+as an associative array,  the first, third, etc. stringare used as the
+keys and the other strings are used as the values.
 )
 xitem(tt(zstyle -t) var(context) var(style) [ var(strings) ...])
 item(tt(zstyle -T) var(context) var(style) [ var(strings) ...])(
Index: Src/Modules/zutil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/zutil.c,v
retrieving revision 1.3
diff -u -r1.3 zutil.c
--- Src/Modules/zutil.c	2000/05/15 08:04:10	1.3
+++ Src/Modules/zutil.c	2000/05/22 09:29:31
@@ -279,7 +279,6 @@
     case 's': min = 3; max =  4; break;
     case 'b': min = 3; max =  3; break;
     case 'a': min = 3; max =  3; break;
-    case 'h': min = 3; max =  3; break;
     case 't': min = 2; max = -1; break;
     case 'T': min = 2; max = -1; break;
     case 'm': min = 3; max =  3; break;
@@ -384,7 +383,6 @@
 	}
 	break;
     case 'a':
-    case 'h':
 	{
 	    Stypat s;
 	    char **ret;
@@ -399,10 +397,7 @@
 		ret = zarrdup(&dummy);
 		val = 1;
 	    }
-	    if (args[0][1] == 'a')
-		setaparam(args[3], ret);
-	    else
-		sethparam(args[3], ret);
+	    setaparam(args[3], ret);
 
 	    return val;
 	}

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author