about summary refs log tree commit diff
path: root/Src/Zle/zle_keymap.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2002-08-27 21:10:30 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2002-08-27 21:10:30 +0000
commit9634760d5eae4e8618e4b9ed9752d7305b3695a9 (patch)
treefc717bec9a623d6e80f2c4544cec14b8b8eb07da /Src/Zle/zle_keymap.c
parent043c302261dfee52e54e9a6c42b4ebcc2f7ccd33 (diff)
downloadzsh-9634760d5eae4e8618e4b9ed9752d7305b3695a9.tar.gz
zsh-9634760d5eae4e8618e4b9ed9752d7305b3695a9.tar.xz
zsh-9634760d5eae4e8618e4b9ed9752d7305b3695a9.zip
17582: Improved option argument handling.
unposted: Updated version to 4.1.0-dev-6 because of interface change.
Diffstat (limited to 'Src/Zle/zle_keymap.c')
-rw-r--r--Src/Zle/zle_keymap.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index 9fd5a9197..c36657697 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -604,12 +604,12 @@ keyisprefix(Keymap km, char *seq)
 
 /**/
 int
-bin_bindkey(char *name, char **argv, char *ops, int func)
+bin_bindkey(char *name, char **argv, Options ops, int func)
 {
     static struct opn {
 	char o;
 	char selp;
-	int (*func) _((char *, char *, Keymap, char **, char *, char));
+	int (*func) _((char *, char *, Keymap, char **, Options, char));
 	int min, max;
     } const opns[] = {
 	{ 'l', 0, bin_bindkey_lsmaps, 0,  0 },
@@ -628,15 +628,16 @@ bin_bindkey(char *name, char **argv, char *ops, int func)
     int n;
 
     /* select operation and ensure no clashing arguments */
-    for(op = opns; op->o && !ops[STOUC(op->o)]; op++) ;
+    for(op = opns; op->o && !OPT_ISSET(ops,STOUC(op->o)); op++) ;
     if(op->o)
 	for(opp = op; (++opp)->o; )
-	    if(ops[STOUC(opp->o)]) {
+	    if(OPT_ISSET(ops,STOUC(opp->o))) {
 		zwarnnam(name, "incompatible operation selection options",
 		    NULL, 0);
 		return 1;
 	    }
-    n = ops['e'] + ops['v'] + ops['a'] + ops['M'];
+    n = OPT_ISSET(ops,'e') + OPT_ISSET(ops,'v') + 
+	OPT_ISSET(ops,'a') + OPT_ISSET(ops,'M');
     if(!op->selp && n) {
 	zwarnnam(name, "keymap cannot be selected with -%c", NULL, op->o);
 	return 1;
@@ -648,13 +649,13 @@ bin_bindkey(char *name, char **argv, char *ops, int func)
 
     /* keymap selection */
     if(op->selp) {
-	if(ops['e'])
+	if(OPT_ISSET(ops,'e'))
 	    kmname = "emacs";
-	else if(ops['v'])
+	else if(OPT_ISSET(ops,'v'))
 	    kmname = "viins";
-	else if(ops['a'])
+	else if(OPT_ISSET(ops,'a'))
 	    kmname = "vicmd";
-	else if(ops['M']) {
+	else if(OPT_ISSET(ops,'M')) {
 	    kmname = *argv++;
 	    if(!kmname) {
 		zwarnnam(name, "-M option requires a keymap argument", NULL, 0);
@@ -667,7 +668,7 @@ bin_bindkey(char *name, char **argv, char *ops, int func)
 	    zwarnnam(name, "no such keymap `%s'", kmname, 0);
 	    return 1;
 	}
-	if(ops['e'] || ops['v'])
+	if(OPT_ISSET(ops,'e') || OPT_ISSET(ops,'v'))
 	    linkkeymap(km, "main", 0);
     } else {
 	kmname = NULL;
@@ -676,7 +677,7 @@ bin_bindkey(char *name, char **argv, char *ops, int func)
 
     /* listing is a special case */
     if(!op->o && (!argv[0] || !argv[1])) {
-	if(ops['e'] || ops['v'])
+	if(OPT_ISSET(ops,'e') || OPT_ISSET(ops,'v'))
 	    return 0;
 	return bin_bindkey_list(name, kmname, km, argv, ops, op->o);
     }
@@ -699,9 +700,9 @@ bin_bindkey(char *name, char **argv, char *ops, int func)
 
 /**/
 static int
-bin_bindkey_lsmaps(char *name, char *kmname, Keymap km, char **argv, char *ops, char func)
+bin_bindkey_lsmaps(char *name, char *kmname, Keymap km, char **argv, Options ops, char func)
 {
-    scanhashtable(keymapnamtab, 1, 0, 0, scanlistmaps, ops['L']);
+    scanhashtable(keymapnamtab, 1, 0, 0, scanlistmaps, OPT_ISSET(ops,'L'));
     return 0;
 }
 
@@ -725,7 +726,7 @@ scanlistmaps(HashNode hn, int list)
 
 /**/
 static int
-bin_bindkey_delall(char *name, char *kmname, Keymap km, char **argv, char *ops, char func)
+bin_bindkey_delall(char *name, char *kmname, Keymap km, char **argv, Options ops, char func)
 {
     keymapnamtab->emptytable(keymapnamtab);
     default_bindings();
@@ -736,7 +737,7 @@ bin_bindkey_delall(char *name, char *kmname, Keymap km, char **argv, char *ops,
 
 /**/
 static int
-bin_bindkey_del(char *name, char *kmname, Keymap km, char **argv, char *ops, char func)
+bin_bindkey_del(char *name, char *kmname, Keymap km, char **argv, Options ops, char func)
 {
     int ret = 0;
 
@@ -755,7 +756,7 @@ bin_bindkey_del(char *name, char *kmname, Keymap km, char **argv, char *ops, cha
 
 /**/
 static int
-bin_bindkey_link(char *name, char *kmname, Keymap km, char **argv, char *ops, char func)
+bin_bindkey_link(char *name, char *kmname, Keymap km, char **argv, Options ops, char func)
 {
     km = openkeymap(argv[0]);
     if(!km) {
@@ -772,7 +773,7 @@ bin_bindkey_link(char *name, char *kmname, Keymap km, char **argv, char *ops, ch
 
 /**/
 static int
-bin_bindkey_new(char *name, char *kmname, Keymap km, char **argv, char *ops, char func)
+bin_bindkey_new(char *name, char *kmname, Keymap km, char **argv, Options ops, char func)
 {
     KeymapName kmn = (KeymapName) keymapnamtab->getnode(keymapnamtab, argv[0]);
 
@@ -800,7 +801,7 @@ bin_bindkey_new(char *name, char *kmname, Keymap km, char **argv, char *ops, cha
 
 /**/
 static int
-bin_bindkey_meta(char *name, char *kmname, Keymap km, char **argv, char *ops, char func)
+bin_bindkey_meta(char *name, char *kmname, Keymap km, char **argv, Options ops, char func)
 {
     char m[3], *str;
     int i;
@@ -830,7 +831,7 @@ bin_bindkey_meta(char *name, char *kmname, Keymap km, char **argv, char *ops, ch
 
 /**/
 static int
-bin_bindkey_bind(char *name, char *kmname, Keymap km, char **argv, char *ops, char func)
+bin_bindkey_bind(char *name, char *kmname, Keymap km, char **argv, Options ops, char func)
 {
     int ret = 0;
 
@@ -847,7 +848,7 @@ bin_bindkey_bind(char *name, char *kmname, Keymap km, char **argv, char *ops, ch
 	zwarnnam(name, "keymap `%s' is protected", kmname, 0);
 	return 1;
     }
-    if (func == 'r' && ops['p']) {
+    if (func == 'r' && OPT_ISSET(ops,'p')) {
 	char *useq, *bseq;
 	int len;
 	struct remprefstate rps;
@@ -878,7 +879,7 @@ bin_bindkey_bind(char *name, char *kmname, Keymap km, char **argv, char *ops, ch
 	}
 	bseq = getkeystring(useq, &len, 2, NULL);
 	seq = metafy(bseq, len, META_USEHEAP);
-	if(ops['R']) {
+	if(OPT_ISSET(ops,'R')) {
 	    int first, last;
 	    char m[3];
 
@@ -924,13 +925,13 @@ scanremoveprefix(char *seq, Thingy bind, char *str, void *magic)
 
 /**/
 static int
-bin_bindkey_list(char *name, char *kmname, Keymap km, char **argv, char *ops, char func)
+bin_bindkey_list(char *name, char *kmname, Keymap km, char **argv, Options ops, char func)
 {
     struct bindstate bs;
 
-    bs.flags = ops['L'] ? BS_LIST : 0;
+    bs.flags = OPT_ISSET(ops,'L') ? BS_LIST : 0;
     bs.kmname = kmname;
-    if(argv[0] && !ops['p']) {
+    if(argv[0] && !OPT_ISSET(ops,'p')) {
 	int len;
 	char *seq;
 
@@ -944,7 +945,7 @@ bin_bindkey_list(char *name, char *kmname, Keymap km, char **argv, char *ops, ch
 	bindlistout(&bs);
     } else {
 	/* empty prefix is equivalent to no prefix */
-	if (ops['p'] && (!argv[0] || argv[0][0])) {
+	if (OPT_ISSET(ops,'p') && (!argv[0] || argv[0][0])) {
 	    if (!argv[0]) {
 		zwarnnam(name, "option -p requires a prefix string", NULL, 0);
 		return 1;