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

Re: [libvirt] [PATCH] json: fix interface locale dependency



On 08/06/2012 04:35 PM, Daniel P. Berrange wrote:
> On Mon, Aug 06, 2012 at 03:59:42PM +0200, Martin Kletzander wrote:
>> On 08/06/2012 02:52 PM, Eric Blake wrote:
>>> On 08/06/2012 06:24 AM, Daniel P. Berrange wrote:
>>>> GLib has a g_ascii_dtostr() which forces uses of '.' as separator. Since
>>>> GLib is LGPLv2+ licensed, we can just copy their impl, which actually
>>>> uses GLibc's uselocale() if possible, otherwise has a fallback impl.
>>>
>>> gnulib also has a module 'ftoastr' for printing an unambiguous
>>> representation of floating point (one problem with the default precision
>>> of %lf and friends is that it rounds, so more than one floating point
>>> value will result in the same ambiguous output string), but alas that
>>> module is GPL at the moment, and I'm not sure whether it has a way to
>>> force the decimal point issue.
>>>
>>
>> I was going through the code of both of these and thanks ftoastr is
>> under GPL, because I didn't quite understand it. Looking at the
>> g_ascii_dtostr I've found that what is being done there and it amused me
>> a bit. After couple of checks, conditions and whatnot, it get's the
>> current decimal_point string from the localeconv() and replaces it with
>> a '.', long story short, the only difference is that instead of
>> strcpy(), there is memmove() used.
>>
>> Not that I don't want to change the code, this is only some info I've
>> found and I don't know whether to change the code and if, then to what
>> to change it.
> 
> FYI looking at the GIT history, the glib fallback code is from 2001 and
> the new uselocale() based code from 2011, and has greater speed than
> the old code.
> 
> So I still think we should just copy what glib has into a src/util/util.c
> 

I missed that non-fallback code because I cloned a wrong repo, sorry.
I'll send next version (that will probably be still more like a RFC) later.

Martin


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