Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
test.c File Reference

Implements the OP_PCRE2_TEST opcode (conditional build). More...

Go to the source code of this file.

Functions

 free_value (a)
 free_value (b)
 free_value (c)
 push_value (vm, make_int(0))

Variables

case OP_PCRE2_TEST
Value b = pop_value(vm)
Value c = pop_value(vm)
 break

Detailed Description

Implements the OP_PCRE2_TEST opcode (conditional build).

Tests whether a PCRE2 pattern matches a subject string and returns 1 on success or 0 otherwise when FUN_WITH_PCRE2 is enabled. When PCRE2 support is disabled at build time, the opcode always returns 0.

Definition in file test.c.

Function Documentation

◆ free_value() [1/3]

free_value(a)

◆ free_value() [2/3]

free_value(b)

◆ free_value() [3/3]

free_value(c)

◆ push_value()

push_value(vm,
make_int(0) )

Variable Documentation

◆ b

Value b = pop_value(vm)

Definition at line 86 of file test.c.

◆ break

break

Definition at line 92 of file test.c.

◆ c

Value c = pop_value(vm)

Definition at line 88 of file test.c.

◆ OP_PCRE2_TEST

case OP_PCRE2_TEST

OP_PCRE2_TEST: (pattern:any, text:any, flags:int|bool=0) -> int

Behavior when FUN_WITH_PCRE2 is enabled:

  • Pops: pattern, text, flags. Converts pattern/text to strings.
  • Flags bits:
    • 1 = PCRE2_CASELESS (I)
    • 2 = PCRE2_MULTILINE (M)
    • 4 = PCRE2_DOTALL (S)
    • 8 = PCRE2_UTF (U)
    • 16 = PCRE2_EXTENDED (X)
  • Returns 1 if pcre2_match() returns a non-negative result, else 0.
  • On compile error or allocation failure, returns 0.

Behavior when FUN_WITH_PCRE2 is disabled:

  • Pops three values and returns 0.

Definition at line 38 of file test.c.