From 964e9d806b90cd407a3006bd7c21dd2a7a617183 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Fri, 27 Oct 2023 18:10:48 +0200 Subject: [PATCH] Split complex regexes to multiple lines in zend_vm_gen.php As requested by Dmitry in GH-12461 for easier reviewing. --- Zend/zend_vm_gen.php | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php index 978c13dc6b005..f7b630bc5a048 100755 --- a/Zend/zend_vm_gen.php +++ b/Zend/zend_vm_gen.php @@ -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"); @@ -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"); @@ -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");