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

/DIR1/DIR2/file.txt won't match glob /DIR1/*/* #21

Closed
PeAb opened this issue Mar 6, 2017 · 7 comments
Closed

/DIR1/DIR2/file.txt won't match glob /DIR1/*/* #21

PeAb opened this issue Mar 6, 2017 · 7 comments
Assignees

Comments

@PeAb
Copy link

PeAb commented Mar 6, 2017

Code example:

Glob glob = Glob.Parse(@"/DIR1/*/*");
MatchInfo matchInfo = glob.Match(@"/DIR1/DIR2/file.txt");
Console.Out.WriteLine("matchInfo.Success = {0}", matchInfo.Success);

gives:
matchInfo.Success = False

@dazinator
Copy link
Owner

Thanks for reporting.
The algortihms for IsMatch and Match are slightly different. Basically because Match() attempts to get additional information and so it does additional analysis, where as IsMatch() always attempts to fail fast if things don't match.
I'll need to check if this is a problem just for Match() or if it also effects IsMatch. I'll add a couple of tests cases for this.

@dazinator dazinator self-assigned this Mar 6, 2017
@dazinator
Copy link
Owner

Ok, this is fixed in latest build
I have extended the tests a bit, and included this as a regression test.
Latest nuget package if you want to re-test is: https://www.nuget.org/packages/DotNet.Glob/1.5.0-unstable0014

Thanks

@PeAb
Copy link
Author

PeAb commented Mar 7, 2017

Thanks, that fixed it. Although in the testcase below:

Glob glob = Glob.Parse(@"/DIR1/ab*d.txt");
string s = @"/DIR1/ab.txt";
bool isMatch = glob.IsMatch(s);
Console.Out.WriteLine("isMatch = {0}", isMatch);
MatchInfo matchInfo = glob.Match(s);
Console.Out.WriteLine("matchInfo.Success = {0}", matchInfo.Success);

The results are:
glob.IsMatch(s) works and returns False
...but glob.Match(s) generates a System.IndexOutOfRangeException

@dazinator
Copy link
Owner

Ok thanks, I'll add that to the test cases and will fix that shortly.

@dazinator dazinator reopened this Mar 7, 2017
@dazinator
Copy link
Owner

Just wondering, do you actually need Match() as opposed to IsMatch() ?

I ask because I'm tempted to drop this method until it can be written in a way that ensure it behaves identically to IsMatch.

@PeAb
Copy link
Author

PeAb commented Mar 28, 2017

I really only use IsMatch() currently.

@dazinator
Copy link
Owner

Closing this, will open a new issue to get rid of Match().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants