GNU bug report logs -
#78690
31.0.50; split string: args out of range with TRIM
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Sat, 21 Jun 2025 11:13:36 +0300
with message-id <86frftjyvj.fsf <at> gnu.org>
and subject line Re: bug#78690: 31.0.50; split string: args out of range with TRIM
has caused the debbugs.gnu.org bug report #78690,
regarding 31.0.50; split string: args out of range with TRIM
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
78690: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=78690
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
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)))))
| (progn (let ((this (substring string this-start this-end))) (if trim (progn (let ((tem (string-match ... 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))))))
| (if (or keep-nulls (< this-start this-end)) (progn (let ((this (substring string this-start this-end))) (if trim (progn (let ((tem ...)) (and tem (< tem ...) (setq this ...))))) (if (or keep-nulls (> (length this) 0)) (progn (setq list (cons this list)))))))
| (#f(lambda () [(list nil) (this-end 0) (this-start 1) (keep-nulls t) (trim "[ \11\n\15-]+") (string "-*- lexical-binding: t; -*-")] (if trim (progn (let ((tem (string-match trim string this-start))) (and (eq tem this-start) (setq this-start (match-end 0)))))) (if (or keep-nulls (< this-start this-end)) (progn (let ((this (substring string this-start this-end))) (if trim (progn (let ... ...))) (if (or keep-nulls (> ... 0)) (progn (setq list ...))))))))
| (funcall #f(lambda () [(list nil) (this-end 0) (this-start 1) (keep-nulls t) (trim "[ \11\n\15-]+") (string "-*- lexical-binding: t; -*-")] (if trim (progn (let ((tem (string-match trim string this-start))) (and (eq tem this-start) (setq this-start (match-end 0)))))) (if (or keep-nulls (< this-start this-end)) (progn (let ((this (substring string this-start this-end))) (if trim (progn (let ... ...))) (if (or keep-nulls (> ... 0)) (progn (setq list ...))))))))
| (while (and (string-match rexp string (if (and notfirst (= start (match-beginning 0)) (< start (length string))) (1+ start) start)) (< start (length string))) (setq notfirst t) (progn (setq this-start start) (setq this-end (match-beginning 0)) (setq start (match-end 0))) (funcall push-one))
| (let* ((keep-nulls (not (if separators omit-nulls t))) (rexp (or separators split-string-default-separators)) (start 0) this-start this-end notfirst (list nil) (push-one #'(lambda nil (if trim (progn (let ... ...))) (if (or keep-nulls (< this-start this-end)) (progn (let ... ... ...)))))) (while (and (string-match rexp string (if (and notfirst (= start (match-beginning 0)) (< start (length string))) (1+ start) start)) (< start (length string))) (setq notfirst t) (progn (setq this-start start) (setq this-end (match-beginning 0)) (setq start (match-end 0))) (funcall push-one)) (progn (setq this-start start) (setq this-end (length string))) (funcall push-one) (nreverse list))
| (split-string "-*- lexical-binding: t; -*-" "-\\*-" nil "[ \11\n\15-]+")
No problem without TRIM arg in the call.
TIA,
Michael.
In GNU Emacs 31.0.50 (build 23, x86_64-pc-linux-gnu, cairo version
1.16.0) of 2025-06-03 built on drachen
Repository revision: 8e4a0ea35908e08c2220bafee33a05c33f24bbc3
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101007
System Description: Debian GNU/Linux 12 (bookworm)
Configured using:
'configure --with-x-toolkit=no --with-native-compilation=no'
[Message part 3 (message/rfc822, inline)]
> From: Michael Heerdegen <michael_heerdegen <at> web.de>
> Cc: 78690 <at> debbugs.gnu.org
> Date: Thu, 19 Jun 2025 19:43:31 +0200
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> > If you tell me what is confusing or unclear, I will try to clarify
> > that. I guess after staring at the code as much as I did, I've lost
> > the ability to see the confusing parts, beyond the comments I added
> > that you saw in the patch.
>
> The comments are actually good. I got a bit confused because of the
> non-functional programming style (the helper lambda `push-one' changes
> state that is not local to that helper function), but... it's ok, it's
> just a complicated semantics being implemented so it takes some time to
> see what is going on where here. All good. Along with the comments one
> can make the way through the code.
Thanks, now installed on the master branch, and closing the bug.
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.