about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2001-10-23 11:22:33 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2001-10-23 11:22:33 +0000
commitc1441714b523d9a390165846632dc18ea10ba91b (patch)
tree03692c52da81708386d7358f5dcb67826c2a4613
parentacd69a7ba3eaafe44799d78c49eeeaefb49baa8d (diff)
downloadzsh-c1441714b523d9a390165846632dc18ea10ba91b.tar.gz
zsh-c1441714b523d9a390165846632dc18ea10ba91b.tar.xz
zsh-c1441714b523d9a390165846632dc18ea10ba91b.zip
zero %n value when reusing printf format (16122)
-rw-r--r--ChangeLog5
-rw-r--r--Src/builtin.c3
-rw-r--r--Test/B03print.ztst5
3 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 4ecd18b12..afcd12e38 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-10-23  Oliver Kiddle  <opk@zsh.org>
+
+	* 16122: Src/builtin.c, Test/B03print.ztst: only count value
+	returned by %n in printf since last format reuse
+
 2001-10-22  Peter Stephenson  <pws@csr.com>
 
 	* 16033: Pavel Roskin <proski@gnu.org>:
diff --git a/Src/builtin.c b/Src/builtin.c
index 038e1a199..1d8195835 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2897,7 +2897,7 @@ bin_print(char *name, char **args, char *ops, int func)
     int flags[5], *len;
     char *start, *endptr, *c, *d, *flag, spec[11], *fmt = NULL;
     char **first, *curarg, *flagch = "0+- #", save, nullstr = '\0';
-    zlong count = 0;
+    zlong count;
     FILE *fout = stdout;
 
     mnumber mnumval;
@@ -3096,6 +3096,7 @@ bin_print(char *name, char **args, char *ops, int func)
     /* printf style output */
     *spec='%';
     do {
+    	count = 0;
     	if (maxarg) {
 	    first += maxarg;
 	    argc -= maxarg;
diff --git a/Test/B03print.ztst b/Test/B03print.ztst
index 3968faec3..1aa6d2051 100644
--- a/Test/B03print.ztst
+++ b/Test/B03print.ztst
@@ -144,6 +144,11 @@
 >two	b:0x2%
 >three	c:0x3%
 
+ printf '%d%n' 123 val val val > /dev/null
+ printf '%d\n' val
+0:%n count zeroed on format reuse
+>1
+
 # this should fill spec string with '%0+- #*.*d\0' - 11 characters
  printf '%1$0+- #-08.5dx\n' 123
 0:maximal length format specification