<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">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:<div class=""><br class=""></div><div class="">(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.</div><div class=""><br class=""></div><div class="">(2) We’d need to invent length modifiers for the interchange and extended types.</div><div class=""><br class=""></div><div class="">(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.</div><div class=""><br class=""></div><div class="">(4) snprintf has a much more complicated (Swiss Army Knife) interface than 754’s description of the convertTo*Character operations would suggest.</div><div class=""><br class=""></div><div class="">- JIm Thomas<br class=""><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Feb 20, 2020, at 5:29 AM, Mike Cowlishaw <<a href="mailto:mfc@speleotrove.com" class="">mfc@speleotrove.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta content="text/html; charset=us-ascii" http-equiv="Content-Type" class="">
<meta name="GENERATOR" content="MSHTML 11.00.9600.19431" class="">
<div class="">
<div dir="ltr" align="left" class=""><font color="#0000ff" size="2" face="Arial" class=""><span class="940382713-20022020">Good to know! I think I'll just stick
to snprintf,all the same. :-)</span></font></div>
<div dir="ltr" align="left" class=""><font color="#0000ff" size="2" face="Arial" class=""><span class="940382713-20022020"></span></font> </div>
<div dir="ltr" align="left" class=""><font color="#0000ff" size="2" face="Arial" class=""><span class="940382713-20022020">Mike</span></font></div><br class="">
<blockquote style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px" class="" type="cite">
<div lang="en-us" class="OutlookMessageHeader" dir="ltr" align="left">
<hr tabindex="-1" class="">
<font size="2" face="Tahoma" class=""><b class="">From:</b> <a href="mailto:cfp-interest-bounces@oakapple.net" class="">cfp-interest-bounces@oakapple.net</a>
[<a href="mailto:cfp-interest-bounces@oakapple.net" class="">mailto:cfp-interest-bounces@oakapple.net</a>] <b class="">On Behalf Of </b>Rajan
Bhakta<br class=""><b class="">Sent:</b> 20 February 2020 02:05<br class=""><b class="">To:</b>
CFP<br class=""><b class="">Subject:</b> [Cfp-interest 1507] Fw: Re: Question about strfromd in
glibc<br class=""></font><br class=""></div>
<div class=""></div><span style="FONT-SIZE: 10pt; FONT-FAMILY: sans-serif" class="">So it seems
glibc does do the right thing (null terminate) and the web page was
wrong.</span><br class=""><br class=""><span style="FONT-SIZE: 10pt; FONT-FAMILY: sans-serif" class="">Regards,<br class=""><br class="">Rajan
Bhakta<br class="">z/OS XL C/C++ Compiler Technical Architect<br class="">ISO C Standards
Representative for Canada, PL22.11 Chair (USA)<br class="">C Compiler
Development<br class="">Contact: <a href="mailto:rbhakta@us.ibm.com" class="">rbhakta@us.ibm.com</a>, Rajan
Bhakta/Houston/IBM</span><br class=""><span style="FONT-SIZE: 9pt; FONT-FAMILY: sans-serif; COLOR: #800080" class="">-----
Forwarded by Rajan Bhakta/Houston/IBM on 02/19/2020 08:04 PM
-----</span><br class=""><br class=""><span style="FONT-SIZE: 9pt; FONT-FAMILY: sans-serif; COLOR: #5f5f5f" class="">From:
</span><span style="FONT-SIZE: 9pt; FONT-FAMILY: sans-serif" class="">Joseph Myers
<<a href="mailto:joseph@codesourcery.com" class="">joseph@codesourcery.com</a>></span><br class=""><span style="FONT-SIZE: 9pt; FONT-FAMILY: sans-serif; COLOR: #5f5f5f" class="">To:
</span><span style="FONT-SIZE: 9pt; FONT-FAMILY: sans-serif" class="">Rajan Bhakta
<<a href="mailto:rbhakta@us.ibm.com" class="">rbhakta@us.ibm.com</a>></span><br class=""><span style="FONT-SIZE: 9pt; FONT-FAMILY: sans-serif; COLOR: #5f5f5f" class="">Date:
</span><span style="FONT-SIZE: 9pt; FONT-FAMILY: sans-serif" class="">02/19/2020 04:20
PM</span><br class=""><span style="FONT-SIZE: 9pt; FONT-FAMILY: sans-serif; COLOR: #5f5f5f" class="">Subject:
</span><span style="FONT-SIZE: 9pt; FONT-FAMILY: sans-serif" class="">[EXTERNAL] Re: Question about
strfromd in glibc</span><br class="">
<hr noshade="" class="">
<br class=""><br class=""><br class=""><tt class=""><span style="FONT-SIZE: 10pt" class="">On Wed, 19 Feb 2020, Rajan
Bhakta wrote:<br class=""><br class="">> Hi Joseph,<br class="">> <br class="">> Looking at
</span></tt><a href="http://man7.org/linux/man-pages/man3/strfromd.3.html" class=""><tt class=""><span style="FONT-SIZE: 10pt" class="">http://man7.org/linux/man-pages/man3/strfromd.3.html</span></tt></a><tt class=""><span style="FONT-SIZE: 10pt" class="">, it seems <br class="">> to say you could end up with
strings that are not null terminated. But <br class="">> from the C standard draft
(N2454 for example) it says that the strings are <br class="">> always null
terminated and only that you may get incomplete (truncation <br class="">> from the
right) if 'n' is too small (yet still null terminated). Was this <br class="">> an
intentional decision or am I understanding the documentation wrong?<br class=""><br class="">The
strfrom functions are equivalent to particular calls to snprintf, so <br class="">they
should always null-terminate their output (when a nonzero size is
<br class="">specified). The manpages are not official glibc
documentation.<br class=""><br class="">-- <br class="">Joseph S.
Myers<br class=""><a href="mailto:joseph@codesourcery.com" class="">joseph@codesourcery.com</a><br class=""><br class=""></span></tt><br class=""><br class=""></blockquote></div>
_______________________________________________<br class="">Cfp-interest mailing list<br class=""><a href="mailto:Cfp-interest@oakapple.net" class="">Cfp-interest@oakapple.net</a><br class="">http://mailman.oakapple.net/mailman/listinfo/cfp-interest<br class=""></div></blockquote></div><br class=""></div></div></body></html>