Skip to content

Commit

Permalink
synced to latest jsmin.c original
Browse files Browse the repository at this point in the history
  • Loading branch information
GerHobbelt committed Jan 17, 2011
1 parent 2e23993 commit 546bf3b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion jsmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ public function __construct($input) {

// -- Protected Instance Methods ---------------------------------------------



/* action -- do something! What you do is determined by the argument:
1 Output A. Copy B to A. Get the next B.
2 Copy B to A. Get the next B. (Delete A).
3 Get the next B. (Delete B).
action treats a string as a single character. Wow!
action recognizes a regular expression if it is preceded by ( or , or =.
*/
protected function action($d) {
switch($d) {
case 1:
Expand Down Expand Up @@ -107,7 +116,9 @@ protected function action($d) {
if ($this->b === '/' && (
$this->a === '(' || $this->a === ',' || $this->a === '=' ||
$this->a === ':' || $this->a === '[' || $this->a === '!' ||
$this->a === '&' || $this->a === '|' || $this->a === '?')) {
$this->a === '&' || $this->a === '|' || $this->a === '?' ||
$this->a === '{' || $this->a === '}' || $this->a === ';' ||
$this->a === "\n" )) {

$this->output .= $this->a . $this->b;

Expand Down Expand Up @@ -156,6 +167,9 @@ protected function get() {
return ' ';
}

/* isAlphanum -- return true if the character is a letter, digit, underscore,
dollar sign, or non-ASCII character.
*/
protected function isAlphaNum($c) {
return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1;
}
Expand Down Expand Up @@ -241,6 +255,9 @@ protected function min() {
return $this->output;
}

/* next -- get the next character, excluding comments. peek() is used to see
if a '/' is followed by a '/' or '*'.
*/
protected function next() {
$c = $this->get();

Expand Down

0 comments on commit 546bf3b

Please sign in to comment.