edicl / cl-ppcre Goto Github PK
View Code? Open in Web Editor NEWCommon Lisp regular expression library
Home Page: https://edicl.github.io/cl-ppcre/
License: BSD 2-Clause "Simplified" License
Common Lisp regular expression library
Home Page: https://edicl.github.io/cl-ppcre/
License: BSD 2-Clause "Simplified" License
OS: FreeBSD
Version: v2.0.10 (also occurs the same on newest version)
I get a memory fault when calling regex-replace-all
or split
.
Here is an example run:
sbcl --eval "(ql:quickload :cl-ppcre)" --eval "(print (ppcre:split \"a\" \"bab\"))" --non-interactive
expected output: ("b" "b")
(running SBCL 1.4.7 on OSX)
actual output on SBCL 1.4.11, with FreeBSD on 64-bit Intel: (NearlyFreeSpeech server)
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x203000a0 (pc=0x22efc663, sp=0x297ff670)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
Unhandled SB-SYS:MEMORY-FAULT-ERROR: Unhandled memory fault at #x203000A0.
Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {10005305B3}>
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x20300090 (pc=0x23816de9, sp=0x297fde70)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x20300098 (pc=0x22e290c6, sp=0x297fd830)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x20300090 (pc=0x23816de9, sp=0x297fde70)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x20300098 (pc=0x22e290c6, sp=0x297fd830)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x20300090 (pc=0x23816de9, sp=0x297fe060)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x20300098 (pc=0x22e290c6, sp=0x297fda20)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x20300090 (pc=0x23816de9, sp=0x297fe060)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x20300098 (pc=0x22e290c6, sp=0x297fda20)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
0: (SB-PCL::CACHE-MISS-VALUES #<STANDARD-GENERIC-FUNCTION CL-PPCRE:SCAN (3)> (#<error printing a (error printing type) SB-PCL::ACCESSOR)
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x20300090 (pc=0x23816de9, sp=0x297fde70)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x20300098 (pc=0x22e290c6, sp=0x297fd830)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x20300090 (pc=0x23816de9, sp=0x297fde70)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x20300098 (pc=0x22e290c6, sp=0x297fd830)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x20300090 (pc=0x23816de9, sp=0x297fe060)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x20300098 (pc=0x22e290c6, sp=0x297fda20)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x20300090 (pc=0x23816de9, sp=0x297fe060)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 13555:
Memory fault at 0x20300098 (pc=0x22e290c6, sp=0x297fda20)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
1: (SB-PCL::INITIAL-DFUN #<STANDARD-GENERIC-FUNCTION CL-PPCRE:SCAN (3)> (#<error printing a (error printing type))
2: (CL-PPCRE:SPLIT #<unavailable argument> "bab" :START 0 :END #<unavailable argument> :LIMIT #<unavailable argument> :WITH-REGISTERS-P NIL :OMIT-UNMATCHED-P NIL :SHAREDP NIL)
3: (SB-INT:SIMPLE-EVAL-IN-LEXENV (CL-PPCRE:SPLIT "a" "bab") #<NULL-LEXENV>)
4: (SB-INT:SIMPLE-EVAL-IN-LEXENV (PRINT (CL-PPCRE:SPLIT "a" "bab")) #<NULL-LEXENV>)
5: (EVAL (PRINT (CL-PPCRE:SPLIT "a" "bab")))
6: (SB-IMPL::PROCESS-EVAL/LOAD-OPTIONS ((:EVAL . "(ql:quickload :cl-ppcre)") (:EVAL . "(print (ppcre:split \"a\" \"bab\"))") (:QUIT)))
7: (SB-IMPL::TOPLEVEL-INIT)
8: ((FLET SB-UNIX::BODY :IN SAVE-LISP-AND-DIE))
9: ((FLET "WITHOUT-INTERRUPTS-BODY-27" :IN SAVE-LISP-AND-DIE))
10: ((LABELS SB-IMPL::RESTART-LISP :IN SAVE-LISP-AND-DIE))
Here is the outcome of (cl-ppcre-test::simple-tests)
on the same system:
Test: Simple tests from file "simple"
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x203000a0 (pc=0x22efc663, sp=0x297ff430)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
1:
got an unexpected error: Unhandled memory fault at #x203000A0.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x203000a0 (pc=0x22efc663, sp=0x297ff430)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
2:
got an unexpected error: Unhandled memory fault at #x203000A0.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x203000a0 (pc=0x22efc663, sp=0x297ff430)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
3:
got an unexpected error: Unhandled memory fault at #x203000A0.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x1001df9578, sp=0x297ff4b8)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
5:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff5a0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
7:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff460)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
8:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff460)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
9:
got an unexpected error: Unhandled memory fault at #x20300090.
.CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff460)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
10:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff478)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
11:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff488)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
12:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff498)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
13:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff478)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
14:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff4c8)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
15:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff4e8)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
16:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff518)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
17:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff528)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
18:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff470)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
19:
got an unexpected error: Unhandled memory fault at #x20300090.
.CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff470)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
20:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff460)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
21:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff460)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
22:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff400)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
23:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff400)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
24:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff400)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
25:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff3f0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
26:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff3f0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
27:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff3f0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
28:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff3e0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
29:
got an unexpected error: Unhandled memory fault at #x20300090.
.CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff400)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
30:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff3f0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
31:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff3f0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
32:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff3f0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
33:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff3f0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
34:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff3f0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
35:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff460)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
36:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff460)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
37:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff460)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
38:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff450)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
39:
got an unexpected error: Unhandled memory fault at #x20300090.
.CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff450)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
40:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff460)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
41:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff460)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
42:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff450)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
43:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff410)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
44:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff428)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
45:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff4c0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
46:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff4c0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
47:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff4d8)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
48:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff4b8)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
49:
got an unexpected error: Unhandled memory fault at #x20300090.
.CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff4c8)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
50:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff528)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
51:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff4c0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
53:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff5a0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
57:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff5a0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
58:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff5a0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
59:
got an unexpected error: Unhandled memory fault at #x20300090.
.CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff5a0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
60:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff5a0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
61:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff5a0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
62:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff5a0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
63:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff5a0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
64:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff418)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
65:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff4d0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
68:
got an unexpected error: Unhandled memory fault at #x20300090.
.CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff598)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
70:
got an unexpected error: Unhandled memory fault at #x20300090.
CORRUPTION WARNING in SBCL pid 12689:
Memory fault at 0x20300090 (pc=0x2381a195, sp=0x297ff4e0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
71:
got an unexpected error: Unhandled memory fault at #x20300090.
NIL
Using 35c5266, I can see that registers within repetitions are not correctly returned:
(cl-ppcre:scan-to-strings "(?:\\s+(\\w+)=(\\w+))*" " a1=A13 a2=A2 ")
" a1=A13 a2=A2"
#("a2" "A2")
I would have expected either an array with 4 strings, or an array with two arrays (or lists) in it.
SCAN
, REGEX-REPLACE
, REGEX-REPLACE-ALL
are all messed up by that, too, of course.
BTW, how is REGEX-REPLACE-ALL
supposed to be used with repetitions? When having a pattern ^A(B)*$
, the replacement lambda only gets called once (and has to return the complete new string), so it doesn't really provide any advantage over using SCAN
.
So, in order to be able to return new strings for each of the B matches (individually) I have to match the A
first, and then call again with :START
for the B
s; there's no easier way, right?
Case is not preserved if the matched term is not a whole word:
(ppcre:regex-replace-all "(?i)foo" "Fooz" "roo" :preserve-case t)
"rooz"
T
It works with whole words though:
> (ppcre:regex-replace-all "(?i)foo" "Foo z" "roo" :preserve-case t)
"Roo z"
T
This is by design, since string-case-modifier
has this:
(if (or (<= to from)
(and (< start from)
(alphanumericp (char str (1- from)))
(alphanumericp (char str from)))
(and (< to end)
(alphanumericp (char str to))
(alphanumericp (char str (1- to)))))
;; if it's a zero-length string or if words extend beyond FROM
;; or TO we return NIL, i.e. #'IDENTITY
nil
My feature request is to add an option to allow preserving case even for words that extend beyond the boundaries.
What do you think?
When I build with a certain high-safety, low-speed compiler policy, it goes into the debugger in SB-C::VOP-OPTIMIZE-BOUNDP-OPTIMIZER
. Using SBCL 2.1.9 and the cl-ppcre-20190521 distribution of CL-PPCRE, which is the current Quicklisp distribution. I set compiler policy with the following series of commands: (log:)
* (sb-ext:restrict-compiler-policy 'speed 0 0)
NIL
((SPEED . 0))
* (sb-ext:restrict-compiler-policy 'safety 3 3)
((SAFETY . 3))
((SPEED . 0))
* (sb-ext:restrict-compiler-policy 'space 0 0)
((SAFETY . 3))
((SPEED . 0) (SPACE . 0))
* (sb-ext:restrict-compiler-policy 'debug 3 3)
((SAFETY . 3) (DEBUG . 3))
((SPEED . 0) (SPACE . 0))
See attached log showing build going into debugger.
sbcl-crash-with-low-speed-high-safety-loading-cl-ppcre-log.txt
Quicklisp will soon require three fields of metadata in every system definition: :license, :author, and :description. As noted in http://report.quicklisp.org/2015-05-26/failure-report/cl-ppcre.html, some of these are missing in the system definitions in cl-ppcre.
I would like to have a register-group-bind like macro for replacing all the regex occurrences in a string.
It would be something like:
replace-register-groups var-list (regex target-string &key start end sharedp) declaration* statement* => result*
where result* is the replacement of regex matching in target-string with the result of statement*
Does this make sense? I looked for something like this for one of my tasks, but I couldn't find it, apart from regex-replace-all
The documentation at http://weitz.de/cl-ppcre/ is gone. Please fix or upload somewhere.
Full warning message:
WARNING: System definition file #P"/home/me/quicklisp/dists/quicklisp/software/cl-ppcre-20190521-git/cl-ppcre.asd" contains definition for system "cl-ppcre-test". Please only define "cl-ppcre" and secondary systems with a name starting with "cl-ppcre/" (e.g. "cl-ppcre/test") in that file.
This is the offending code, in cl-ppcre.asd
(line 72)
(defsystem :cl-ppcre-test
:description "Perl-compatible regular expression library tests"
:author "Dr. Edi Weitz"
:license "BSD"
:depends-on (:cl-ppcre :flexi-streams)
:components ((:module "test"
:serial t
:components ((:file "packages")
(:file "tests")
(:file "perl-tests")))))
Using (safety 0) everywhere by default is quite a poor choice, it leads to hard to debug situations when things are used wrong, like bad indexes or if the result of create-scanner is called with a wrong number of arguments. Worse, it could lead to silent data corruption. I don't think the slight speed up is worth the headache.
Would you please consider adding a :description option to your system definition of cl-ppcre and cl-ppcre-unicode?
It would be nice if branch reset patterns were supported.
CL-USER> (scan-to-strings "(?|(abc)|(123))" "abcdef")
"abc"
#("abc")
CL-USER> (scan-to-strings "(?|(abc)|(123))" "123456")
"123"
#("123")
instead of the default behaviour:
CL-USER> (scan-to-strings "(abc)|(123)" "abcdef")
"abc"
#("abc" NIL)
CL-USER> (scan-to-strings "(abc)|(123)" "123456")
"123"
#(NIL "123")
Some implementations warn about method parameters that are not used,
when they don't have a type specified:
[package cl-ppcre]...................
;Compiler warnings for "home:quicklisp;dists;quicklisp;software;cl-ppcre-2.0.4;convert.lisp.newest" :
; In (convert-compound-parse-tree (t t)) inside an anonymous lambda form: Unused lexical variable parse-tree
..
; Warning: COMPILE-FILE warned while performing #<compile-op (:verbose nil) #x30200256B4CD> on #<cl-source-file "cl-ppcre" "convert">.
; While executing: #<standard-method asdf:perform (asdf:compile-op asdf:cl-source-file)>, in process repl-thread(14).
This can be solved with an ignorable declaration:
(declare (ignorable parse-tree))
in:
(defgeneric convert-compound-parse-tree (token parse-tree &key)
(declare #.*standard-optimize-settings*)
(:documentation "Helper function for CONVERT-AUX which converts
parse trees which are conses and dispatches on TOKEN which is the
first element of the parse tree.")
(:method ((token t) parse-tree &key)
(declare (ignorable parse-tree))
(signal-syntax-error "Unknown token ~A in parse-tree." token)))
This is my
(defun testreg (trojan)
(ppcre:register-groups-bind (first second third fouth fifth sixth seventh eighth ninth tenth eleventh twelfth) ("^(?:(1)|(2)|(3)|(4)|(5)|(6)|(7)|(8)|(9)|(a)|(b)|(c))+$" trojan)
(remove nil (list first second third fouth fifth sixth seventh eighth ninth tenth eleventh twelfth))))
(help-trojan-tolist "123456789ab")
but, I must define 12 parameters, is there other way that I use one parameter of list type to take 12 groups?
The version in quicklisp 2011-12-03.
3 tests fail on Allegro.
Test log from acl-8.2a-linux-x64:
https://cl-test-grid.appspot.com/blob?key=AMIfv96z3zpAJ7NBVUox0ZXqXE0MofFZLcuaXtttHS6VFsXVRDyJqCFVZRfdNYiJqAOZbRbnUvIfyUzsK9t-qRBQmGtwyaVd7WcGMTa0XaKEAEY1AL1NRz6SkwlB6mV-2utmWKkmHQC94iVpGHbaZ2ZifpGBjtp_Hg
The same tests fail on acl-8.2a-macosx-x64:
https://cl-test-grid.appspot.com/blob?key=AMIfv95LxbkgWChpsuKddRA8bTozHhRzkT8zH7wqG_e6E84kTL58N5duGsXDkKDTthXmv7QjDAJtGxnRFshqkUKk9L59UvGg7luWEjxfEpPqcq9mNLAdus1SMdmQewx0_TUrkyOEX-TAV76U2LZX_i9qfa-q0RerOQ
I often have to generate regexes dynamically. For this the tree syntax of CL-PPCRE is the most optimal solution. However I have discovered a strange corner case. In the documentation it says that
The symbol :VOID is equivalent to the empty string.
However in practice the empty string ""
and :VOID
have different behavior in some cases.
Consider two parse trees: (:sequence "" "a")
and (:sequence :void "a")
. Logically both are supposed to match "a". However
(ppcre:create-scanner '(:sequence "" "a"))
results in an error:
Invalid index 0 for (SIMPLE-ARRAY CHARACTER (0)), should be a non-negative integer below 0.
[Condition of type SB-INT:INVALID-ARRAY-INDEX-ERROR]
The version with :void
works just fine. Also if the empty string is not the first item of a sequence, it also works.
However if :sequence
is replaced by :alternation
, empty string causes an error in any position!
This behavior makes it harder to create dynamic regex trees, since I need to check if a string is empty and replace it with :void
to avoid the error.
While I'm familiarising myself with the library and Regexp with the Perl tutorial (https://perldoc.perl.org/perlretut) I stumbled upon this:
(ppcre:parse-string "[0-9a-fA-F]")
;; => (:CHAR-CLASS (:RANGE #\0 #\9) (:RANGE #\a #\f) (:RANGE #\A #\F))
(ppcre:scan "[0-9a-fA-F]" "0BaC16")
;; => 0, 1, #(), #()
(ppcre:scan "[0-9a-fA-F]" "G7Staaten")
;; => 1, 2, #(), #() -> BUG?
(ppcre:scan (ppcre:parse-string "[0-9a-fA-F]" "G7Staaten")
;; => 1, 2, #(), #() -> BUG?
It's from this in the mentioned tutorial:
/item[0-9]/; # matches 'item0' or ... or 'item9'
/[0-9bx-z]aa/; # matches '0aa', ..., '9aa',
# 'baa', 'xaa', 'yaa', or 'zaa'
/[0-9a-fA-F]/; # matches a hexadecimal digit
/[0-9a-zA-Z_]/; # matches a "word" character,
# like those in a Perl variable name`
By the way, I couldn't reproduce this example as well:
$x = 'bcr';
/[$x]at/; # matches 'bat', 'cat', or 'rat'
/[\$x]at/; # matches '$at' or 'xat'
/[\\$x]at/; # matches '\at', 'bat, 'cat', or 'rat'
I got this:
;; Different from the Perl related tutorium, in CL-PPCRE the $
;; seems not denote a scalar variable in a character class
;; - of CL-PPCRE. So here $ is not a special character:
(defparameter x "bcr")
(ppcre:parse-string "[$x]at") ; => (:SEQUENCE (:CHAR-CLASS #\$ #\x) "at")
(ppcre:parse-string "[\$x]at") ; => (:SEQUENCE (:CHAR-CLASS #\$ #\x) "at")
(ppcre:parse-string "[\\$x]at") ; => (:SEQUENCE (:CHAR-CLASS #\$ #\x) "at")
(ppcre:scan "[$x]at" "bat") ; => NIL -> same with \$ and \\$, of course
But I thought this isn't an issue but a decision.
It would be nice if there was a function which, given a regexp (or the source of one), would return a count of the number of registers in it (in other words the length of the arrays that scan
will return on a match for this regexp. It's not quite clear to me that that's fixed for a specific regexp (things like "(x)|y"
for instance) but I think it is in fact.
The reason this would be useful is that it would enable case-like macros which treat regexps as literals to move a check from run-time to macroexpansion-time and hence catch program errors ealier. As an example I have a macro called regexp-case
where this:
(regexp-case v
("^fo(o)?" (:registers (a b))
...))
is an error (more register variables than registers) but that error must be checked at run time, when it could be checked at macroexpansion time. The run-time check is extremely cheap (a known constant against the length of a vector) but having it at macroexpansion time would mean errors got caught earlier.
For the non ACL case an easy solution would be to return the number of registers from create-scanner
as an additional value as it knows it. But that's arguably an incompatible change as anything which actually checks the number of values would break, if there is anything that does that. On the other hand create-scanner
can already return only one value in the case of a function.
I don't know how it could be fixed for ACL since I'm not familiar with it any more.
This is probably too rare a case to justify a change, but I thought I would suggest it.
How can I get all the captured groups with the following positive lookahead regex?
My attempts:
(ppcre:all-matches-as-strings "(?=one|two|three|four|five|six|seven|eight|nine|ten)" "eighthree") ; => ("" "")
(ppcre:all-matches-as-strings "(?=(one)|(two)|(three)|(four)|(five)|(six)|(seven)|(eight)|(nine))" "eighthree") ; => ("" "")
(ppcre:scan-to-strings "(?=(one)|(two)|(three)|(four)|(five)|(six)|(seven)|(eight)|(nine))" "eighthree") ; => "" #(NIL NIL NIL NIL NIL NIL NIL "eight" NIL)
(ppcre:scan-to-strings "(?=(one|two|three|four|five|six|seven|eight|nine|ten))" "eighthree") ; => "" #("eight")
(cl-ppcre:register-groups-bind
(one two three four five six seven eight nine)
("(?=(one)|(two)|(three)|(four)|(five)|(six)|(seven)|(eight)|(nine))" "eighthree" :sharedp t)
(remove nil (list one two three four five six seven eight nine))) ; => ("eight")
You can get both groups using regex101 for example:
https://regex101.com/r/mJmQwA/1
https://regex101.com/r/XTw3x7/1
Is cl-ppcre:split doing it right?
harem> (cl-ppcre:split "\\|" "|OUTRO")
("" "OUTRO")
harem> (cl-ppcre:split "\\|" "OUTRO|")
("OUTRO")
In the second case, I would expect ("OUTRO" "")
. Ideas?
Back references named "NIL" don't actually get associated with the register named "NIL" (at least not usually). In fact, they are often associated with unnamed registers. For example, the following match succeeds:
(ppcre:scan '(:sequence (:register "f") (:register "o") (:back-reference "NIL")) "foo")
This is caused by comparing with STRING= without first confirming STRINGP.
I'll send in a fix for this shortly.
md> (last (pathname-directory (asdf:component-pathname (asdf:find-system "cl-ppcre"))))
("cl-ppcre-2.0.3")
md> (cl-ppcre:regex-replace-all "@" "@hi@" "\\@")
"\\@hi\\@"
t
md> (cl-ppcre:regex-replace-all "'" "'hi'" "\\'")
"hi'hi"
t
md> (values (lisp-implementation-version) (lisp-implementation-type))
"Version 1.9-r15759 (Darwinx8664)"
"Clozure Common Lisp"
md>
(scan "^\s+$" " ")
(scan "^\s+$" " ")
All return nil.
Hi!
I found the values returned by split bit strange sometimes, in particular:
(cl-ppcre:split "a" "aa") ; => nil
but
(cl-ppcre:split "a" "aab") ; => ("" "" "b")
Is not that strange?
Bye!
C.
Is this ok ?
(ppcre:split "/" "///a" ) ; => ("" "" "" "a")
(ppcre:split "/" "///" ) ; => NIL
Why NIL
instead of ("" "" "")
?
Hi,
I was using lisp-unit2 to test my lisp code and it has dependency on cl-ppcre. And I am developing in MKCL. When I tried to compile and run my Lisp code using ql:quickload I got the following error from cl-ppcre package.
Expected end of string. at position 8 in string "\Q((?:[^\\]|\(?!Q))*?)(?:\E|$)"
On further investigation I found that the error was caused by line no. 1210 of api.lisp.
(section-scanner (create-scanner "\Q((?:[^\\]|\(?!Q))*?)(?:\E|$)")))
I reason is what I guess, the if block of parse-string function of parser.lisp is returning false. I couldn't dig anymore. Please help me resolving the issue. I am stuck up, couldn't even run my first test method.
Thanks and regards
Santanu
CL-PPCRE validates register names too early in the regex compilation phase. The converter should wait until it has seen all register names before asserting that named back-references refer to existing registers.
(setf *allow-named-registers* t)
==> T
(scan "\\k<regOne>(?<regOne>.)" "a")
; Evaluation aborted on #<PPCRE-SYNTAX-ERROR "Illegal back-reference: ~S." {1006D50F93}>.
(scan "\\1(.)" "a")
==> NIL
Compare this to Perl:
say 'a' =~ /\k<regOne>(?<regOne>.)/ ? 'true' : 'false';
==> false
say 'a' =~ /\k<regTwo>(?<regOne>.)/ ? 'true' : 'false';
==> Reference to nonexistent named group in regex...
I plan on fixing this in my subpattern references branch, which is nearing completion.
Tests 636 and 638 from test/perltestdata fail with stack overflows. Here are the relevant calls:
(ppcre:scan "((a{0,5}){0,5}){0,5}[c]" "aaaaaaaaaa")
(ppcre:scan "((a{0,5}){0,5})*[c]" "aaaaaaaaaa")
Hello,
I am using this library to implement my own strings library, and I have run into several instances of unexpected behavior. The first thing that I noticed relates to ppcre:scan
. I have a function that scans a given string to ensure that every character within said string is alphabetic, but it thinks that numbers are alphabetic. The function in question is as follows.
(defun alpha-p (target-string)
"Determines if TARGET-STRING contains at last one character and all characters are alphabetic."
(when (ppcre:scan "[a-zA-Z]+$" target-string)
t))
I have written a few tests for this function, which can be seen here, but the one I want to focus on is as follows. If I run the below statement.
(alpha-p "1My other string")
It should return nil
, because 1
not alphabetic, However, it always returns true. I, playing around, changed my function to the following.
(defun alpha-p (target-string)
"Determines if TARGET-STRING contains at last one character and all characters are alphabetic."
(when (ppcre:scan "^[a-zA-Z]+$" target-string)
t))
This caused the aformentioned test to run properly, returning nil
. However, it then started to fail another test.
(alpha-p "My fun string")
Now returns nil
every single time when it should return T
. I tried changing the entire statement to lowecase letters to no avail and I have gone over this to the point where I cannot find any errors and bugs in my code. When I statements outside of my function directly in a REPL I get the same problems. Is there perhaps a bug in this library? I have also experienced an issue where the following
(ppcre:scan "\\p{L}" STRING)
Will always return nil
as well. I do not know enough Common Lisp to properly debug this massive library, have you by chance heard others having this issue?
Hi, there's something I don't understand. The following snippet uses a single-character RE - and gets a match (wrongly), at invalid positions. When using a two-character RE, it correctly gives NIL
.
(let ((regex842 "k")
(string "1 a 312"))
(multiple-value-bind (cregex843 mregex844)
(let ((cl-ppcre:*allow-named-registers* t))
(cl-ppcre:create-scanner regex842))
(print (list cregex843 mregex844))
(multiple-value-bind (begin846 end847 starts848 ends849)
(funcall cregex843 string 0 nil)
;(cl-ppcre:scan regex842 string :start 0 :end nil)
(print (list begin846 end847 starts848 ends849))
(print (list string regex842)))))
Either version (with the precompiled scanner function, and the direct call to SCAN) fail.
Example results (actual values different each time):
(415 416 #() #())
("1 a 312" "q")
("1 a 312" "q")
(16589 16590 #() #())
("1 a 312" "k")
("1 a 312" "k")
This is with git HEAD (26aa9b6), and SBCL 1.3.3.debian.
Help, please?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.