mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-27 21:20:18 +00:00
920a0395ba
[BZ #18206] * wcsmbs/wcsncmp.c (wcsncmp): Compare as wchar_t, not wint_t. Use signed comparision instead of substraction to avoid overflow bug. * localedata/tests-mbwc/tst_wcsncmp.c (tst_wcsncmp): Take the sign of ret. * localedata/tests-mbwc/dat_wcsncmp.c (tst_wcsncmp_loc): Do not expect precise return values. Only the sign matters. * wcsmbs/Makefile (strop-tests): Add wcsncmp. * wcsmbs/test-wcsncmp.c: New File. * string/test-strncmp.c: Add wcsncmp support.
42 lines
980 B
C
42 lines
980 B
C
/*-------------------------------------------------------------------------------------*/
|
|
/* WCSNCMP: int wcsncmp( const wchar_t *ws1, const wchar_t *ws2, size_t n ) */
|
|
/*-------------------------------------------------------------------------------------*/
|
|
|
|
#define TST_FUNCTION wcsncmp
|
|
|
|
#include "tsp_common.c"
|
|
#include "dat_wcsncmp.c"
|
|
|
|
int
|
|
tst_wcsncmp (FILE * fp, int debug_flg)
|
|
{
|
|
TST_DECL_VARS (int);
|
|
wchar_t *ws1, *ws2;
|
|
size_t n;
|
|
|
|
TST_DO_TEST (wcsncmp)
|
|
{
|
|
TST_HEAD_LOCALE (wcsncmp, S_WCSNCMP);
|
|
TST_DO_REC (wcsncmp)
|
|
{
|
|
TST_GET_ERRET (wcsncmp);
|
|
ws1 = TST_INPUT (wcsncmp).ws1; /* external value: size WCSSIZE */
|
|
ws2 = TST_INPUT (wcsncmp).ws2;
|
|
n = TST_INPUT (wcsncmp).n;
|
|
ret = wcsncmp (ws1, ws2, n);
|
|
ret = (ret > 0 ? 1 : ret < 0 ? -1 : 0);
|
|
|
|
if (debug_flg)
|
|
{
|
|
fprintf (stderr, "tst_wcsncmp: ret = %d, 0x%x\n", ret, ret);
|
|
}
|
|
|
|
TST_IF_RETURN (S_WCSNCMP)
|
|
{
|
|
};
|
|
}
|
|
}
|
|
|
|
return err_count;
|
|
}
|