diff options
Diffstat (limited to 'Src')
-rw-r--r-- | Src/Modules/files.c | 8 | ||||
-rw-r--r-- | Src/Modules/socket.c | 24 | ||||
-rw-r--r-- | Src/Modules/tcp.c | 42 | ||||
-rw-r--r-- | Src/Zle/zle_keymap.c | 6 | ||||
-rw-r--r-- | Src/Zle/zle_main.c | 2 | ||||
-rw-r--r-- | Src/zsh.h | 7 |
6 files changed, 38 insertions, 51 deletions
diff --git a/Src/Modules/files.c b/Src/Modules/files.c index 51f362631..82429a986 100644 --- a/Src/Modules/files.c +++ b/Src/Modules/files.c @@ -74,12 +74,8 @@ bin_mkdir(char *nam, char **args, Options ops, int func) umask(oumask); if(OPT_ISSET(ops,'m')) { - char *str = *args++, *ptr; + char *str = OPT_ARG(ops,'m'), *ptr; - if(!*args) { - zwarnnam(nam, "not enough arguments", NULL, 0); - return 1; - } mode = zstrtol(str, &ptr, 8); if(!*str || *ptr) { zwarnnam(nam, "invalid mode `%s'", str, 0); @@ -703,7 +699,7 @@ static struct builtin bintab[] = { BUILTIN("chgrp", 0, bin_chown, 2, -1, BIN_CHGRP, "Rs", NULL), BUILTIN("chown", 0, bin_chown, 2, -1, BIN_CHOWN, "Rs", NULL), BUILTIN("ln", 0, bin_ln, 1, -1, BIN_LN, LN_OPTS, NULL), - BUILTIN("mkdir", 0, bin_mkdir, 1, -1, 0, "pm", NULL), + BUILTIN("mkdir", 0, bin_mkdir, 1, -1, 0, "pm:", NULL), BUILTIN("mv", 0, bin_ln, 2, -1, BIN_MV, "fi", NULL), BUILTIN("rm", 0, bin_rm, 1, -1, 0, "dfirs", NULL), BUILTIN("rmdir", 0, bin_rmdir, 1, -1, 0, NULL, NULL), diff --git a/Src/Modules/socket.c b/Src/Modules/socket.c index 2b70eba6d..cca980845 100644 --- a/Src/Modules/socket.c +++ b/Src/Modules/socket.c @@ -62,7 +62,6 @@ bin_zsocket(char *nam, char **args, Options ops, int func) { int err=1, verbose=0, test=0, targetfd=0; SOCKLEN_T len; - char **dargs; struct sockaddr_un soun; int sfd; @@ -73,26 +72,23 @@ bin_zsocket(char *nam, char **args, Options ops, int func) test = 1; if (OPT_ISSET(ops,'d')) { - targetfd = atoi(args[0]); - dargs = args + 1; + targetfd = atoi(OPT_ARG(ops,'d')); if (!targetfd) { - zwarnnam(nam, "%s is an invalid argument to -d", args[0], 0); + zwarnnam(nam, "%s is an invalid argument to -d", + OPT_ARG(ops, 'd'), 0); return 1; } } - else - dargs = args; - if (OPT_ISSET(ops,'l')) { char *localfn; - if (!dargs[0]) { + if (!args[0]) { zwarnnam(nam, "-l requires an argument", NULL, 0); return 1; } - localfn = dargs[0]; + localfn = args[0]; sfd = socket(PF_UNIX, SOCK_STREAM, 0); @@ -139,12 +135,12 @@ bin_zsocket(char *nam, char **args, Options ops, int func) { int lfd, rfd; - if (!dargs[0]) { + if (!args[0]) { zwarnnam(nam, "-a requires an argument", NULL, 0); return 1; } - lfd = atoi(dargs[0]); + lfd = atoi(args[0]); if (!lfd) { zwarnnam(nam, "invalid numerical argument", NULL, 0); @@ -212,7 +208,7 @@ bin_zsocket(char *nam, char **args, Options ops, int func) } else { - if (!dargs[0]) { + if (!args[0]) { zwarnnam(nam, "zsocket requires an argument", NULL, 0); return 1; } @@ -225,7 +221,7 @@ bin_zsocket(char *nam, char **args, Options ops, int func) } soun.sun_family = AF_UNIX; - strncpy(soun.sun_path, dargs[0], UNIX_PATH_MAX); + strncpy(soun.sun_path, args[0], UNIX_PATH_MAX); if ((err = connect(sfd, (struct sockaddr *)&soun, sizeof(struct sockaddr_un)))) { zwarnnam(nam, "connection failed: %e", NULL, errno); @@ -251,7 +247,7 @@ bin_zsocket(char *nam, char **args, Options ops, int func) } static struct builtin bintab[] = { - BUILTIN("zsocket", 0, bin_zsocket, 0, 3, 0, "adltv", NULL), + BUILTIN("zsocket", 0, bin_zsocket, 0, 3, 0, "ad:ltv", NULL), }; /* The load/unload routines required by the zsh library interface */ diff --git a/Src/Modules/tcp.c b/Src/Modules/tcp.c index cc591f6eb..2f3d0424d 100644 --- a/Src/Modules/tcp.c +++ b/Src/Modules/tcp.c @@ -341,7 +341,7 @@ bin_ztcp(char *nam, char **args, Options ops, int func) { int herrno, err=1, destport, force=0, verbose=0, test=0, targetfd=0; SOCKLEN_T len; - char **addrp, *desthost, *localname, *remotename, **dargs; + char **addrp, *desthost, *localname, *remotename; struct hostent *zthost = NULL, *ztpeer = NULL; struct servent *srv; Tcp_session sess = NULL; @@ -356,26 +356,24 @@ bin_ztcp(char *nam, char **args, Options ops, int func) test = 1; if (OPT_ISSET(ops,'d')) { - targetfd = atoi(args[0]); - dargs = args + 1; + targetfd = atoi(OPT_ARG(ops,'d')); if (!targetfd) { - zwarnnam(nam, "%s is an invalid argument to -d", args[0], 0); + zwarnnam(nam, "%s is an invalid argument to -d", + OPT_ARG(ops,'d'), 0); return 1; } } - else - dargs = args; if (OPT_ISSET(ops,'c')) { - if (!dargs[0]) { + if (!args[0]) { tcp_cleanup(); } else { - targetfd = atoi(dargs[0]); + targetfd = atoi(args[0]); sess = zts_byfd(targetfd); if(!targetfd) { - zwarnnam(nam, "%s is an invalid argument to -c", dargs[0], 0); + zwarnnam(nam, "%s is an invalid argument to -c", args[0], 0); return 1; } @@ -391,7 +389,7 @@ bin_ztcp(char *nam, char **args, Options ops, int func) } else { - zwarnnam(nam, "fd %s not found in tcp table", dargs[0], 0); + zwarnnam(nam, "fd %s not found in tcp table", args[0], 0); return 1; } } @@ -399,16 +397,16 @@ bin_ztcp(char *nam, char **args, Options ops, int func) else if (OPT_ISSET(ops,'l')) { int lport = 0; - if (!dargs[0]) { + if (!args[0]) { zwarnnam(nam, "-l requires an argument", NULL, 0); return 1; } - srv = getservbyname(dargs[0], "tcp"); + srv = getservbyname(args[0], "tcp"); if (srv) lport = srv->s_port; else - lport = htons(atoi(dargs[0])); + lport = htons(atoi(args[0])); if (!lport) { zwarnnam(nam, "bad service name or port number", NULL, 0); return 1; } @@ -469,12 +467,12 @@ bin_ztcp(char *nam, char **args, Options ops, int func) { int lfd, rfd; - if (!dargs[0]) { + if (!args[0]) { zwarnnam(nam, "-a requires an argument", NULL, 0); return 1; } - lfd = atoi(dargs[0]); + lfd = atoi(args[0]); if (!lfd) { zwarnnam(nam, "invalid numerical argument", NULL, 0); @@ -483,7 +481,7 @@ bin_ztcp(char *nam, char **args, Options ops, int func) sess = zts_byfd(lfd); if (!sess) { - zwarnnam(nam, "fd %s is not registered as a tcp connection", dargs[0], 0); + zwarnnam(nam, "fd %s is not registered as a tcp connection", args[0], 0); return 1; } @@ -556,7 +554,7 @@ bin_ztcp(char *nam, char **args, Options ops, int func) } else { - if (!dargs[0]) { + if (!args[0]) { LinkNode node; for(node = firstnode(ztcp_sessions); node; incnode(node)) { @@ -601,19 +599,19 @@ bin_ztcp(char *nam, char **args, Options ops, int func) } return 0; } - else if (!dargs[1]) { + else if (!args[1]) { destport = htons(23); } else { - srv = getservbyname(dargs[1],"tcp"); + srv = getservbyname(args[1],"tcp"); if (srv) destport = srv->s_port; else - destport = htons(atoi(dargs[1])); + destport = htons(atoi(args[1])); } - desthost = ztrdup(dargs[0]); + desthost = ztrdup(args[0]); zthost = zsh_getipnodebyname(desthost, AF_INET, 0, &herrno); if (!zthost || errflag) { @@ -675,7 +673,7 @@ bin_ztcp(char *nam, char **args, Options ops, int func) } static struct builtin bintab[] = { - BUILTIN("ztcp", 0, bin_ztcp, 0, 3, 0, "acdflLtv", NULL), + BUILTIN("ztcp", 0, bin_ztcp, 0, 3, 0, "acd:flLtv", NULL), }; /* The load/unload routines required by the zsh library interface */ diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c index 3a06bb632..58e5e2175 100644 --- a/Src/Zle/zle_keymap.c +++ b/Src/Zle/zle_keymap.c @@ -656,11 +656,7 @@ bin_bindkey(char *name, char **argv, Options ops, int func) else if(OPT_ISSET(ops,'a')) kmname = "vicmd"; else if(OPT_ISSET(ops,'M')) { - kmname = *argv++; - if(!kmname) { - zwarnnam(name, "-M option requires a keymap argument", NULL, 0); - return 1; - } + kmname = OPT_ARG(ops,'M'); } else kmname = "main"; km = openkeymap(kmname); diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 8daf60085..047aa3d12 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1336,7 +1336,7 @@ zleaftertrap(Hookdef dummy, void *dat) } static struct builtin bintab[] = { - BUILTIN("bindkey", 0, bin_bindkey, 0, -1, 0, "evaMldDANmrsLRp", NULL), + BUILTIN("bindkey", 0, bin_bindkey, 0, -1, 0, "evaM:ldDANmrsLRp", NULL), BUILTIN("vared", 0, bin_vared, 1, 7, 0, NULL, NULL), BUILTIN("zle", 0, bin_zle, 0, -1, 0, "aAcCDFgGIKlLmMNRU", NULL), }; diff --git a/Src/zsh.h b/Src/zsh.h index 1733ce9bc..16558c3d3 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -955,10 +955,11 @@ struct funcwrap { /* Option was set as +X */ #define OPT_PLUS(ops,c) ((ops)->ind[c] & 2) /* - * Option was set any old how, maybe including an argument - * (cheap test when we don't care). + * Option was set any old how, maybe including an argument + * (cheap test when we don't care). Some bits of code + * expect this to be 1 or 0. */ -#define OPT_ISSET(ops,c) ((ops)->ind[c]) +#define OPT_ISSET(ops,c) ((ops)->ind[c] != 0) /* Option has an argument */ #define OPT_HASARG(ops,c) ((ops)->ind[c] > 3) /* The argument for the option; not safe if it doesn't have one */ |