Mercurial > octave
diff libinterp/corefcn/strfns.cc @ 25698:ac386820f2b6
Return true when strncmp matches, but number of characters exceeds strlen (bug #54373)
* NEWS: Announce change in behavior.
* oct-string.cc (strncmp, strncmpi): Change templates to check length of
strings against neff (N effective) which is the smaller of the actual string
length or N itself.
* strfns.cc: Add new BIST tests, marked as regressions, for this behavior.
Change existing BIST tests to pass.
* publish.m (is_publish_markup): New nested function replacing an anonymous
function. This version does not index past the length of the string when
checking if the N+1 character is a space.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 25 Jul 2018 10:55:46 -0700 |
parents | da077c5be8f2 |
children | b543cf12c63f |
line wrap: on
line diff
--- a/libinterp/corefcn/strfns.cc Fri Jul 27 18:15:17 2018 -0400 +++ b/libinterp/corefcn/strfns.cc Wed Jul 25 10:55:46 2018 -0700 @@ -658,11 +658,13 @@ %!assert (strncmp ("abce", "aBc", 3), false) %!assert (strncmp (100, 100, 1), false) %!assert (strncmp ("abce", {"abcd", "bca", "abc"}, 3), logical ([1, 0, 1])) -%!assert (strncmp ("abc", {"abcd", "bca", "abc"}, 4), logical ([0, 0, 0])) +%!assert (strncmp ("abc", {"abcd", "bca", "abc"}, 4), logical ([0, 0, 1])) %!assert (strncmp ({"abcd", "bca", "abc"},"abce", 3), logical ([1, 0, 1])) %!assert (strncmp ({"abcd", "bca", "abc"},{"abcd", "bca", "abe"}, 3), logical ([1, 1, 0])) %!assert (strncmp ("abc", {"abcd", 10}, 2), logical ([1, 0])) +%!assert <*54373> (strncmp ("abc", "abc", 100)) + %!error strncmp () %!error strncmp ("abc", "def") */ @@ -733,6 +735,8 @@ /* %!assert (strncmpi ("abc123", "ABC456", 3), true) + +%!assert <*54373> (strncmpi ("abc", "abC", 100)) */ DEFUN (__native2unicode__, args, ,