]> gitweb.factorcode.org Git - factor.git/commitdiff
pcre: pcre-config throws bad-option on error
authorBjörn Lindqvist <bjourne@gmail.com>
Fri, 29 Nov 2013 14:52:30 +0000 (15:52 +0100)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 3 Dec 2013 01:07:17 +0000 (17:07 -0800)
extra/pcre/ffi/ffi.factor
extra/pcre/pcre-tests.factor
extra/pcre/pcre.factor

index 772486373b6884ab8d56e948f7fe0035937da64d..8a7882479dcd25dd3fa3d75336d014f435ba6493 100644 (file)
@@ -75,33 +75,6 @@ ENUM: PCRE_ERRORS
     { PCRE_ERROR_BADOFFSET      -24 }
     { PCRE_ERROR_SHORTUTF8      -25 } ;
 
-CONSTANT: PCRE_ERROR_NOMATCH         -1
-CONSTANT: PCRE_ERROR_NULL            -2
-CONSTANT: PCRE_ERROR_BADOPTION       -3
-CONSTANT: PCRE_ERROR_BADMAGIC        -4
-CONSTANT: PCRE_ERROR_UNKNOWN_OPCODE  -5
-CONSTANT: PCRE_ERROR_UNKNOWN_NODE    -5
-CONSTANT: PCRE_ERROR_NOMEMORY        -6
-CONSTANT: PCRE_ERROR_NOSUBSTRING     -7
-CONSTANT: PCRE_ERROR_MATCHLIMIT      -8
-CONSTANT: PCRE_ERROR_CALLOUT         -9
-CONSTANT: PCRE_ERROR_BADUTF8        -10
-CONSTANT: PCRE_ERROR_BADUTF8_OFFSET -11
-CONSTANT: PCRE_ERROR_PARTIAL        -12
-CONSTANT: PCRE_ERROR_BADPARTIAL     -13
-CONSTANT: PCRE_ERROR_INTERNAL       -14
-CONSTANT: PCRE_ERROR_BADCOUNT       -15
-CONSTANT: PCRE_ERROR_DFA_UITEM      -16
-CONSTANT: PCRE_ERROR_DFA_UCOND      -17
-CONSTANT: PCRE_ERROR_DFA_UMLIMIT    -18
-CONSTANT: PCRE_ERROR_DFA_WSSIZE     -19
-CONSTANT: PCRE_ERROR_DFA_RECURSE    -20
-CONSTANT: PCRE_ERROR_RECURSIONLIMIT -21
-CONSTANT: PCRE_ERROR_NULLWSLIMIT    -22
-CONSTANT: PCRE_ERROR_BADNEWLINE     -23
-CONSTANT: PCRE_ERROR_BADOFFSET      -24
-CONSTANT: PCRE_ERROR_SHORTUTF8      -25
-
 CONSTANT: PCRE_INFO_OPTIONS            0
 CONSTANT: PCRE_INFO_SIZE               1
 CONSTANT: PCRE_INFO_CAPTURECOUNT       2
@@ -144,7 +117,7 @@ STRUCT: pcre_extra
     { mark uchar** }
     { executable_jit void* } ;
 
-FUNCTION: void pcre_config ( int what, void* where ) ;
+FUNCTION: int pcre_config ( int what, void* where ) ;
 
 FUNCTION: void* pcre_compile ( c-string pattern,
                                int options,
index fc0a56483f294a0036231ee0ea8040bcf2def09b..96cd03cbe7a74aa6d6a09c41e76fb0238c3e0235 100644 (file)
@@ -1,5 +1,6 @@
-USING: accessors arrays assocs http.client kernel math.ranges
-pcre pcre.ffi pcre.private random sequences system tools.test ;
+USING: accessors arrays assocs continuations http.client kernel
+literals math.ranges pcre pcre.ffi pcre.private random sequences
+system tools.test ;
 QUALIFIED: regexp
 IN: pcre.tests
 
@@ -34,9 +35,16 @@ os unix? [ [ 10 ] [ PCRE_CONFIG_NEWLINE pcre-config ] unit-test ] when
 
 [ 1 ] [ PCRE_CONFIG_UNICODE_PROPERTIES pcre-config ] unit-test
 
-! libpcre must not support 16 or 32 bit code points.
-[ 0 ] [ PCRE_CONFIG_UTF16 pcre-config ] unit-test
-[ 0 ] [ PCRE_CONFIG_UTF32 pcre-config ] unit-test
+! Ok if these options throw if the pcre library is to old to support
+! these configuration parameters.
+[ t ] [
+    [ PCRE_CONFIG_UTF16 pcre-config ] [ what>> ] recover
+    { 0 $ PCRE_CONFIG_UTF16 } member?
+] unit-test
+[ t ] [
+    [ PCRE_CONFIG_UTF32 pcre-config ] [ what>> ] recover
+    { 0 $ PCRE_CONFIG_UTF32 } member?
+] unit-test
 
 ! Tests for findall
 [
index 461f03ddda050f431463eb7c019894d3b90d2c9a..585ab4743e7f125e9d712050a5f3e3c5c390ef17 100644 (file)
@@ -8,6 +8,8 @@ math.bitwise pcre.ffi sequences splitting strings ;
 QUALIFIED: regexp
 IN: pcre
 
+ERROR: bad-option what ;
+
 ERROR: malformed-regexp expr error ;
 
 ERROR: pcre-error value ;
@@ -32,14 +34,8 @@ ERROR: pcre-error value ;
     ] [ 2drop f ] if* ;
 
 : pcre-config ( what -- value )
-    dup {
-        PCRE_CONFIG_MATCH_LIMIT
-        PCRE_CONFIG_MATCH_LIMIT_RECURSION
-    } member? [
-        { long } [ pcre_config ] with-out-parameters
-    ] [
-        { int } [ pcre_config ] with-out-parameters
-    ] if dup PCRE_ERROR_BADOPTION = [ pcre-error ] when ;
+    [ { long } [ pcre_config ] with-out-parameters ] keep
+    rot 0 = [ drop ] [ bad-option ] if ;
 
 : pcre-fullinfo ( pcre extra what -- obj )
     { int } [ pcre_fullinfo ] with-out-parameters nip ;
@@ -59,7 +55,7 @@ ERROR: pcre-error value ;
 
 : name-table-entry ( addr -- group-index group-name )
     [ <alien> 1 alien-unsigned-1 ]
-    [ 2 + <alien> utf8 alien>string ] bi ; 
+    [ 2 + <alien> utf8 alien>string ] bi ;
 
 : name-table-entries ( pcre extra -- addrs )
     [ name-table ] [ name-entry-size ] [ name-count ] 2tri