<html><body><div>Hi Octo,<br><br>On Mon, Jan 31, 2011 at 05:40:06PM +0000, Lee Essen wrote:<br></div><div><div><blockquote type="cite"><div class="msg-quote"><div class="_stretch">
> Looking at the code for the curl plugin and then utils_match.c it just<br>
> does a strtod on the matched string which will only ever convert the<br>
> bit before the comma.<br>
<br>
that's right. Unfortunately, the behavior of strtod(3) depends on the<br>
locale setting, more precisely the LC_NUMERIC environment variable as<br>
described in locale(7).<br>
<br>
If it was possible to set the locale on a per-thread basis, we might be<br>
able to make this configurable for the user. I suspect locales can only<br>
be set on a per-process basis, but I don't know for sure.</div></div></blockquote><span> </span><br>I'm not convinced that the LC_NUMERIC setting is honored properly as far as the thousands_sep goes for strtod, at least on my Solaris box, or on an Ubuntu box.<br><br>I suspect a sensible approach would be to query the thousands_sep and then remove that from the string before the strtod (or strtoll etc)??<br><br><br><br>#include <stdio.h><br>#include <stdlib.h><br><br>int main(int argc, char *argv[]) {<br> char *ep = NULL;<br><br> double d = strtod(argv[1], &ep);<br> printf("Double is %f\n", d);<br><br>}<br><br>essele@core:~/dev/tmp$ ./go 123<br>Double is 123.000000<br>essele@core:~/dev/tmp$ ./go 123.45<br>Double is 123.450000<br>essele@core:~/dev/tmp$ ./go 1,234.56<br>Double is 1.000000<br>essele@core:~/dev/tmp$ locale -ck thousands_sep<br>LC_NUMERIC<br>thousands_sep=","<br><br><br>Regards,<br><br>Lee.<br><br><br><br><br></div></div></body></html>