zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: printf %b
Date: Thu, 04 Jan 2007 17:07:20 +0000	[thread overview]
Message-ID: <200701041707.l04H7KRg018280@news01.csr.com> (raw)
In-Reply-To: <20070104163200.GA4883@sc>

Stephane Chazelas wrote:
> POSIX says
> 
> printf '\123'
> and
> printf %b '\0123'
> 
> should output "S" (note that the two syntaxes are different!)
> 
> and
> 
> printf '\0123' should output <NL>3
> printf %b '\123' should output \123 (I think).

Thanks, I hadn't found that bit.  At least the really world is screwed
up, too.

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.171
diff -u -r1.171 builtin.c
--- Src/builtin.c	10 Dec 2006 23:27:03 -0000	1.171
+++ Src/builtin.c	4 Jan 2007 17:05:53 -0000
@@ -3490,7 +3490,7 @@
 	fmt = OPT_ARG(ops,'f');
     if (fmt)
 	fmt = getkeystring(fmt, &flen, OPT_ISSET(ops,'b') ? GETKEYS_BINDKEY :
-			   GETKEYS_PRINTF, &fmttrunc);
+			   GETKEYS_PRINTF_FMT, &fmttrunc);
 
     first = args;
     
@@ -3954,7 +3954,7 @@
 			b = getkeystring(metafy(curarg, curlen, META_USEHEAP),
 					 &l,
 					 OPT_ISSET(ops,'b') ? GETKEYS_BINDKEY :
-					 GETKEYS_PRINTF, &nnl);
+					 GETKEYS_PRINTF_ARG, &nnl);
 		    } else {
 			b = curarg;
 			l = curlen;
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.104
diff -u -r1.104 zsh.h
--- Src/zsh.h	4 Jan 2007 15:41:23 -0000	1.104
+++ Src/zsh.h	4 Jan 2007 17:05:55 -0000
@@ -1990,8 +1990,10 @@
  */
 /* echo builtin */
 #define GETKEYS_ECHO	(GETKEY_BACKSLASH_C)
-/* printf format string */
-#define GETKEYS_PRINTF	(GETKEY_BACKSLASH_C)
+/* printf format string:  \123 -> S, \0123 -> NL 3 */
+#define GETKEYS_PRINTF_FMT	(GETKEY_OCTAL_ESC|GETKEY_BACKSLASH_C)
+/* printf argument:  \123 -> \123, \0123 -> S */
+#define GETKEYS_PRINTF_ARG	(GETKEY_BACKSLASH_C)
 /* Full print without -e */
 #define GETKEYS_PRINT	(GETKEY_OCTAL_ESC|GETKEY_BACKSLASH_C|GETKEY_EMACS)
 /* bindkey */

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


      reply	other threads:[~2007-01-04 17:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-27 14:58 Stephane Chazelas
2007-01-04 15:36 ` Peter Stephenson
2007-01-04 16:32   ` Stephane Chazelas
2007-01-04 17:07     ` Peter Stephenson [this message]

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=200701041707.l04H7KRg018280@news01.csr.com \
    --to=pws@csr.com \
    --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).