]> gitweb.factorcode.org Git - factor.git/commitdiff
pcre: only include PCRE_UCP on versions >= 8.10 of PCRE
authorBjörn Lindqvist <bjourne@gmail.com>
Fri, 19 Aug 2016 19:09:00 +0000 (21:09 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Fri, 19 Aug 2016 19:09:00 +0000 (21:09 +0200)
Very old versions of the library doesn't seem to have that option.

extra/pcre/ffi/ffi.factor
extra/pcre/pcre-tests.factor
extra/pcre/pcre.factor

index 3144cbfaa53c2057e6c06e78c9e8d4f616c9f9e0..4e581818617406e1ddbf74cebc285440518965c0 100644 (file)
@@ -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,
index d87be91a6d2b6f1b8865cce587e6b435e477788a..686d93e7724f87127f66dc810c56a1e42d37dc89 100644 (file)
@@ -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
 
index eb18f4bb793269306038096b02334ed94d3b93a8..2ef992ab2681e068cc39c6badb52ba932189ce46 100644 (file)
@@ -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 ;