Skip to content

Commit

Permalink
Split complex regexes to multiple lines in zend_vm_gen.php
Browse files Browse the repository at this point in the history
As requested by Dmitry in GH-12461 for easier reviewing.
  • Loading branch information
iluuu1994 committed Oct 27, 2023
1 parent d97ce2f commit 964e9d8
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions Zend/zend_vm_gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -2414,7 +2414,16 @@ function gen_vm($def, $skel) {
strpos($line,"ZEND_VM_COLD_CONSTCONST_HANDLER(") === 0) {
// Parsing opcode handler's definition
if (preg_match(
"/^ZEND_VM_(HOT_|INLINE_|HOT_OBJ_|HOT_SEND_|HOT_NOCONST_|HOT_NOCONSTCONST_|COLD_|COLD_CONST_|COLD_CONSTCONST_)?HANDLER\(\s*([0-9]+)\s*,\s*([A-Z_]+)\s*,\s*([A-Z_|]+)\s*,\s*([A-Z_|]+)\s*(,\s*([A-Z_|]+)\s*)?(,\s*SPEC\(([A-Z_|=,]+)\)\s*)?\)/",
"/^
ZEND_VM_(HOT_|INLINE_|HOT_OBJ_|HOT_SEND_|HOT_NOCONST_|HOT_NOCONSTCONST_|COLD_|COLD_CONST_|COLD_CONSTCONST_)?HANDLER\(
\s*([0-9]+)\s*,
\s*([A-Z_]+)\s*,
\s*([A-Z_|]+)\s*,
\s*([A-Z_|]+)\s*
(,\s*([A-Z_|]+)\s*)?
(,\s*SPEC\(([A-Z_|=,]+)\)\s*)?
\)
$/x",
$line,
$m) == 0) {
die("ERROR ($def:$lineno): Invalid ZEND_VM_HANDLER definition.\n");
Expand Down Expand Up @@ -2465,7 +2474,17 @@ function gen_vm($def, $skel) {
strpos($line,"ZEND_VM_HOT_OBJ_TYPE_SPEC_HANDLER(") === 0) {
// Parsing opcode handler's definition
if (preg_match(
"/^ZEND_VM_(HOT_|INLINE_|HOT_OBJ_|HOT_SEND_|HOT_NOCONST_|HOT_NOCONSTCONST_)?TYPE_SPEC_HANDLER\(\s*([A-Z_|]+)\s*,\s*((?:[^(,]|\([^()]*|(?R)*\))*),\s*([A-Za-z_]+)\s*,\s*([A-Z_|]+)\s*,\s*([A-Z_|]+)\s*(,\s*([A-Z_|]+)\s*)?(,\s*SPEC\(([A-Z_|=,]+)\)\s*)?\)/",
"/^
ZEND_VM_(HOT_|INLINE_|HOT_OBJ_|HOT_SEND_|HOT_NOCONST_|HOT_NOCONSTCONST_)?TYPE_SPEC_HANDLER\(
\s*([A-Z_|]+)\s*,
\s*((?:[^(,]|\([^()]*|(?R)*\))*),
\s*([A-Za-z_]+)\s*,
\s*([A-Z_|]+)\s*,
\s*([A-Z_|]+)\s*
(,\s*([A-Z_|]+)\s*)?
(,\s*SPEC\(([A-Z_|=,]+)\)\s*)?
\)
$/x",
$line,
$m) == 0) {
die("ERROR ($def:$lineno): Invalid ZEND_VM_TYPE_HANDLER_HANDLER definition.\n");
Expand Down Expand Up @@ -2513,7 +2532,15 @@ function gen_vm($def, $skel) {
strpos($line,"ZEND_VM_HOT_HELPER(") === 0) {
// Parsing helper's definition
if (preg_match(
"/^ZEND_VM(_INLINE|_COLD|_HOT)?_HELPER\(\s*([A-Za-z_]+)\s*,\s*([A-Z_|]+)\s*,\s*([A-Z_|]+)\s*(?:,\s*SPEC\(([A-Z_|=,]+)\)\s*)?(?:,\s*([^)]*)\s*)?\)/",
"/^
ZEND_VM(_INLINE|_COLD|_HOT)?_HELPER\(
\s*([A-Za-z_]+)\s*,
\s*([A-Z_|]+)\s*,
\s*([A-Z_|]+)\s*
(?:,\s*SPEC\(([A-Z_|=,]+)\)\s*)?
(?:,\s*([^)]*)\s*)?
\)
$/x",
$line,
$m) == 0) {
die("ERROR ($def:$lineno): Invalid ZEND_VM_HELPER definition.\n");
Expand Down

0 comments on commit 964e9d8

Please sign in to comment.