about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2011-01-06 16:49:25 +0000
committerBart Schaefer <barts@users.sourceforge.net>2011-01-06 16:49:25 +0000
commit87d6527628583c355883cc997d54d337abae2a7a (patch)
treea453aa43faf4fe7d2f24d0fc60657200ad1defe3 /Src
parentdd0ad1ac2310853e3d4963c5715de6a9c058479f (diff)
downloadzsh-87d6527628583c355883cc997d54d337abae2a7a.tar.gz
zsh-87d6527628583c355883cc997d54d337abae2a7a.tar.xz
zsh-87d6527628583c355883cc997d54d337abae2a7a.zip
28578: fix handling of numeric escapes that expand to "%" in printf
format strings, so they are not treated as format introducers.
Diffstat (limited to 'Src')
-rw-r--r--Src/utils.c3
-rw-r--r--Src/zsh.h11
2 files changed, 10 insertions, 4 deletions
diff --git a/Src/utils.c b/Src/utils.c
index a1cac2537..a4cd67812 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -1,4 +1,3 @@
-
 /*
  * utils.c - miscellaneous utilities
  *
@@ -5523,6 +5522,8 @@ getkeystring(char *s, int *len, int how, int *misc)
 		    }
 		    *t++ = zstrtol(s + (*s == 'x'), &s,
 				   (*s == 'x') ? 16 : 8);
+		    if ((how & GETKEY_PRINTF_PERCENT) && t[-1] == '%')
+		        *t++ = '%';
 		    if (svchar) {
 			u[3] = svchar;
 			svchar = '\0';
diff --git a/Src/zsh.h b/Src/zsh.h
index 6dc918c09..6d8ac0353 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -2492,7 +2492,11 @@ enum {
      * Yes, I know that doesn't seem to make much sense.
      * It's for use in completion, comprenez?
      */
-    GETKEY_UPDATE_OFFSET = (1 << 7)
+    GETKEY_UPDATE_OFFSET = (1 << 7),
+    /*
+     * When replacing numeric escapes for printf format strings, % -> %%
+     */
+    GETKEY_PRINTF_PERCENT = (1 << 8)
 };
 
 /*
@@ -2501,8 +2505,9 @@ enum {
  */
 /* echo builtin */
 #define GETKEYS_ECHO	(GETKEY_BACKSLASH_C)
-/* printf format string:  \123 -> S, \0123 -> NL 3 */
-#define GETKEYS_PRINTF_FMT	(GETKEY_OCTAL_ESC|GETKEY_BACKSLASH_C)
+/* printf format string:  \123 -> S, \0123 -> NL 3, \045 -> %% */
+#define GETKEYS_PRINTF_FMT	\
+        (GETKEY_OCTAL_ESC|GETKEY_BACKSLASH_C|GETKEY_PRINTF_PERCENT)
 /* printf argument:  \123 -> \123, \0123 -> S */
 #define GETKEYS_PRINTF_ARG	(GETKEY_BACKSLASH_C)
 /* Full print without -e */