Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[RFC PATCH] Allow grouping of thousands in format string
- X-seq: zsh-workers 34841
- From: Øystein Walle <oystwa@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [RFC PATCH] Allow grouping of thousands in format string
- Date: Fri, 3 Apr 2015 15:52:36 +0200
- Cc: Øystein Walle <oystwa@xxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=5tvtwHcrmH1j6tkQt8X9ydAvmuTAWNIkEabpqUuHtaU=; b=ubgb6EphGLyHaN1JXHqzkxrSSShbDn2bA0b3tMcB3LqELSSpCyOvRFo5iHqbVlAsCu 9bXWU4ExxSLvbUyjsZk4/GvqKeL8ZY5pOLXmSOORg1rkslFnumIMmijjgkq/om1kC3t2 M3esKwx/q6OO4sm7XLYqpGEKGCYDwD1OdwpuJuu1Fc0Kq+JaFRi+s1cWZfevJtFChQ6j XTiqxylbHgPBx9ir6NmaZ8kpcYeDrpx9R6BH7wifjN1HcXiNhKcvVObbGQ+Hb1/oVWSt cmBV7dzyjnbpypt1Xvw0RirqBzRyRXxy8zBv/H63V6enfXYGxV7ofW6dI+XmEwSI1JQH YXJw==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author