Very old versions of the library doesn't seem to have that option.
CONSTANT: PCRE_NO_START_OPTIMISE 0x04000000
CONSTANT: PCRE_PARTIAL_HARD 0x08000000
CONSTANT: PCRE_NOTEMPTY_ATSTART 0x10000000
+! New in 8.10
CONSTANT: PCRE_UCP 0x20000000
ENUM: PCRE_ERRORS
char* tableptr )
FUNCTION: int pcre_info ( void* pcre, int* optptr, int* first_byte )
-FUNCTION: int pcre_fullinfo ( void* pcre, pcre_extra* extra, int what, void *where )
+FUNCTION: int pcre_fullinfo ( void* pcre,
+ pcre_extra* extra,
+ int what, void *where )
FUNCTION: pcre_extra* pcre_study ( void* pcre, int options, char** errptr )
FUNCTION: int pcre_exec ( void* pcre,
{ "year" "month" "day" } [ pcre_get_stringnumber ] with map
] unit-test
-{ t } [ "foo" <compiled-pcre> PCRE_UTF8 has-option? ] unit-test
+{ t } [
+ "foo" <compiled-pcre> PCRE_UTF8 has-option?
+] unit-test
+
+! This option is not present on old PCRE versions.
+{ t } [
+ "foo" <compiled-pcre> version 8.10 >
+ [ PCRE_UCP has-option? ] [ PCRE_UCP has-option? not ] if
+] unit-test
os unix? [ [ 10 ] [ PCRE_CONFIG_NEWLINE pcre-config ] unit-test ] when
USING: accessors alien alien.accessors alien.c-types alien.data
alien.enums alien.strings arrays assocs combinators fry
io.encodings.string io.encodings.utf8 kernel literals math
-math.bitwise math.parser pcre.ffi sequences splitting strings ;
-QUALIFIED: regexp
+math.bitwise math.parser pcre.ffi regexp sequences splitting strings ;
IN: pcre
ERROR: bad-option what ;
ERROR: pcre-error value ;
+: version ( -- f )
+ pcre_version " " splitting:split1 drop string>number ;
+
<PRIVATE
: replace-all ( seq subseqs new -- seq )
: options ( pcre -- opts )
f PCRE_INFO_OPTIONS pcre-fullinfo ;
-CONSTANT: default-opts flags{ PCRE_UTF8 PCRE_UCP }
+: default-opts ( -- opts )
+ PCRE_UTF8 version 8.10 >= [ PCRE_UCP bitor ] when ;
: (pcre) ( expr -- pcre err-message err-offset )
default-opts { c-string int } [ f pcre_compile ] with-out-parameters ;
: split ( subject obj -- strings )
dupd findall [ first second ] map split-subseqs ;
-
-: version ( -- r )
- pcre_version " " splitting:split1 drop string>number ;