Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Stefan Liebler authored and Andreas Krebbel committed Apr 13, 2015
1 parent de8aadd commit 920a039
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 78 deletions.
14 changes: 14 additions & 0 deletions ChangeLog
@@ -1,3 +1,17 @@
2015-04-13 Stefan Liebler <stli@linux.vnet.ibm.com>

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

2015-04-13 Stefan Liebler <stli@linux.vnet.ibm.com>

[BZ #6792]
Expand Down
2 changes: 1 addition & 1 deletion NEWS
Expand Up @@ -16,7 +16,7 @@ Version 2.22
17969, 17978, 17987, 17991, 17996, 17998, 17999, 18019, 18020, 18029,
18030, 18032, 18036, 18038, 18039, 18042, 18043, 18046, 18047, 18068,
18080, 18093, 18100, 18104, 18110, 18111, 18128, 18138, 18185, 18197,
18210, 18211, 18247.
18206, 18210, 18211, 18247.

* A powerpc and powerpc64 optimization for TLS, similar to TLS descriptors
for LD and GD on x86 and x86-64, has been implemented. You will need
Expand Down
18 changes: 9 additions & 9 deletions localedata/tests-mbwc/dat_wcsncmp.c
Expand Up @@ -33,19 +33,19 @@ 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 */
/*expect*/ { 0,1,0, },
},
{ /*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 }
}
Expand Down Expand Up @@ -75,19 +75,19 @@ 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 */
/*expect*/ { 0,1,0, },
},
{ /*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 }
}
Expand Down Expand Up @@ -117,19 +117,19 @@ 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 */
/*expect*/ { 0,1,0, },
},
{ /*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 }
}
Expand Down
1 change: 1 addition & 0 deletions localedata/tests-mbwc/tst_wcsncmp.c
Expand Up @@ -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)
{
Expand Down

0 comments on commit 920a039

Please sign in to comment.