zsh-workers
 help / color / mirror / code / Atom feed
* [RFC PATCH] Allow grouping of thousands in format string
@ 2015-04-03 13:52 Øystein Walle
  2015-04-04 11:11 ` Oliver Kiddle
  0 siblings, 1 reply; 3+ messages in thread
From: Øystein Walle @ 2015-04-03 13:52 UTC (permalink / raw)
  To: zsh-workers; +Cc: Øystein Walle

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-05  6:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-03 13:52 [RFC PATCH] Allow grouping of thousands in format string Øystein Walle
2015-04-04 11:11 ` Oliver Kiddle
2015-04-05  6:19   ` Jun T.

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).