Subject: bug#78690: 31.0.50; split string: args out of range with TRIM

From: Michael Heerdegen <[email-masked]>
Date: Thu, 12 Jun 2025 10:42:42 +0200

Eli Zaretskii <[email-masked]> writes:

> > #+begin_src emacs-lisp
> > (let ((text " -*- lexical-binding: t; -*-")
> >       ;;    ^^^ see here
> >       (seps "-\\*-")
> >       (trim "[ \t\n\r-]+"))
> >   (split-string text seps nil trim))
> > #+end_src
> > 
> >   ~~> split-string: Args out of range: " -*- lexical-binding: t; -*-", 2, 1
> > 
> > Could you please have a look?
>
> Thanks.  I guess I've found something similar independently, because
> the changes I have stashed (reproduced below) don't signal an error in
> this case.  With those changes, I get what I think is the expected
> value
>
>   ("" "lexical-binding: t;" "")

> Here's the up-to-date version of the patch:
> [...]

Confirmed - works for me, thank you.

BTW, I tried to follow the code and find it a bit troublesome.  If you
would want to try to give some local variables a bit more meaningful
names where possible, or want to add some very short comments, I would
not be opposed to that.

Michael.