diff --git a/extra/pcre/ffi/ffi.factor b/extra/pcre/ffi/ffi.factor index 3144cbfaa5..4e58181861 100644 --- a/extra/pcre/ffi/ffi.factor +++ b/extra/pcre/ffi/ffi.factor @@ -49,6 +49,7 @@ CONSTANT: PCRE_NO_START_OPTIMIZE 0x04000000 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 @@ -137,7 +138,9 @@ FUNCTION: void* pcre_compile2 ( c-string pattern, 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, diff --git a/extra/pcre/pcre-tests.factor b/extra/pcre/pcre-tests.factor index d87be91a6d..686d93e772 100644 --- a/extra/pcre/pcre-tests.factor +++ b/extra/pcre/pcre-tests.factor @@ -27,7 +27,15 @@ CONSTANT: iso-date "(?P\\d{4})-(?P\\d{2})-(?P\\d{2})" { "year" "month" "day" } [ pcre_get_stringnumber ] with map ] unit-test -{ t } [ "foo" PCRE_UTF8 has-option? ] unit-test +{ t } [ + "foo" PCRE_UTF8 has-option? +] unit-test + +! This option is not present on old PCRE versions. +{ t } [ + "foo" 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 diff --git a/extra/pcre/pcre.factor b/extra/pcre/pcre.factor index eb18f4bb79..2ef992ab26 100644 --- a/extra/pcre/pcre.factor +++ b/extra/pcre/pcre.factor @@ -4,8 +4,7 @@ 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 ; @@ -14,6 +13,9 @@ ERROR: malformed-regexp expr error ; ERROR: pcre-error value ; +: version ( -- f ) + pcre_version " " splitting:split1 drop string>number ; + = [ PCRE_UCP bitor ] when ; : (pcre) ( expr -- pcre err-message err-offset ) default-opts { c-string int } [ f pcre_compile ] with-out-parameters ; @@ -155,6 +158,3 @@ M: regexp:regexp findall : split ( subject obj -- strings ) dupd findall [ first second ] map split-subseqs ; - -: version ( -- r ) - pcre_version " " splitting:split1 drop string>number ;