[Cfp-interest 1512] Re: Question about strfromd in glibc
Jim Thomas
jaswthomas at sbcglobal.net
Thu Feb 20 15:28:14 PST 2020
The reason we have the strfrom functions is to support 754’s convertToDecimalCharacter and convertToHexCharacter operations. The alternative of just saying snprintf supports them has these drawbacks:
(1) snprintf is from <stdio.h> which need not be supported by freestanding implementations. Freestanding implementations (that define __STDC_IEC_60559_BFP__ or __STDC_IEC_60559_DFP__) do need to support the numeric conversion functions in <stdlib.h> which include the strfrom functions.
(2) We’d need to invent length modifiers for the interchange and extended types.
(3) We’d have to figure out how to support the convertTo*Character operations for non-arithmetic formats (which don’t have associated types), either by further extending snprintf or by some other mechanism.
(4) snprintf has a much more complicated (Swiss Army Knife) interface than 754’s description of the convertTo*Character operations would suggest.
- JIm Thomas
> On Feb 20, 2020, at 5:29 AM, Mike Cowlishaw <mfc at speleotrove.com> wrote:
>
> Good to know! I think I'll just stick to snprintf,all the same. :-)
>
> Mike
>
>> From: cfp-interest-bounces at oakapple.net [mailto:cfp-interest-bounces at oakapple.net] On Behalf Of Rajan Bhakta
>> Sent: 20 February 2020 02:05
>> To: CFP
>> Subject: [Cfp-interest 1507] Fw: Re: Question about strfromd in glibc
>>
>> So it seems glibc does do the right thing (null terminate) and the web page was wrong.
>>
>> Regards,
>>
>> Rajan Bhakta
>> z/OS XL C/C++ Compiler Technical Architect
>> ISO C Standards Representative for Canada, PL22.11 Chair (USA)
>> C Compiler Development
>> Contact: rbhakta at us.ibm.com, Rajan Bhakta/Houston/IBM
>> ----- Forwarded by Rajan Bhakta/Houston/IBM on 02/19/2020 08:04 PM -----
>>
>> From: Joseph Myers <joseph at codesourcery.com>
>> To: Rajan Bhakta <rbhakta at us.ibm.com>
>> Date: 02/19/2020 04:20 PM
>> Subject: [EXTERNAL] Re: Question about strfromd in glibc
>>
>>
>>
>> On Wed, 19 Feb 2020, Rajan Bhakta wrote:
>>
>> > Hi Joseph,
>> >
>> > Looking at http://man7.org/linux/man-pages/man3/strfromd.3.html <http://man7.org/linux/man-pages/man3/strfromd.3.html>, it seems
>> > to say you could end up with strings that are not null terminated. But
>> > from the C standard draft (N2454 for example) it says that the strings are
>> > always null terminated and only that you may get incomplete (truncation
>> > from the right) if 'n' is too small (yet still null terminated). Was this
>> > an intentional decision or am I understanding the documentation wrong?
>>
>> The strfrom functions are equivalent to particular calls to snprintf, so
>> they should always null-terminate their output (when a nonzero size is
>> specified). The manpages are not official glibc documentation.
>>
>> --
>> Joseph S. Myers
>> joseph at codesourcery.com
>>
>>
>>
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20200220/18fb4ca8/attachment-0001.html
More information about the Cfp-interest
mailing list