]> gitweb.factorcode.org Git - factor.git/commitdiff
pcre: handle long values in pcre-config and throw errors.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sat, 23 Nov 2013 16:58:52 +0000 (08:58 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 23 Nov 2013 16:58:52 +0000 (08:58 -0800)
extra/pcre/pcre.factor

index ab5987af95dbbccb6a2335a5791045ffe4bff984..461f03ddda050f431463eb7c019894d3b90d2c9a 100644 (file)
@@ -31,8 +31,15 @@ ERROR: pcre-error value ;
         utf8-start-byte? [ nip ] [ next-utf8-char ] if
     ] [ 2drop f ] if* ;
 
-: pcre-config ( what -- alien )
-    { int } [ pcre_config ] with-out-parameters ;
+: 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 ;
 
 : pcre-fullinfo ( pcre extra what -- obj )
     { int } [ pcre_fullinfo ] with-out-parameters nip ;