-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Replace std::os::glob with extra::glob, which is written in rust ... #8201
Conversation
How does one match a literal |
'[' => { | ||
let mut chars = ~[]; | ||
let is_except = match pattern_iter.next() { | ||
None => false, // let the following loop fail with a message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless things have changed in the past 2 weeks, the iterator contract does not require that an iterator that returns None
once continue to return None
forever. In fact, the iterator contract specifies nothing at all about the behavior after None
has been returned once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you state appears to be true. Maybe the Iterator docs should be more explicit about this situation. I can rework the glob code to avoid the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dretch After discussion with @thestinger it sounds like he wants the iterator protocol to actually state that once None
is returned, future calls to next()
will continue to return None
.
I'd love to see a public function equivalent to |
Also, your implementation of the glob is inefficient when it hits Instead, you can split your pattern on all instances of |
pattern | ||
} | ||
|
||
fn pattern_matches(mut file: &str, pattern: &[PatternToken]) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that pattern_matches
lacks some considerations required by Patterns Used for Filename Expansion in SUSv4.
For example, foo/.bar
shall not be matched by the pattern foo/*
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. Special behaviour for dot-files would at least be consistent with the python glob module.
@Dretch: If you can make a |
Note that @kballard there is also |
@omasanori There's also |
there was no way to match NOT ']'). Also do some refactoring to avoid relying on the vector iterator always returning None after returning None for the first time (as requested by @kballard).
@kballard I agree with you. ( |
method that acts something like the C fnmatch function (albeit without any options... yet).
and Pattern::matches, and provide a case_sensitive option that defaults to true.
to the FNM_PATHNAME flag in the libc fnmatch function
@Dretch Needs a rebase. |
Closing due to lack of activity. Please reopen if you have time to rebase it! |
I am still working on this (albeit slowly)! I have some more commits coming (including a rebase). I can't see any way to reopen this pull request - should I start a new one? |
This is #8201 with a bunch of amendments to address the comments (and re-based).
Change `unnecessary_to_owned` `into_iter` suggestions to `MaybeIncorrect` I am having a hard time finding a good solution for rust-lang#8148, so I am wondering if is enough to just change the suggestion's applicability to `MaybeIncorrect`? I apologize, as I realize this is a bit of a cop out. changelog: none
... fixing issue #6100. This also addresses #6101.