Skip to content
Snippets Groups Projects
Commit 39600d93 authored by Simon McVittie's avatar Simon McVittie
Browse files

pv-wrap: Communicate timeouts to pv-adverb as locale-independent ASCII

These arguments take a G_OPTION_ARG_DOUBLE, which is documented to be
parsed using either the user's locale or the C locale (in fact they
use g_strtod(), which parses it both ways and takes the longer match).
The locale matters in locales like de_DE that use a decimal comma
instead of a decimal point: we can always parse 2.000000 in the C
locale, but we can only parse 2,000000 if we are in a correctly-set-up
locale that uses the decimal comma.

If we needed to generate new locale files inside the container, then
pv-adverb needs to be able to parse its command-line before we have
generated those locale files. This means that
--terminate-idle-timeout=2,000000 won't work reliably, so we need to
use the C locale format, --terminate-idle-timeout=2.000000.

Using g_ascii_dtostr() has the side benefit that it uses the shortest
possible representation that does not lose precision; in the common case
that the timeout is an integer number of seconds, we'll just print it
as an integer.

Helps: https://github.com/ValveSoftware/steam-runtime/issues/381


Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent 027f908a
No related branches found
No related tags found
1 merge request!270pv-wrap: Communicate timeouts to pv-adverb as locale-independent ASCII
Pipeline #10307 passed
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment