Documentation of g_strrstr_len is misleading; suggested fix
(Checked against current git.)
The docstring for g_strrstr_len
says:
@haystack: a nul-terminated string
@haystack_len: the maximum length of @haystack
But in fact the string only needs to be nul-terminated if haystack_len
is negative (this is obvious in the source code, where g_strstr is called if haystack_len < 0
, and otherwise there is no nul
detection). The documentation for g_strstr_len
, which works the same way, is better:
@haystack: a string
@haystack_len: the maximum length of @haystack. Note that -1 is
a valid length, if @haystack is nul-terminated, meaning it will
search through the whole string.
I suggest the following clarification: for both g_strstr_len
and g_strrstr_len
, have (substituting "g_strrstr" for "strstr" in the docstring for "g_strrstr_len"):
@haystack: a string
@haystack_len: the length of @haystack. If @haystack is nul-terminated,
a length of -1 can be used to mean "search the entire string", like strstr.