Compare commits

...

2 Commits

Author SHA1 Message Date
Andrew Gallant
0891b4a3c0 update appveyor 2016-09-05 22:01:53 -04:00
Andrew Gallant
af48aaa647 another try 2016-09-05 21:57:57 -04:00
2 changed files with 15 additions and 18 deletions

View File

@@ -32,15 +32,13 @@ build: false
# Equivalent to Travis' `script` phase # Equivalent to Travis' `script` phase
# TODO modify this phase as you see fit # TODO modify this phase as you see fit
test_script: test_script:
# - cargo build --verbose - cargo test --verbose
- cargo test matchslash2 -- --nocapture
before_deploy: before_deploy:
# Generate artifacts for release # Generate artifacts for release
- SET RUSTFLAGS="-C target-feature=+ssse3" # TODO(burntsushi): How can we enable SSSE3 on Windows?
- cargo build --release --features simd-accel - cargo build --release
- mkdir staging - mkdir staging
# TODO update this part to copy the artifacts that make sense for your project
- copy target\release\xrep.exe staging - copy target\release\xrep.exe staging
- cd staging - cd staging
# release zipfile will look like 'rust-everywhere-v1.2.3-x86_64-pc-windows-msvc' # release zipfile will look like 'rust-everywhere-v1.2.3-x86_64-pc-windows-msvc'

View File

@@ -29,7 +29,6 @@ to make its way into `glob` proper.
use std::error::Error as StdError; use std::error::Error as StdError;
use std::fmt; use std::fmt;
use std::iter; use std::iter;
use std::path;
use std::str; use std::str;
use regex; use regex;
@@ -214,7 +213,7 @@ impl Pattern {
/// regular expression and will represent the matching semantics of this /// regular expression and will represent the matching semantics of this
/// glob pattern and the options given. /// glob pattern and the options given.
pub fn to_regex_with(&self, options: &MatchOptions) -> String { pub fn to_regex_with(&self, options: &MatchOptions) -> String {
let sep = regex::quote(&path::MAIN_SEPARATOR.to_string()); let seps = regex::quote(r"/\");
let mut re = String::new(); let mut re = String::new();
re.push_str("(?-u)"); re.push_str("(?-u)");
if options.case_insensitive { if options.case_insensitive {
@@ -235,26 +234,27 @@ impl Pattern {
} }
Token::Any => { Token::Any => {
if options.require_literal_separator { if options.require_literal_separator {
re.push_str(&format!("[^{}]", sep)); re.push_str(&format!("[^{}]", seps));
} else { } else {
re.push_str("."); re.push_str(".");
} }
} }
Token::ZeroOrMore => { Token::ZeroOrMore => {
if options.require_literal_separator { if options.require_literal_separator {
re.push_str(&format!("[^{}]*", sep)); re.push_str(&format!("[^{}]*", seps));
} else { } else {
re.push_str(".*"); re.push_str(".*");
} }
} }
Token::RecursivePrefix => { Token::RecursivePrefix => {
re.push_str(&format!("(?:{sep}?|.*{sep})", sep=sep)); re.push_str(&format!("(?:[{sep}]?|.*[{sep}])", sep=seps));
} }
Token::RecursiveSuffix => { Token::RecursiveSuffix => {
re.push_str(&format!("(?:{sep}?|{sep}.*)", sep=sep)); re.push_str(&format!("(?:[{sep}]?|[{sep}].*)", sep=seps));
} }
Token::RecursiveZeroOrMore => { Token::RecursiveZeroOrMore => {
re.push_str(&format!("(?:{sep}|{sep}.*{sep})", sep=sep)); re.push_str(&format!("(?:[{sep}]|[{sep}].*[{sep}])",
sep=seps));
} }
Token::Class { negated, ref ranges } => { Token::Class { negated, ref ranges } => {
re.push('['); re.push('[');
@@ -480,9 +480,9 @@ mod tests {
let pat = Pattern::new($pat).unwrap(); let pat = Pattern::new($pat).unwrap();
let path = &Path::new($path).to_str().unwrap(); let path = &Path::new($path).to_str().unwrap();
let re = Regex::new(&pat.to_regex_with(&$options)).unwrap(); let re = Regex::new(&pat.to_regex_with(&$options)).unwrap();
println!("PATTERN: {}", $pat); // println!("PATTERN: {}", $pat);
println!("REGEX: {:?}", re); // println!("REGEX: {:?}", re);
println!("PATH: {}", path); // println!("PATH: {}", path);
assert!(!re.is_match(path.as_bytes())); assert!(!re.is_match(path.as_bytes()));
} }
}; };
@@ -564,12 +564,11 @@ mod tests {
case_insensitive: true, case_insensitive: true,
require_literal_separator: false, require_literal_separator: false,
}; };
const SEP: char = ::std::path::MAIN_SEPARATOR;
toregex!(re_casei, "a", "(?i)^a$", &CASEI); toregex!(re_casei, "a", "(?i)^a$", &CASEI);
toregex!(re_slash1, "?", format!("^[^{}]$", SEP), SLASHLIT); toregex!(re_slash1, "?", r"^[^/\\]$", SLASHLIT);
toregex!(re_slash2, "*", format!("^[^{}]*$", SEP), SLASHLIT); toregex!(re_slash2, "*", r"^[^/\\]*$", SLASHLIT);
toregex!(re1, "a", "^a$"); toregex!(re1, "a", "^a$");
toregex!(re2, "?", "^.$"); toregex!(re2, "?", "^.$");