#include <assert.h>
#include <limits.h>
#include <math.h>
+#ifdef HAVE_ONIGURUMA
#include <oniguruma.h>
+#endif
#include <stdlib.h>
#include <string.h>
#include "builtin.h"
}
}
+#ifdef HAVE_ONIGURUMA
static int f_match_name_iter(const UChar* name, const UChar *name_end, int ngroups,
int *groups, regex_t *reg, void *arg) {
jv captures = *(jv*)arg;
return 0;
}
-
static jv f_match(jq_state *jq, jv input, jv regex, jv modifiers, jv testmode) {
int test = jv_equal(testmode, jv_true());
jv result;
jv_free(regex);
return result;
}
+#endif /* HAVE_ONIGURUMA */
static jv minmax_by(jv values, jv keys, int is_min) {
if (jv_get_kind(values) != JV_KIND_ARRAY)
{(cfunction_ptr)f_get_search_list, "get_search_list", 1},
{(cfunction_ptr)f_get_prog_origin, "get_prog_origin", 1},
{(cfunction_ptr)f_get_jq_origin, "get_jq_origin", 1},
+#ifdef HAVE_ONIGURUMA
{(cfunction_ptr)f_match, "_match_impl", 4},
+#endif
{(cfunction_ptr)f_modulemeta, "modulemeta", 1},
{(cfunction_ptr)f_input, "_input", 1},
{(cfunction_ptr)f_debug, "debug", 1},
"def flatten: reduce .[] as $i ([]; if $i | type == \"array\" then . + ($i | flatten) else . + [$i] end);",
"def flatten($x): reduce .[] as $i ([]; if $i | type == \"array\" and $x > 0 then . + ($i | flatten($x-1)) else . + [$i] end);",
"def range($x): range(0;$x);",
+#ifdef HAVE_ONIGURUMA
"def match(re; mode): _match_impl(re; mode; false)|.[];",
"def match($val): ($val|type) as $vt | if $vt == \"string\" then match($val; null)"
" elif $vt == \"array\" and ($val | length) > 1 then match($val[0]; $val[1])"
" end"
" end ;"
" [match($re; flags + \"g\")] as $edits | _stredit($edits; s) ;",
- "def gsub($re; s): gsub($re; s; \"\");"
+ "def gsub($re; s): gsub($re; s; \"\");",
+#endif /* HAVE_ONIGURUMA */
//#######################################################################
// range/3, with a `by` expression argument