shithub: femtolisp

Download patch

ref: 97d0c80fcc6e076d3a856f3ec2230194ce0e7b3f
parent: 34f94d8f686d27d00fcca2c4bc596d339fd3f5b0
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Oct 27 21:00:10 EDT 2024

fix string-trim cutting off too much at the end

--- a/flisp.boot
+++ b/flisp.boot
@@ -427,7 +427,7 @@
 							     string-rep #fn(string-length)) string-rpad)
 	    string-tail #fn("8000n2200162:" #(#fn(string-sub)) string-tail)
 	    string-trim #fn("8000n320>DD62:" #(#fn("8000n220>?0421>?1422>23A5161:" #(#fn(":000n48283L;3?042012108252523@0A017282518364:82:" #(#fn(string-find)
-  #fn(string-char) 1+) trim-start) #fn(":000n37082E52;3?042112208252523>0F0173825163:82:" #(>
+  #fn(string-char) 1+) trim-start) #fn(";000n37082E52;3C0421122073825152523>0F0173825163:82:" #(>
   #fn(string-find) #fn(string-char) 1-) trim-end)
   #fn("<000n120910A910911E054F91091205363:" #(#fn(string-sub)))
   #fn(string-length)))) string-trim)
--- a/system.lsp
+++ b/system.lsp
@@ -685,15 +685,13 @@
 
 (define (string-trim s at-start at-end)
   (define (trim-start s chars i L)
-    (if (and (< i L)
-	     (string-find chars (string-char s i)))
-	(trim-start s chars (1+ i) L)
-	i))
+    (if (and (< i L) (string-find chars (string-char s i)))
+	      (trim-start s chars (1+ i) L)
+	      i))
   (define (trim-end s chars i)
-    (if (and (> i 0)
-	     (string-find chars (string-char s i)))
-	(trim-end s chars (1- i))
-	i))
+    (if (and (> i 0) (string-find chars (string-char s (1- i))))
+	      (trim-end s chars (1- i))
+	      i))
   (let ((L (string-length s)))
     (string-sub s
 		(trim-start s at-start 0 L)