pcre: only include PCRE_UCP on versions >= 8.10 of PCRE
Very old versions of the library doesn't seem to have that option.char-rename
parent
3ea34c667d
commit
eb8ce16277
|
@ -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,
|
||||
|
|
|
@ -27,7 +27,15 @@ CONSTANT: iso-date "(?P<year>\\d{4})-(?P<month>\\d{2})-(?P<day>\\d{2})"
|
|||
{ "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
|
||||
|
||||
|
|
|
@ -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 ;
|
||||
|
||||
<PRIVATE
|
||||
|
||||
: replace-all ( seq subseqs new -- seq )
|
||||
|
@ -75,7 +77,8 @@ ERROR: pcre-error value ;
|
|||
: 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 ;
|
||||
|
@ -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 ;
|
||||
|
|
Loading…
Reference in New Issue