[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with "." and ","

From: Eric Blake
Subject: Re: Problem with "." and ","
Date: Fri, 15 Mar 2019 09:09:18 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1

On 3/15/19 5:45 AM, Michal wrote:
> Hi,
> I terrible sorry if I'm wasting you time, but probably I found a bug. In
> example like this:
>  find /home/certget/ssl/example.pem -mtime -0,1
> This will work on server with locales changed to "pl_PL.UTF-8" and on
> servers with "en_US.UTF-8" I need to use "-mtime -0.1". It's very
> irritating when I need to check if this same script works on every server.

Not a bug, but by design - the behavior of strtod() is locale-dependent.
In locales where ',' is treated as a decimal point (such as
pl_PL.UTF-8), strtod("0,1") returns 0.1 (the value 1/10); in locales
where '.' is decimal point (such as en_US.UTF-8), it returns 0 with ",1"
as trailing garbage.

> Is it possible to unify this and use for example always ".".

strtod() always parses "." as a decimal separator regardless of what
other characters it might ALSO parse depending on locale.  Beyond that,
it is your responsibility to be aware of what locale your script is using.

Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]