summaryrefslogtreecommitdiffstats
path: root/crates/core/args.rs
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2023-06-18 13:07:48 -0400
committerAndrew Gallant <jamslam@gmail.com>2023-07-05 14:04:29 -0400
commit4b8aa91ae5b17bd988ed05ab5c7c387de9247b13 (patch)
tree7d93dc03737260e6793b41e5b6f8f627f429fc08 /crates/core/args.rs
parenta775b493fd0d8dc23bdf43bbffe6d4c9f449e2ee (diff)
deps: update to pcre2 0.2.4
0.2.4 updates to PCRE2 10.42 and has a few other nice changes. For example, when `utf` is enabled, the crate will always set the PCRE2_MATCH_INVALID_UTF option. That means we no longer need to do transcoding or UTF-8 validity checks. Because of this, we actually get to remove one of the two uses of `unsafe` in ripgrep's `main` program. (This also updates a couple other dependencies for convenience.)
Diffstat (limited to 'crates/core/args.rs')
-rw-r--r--crates/core/args.rs33
1 files changed, 0 insertions, 33 deletions
diff --git a/crates/core/args.rs b/crates/core/args.rs
index 10e6a64f..3d5f7742 100644
--- a/crates/core/args.rs
+++ b/crates/core/args.rs
@@ -472,24 +472,6 @@ enum EncodingMode {
Disabled,
}
-impl EncodingMode {
- /// Checks if an explicit encoding has been set. Returns false for
- /// automatic BOM sniffing and no sniffing.
- ///
- /// This is only used to determine whether PCRE2 needs to have its own
- /// UTF-8 checking enabled. If we have an explicit encoding set, then
- /// we're always guaranteed to get UTF-8, so we can disable PCRE2's check.
- /// Otherwise, we have no such guarantee, and must enable PCRE2' UTF-8
- /// check.
- #[cfg(feature = "pcre2")]
- fn has_explicit_encoding(&self) -> bool {
- match self {
- EncodingMode::Some(_) => true,
- _ => false,
- }
- }
-}
-
impl ArgMatches {
/// Create an ArgMatches from clap's parse result.
fn new(clap_matches: clap::ArgMatches<'static>) -> ArgMatches {
@@ -732,14 +714,6 @@ impl ArgMatches {
}
if self.unicode() {
builder.utf(true).ucp(true);
- if self.encoding()?.has_explicit_encoding() {
- // SAFETY: If an encoding was specified, then we're guaranteed
- // to get valid UTF-8, so we can disable PCRE2's UTF checking.
- // (Feeding invalid UTF-8 to PCRE2 is undefined behavior.)
- unsafe {
- builder.disable_utf_check();
- }
- }
}
if self.is_present("multiline") {
builder.dotall(self.is_present("multiline-dotall"));
@@ -1080,7 +1054,6 @@ impl ArgMatches {
}
let label = match self.value_of_lossy("encoding") {
- None if self.pcre2_unicode() => "utf-8".to_string(),
None => return Ok(EncodingMode::Auto),
Some(label) => label,
};
@@ -1641,12 +1614,6 @@ impl ArgMatches {
!(self.is_present("no-unicode") || self.is_present("no-pcre2-unicode"))
}
- /// Returns true if and only if PCRE2 is enabled and its Unicode mode is
- /// enabled.
- fn pcre2_unicode(&self) -> bool {
- self.is_present("pcre2") && self.unicode()
- }
-
/// Returns true if and only if file names containing each match should
/// be emitted.
fn with_filename(&self, paths: &[PathBuf]) -> bool {