From 932c9633c35b390beb2cfdea69a41ea7dbc8d759 Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Mon, 30 Mar 2015 11:04:42 -0400 Subject: [PATCH] Whitespace fixes --- src/JSMin/JSMin.php | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/JSMin/JSMin.php b/src/JSMin/JSMin.php index 1799be6..4fc320b 100644 --- a/src/JSMin/JSMin.php +++ b/src/JSMin/JSMin.php @@ -282,8 +282,8 @@ protected function isRegexpLiteral() return true; } - // check if first non-ws token is "/" (see starts-regex.js) - $length = strlen($this->output); + // check if first non-ws token is "/" (see starts-regex.js) + $length = strlen($this->output); if ($this->a === ' ' || $this->a === "\n") { if ($length < 2) { // weird edge case return true; @@ -292,25 +292,25 @@ protected function isRegexpLiteral() // if the "/" follows a keyword, it must be a regexp, otherwise it's best to assume division - $subject = $this->output . trim($this->a); - if (!preg_match('/(?:case|else|in|return|typeof)$/', $subject, $m)) { - // not a keyword - return false; - } - - // can't be sure it's a keyword yet (see not-regexp.js) - $charBeforeKeyword = substr($subject, 0 - strlen($m[0]) - 1, 1); - if ($this->isAlphaNum($charBeforeKeyword)) { - // this is really an identifier ending in a keyword, e.g. "xreturn" - return false; - } - - // it's a regexp. Remove unneeded whitespace after keyword - if ($this->a === ' ' || $this->a === "\n") { - $this->a = ''; - } - - return true; + $subject = $this->output . trim($this->a); + if (!preg_match('/(?:case|else|in|return|typeof)$/', $subject, $m)) { + // not a keyword + return false; + } + + // can't be sure it's a keyword yet (see not-regexp.js) + $charBeforeKeyword = substr($subject, 0 - strlen($m[0]) - 1, 1); + if ($this->isAlphaNum($charBeforeKeyword)) { + // this is really an identifier ending in a keyword, e.g. "xreturn" + return false; + } + + // it's a regexp. Remove unneeded whitespace after keyword + if ($this->a === ' ' || $this->a === "\n") { + $this->a = ''; + } + + return true; } /**