wcstold implementation

Corinna Vinschen vinschen@redhat.com
Thu Jan 22 22:13:00 GMT 2015


Hi Craig,

On Jan 22 12:44, Craig Howland wrote:
> On 01/22/2015 11:16 AM, Corinna Vinschen wrote:
> >On Jan 22 16:28, Corinna Vinschen wrote:
> >
> >
> >On Jan 22 15:11, Nick Clifton wrote:
> >>>Hi Corinna, Hi Yaakov,
> >>>
> >>>   What do you think of the attached patch for an implementation of
> >>>   wcstold() for sizeof (long double) > sizeof (double) ? The patch is
> >>>   against the devo sources, but it could be adapted for FSF newlib
> >>>   easily enough.  One thing that you might not like is that the
> >>>   _wcstold_r implementation calls _strtold and not _strtold_r.  I can
> >>>   fix this too if you think that it is worth it.
> >>We don't have a _strtold_r function, only _strtold.  Along these lines,
> >>I think it should be sufficent to implement wcstold and just skip
> >>_wcstold_r.
> >Hmm, on second thought.
> >
> >The _strtold function in ldtoa.c is old, it never sets errno, it doesn't
> >take _localeconv_r (ptr)->decimal_point into account...
> >
> >Maybe we should in fact start with creating an _strtold_r function from
> >the _strtod_r function first?
> >
> I actually have a _strtold_r() function that I did back in 2009 but never
> quite got to the last step of submitting.  I had gotten an updated version
> of ldtoa.c (the present one in Newlib is not David Gay's latest), and made a
> wrapper for it.

This is cool.

> One thing that I did is that the function call for _strtold_r() has an
> additional argument over strtold() to allow it to be called from scanf.  The
> former wants errno set but the latter does not.
> 
> It does not, however, have the locale thing, as that was added after I had done it.
> 
> I have attached it for discussion and as a possible starting point. The
> exact method by which error or not errno is handled is a question.  As
> noted, I had put it into the _strtold_r() call, rather than having yet
> another wrapper level.  The reasoning is that you already need to add the
> reentry pointer, so another argument different from the standard call is not
> necessarily a bad thing.

Hmm.  I'm wondering if that's feasible.  There's a certain expectation
that the _r functions follow the non-_r functions with just the extra
struct reent param, isn't it?  Wouldn't a wrapper be better, in fact?

> The list mailer bounced with all 3 files, so here are 2, the other
> will follow.

Thanks.  I'm not overly fluent in floating point math coding, so, to
me, if it's working it's fine :)

Well, the locale decimal_point handling should be added, but apart from
the wrapper thingy above, that's all about it from my POV.

Feel free to send this eventually as a real patch submission.


Thanks a lot,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20150122/1abb3f20/attachment.sig>


More information about the Newlib mailing list