Re: Gtk+ print support - request for feedback
- From: Alexander Larsson <alexl redhat com>
- To: Michael Sweet <mike easysw com>
- Cc: gtk-devel-list gnome org, Morten Welinder <mortenw gnome org>
- Subject: Re: Gtk+ print support - request for feedback
- Date: Mon, 06 Mar 2006 16:22:26 +0100
On Mon, 2006-03-06 at 10:03 -0500, Michael Sweet wrote:
> > The unfortunate effect is that sscanf is not going to be useful
> > for a library. Unless you are willing to fork() but that comes
> > with its own set of problems.
>
> Well, fuck, so much for the CUPS 1.2 beta release today...
This is one of the few really major warts in the POSIX api imho.
> I'll make sure we reduce our use of setlocale() to query-only and
> add all sorts of wrapper crap to "fix" things for non-POSIX locales
> as needed. One of the big new things for CUPS 1.2 is thread-safety,
> so this is a show-stopper... :(
>
> FWIW, I filed this issue as STR #1463, accessible at:
>
> http://www.cups.org/str.php?L1463
>
> Please feel free to post suggestions, code, etc. that we can use.
I'd recommend going the glib way of just reading what the current locale
uses for decimal separator and manually switching between that and ".".
Actually doing the string to float conversion yourself is extremely
complicated and easy to get wrong.
Also, when testing this, make sure you test locales that have a
multi-byte decimal separator string. (Some farsi local has this if I
remember correctly.)
If you don't want to use a strtod() approach you might be able to keep
using sscanf if you create a general string-rewrite function that
converts "." to localeconv()->decimal_point. Of course, that assumes
that all uses of '.' in the string are part of a number and that there
are no cases of decimal_point in the original string next to a digit.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Alexander Larsson Red Hat, Inc
alexl redhat com alla lysator liu se
He's a superhumanly strong umbrella-wielding photographer on his last day in
the job. She's a warm-hearted gypsy femme fatale with a song in her heart and
a spring in her step. They fight crime!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]