Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex failure when specifying path using backslashes (i.e. Windows-style). #300

Closed
seraku24 opened this issue Nov 1, 2016 · 0 comments
Closed
Assignees
Labels

Comments

@seraku24
Copy link
Contributor

seraku24 commented Nov 1, 2016

Consider the following commands:
haxelib run checkstyle -s tests/unit/src (Unix-style path)
haxelib run checkstyle -s tests\unit\src (Windows-style path)

On Windows, both commands run; however, the second one results in errors for each file processed. Here is an example of the output, when run against the haxe-flixel project:

tests\unit\src/FlxAssert.hx:1: character 0 : Error: Check AvoidStarImport failed: regexp.c(115) : Regexp compilation error : PCRE does not support \L, \l, \N{name}, \U, or \u in tests\unit\src:flixel:math:FlxRandomTest:.*?FlxAssert$
Stacktrace:
Called from /usr/local/lib/haxe/std/neko/_std/EReg.hx line 33
Called from /usr/local/lib/haxe/std/neko/_std/EReg.hx line 22
Called from checkstyle/Checker.hx line 288
Called from checkstyle/Checker.hx line 268

From a quick review of the code, the function Checker.checkForExclude() appears to only handle forward slashes. I suspect the escaping logic could be updated to something like the following:

var slashes = ~/[/\\]/g;
cls = slashes.replace(cls, ":");
for (exclude in excludesForCheck) {
	var regStr:String = slashes.replace(exclude, ":") + ":.*?" +
		cls.substring(cls.lastIndexOf(":") + 1, cls.length) + "$";
	var r = new EReg(regStr, "i");
	if (r.match(cls)) return true;
}
@seraku24 seraku24 changed the title Regex failure when specifiying path using backslashes (i.e. Windows-style). Regex failure when specifying path using backslashes (i.e. Windows-style). Nov 1, 2016
@adireddy adireddy added the bug label Nov 1, 2016
@adireddy adireddy self-assigned this Nov 1, 2016
adireddy added a commit that referenced this issue Nov 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants