GNOME Bugzilla – Bug 549707
g_strstr_len() ignores haystack_len
Last modified: 2018-05-24 11:32:09 UTC
g_strstr_len() ignores the haystack_len, and will only process the haystack up until the first nul-terminator, even though haystack_len is defined. g_strstr_len() should process the string up to haystack_len instead of stopping in the middle.
See bug 332672. Unfortunately many glib string functions (as well as pango_layout_set_text()) use the provided len as a "max len", making it much less useful than it could be if it was simply "len". I don't think it's possible to change this meaning at this time. When I asked Owen why this is the case, he said that the max-len argument is supposed to be used for things like "truncating" strings. However, one can't do such things with UTF-8 without examining the string first, so that use case is moot.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/159.