[PATCH v2] mbstowcs: Document, test, and fix null pointer dst semantics (Bug 25219)

Florian Weimer fw@deneb.enyo.de
Mon Jun 1 16:17:40 GMT 2020


* 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.

> +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?

> 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).

Rest looks okay.


More information about the Libc-alpha mailing list