zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-workers@sunsite.dk
Subject: PATCH: %n value with format reuse
Date: Tue, 23 Oct 2001 12:09:46 +0100	[thread overview]
Message-ID: <3BD54FFA.1990F3A4@yahoo.co.uk> (raw)
In-Reply-To: <3BC1802A.1F0FF490@yahoo.co.uk>

I wrote:
> 
> Any views on whether the count (as returned with %n) should be zeroed
> when reusing the format string?

At the time I wrote that, I hadn't realised that ksh supports %n because
it is not documented. Anyway, ksh does restart the count at zero when
reusing the format strings so for consistency, zsh should do the same.

Oliver

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.60
diff -u -r1.60 builtin.c
--- Src/builtin.c       2001/10/18 14:22:21     1.60
+++ Src/builtin.c       2001/10/23 11:07:55
@@ -2897,7 +2897,7 @@
     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 @@
     /* printf style output */
     *spec='%';
     do {
+       count = 0;
        if (maxarg) {
            first += maxarg;
            argc -= maxarg;
Index: Test/B03print.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/B03print.ztst,v
retrieving revision 1.3
diff -u -r1.3 B03print.ztst
--- Test/B03print.ztst  2001/10/18 14:22:21     1.3
+++ Test/B03print.ztst  2001/10/23 11:07:55
@@ -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


      reply	other threads:[~2001-10-23 11:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-08 10:30 PATCH: print -f Oliver Kiddle
2001-10-23 11:09 ` Oliver Kiddle [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=3BD54FFA.1990F3A4@yahoo.co.uk \
    --to=okiddle@yahoo.co.uk \
    --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).