diff options
author | Wayne Davison <wayned@users.sourceforge.net> | 2005-08-10 07:45:17 +0000 |
---|---|---|
committer | Wayne Davison <wayned@users.sourceforge.net> | 2005-08-10 07:45:17 +0000 |
commit | b97ff864af803eac1992b660a102f58953b0fe51 (patch) | |
tree | cfafbd7bd06ece46879a4ca33bc61698e02751b0 | |
parent | c73dd460190ca602114503d8dea3171165ff099e (diff) | |
download | zsh-b97ff864af803eac1992b660a102f58953b0fe51.tar.gz zsh-b97ff864af803eac1992b660a102f58953b0fe51.tar.xz zsh-b97ff864af803eac1992b660a102f58953b0fe51.zip |
Make printf %s handle an embedded null (21579).
-rw-r--r-- | Src/builtin.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Src/builtin.c b/Src/builtin.c index 811d02506..2df342533 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -3745,21 +3745,24 @@ bin_print(char *name, char **args, Options ops, int func) d[1] = '\0'; switch (*d = *c) { case 'c': - if (curarg) { + if (curarg) intval = *curarg; - } else + else intval = 0; print_val(intval); break; case 's': - stringval = curarg ? curarg : &nullstr; - print_val(stringval); - break; case 'b': if (curarg) { + char *b; int l; - char *b = getkeystring(metafy(curarg, curlen, META_USEHEAP), &l, - OPT_ISSET(ops,'b') ? 2 : 0, &nnl); + if (*c == 'b') { + b = getkeystring(metafy(curarg, curlen, META_USEHEAP), &l, + OPT_ISSET(ops,'b') ? 2 : 0, &nnl); + } else { + b = curarg; + l = curlen; + } /* handle width/precision here and use fwrite so that * nul characters can be output */ if (prec >= 0 && prec < l) l = prec; |