Also add a test and correct the documentation.
@end deftypefn
@cindex strings, searching backwards
-@deftypefn {Function} {} RINDEX (@var{string}, @var{format})
+@deftypefn {Function} {} RINDEX (@var{haystack}, @var{needle})
Returns a positive integer indicating the position of the last
occurrence of @var{needle} in @var{haystack}. Returns 0 if
@var{haystack} does not contain @var{needle}. Returns system-missing if
returns the largest value. Returns 0 if @var{haystack} does not contain
any part in @var{needle}. It is an error if @var{needle_len} does not
evenly divide the length of @var{needle}. Returns system-missing
-if @var{needle} is an empty string.
+if @var{needle} is an empty string or if needle_len is less than 1.
@end deftypefn
@cindex padding strings
function RINDEX (string haystack, string needles, needle_len_d)
{
- if (needle_len_d <= INT_MIN || needle_len_d >= INT_MAX
+ if (needle_len_d <= 0 || needle_len_d >= INT_MAX
|| (int) needle_len_d != needle_len_d
|| needles.length == 0)
return SYSMIS;
[[rindex('abcbcde', 'abc', 1)], [5.00]],
[[rindex('abcbcde', 'bccb', 2)], [4.00]],
[[rindex('abcbcde', 'bcbc', 2)], [4.00]],
+ [[rindex('abcbcde', 'bcbc', 0)], [sysmis]],
[[rindex('abcbcde', 'bcbc', $sysmis)], [sysmis]],
[[rindex('abcbcde', 'bcbcg', 2)], [sysmis]],
[[rindex('abcbcde', 'bcbcg', $sysmis)], [sysmis]],