zsh-workers
 help / color / mirror / code / Atom feed
From: "Øystein Walle" <oystwa@gmail.com>
To: zsh-workers@zsh.org
Cc: "Øystein Walle" <oystwa@gmail.com>
Subject: [RFC PATCH] Allow grouping of thousands in format string
Date: Fri,  3 Apr 2015 15:52:36 +0200	[thread overview]
Message-ID: <1428069156-29982-1-git-send-email-oystwa@gmail.com> (raw)

Putting an apostrophe before i, d, u, f, F, g or G is specified in POSIX
albeit noted as an extension to ISO C.
---

Bash handles this this and from what I can tell implements it much in the same
way so that stuff like %'s is passed straight on to the system's printf().
However POSIX also says that using the grouping specifier with other flags is
undefined. It works just fine on the limited range of systems I've tested it on
(all GNU).

If desired I could set a flag and then handle it further on by checking that
type == 2 or type == 3 or something like that, but that needs some rearranging.

If the idea behind the patch itself is undesired then I think the documentation
for zsh's printf should be updated.

 Src/builtin.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Src/builtin.c b/Src/builtin.c
index 614b17d..225c034 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3735,7 +3735,7 @@ bin_print(char *name, char **args, Options ops, int func)
     int nnl = 0, fmttrunc = 0, ret = 0, maxarg = 0, nc = 0;
     int flags[5], *len;
     char *start, *endptr, *c, *d, *flag, *buf = NULL, spec[13], *fmt = NULL;
-    char **first, **argp, *curarg, *flagch = "0+- #", save = '\0', nullstr = '\0';
+    char **first, **argp, *curarg, *flagch = "'0+- #", save = '\0', nullstr = '\0';
     size_t rcount, count = 0;
 #ifdef HAVE_OPEN_MEMSTREAM
     size_t mcount;
@@ -4312,8 +4312,8 @@ bin_print(char *name, char **args, Options ops, int func)
 		if (prec >= 0) *d++ = '.', *d++ = '*';
 	    }
 
-	    /* ignore any size modifier */
-	    if (*c == 'l' || *c == 'L' || *c == 'h') c++;
+	    /* ignore any size modifier and grouping specifier */
+	    if (*c == 'l' || *c == 'L' || *c == 'h' || *c == '\'') c++;
 
 	    if (!curarg && *argp) {
 		curarg = *argp;
-- 
2.2.0


             reply	other threads:[~2015-04-03 13:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-03 13:52 Øystein Walle [this message]
2015-04-04 11:11 ` Oliver Kiddle
2015-04-05  6:19   ` Jun T.

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=1428069156-29982-1-git-send-email-oystwa@gmail.com \
    --to=oystwa@gmail.com \
    --cc=zsh-workers@zsh.org \
    /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).