Ethereal-dev: [PATCH] Re: [Ethereal-dev] Problem with parsing float values on some machines

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: "Lars Ruoff" <lars.ruoff@xxxxxxxxxxxxxxxxxx>
Date: Tue, 27 Jan 2004 14:48:26 +0100
I confirm that the problem is due to locale settings on Win98SE.
(Apprently independent of locale settings on Win2000.)

Here is a patch that introduces a new global function to gtk_stat_util.h/.c
(right place?)
to compare two string values representing floats (works like strcmp).
However the function uses possibly heavy string processing and needs
refinement for cases of scientific notation.
Will it be worth the effort? Perhaps we can use #ifdefs to check if
OS=WinOT?
If you consider the function worth of being checked-in, i will do the
patches to the appropriate portions of code to use this function in column
sorting.


> On Mon, Jan 26, 2004 at 09:25:56AM +0100, Lars Ruoff wrote:
> > The sort column feature for float values in rtp_analysis didnt work
> > correctly.
> > After investigation i found that this was due to atof() returning always
> > zero.
> > I changed the code to use sscanf("%f"), like it is done in other places
that
> > use column sorting on floats. But didnt work either.
> > I then noticed that the problem occurs in those other places too.
> > (example: LDAP service response time for the c06-ldapv3-app-r1.pcap
sample
> > capture, then sort on "Min SRT")
> > I suspect this to be a locale issue (e.g. dot vs comma notation for
> > separating the decimal fraction) ??
>
> Quite possibly, although as the column is printed with "%f", I'd expect
> the locale issues to cancel out (i.e., in locales with "." as the
> decimal separator, I'd expect, for example, 1/2 to be g_snprintf'ed as
> ".5" and ".5" to be sscanf'ed or atof'ed into 1/2, and in locales with
> "," as the decimal separator, I'd expect 1/2 to go to ",5" and ",5" to
> become 1/2).
>
> Perhaps "g_snprintf()" isn't obeying the locale settings?
>
> > tests were carried out on
> > Win2000 SP2 (french) - ok
> > Win98SE (german)     - failed!
>
> If by "french" and "german" you mean you've selected those locales, I'd
> expect them to succeed or fail in the same way, if it's purely a local
> issue - folks on both sides of the Rhine use ",", n'est ce pas/nicht
> war?
>
> This might be a Windows OT vs.  Windows NT issue.  We appear *not* to
> use our private "snprintf()" on Windows, presumably meaning we use a
> version that comes with MSVC++'s C library, at least when building with
> "nmake"...
>
> > both compiled with msvc6 from cvs snapshot 2004-01-24.
>
> ...which you were doing.
>
> You might want to experiment with having the sort code copy the strings,
> replace the decimal separator that's displayed with the other one, and
> try converting that with "atof()" or "sscanf()", and see if that fixes
> the problem.  (Also, is the decimal separator being displayed the right
> one for the locale?)

Attachment: gtk_stat_util.c.diff
Description: Binary data

Attachment: gtk_stat_util.h.diff
Description: Binary data