> Documenting the intended use of maxlen would be nice. Does that mean we assume now that maxlen <= buflen(str)?

Yes, I do not see any other clean way to do it. Because in both the old and the new code, if `maxlen > 0`, then str[maxlen - 1] is accessed whenever `str_to_reg` is call.

It's all a bit annoying though. For example `set_last_search_pat` doesn't take a `len` param and thus always takes an implicit `strlen`. Should we truncate the string to `len` (formerly `maxlen`) in this case?