zsh-users
 help / color / mirror / code / Atom feed
* printf shortcomings
@ 2011-09-27  7:09 Micah Elliott
  2011-09-27  7:51 ` Oliver Kiddle
  0 siblings, 1 reply; 2+ messages in thread
From: Micah Elliott @ 2011-09-27  7:09 UTC (permalink / raw)
  To: Zsh Users

I was looking at `printf(3)` and also this lovely reference
(http://www.pixelbeat.org/programming/gcc/format_specs.html) and
noticed that the "locale thousands grouping" flag (') doesn't appear
to be supported by Zsh's builtin printf. I don't have an important
need for this today, but noticing that it could be pretty useful.

  % printf "%'i" 3210384
  print: %': invalid directive
  % /usr/bin/printf "%'i" 3210384
  3,210,384%

Is the prescription to just fall back to the system printf when
certain complex formats are needed? Or are there plans to implement
(most) everything from the system version? I see LC_NUMERIC
(zshparam(1)) hinting at the "thousands separator" but I'm not seeing
where that gets used.

--
twitter:@MicahElliott  |  email:mde@MicahElliott.com  |  http://membean.com
Remember your words on exam day with Membean!


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

* Re: printf shortcomings
  2011-09-27  7:09 printf shortcomings Micah Elliott
@ 2011-09-27  7:51 ` Oliver Kiddle
  0 siblings, 0 replies; 2+ messages in thread
From: Oliver Kiddle @ 2011-09-27  7:51 UTC (permalink / raw)
  To: Zsh Users

Micah Elliott wrote:
> I was looking at `printf(3)` and also this lovely reference
> (http://www.pixelbeat.org/programming/gcc/format_specs.html) and
> noticed that the "locale thousands grouping" flag (') doesn't appear
> to be supported by Zsh's builtin printf. I don't have an important
> need for this today, but noticing that it could be pretty useful.

That is a reference for the GNU libc printf. The thousand grouping flag
is by no means standard. Zsh's printf largely uses the system printf
underneath, so it isn't completely trivial to support GNU specific flags
portably (keep in mind that lots of flags can be combined so it isn't
just a case of sticking a character in before every third digit). We
could pass through the ' so that it only works where supported by the
system printf but we'd need to be sure it doesn't have any nasty side
effects on some system.

If you do zmodload zsh/langinfo, you can get the thousand separator from
$langinfo[THOUSEP] so if you ever do need the feature, it may be
possible to implement it using that.

Oliver


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

end of thread, other threads:[~2011-09-27  7:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-27  7:09 printf shortcomings Micah Elliott
2011-09-27  7:51 ` Oliver Kiddle

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