GNU bug report logs -
#78690
31.0.50; split string: args out of range with TRIM
Previous Next
Full log
Message #8 received at 78690 <at> debbugs.gnu.org (full text, mbox):
> Date: Wed, 04 Jun 2025 04:36:26 +0200
> From: Michael Heerdegen via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>
>
> Hello,
>
> I stumbled across this:
>
> #+begin_src emacs-lisp
> (split-string
> "-*- lexical-binding: t; -*-"
> "-\\*-" nil "[ \t\n\r-]+")
> #+end_src
>
> ~~>
>
> | Debugger entered--Lisp error: (args-out-of-range "-*- lexical-binding: t; -*-" 1 0)
> | (substring "-*- lexical-binding: t; -*-" 1 0)
> | (let ((this (substring string this-start this-end))) (if trim (progn (let ((tem (string-match (concat trim "\\'") this 0))) (and tem (< tem (length this)) (setq this (substring this 0 tem)))))) (if (or keep-nulls (> (length this) 0)) (progn (setq list (cons this list)))))
It is quite obvious that split-string is not prepared to deal with a
situation where the argument STRING begins with a match for
SEPARATORS. The breakage here happens because the match for
SEPARATORS at the very beginning of STRING also matches TRIM, but even
if that is not so, a match for SEPARATORS at the beginning of STRING
sets THIS-START incorrectly for the first call to push-one inside the
while-loop.
This bug report was last modified 21 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.