Skip to content

Commit

Permalink
#2321 - Remove redundant character escapes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Nov 21, 2021
1 parent 9e9231a commit d5cf342
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Library/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -1316,13 +1316,13 @@ public function processExtensionGlobals(string $namespace): array
* Process compound structures
*/
foreach ($structures as $structureName => $internalStructure) {
if (preg_match('/^[0-9a-zA-Z\_]$/', $structureName)) {
if (preg_match('/^[0-9a-zA-Z_]$/', $structureName)) {
throw new Exception("Struct name: '".$structureName."' contains invalid characters");
}

$structBuilder = new Struct('_zephir_struct_'.$structureName, $structureName);
foreach ($internalStructure as $field => $global) {
if (preg_match('/^[0-9a-zA-Z\_]$/', $field)) {
if (preg_match('/^[0-9a-zA-Z_]$/', $field)) {
throw new Exception("Struct field name: '".$field."' contains invalid characters");
}

Expand All @@ -1345,7 +1345,7 @@ public function processExtensionGlobals(string $namespace): array
* Process single variables
*/
foreach ($variables as $name => $global) {
if (preg_match('/^[0-9a-zA-Z\_]$/', $name)) {
if (preg_match('/^[0-9a-zA-Z_]$/', $name)) {
throw new Exception("Extension global variable name: '".$name."' contains invalid characters");
}

Expand Down Expand Up @@ -2167,11 +2167,12 @@ private function loadConstantsSources(array $constantsSources)
}

foreach (file($constantsSource) as $line) {
if (preg_match('/^\#define[ \t]+([A-Z0-9\_]+)[ \t]+([0-9]+)/', $line, $matches)) {
if (preg_match('/^#define[ \t]+([A-Z0-9_]+)[ \t]+([0-9]+)/', $line, $matches)) {
$this->constants[$matches[1]] = ['int', $matches[2]];
continue;
}
if (preg_match('/^\#define[ \t]+([A-Z0-9\_]+)[ \t]+(\'(.){1}\')/', $line, $matches)) {

if (preg_match('/^#define[ \t]+([A-Z0-9_]+)[ \t]+(\'(.)\')/', $line, $matches)) {
$this->constants[$matches[1]] = ['char', $matches[3]];
}
}
Expand Down

0 comments on commit d5cf342

Please sign in to comment.