mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-08-03 05:32:04 -07:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
af48aaa647 | ||
|
ee7f300ae2 | ||
|
a4d8db16f7 | ||
|
3bb387abdd | ||
|
7f0273c347 | ||
|
5b42999a3d | ||
|
8887250860 | ||
|
5c820ba638 |
65
appveyor.yml
65
appveyor.yml
@@ -1,17 +1,70 @@
|
|||||||
environment:
|
environment:
|
||||||
|
global:
|
||||||
|
PROJECT_NAME: xrep
|
||||||
matrix:
|
matrix:
|
||||||
- TARGET: x86_64-pc-windows-msvc
|
# Nightly channel
|
||||||
- TARGET: i686-pc-windows-gnu
|
- TARGET: i686-pc-windows-gnu
|
||||||
|
CHANNEL: nightly
|
||||||
|
- TARGET: i686-pc-windows-msvc
|
||||||
|
CHANNEL: nightly
|
||||||
|
- TARGET: x86_64-pc-windows-gnu
|
||||||
|
CHANNEL: nightly
|
||||||
|
- TARGET: x86_64-pc-windows-msvc
|
||||||
|
CHANNEL: nightly
|
||||||
|
|
||||||
|
# Install Rust and Cargo
|
||||||
|
# (Based on from https://github.com/rust-lang/libc/blob/master/appveyor.yml)
|
||||||
install:
|
install:
|
||||||
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe"
|
- ps: Start-FileDownload "https://static.rust-lang.org/dist/channel-rust-stable"
|
||||||
- rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
|
- ps: $env:RUST_VERSION = Get-Content channel-rust-stable | select -first 1 | %{$_.split('-')[1]}
|
||||||
|
- if NOT "%CHANNEL%" == "stable" set RUST_VERSION=%CHANNEL%
|
||||||
|
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-${env:RUST_VERSION}-${env:TARGET}.exe"
|
||||||
|
- rust-%RUST_VERSION%-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
|
||||||
- SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin
|
- SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin
|
||||||
- SET PATH=%PATH%;C:\MinGW\bin
|
- if "%TARGET%" == "i686-pc-windows-gnu" set PATH=%PATH%;C:\msys64\mingw32\bin
|
||||||
|
- if "%TARGET%" == "x86_64-pc-windows-gnu" set PATH=%PATH%;C:\msys64\mingw64\bin
|
||||||
- rustc -V
|
- rustc -V
|
||||||
- cargo -V
|
- cargo -V
|
||||||
|
|
||||||
|
# ???
|
||||||
build: false
|
build: false
|
||||||
|
|
||||||
|
# Equivalent to Travis' `script` phase
|
||||||
|
# TODO modify this phase as you see fit
|
||||||
test_script:
|
test_script:
|
||||||
- cargo build --verbose
|
# - cargo build --verbose
|
||||||
- cargo test --verbose
|
- cargo test matchslash2 -- --nocapture
|
||||||
|
|
||||||
|
before_deploy:
|
||||||
|
# Generate artifacts for release
|
||||||
|
- SET RUSTFLAGS="-C target-feature=+ssse3"
|
||||||
|
- cargo build --release --features simd-accel
|
||||||
|
- mkdir staging
|
||||||
|
# TODO update this part to copy the artifacts that make sense for your project
|
||||||
|
- copy target\release\xrep.exe staging
|
||||||
|
- cd staging
|
||||||
|
# release zipfile will look like 'rust-everywhere-v1.2.3-x86_64-pc-windows-msvc'
|
||||||
|
- 7z a ../%PROJECT_NAME%-%APPVEYOR_REPO_TAG_NAME%-%TARGET%.zip *
|
||||||
|
- appveyor PushArtifact ../%PROJECT_NAME%-%APPVEYOR_REPO_TAG_NAME%-%TARGET%.zip
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
description: 'Windows release'
|
||||||
|
# All the zipped artifacts will be deployed
|
||||||
|
artifact: /.*\.zip/
|
||||||
|
auth_token:
|
||||||
|
secure: vv4vBCEosGlyQjaEC1+kraP2P6O4CQSa+Tw50oHWFTGcmuXxaWS0/yEXbxsIRLpw
|
||||||
|
provider: GitHub
|
||||||
|
# deploy when a new tag is pushed and only on the stable channel
|
||||||
|
on:
|
||||||
|
# channel to use to produce the release artifacts
|
||||||
|
# NOTE make sure you only release *once* per target
|
||||||
|
# TODO you may want to pick a different channel
|
||||||
|
CHANNEL: nightly
|
||||||
|
appveyor_repo_tag: true
|
||||||
|
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- appveyor
|
||||||
|
- /\d+\.\d+\.\d+/
|
||||||
|
except:
|
||||||
|
- master
|
||||||
|
31
src/glob.rs
31
src/glob.rs
@@ -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 = 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!("[^{}]", regex::quote(&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!("[^{}]*", regex::quote(&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('[');
|
||||||
@@ -414,6 +414,8 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
use regex::bytes::Regex;
|
use regex::bytes::Regex;
|
||||||
|
|
||||||
use super::{Error, Pattern, MatchOptions, SetBuilder, Token};
|
use super::{Error, Pattern, MatchOptions, SetBuilder, Token};
|
||||||
@@ -461,8 +463,9 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn $name() {
|
fn $name() {
|
||||||
let pat = Pattern::new($pat).unwrap();
|
let pat = Pattern::new($pat).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();
|
||||||
assert!(re.is_match($path.as_bytes()));
|
assert!(re.is_match(path.as_bytes()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -475,8 +478,12 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn $name() {
|
fn $name() {
|
||||||
let pat = Pattern::new($pat).unwrap();
|
let pat = Pattern::new($pat).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();
|
||||||
assert!(!re.is_match($path.as_bytes()));
|
// println!("PATTERN: {}", $pat);
|
||||||
|
// println!("REGEX: {:?}", re);
|
||||||
|
// println!("PATH: {}", path);
|
||||||
|
assert!(!re.is_match(path.as_bytes()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -557,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, "?", "^.$");
|
||||||
@@ -638,6 +644,7 @@ mod tests {
|
|||||||
|
|
||||||
matches!(matchslash1, "abc/def", "abc/def", SLASHLIT);
|
matches!(matchslash1, "abc/def", "abc/def", SLASHLIT);
|
||||||
nmatches!(matchslash2, "abc?def", "abc/def", SLASHLIT);
|
nmatches!(matchslash2, "abc?def", "abc/def", SLASHLIT);
|
||||||
|
nmatches!(matchslash2_win, "abc?def", "abc\\def", SLASHLIT);
|
||||||
nmatches!(matchslash3, "abc*def", "abc/def", SLASHLIT);
|
nmatches!(matchslash3, "abc*def", "abc/def", SLASHLIT);
|
||||||
matches!(matchslash4, "abc[/]def", "abc/def", SLASHLIT); // differs
|
matches!(matchslash4, "abc[/]def", "abc/def", SLASHLIT); // differs
|
||||||
|
|
||||||
|
@@ -239,6 +239,7 @@ impl<W: Send + io::Write> Printer<W> {
|
|||||||
fn line_number(&mut self, n: u64, sep: u8) {
|
fn line_number(&mut self, n: u64, sep: u8) {
|
||||||
if self.wtr.is_color() {
|
if self.wtr.is_color() {
|
||||||
let _ = self.wtr.fg(YELLOW);
|
let _ = self.wtr.fg(YELLOW);
|
||||||
|
let _ = self.wtr.attr(term::Attr::Bold);
|
||||||
}
|
}
|
||||||
self.write(n.to_string().as_bytes());
|
self.write(n.to_string().as_bytes());
|
||||||
if self.wtr.is_color() {
|
if self.wtr.is_color() {
|
||||||
|
@@ -37,6 +37,6 @@ pub fn stdout_is_atty() -> bool {
|
|||||||
unsafe {
|
unsafe {
|
||||||
let fd = winapi::winbase::STD_OUTPUT_HANDLE;
|
let fd = winapi::winbase::STD_OUTPUT_HANDLE;
|
||||||
let mut out = 0;
|
let mut out = 0;
|
||||||
kernel32::GetConsoleMode(handle, &mut out) != 0
|
kernel32::GetConsoleMode(kernel32::GetStdHandle(fd), &mut out) != 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user