diff options
author | Stefan Liebler <stli@linux.vnet.ibm.com> | 2015-04-13 21:23:10 +0200 |
---|---|---|
committer | Andreas Krebbel <krebbel@linux.vnet.ibm.com> | 2015-04-13 21:25:04 +0200 |
commit | 920a0395ba9fa5949ec87aaf5daa0259da16749d (patch) | |
tree | f590d2c50132feb89be712a38754faaf3c7f45c6 /localedata/tests-mbwc | |
parent | de8aadd52c97f9a04d5e8709b16dc5baf9292a09 (diff) | |
download | glibc-920a0395ba9fa5949ec87aaf5daa0259da16749d.zip glibc-920a0395ba9fa5949ec87aaf5daa0259da16749d.tar.gz glibc-920a0395ba9fa5949ec87aaf5daa0259da16749d.tar.bz2 |
Use correct signedness in wcsncmp
[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.
Diffstat (limited to 'localedata/tests-mbwc')
-rw-r--r-- | localedata/tests-mbwc/dat_wcsncmp.c | 18 | ||||
-rw-r--r-- | localedata/tests-mbwc/tst_wcsncmp.c | 1 |
2 files changed, 10 insertions, 9 deletions
diff --git a/localedata/tests-mbwc/dat_wcsncmp.c b/localedata/tests-mbwc/dat_wcsncmp.c index 167ce48..f468a8b 100644 --- a/localedata/tests-mbwc/dat_wcsncmp.c +++ b/localedata/tests-mbwc/dat_wcsncmp.c @@ -33,7 +33,7 @@ TST_WCSNCMP tst_wcsncmp_loc [] = { }, { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 }, { 0x0000,0x00D2,0x00D3,0x0000 }, 3 }, /* #06 */ - /*expect*/ { 0,1,0x00D1, }, + /*expect*/ { 0,1,1, }, }, { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 }, { 0x00D1,0x00D2,0x00D9,0x0000 }, 2 }, /* #07 */ @@ -41,11 +41,11 @@ TST_WCSNCMP tst_wcsncmp_loc [] = { }, { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 }, { 0x00D1,0x00D2,0x00D9,0x0000 }, 3 }, /* #08 */ - /*expect*/ { 0,1,-0x0006, }, + /*expect*/ { 0,1,-1, }, }, { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 }, { 0x00D1,0x00D2,0x0000 }, 4 }, /* #09 */ - /*expect*/ { 0,1,0x00D3, }, + /*expect*/ { 0,1,1, }, }, { .is_last = 1 } } @@ -75,7 +75,7 @@ TST_WCSNCMP tst_wcsncmp_loc [] = { }, { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 }, { 0x0000,0x0042,0x0043,0x0000 }, 3 }, /* #06 */ - /*expect*/ { 0,1,0x0041, }, + /*expect*/ { 0,1,1, }, }, { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 }, { 0x0041,0x0042,0x0049,0x0000 }, 2 }, /* #07 */ @@ -83,11 +83,11 @@ TST_WCSNCMP tst_wcsncmp_loc [] = { }, { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 }, { 0x0041,0x0042,0x0049,0x0000 }, 3 }, /* #08 */ - /*expect*/ { 0,1,-0x0006, }, + /*expect*/ { 0,1,-1, }, }, { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 }, { 0x0041,0x0042,0x0000 }, 4 }, /* #09 */ - /*expect*/ { 0,1,0x0043, }, + /*expect*/ { 0,1,1, }, }, { .is_last = 1 } } @@ -117,7 +117,7 @@ TST_WCSNCMP tst_wcsncmp_loc [] = { }, { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 }, { 0x0000,0x3042,0x3043,0x0000 }, 3 }, /* #06 */ - /*expect*/ { 0,1,0x3041, }, + /*expect*/ { 0,1,1, }, }, { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 }, { 0x3041,0x3042,0x3049,0x0000 }, 2 }, /* #07 */ @@ -125,11 +125,11 @@ TST_WCSNCMP tst_wcsncmp_loc [] = { }, { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 }, { 0x3041,0x3042,0x3049,0x0000 }, 3 }, /* #08 */ - /*expect*/ { 0,1,-0x0006, }, + /*expect*/ { 0,1,-1, }, }, { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 }, { 0x3041,0x3042,0x0000 }, 4 }, /* #09 */ - /*expect*/ { 0,1,0x3043, }, + /*expect*/ { 0,1,1, }, }, { .is_last = 1 } } diff --git a/localedata/tests-mbwc/tst_wcsncmp.c b/localedata/tests-mbwc/tst_wcsncmp.c index d046ecd..f93ca49 100644 --- a/localedata/tests-mbwc/tst_wcsncmp.c +++ b/localedata/tests-mbwc/tst_wcsncmp.c @@ -24,6 +24,7 @@ tst_wcsncmp (FILE * fp, int debug_flg) 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) { |