[PATCH v2] mbstowcs: Document, test, and fix null pointer dst semantics (Bug 25219)
Carlos O'Donell
carlos@redhat.com
Mon Jun 1 16:28:20 GMT 2020
On 6/1/20 12:17 PM, Florian Weimer wrote:
> * Carlos O'Donell via Libc-alpha:
>
>> +If @var{wstring} is a null pointer then no output is written and the
>> +conversion proceeds as above, and the result is returned. In practice
>
> Missing two spaces after sentence-ending period.
Fixed.
>> +such behaviour is useful for calculating the exact number of wide
>> +characters required to convert @var{string}. This behaviour of
>> +accepting a null pointer for @var{wstring} is an @w{XPG4.2} extension to
>> +the requirements in @w{ISO C} and @w{POSIX}.
>
> Drop POSIX here? Aren't the XSI-shaded bits of POSIX still POSIX?
You can still be POSIX compliant but not XSI-conforming implementation?
How about this?
~~~
This behaviour of accepting a null pointer for @var{wstring} is an @w{XPG4.2}
extension that is not specified in @w{ISO C} and is optional in @w{POSIX}.
~~~
>> diff --git a/wcsmbs/tst-mbstowcs.c b/wcsmbs/tst-mbstowcs.c
>> new file mode 100644
>> index 0000000000..903ad55102
>> --- /dev/null
>> +++ b/wcsmbs/tst-mbstowcs.c
>
>> + /* The input ASCII string in the C/POSIX locale must convert
>> + to the matching WSTRING. */
>> + result = mbstowcs (wout, string, NUM_WCHAR);
>> + TEST_VERIFY (result == (NUM_WCHAR - 1));
>> + TEST_COMPARE_BLOB (wstring, sizeof(wchar_t) * (NUM_WCHAR - 1),
>> + wout, sizeof(wchar_t) * result);
>
> Missing space after sizeof (twice).
Fixed.
--
Cheers,
Carlos.
More information about the Libc-alpha
mailing list