From: "Thorsten Dahlheimer" <tdahlheim@gmx.net>
To: <zsh-workers@sunsite.dk>
Subject: PATCH: Slightly improve printf %s
Date: Mon, 8 Aug 2005 20:21:28 +0200 [thread overview]
Message-ID: <024501c59c46$2ae19dc0$cc74fea9@pcdahl4201> (raw)
[-- Attachment #1: Type: text/plain, Size: 334 bytes --]
This change makes it possible to print strings containing NULs with
printf '%s', by sharing the code for the %b specifier.
After I made this change, the test suite uncovered a bug (which I
introduced) in the handling of %b (and now %s) when no argument is
left, so the patch includes a fix for that, too.
Regards,
Thorsten Dahlheimer
[-- Attachment #2: printf_s.patch --]
[-- Type: application/octet-stream, Size: 1024 bytes --]
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.143
diff -u -p -r1.143 builtin.c
--- Src/builtin.c 1 Aug 2005 22:20:36 -0000 1.143
+++ Src/builtin.c 8 Aug 2005 15:31:32 -0000
@@ -3752,14 +3752,18 @@ bin_print(char *name, char **args, Optio
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;
+ nnl = 0;
+ }
/* handle width/precision here and use fwrite so that
* nul characters can be output */
if (prec >= 0 && prec < l) l = prec;
next reply other threads:[~2005-08-08 18:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-08 18:21 Thorsten Dahlheimer [this message]
2005-08-08 23:09 ` Wayne Davison
2005-08-09 14:03 ` Thorsten Dahlheimer
2005-08-09 17:31 ` Wayne Davison
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='024501c59c46$2ae19dc0$cc74fea9@pcdahl4201' \
--to=tdahlheim@gmx.net \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).