Hi Bruno,
Bruno Haible via Gnulib discussion list <[email protected]> writes:
> This patch fixes it, by considering the 'grouping' sequence of numbers.
On FreeBSD 15.0 (cfarm427) I see the following warnings:
In file included from unistdio/u16-u16-vasnprintf.c:57:
./vasnprintf.c:5224:77: warning: incompatible pointer types passing
'unistring_uint16_t[10]' (aka 'unsigned short[10]') to parameter of type 'char
*' [-Wincompatible-pointer-types]
5224 | thousep =
thousands_separator_char (thousep_buf);
|
^~~~~~~~~~~
./vasnprintf.c:415:32: note: passing argument to parameter 'stackbuf' here
415 | thousands_separator_char (char stackbuf[10])
| ^
./vasnprintf.c:5224:49: warning: incompatible pointer types assigning to
'const unistring_uint16_t *' (aka 'const unsigned short *') from 'const char *'
[-Wincompatible-pointer-types]
5224 | thousep =
thousands_separator_char (thousep_buf);
| ^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./vasnprintf.c:5225:63: warning: incompatible pointer types passing 'const
unistring_uint16_t *' (aka 'const unsigned short *') to parameter of type
'const char *' [-Wincompatible-pointer-types]
5225 | thousep_len = strlen
(thousep);
|
^~~~~~~
/usr/include/string.h:102:28: note: passing argument to parameter here
102 | size_t strlen(const char *) __pure;
| ^
IIRC, recent GCC versions will error out here instead of warning like
Clang.
Looking at the code, it looks like the comment here is incorrect:
# if WIDE_CHAR_VERSION
/* DCHAR_T is wchar_t. */
thousep = thousands_separator_wchar
(thousep_buf);
# define thousep_len 1
# else
/* DCHAR_T is char. */
thousep = thousands_separator_char
(thousep_buf);
thousep_len = strlen (thousep);
# endif
Since when compiling unistdio DCHAR_T is not a char.
Wouldn't it be correct to use:
static const DCHAR_T *
thousands_separator_char (DCHAR_T *stackbuf[10])
{
...
}
And copy nl_langinfo (THOUSEP) into stackbuf? And use the unistring
equivelent of strlen if DCHAR_T != char?
Collin