guix_mirror_bot pushed a commit to branch lisp-team
in repository guix.

commit f4ca2484cd1294577aac6bbfe4618961324de8e5
Author: Guillaume Le Vaillant <[email protected]>
AuthorDate: Fri Nov 13 19:06:27 2026 +0100

    gnu: cl-ppcre: Update to 2.1.2.
    
    * gnu/packages/patches/sbcl-cl-ppcre-fix-loops.patch: New file.
    * gnu/packages/lisp-xyz.scm (sbcl-cl-ppcre): Update to 2.1.2.
      [source]: Use patch.
---
 gnu/packages/lisp-xyz.scm                          |  9 +--
 gnu/packages/patches/sbcl-cl-ppcre-fix-loops.patch | 67 ++++++++++++++++++++++
 2 files changed, 72 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index 58a80e79dce..276fc68fce5 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -9415,7 +9415,7 @@ to setup.")
 (define-public sbcl-cl-ppcre
   (package
     (name "sbcl-cl-ppcre")
-    (version "2.1.1")
+    (version "2.1.2")
     (source
      (origin
        (method git-fetch)
@@ -9424,7 +9424,9 @@ to setup.")
              (commit (string-append "v" version))))
        (file-name (git-file-name "cl-ppcre" version))
        (sha256
-        (base32 "0dwvr29diqzcg5n6jvbk2rnd90i05l7n828hhw99khmqd0kz7xsi"))))
+        (base32 "0aw7lh79wgn18c75v29md2x8irl8v7f96lj1mfkp7x0mkqsb0cs8"))
+       ;; Patch for clasp from https://github.com/edicl/cl-ppcre/pull/64.
+       (patches (search-patches "sbcl-cl-ppcre-fix-loops.patch"))))
     (build-system asdf-build-system/sbcl)
     (native-inputs
      (list sbcl-flexi-streams))
@@ -9436,8 +9438,7 @@ to setup.")
            ;; to work around the circular dependency between edicl/cl-ppcre
            ;; and edicl/cl-unicode.
            (lambda _
-             (delete-file "cl-ppcre-unicode.asd")
-             #t)))))
+             (delete-file "cl-ppcre-unicode.asd"))))))
     (synopsis "Portable regular expression library for Common Lisp")
     (description "CL-PPCRE is a portable regular expression library for Common
 Lisp, which is compatible with perl.  It is pretty fast, thread-safe, and
diff --git a/gnu/packages/patches/sbcl-cl-ppcre-fix-loops.patch 
b/gnu/packages/patches/sbcl-cl-ppcre-fix-loops.patch
new file mode 100644
index 00000000000..434b249c986
--- /dev/null
+++ b/gnu/packages/patches/sbcl-cl-ppcre-fix-loops.patch
@@ -0,0 +1,67 @@
+From 1807e8edcfbe9c6d0eeec8422bc4d0beb98b3d21 Mon Sep 17 00:00:00 2001
+From: Chris Schafmeister <[email protected]>
+Date: Sat, 12 Sep 2026 19:41:45 +0000
+Subject: [PATCH] Fix lazy repetition endpoint matching across LOOP
+ implementations
+
+Track the cursor explicitly in bounded and unbounded non-greedy
+constant-length matchers instead of relying on an arithmetic LOOP
+variable's value in FINALLY.
+
+Clasp's LOOP uses Khazern, a portable LOOP implementation written by
+Robert Strandh and Tarn Burton, originally developed as part of SICL.
+See Robert Strandh, "A modern implementation of the LOOP macro,"
+European Lisp Symposium, 2016:
+https://metamodular.com/SICL/loop.pdf
+
+The Khazern version in which this problem was observed leaves the
+arithmetic iteration variable at the last in-range position, causing
+the endpoint check to fail for patterns such as "^.+?$".
+Explicit advancement preserves the intended matching behavior
+without depending on this disputed LOOP interpretation.
+
+I found the source code responsible for the problem
+with ChatGPT Astra.
+
+Clasp returned the wrong result for:
+(cl-ppcre:scan-to-strings "^.+?$" "Foo") --> NIL
+It should return "Foo"
+---
+ repetition-closures.lisp | 14 ++++++++------
+ 1 file changed, 8 insertions(+), 6 deletions(-)
+
+diff --git a/repetition-closures.lisp b/repetition-closures.lisp
+index 1bcb08b..5a2ff9a 100644
+--- a/repetition-closures.lisp
++++ b/repetition-closures.lisp
+@@ -376,22 +376,24 @@ repetition matches at CURR-POS."
+                                     (the fixnum (* len maximum))))))
+         ;; move forward by LEN and always try NEXT-FN first, then
+         ;; CHECK-CUR-POS
+-        (loop for curr-pos of-type fixnum from start-pos
+-                                          below target-end-pos
+-                                          by len
++        ;; Advance explicitly so FINALLY sees the endpoint independently
++        ;; of LOOP's arithmetic iteration variable semantics.
++        (loop with curr-pos of-type fixnum = start-pos
++              while (< curr-pos target-end-pos)
+               thereis (funcall next-fn curr-pos)
+               while ,check-curr-pos
++              do (incf curr-pos len)
+               finally (return (funcall next-fn curr-pos)))))
+   ;; basically the same code; it's just a bit easier because we're
+   ;; not bounded by MAXIMUM
+   (lambda (start-pos)
+     (declare (fixnum start-pos))
+     (let ((target-end-pos (1+ (- *end-pos* len min-rest))))
+-      (loop for curr-pos of-type fixnum from start-pos
+-                                        below target-end-pos
+-                                        by len
++      (loop with curr-pos of-type fixnum = start-pos
++            while (< curr-pos target-end-pos)
+             thereis (funcall next-fn curr-pos)
+             while ,check-curr-pos
++            do (incf curr-pos len)
+             finally (return (funcall next-fn curr-pos)))))))
+ 
+ (defgeneric create-non-greedy-constant-length-matcher (repetition next-fn)

Reply via email to