From 46a163bd348f462e11cf4bc326b17735a93b9980 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 4 Jan 2007 17:24:01 +0000 Subject: 23088: printf formats and arguments need different octal escape sequences --- ChangeLog | 3 +++ Src/builtin.c | 4 ++-- Src/zsh.h | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1ae2b45c6..cf744ba67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2007-01-04 Peter Stephenson + * 23088: Src/builtin.c, Src/zsh.h: Stephane says printf + formats and arguments should actually be escaped differently. + * 20386: Src/zsh.h, Test/B03print.ztst: printf should handle octal escapes in the '\0NNN' form. diff --git a/Src/builtin.c b/Src/builtin.c index d756b28bb..8e579d24e 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -3490,7 +3490,7 @@ bin_print(char *name, char **args, Options ops, int func) 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 @@ bin_print(char *name, char **args, Options ops, int func) 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; diff --git a/Src/zsh.h b/Src/zsh.h index 48f50e6a1..752587c57 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -1990,8 +1990,10 @@ enum { */ /* 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 */ -- cgit 1.4.1