45 Value vflags = pop_value(vm);
46 Value vtext = pop_value(vm);
47 Value vpat = pop_value(vm);
57 if (subject)
free(subject);
61#ifndef PCRE2_CODE_UNIT_WIDTH 62#define PCRE2_CODE_UNIT_WIDTH 8 68 if (flags & 1) opt |= PCRE2_CASELESS;
69 if (flags & 2) opt |= PCRE2_MULTILINE;
70 if (flags & 4) opt |= PCRE2_DOTALL;
71 if (flags & 8) opt |= PCRE2_UTF;
72 if (flags & 16) opt |= PCRE2_EXTENDED;
73 pcre2_code *re = pcre2_compile((PCRE2_SPTR)
pattern, PCRE2_ZERO_TERMINATED, opt, &errorcode, &erroff, NULL);
80 pcre2_match_data *mdata = pcre2_match_data_create_from_pattern(re, NULL);
81 int rc = pcre2_match(re, (PCRE2_SPTR)subject, (PCRE2_SIZE)strlen(subject), 0, 0, mdata, NULL);
83 pcre2_match_data_free(mdata);
90 PCRE2_SIZE *ov = pcre2_get_ovector_pointer(mdata);
93 int start0 = (int)ov[0];
94 int end0 = (int)ov[1];
102 for (
int i = 1; i <
rc; ++i) {
103 int s = (int)ov[2 * i];
104 int e = (int)ov[2 * i + 1];
107 if (gstr)
free(gstr);
111 pcre2_match_data_free(mdata);
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.
push_value(vm, make_nil())
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_nil(void)
Construct a nil 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.