47 Value vflags = pop_value(vm);
48 Value vtext = pop_value(vm);
49 Value vpat = pop_value(vm);
59 if (subject)
free(subject);
63#ifndef PCRE2_CODE_UNIT_WIDTH 64#define PCRE2_CODE_UNIT_WIDTH 8 70 if (flags & 1) opt |= PCRE2_CASELESS;
71 if (flags & 2) opt |= PCRE2_MULTILINE;
72 if (flags & 4) opt |= PCRE2_DOTALL;
73 if (flags & 8) opt |= PCRE2_UTF;
74 if (flags & 16) opt |= PCRE2_EXTENDED;
75 pcre2_code *re = pcre2_compile((PCRE2_SPTR)
pattern, PCRE2_ZERO_TERMINATED, opt, &errorcode, &erroff, NULL);
82 pcre2_match_data *mdata = pcre2_match_data_create_from_pattern(re, NULL);
84 size_t subj_len = strlen(subject);
88 int rc = pcre2_match(re, (PCRE2_SPTR)subject, (PCRE2_SIZE)subj_len, start_off, 0, mdata, NULL);
90 PCRE2_SIZE *ov = pcre2_get_ovector_pointer(mdata);
101 for (
int i = 1; i <
rc; ++i) {
102 int s = (int)ov[2 * i];
103 int e = (int)ov[2 * i + 1];
106 if (gstr)
free(gstr);
113 if ((
size_t)e0 < subj_len) {
123 pcre2_match_data_free(mdata);
push_value(vm, make_array_from_values(NULL, 0))
int map_set(Value *vm, const char *key, Value v)
Insert or replace a key in the map.
Value make_map_empty(void)
Construct a new empty map Value.
char * string_substr(const char *s, int start, int len)
Create a newly allocated substring of s.
Tagged union representing a Fun value.
Value make_string(const char *s)
Construct a string Value by duplicating the given C string.
char * value_to_string_alloc(const Value *v)
Allocate a printable C string for a Value.
int array_push(Value *v, Value newElem)
Append a Value to an array.
Value make_int(int64_t v)
Construct a Value representing a 64-bit integer.
Value make_array_from_values(const Value *vals, int count)
Create an array Value by copying items from an input span.