Skip to content

Commit

Permalink
#22 Rewrite regular expressions that start with '^' or end with '$'
Browse files Browse the repository at this point in the history
  • Loading branch information
melloc committed Mar 15, 2017
1 parent 9600c7e commit b9f5092
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion jsstyle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# Copyright 2016 Joyent, Inc. All rights reserved.
# Copyright 2017 Joyent, Inc. All rights reserved.
#
# jsstyle - check for some common stylistic errors.
#
Expand Down Expand Up @@ -308,6 +308,15 @@ line: while (<$filehandle>) {
s/'([^\\']|\\.)*'/\'\'/g;
s/"([^\\"]|\\.)*"/\"\"/g;

#
# Strip out contents of easily identifiable regular expressions so that
# they don't trip us up. We only modify those that start with '^' or end
# with '$' since these are unlikely to be confused with other legitimate
# uses of '/' (such as division or comments).
#
s!/\^([^\\/]|\\.)*/!/ /!g;
s!/([^\\/]|\\.)*\$/!/ /!g;

#
# detect string continuation
#
Expand Down

0 comments on commit b9f5092

Please sign in to comment.