]> gitweb.factorcode.org Git - factor.git/commitdiff
pcre: pcre_config returns a long for some parameters and int otherwise
authorBjörn Lindqvist <bjourne@gmail.com>
Sat, 30 Nov 2013 17:38:55 +0000 (18:38 +0100)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 3 Dec 2013 01:07:18 +0000 (17:07 -0800)
extra/pcre/pcre.factor

index 25707a07aa34b01835ec449d9904cfdd8d6d205a..bfd16ce835281ebf9c3c7a3322f8b17239bb13b0 100644 (file)
@@ -33,13 +33,24 @@ ERROR: pcre-error value ;
         utf8-start-byte? [ nip ] [ next-utf8-char ] if
     ] [ 2drop f ] if* ;
 
-: pcre-config ( what -- value )
-    [ { long } [ pcre_config ] with-out-parameters ] keep
+: check-bad-option ( err value what -- value )
     rot 0 = [ drop ] [ bad-option ] 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
+    ] keep check-bad-option ;
+
 : pcre-fullinfo ( pcre extra what -- obj )
     [ { int } [ pcre_fullinfo ] with-out-parameters ] keep
-    rot 0 = [ drop ] [ bad-option ] if ;
+    check-bad-option ;
 
 : pcre-substring-list ( subject match-array count -- alien )
     { void* } [ pcre_get_substring_list drop ] with-out-parameters ;