This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Another idea for 6015


On Thu, 2002-04-04 at 02:13, Paolo Carlini wrote:

> After the call to snprintf, on MT systems indeed (all of this may be 
> conditionalized to only (MT && !glibc2.3)), we have a c-string __out, 
> which possibly may be formatted according to a locale /different/ from 
> "C". Ok. What about "cleaning" it? Of course I have to study in detail 
> the C-locale documentation, but it should be not that difficult: a scan 
> right to left adjusting the decimal separator and removing any thousands 
> separators (anything different from a number counts) should be 90% of 
> the work...

Something like this is possible and it is, I think, what Nathan proposed
at some time.

But the extraction code needs to be clever:

There are 8 different non-digit characters

    + thousand separator: can be anything but must be unique
    + decimal point: likewise
    + exponent decimal format: always 'e' or 'E'
    + exponent hexadecimal format: always 'p' or 'P'
    + negative prefix: always '-'
    + positive prefix: always '+'

In addition you have '0' to '9' and 'a' to 'f' and 'A' to 'F'

If the hexadecimal float format can never appear things get a bit
easier.

The tricky part is to distinguish between decimal point and thousand
separator.  If the precision is greater zero or the '#' flag is used and
the number has a fractional part than you can scan from the back to find
the decimal point.  There will be several more rules like this and with
some intelligence you should be able to reconstruct the output.

WHile we are at it, you might want to look at the ecvt, fcvt, gcvt
functions which are generally available on Unix systems (although they
are marked as legacy now).  They were initially meant as functions the
printf() functions can use to print floating-point numbers.  You should
be able to use them and so cover at least Unix systems (and what else is
there to care about).

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------

Attachment: signature.asc
Description: This is a digitally signed message part


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]