![]() |
Fun 0.41.5
The programming language that makes you have fun!
|
Implements the OP_PCRE2_MATCH opcode (conditional build). More...
#include <pcre2.h>Go to the source code of this file.
Macros | |
| #define | PCRE2_CODE_UNIT_WIDTH 8 |
Functions | |
| if (vflags.type==VAL_INT||vflags.type==VAL_BOOL) flags | |
| free_value (vflags) | |
| free_value (vtext) | |
| free_value (vpat) | |
| if (!pattern||!subject) | |
| if (flags &1) opt| | |
| if (!re) | |
| if (rc<=0) | |
| void map_set & | res (full ? full :"") |
| if (full) | |
| pcre2_match_data_free (mdata) | |
| pcre2_code_free (re) | |
| free (pattern) | |
| free (subject) | |
| push_value (vm, res) | |
Variables | |
| case | OP_PCRE2_MATCH |
| Value | vtext = pop_value(vm) |
| Value | vpat = pop_value(vm) |
| int | flags = 0 |
| char * | pattern = value_to_string_alloc(&vpat) |
| char * | subject = value_to_string_alloc(&vtext) |
| int | errorcode |
| PCRE2_SIZE | erroff |
| uint32_t | opt = 0 |
| pcre2_code * | re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, opt, &errorcode, &erroff, NULL) |
| pcre2_match_data * | mdata = pcre2_match_data_create_from_pattern(re, NULL) |
| int | rc = pcre2_match(re, (PCRE2_SPTR)subject, (PCRE2_SIZE)strlen(subject), 0, 0, mdata, NULL) |
| PCRE2_SIZE * | ov = pcre2_get_ovector_pointer(mdata) |
| Value | res = make_map_empty() |
| int | start0 = (int)ov[0] |
| int | end0 = (int)ov[1] |
| char * | full = string_substr(subject, start0, end0 - start0) |
| break | |
Implements the OP_PCRE2_MATCH opcode (conditional build).
Executes a single PCRE2 pattern match against a subject string and returns a map describing the first match and its capture groups when FUN_WITH_PCRE2 is enabled. Returns Nil when there is no match or on error. When PCRE2 support is disabled at build time, the opcode always returns Nil.
Definition in file match.c.
| free | ( | pattern | ) |
| free | ( | subject | ) |
| free_value | ( | vflags | ) |
| free_value | ( | vpat | ) |
| free_value | ( | vtext | ) |
| if | ( | flags & | 1 | ) |
| pcre2_code_free | ( | re | ) |
| pcre2_match_data_free | ( | mdata | ) |
| push_value | ( | vm | , |
| res | ) |
| pcre2_match_data* mdata = pcre2_match_data_create_from_pattern(re, NULL) |
| case OP_PCRE2_MATCH |
OP_PCRE2_MATCH: (pattern:any, text:any, flags:int|bool=0) -> map|Nil
Behavior when FUN_WITH_PCRE2 is enabled:
Behavior when FUN_WITH_PCRE2 is disabled:
| char* pattern = value_to_string_alloc(&vpat) |
| void map_set& res = make_map_empty() |
| char* subject = value_to_string_alloc(&vtext) |