[Cfp-interest 1505] Re: AI item to submit proposal about why no wide string strfrom functions

Damian McGuckin damianm at esi.com.au
Wed Feb 19 12:38:27 PST 2020


Hi Fred,

On Wed, 19 Feb 2020, Fred J. Tydeman wrote:

> On Thu, 20 Feb 2020 05:32:26 +1100 (AEDT) Damian McGuckin wrote:
>>
>> Note that Mike is correct in that C2X explicitly says that the string 's'
>> will NOT be NUL ('\0') terminated if
>>
>>       n < nc
>
> Where are you seeing that?

I was quoting from the last sentence of C2X Draft in the References 
section on the Wiki, N2454.pdf. See the full quote at the very bottom of 
this email.

.... the null-terminated output has been completely written if and only if 
the returned value is less than 'n'.

> 7.22.1.3 in returns has: ;... null-terminated output ...

See the full text.
>
> 7.21.6.5 has: ... output characters beyond the n-1st are discarded 
> rather than being written to the array, and a null character is written 
> at the end of the characters actually written into the array.

You are quoting from snprintf, not strfromd.

This is what I would expect the behaviour of strfromd would/should be. But 
instead it is different. Excuse my cutting and pasting below.

In 7.22.1.3

Returns

The strfromd, strfromf, and strfroml functions return the number of 
characters that would have been written had been sufficiently large, not 
counting the terminating null character. Thus, the null-terminated output 
has been completely written if and only if the returned value is less 
than n.

- Damian

Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037
Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here
Views & opinions here are mine and not those of any past or present employer


More information about the Cfp-interest mailing list