[Cfp-interest 1513] Re: Question about strfromd in glibc

Mike Cowlishaw mfc at speleotrove.com
Thu Feb 20 23:40:13 PST 2020


I wasn't saying they shouldn't be in the Standard.
 
Mike


  _____  

From: Jim Thomas [mailto:jaswthomas at sbcglobal.net] 
Sent: 20 February 2020 23:28
To: Mike Cowlishaw
Cc: Rajan Bhakta; CFP
Subject: Re: [Cfp-interest 1509] Question about strfromd in glibc


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/20200221/118a5782/attachment.html 


More information about the Cfp-interest mailing list