diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /vendor/regex/src | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-upstream/1.69.0+dfsg1.tar.xz rustc-upstream/1.69.0+dfsg1.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | vendor/regex/src/lib.rs | 3 | ||||
-rw-r--r-- | vendor/regex/src/re_bytes.rs | 12 | ||||
-rw-r--r-- | vendor/regex/src/re_unicode.rs | 12 |
3 files changed, 15 insertions, 12 deletions
diff --git a/vendor/regex/src/lib.rs b/vendor/regex/src/lib.rs index 3e3b0a007..6b95739c5 100644 --- a/vendor/regex/src/lib.rs +++ b/vendor/regex/src/lib.rs @@ -353,6 +353,9 @@ $ the end of text (or end-of-line with multi-line mode) \B not a Unicode word boundary </pre> +The empty regex is valid and matches the empty string. For example, the empty +regex matches `abc` at positions `0`, `1`, `2` and `3`. + ## Grouping and flags <pre class="rust"> diff --git a/vendor/regex/src/re_bytes.rs b/vendor/regex/src/re_bytes.rs index d71969257..07e9f98ac 100644 --- a/vendor/regex/src/re_bytes.rs +++ b/vendor/regex/src/re_bytes.rs @@ -496,12 +496,12 @@ impl Regex { let mut new = Vec::with_capacity(text.len()); let mut last_match = 0; for (i, m) in it { - if limit > 0 && i >= limit { - break; - } new.extend_from_slice(&text[last_match..m.start()]); new.extend_from_slice(&rep); last_match = m.end(); + if limit > 0 && i >= limit - 1 { + break; + } } new.extend_from_slice(&text[last_match..]); return Cow::Owned(new); @@ -516,14 +516,14 @@ impl Regex { let mut new = Vec::with_capacity(text.len()); let mut last_match = 0; for (i, cap) in it { - if limit > 0 && i >= limit { - break; - } // unwrap on 0 is OK because captures only reports matches let m = cap.get(0).unwrap(); new.extend_from_slice(&text[last_match..m.start()]); rep.replace_append(&cap, &mut new); last_match = m.end(); + if limit > 0 && i >= limit - 1 { + break; + } } new.extend_from_slice(&text[last_match..]); Cow::Owned(new) diff --git a/vendor/regex/src/re_unicode.rs b/vendor/regex/src/re_unicode.rs index 60d81a7d9..197510ea0 100644 --- a/vendor/regex/src/re_unicode.rs +++ b/vendor/regex/src/re_unicode.rs @@ -554,12 +554,12 @@ impl Regex { let mut new = String::with_capacity(text.len()); let mut last_match = 0; for (i, m) in it { - if limit > 0 && i >= limit { - break; - } new.push_str(&text[last_match..m.start()]); new.push_str(&rep); last_match = m.end(); + if limit > 0 && i >= limit - 1 { + break; + } } new.push_str(&text[last_match..]); return Cow::Owned(new); @@ -574,14 +574,14 @@ impl Regex { let mut new = String::with_capacity(text.len()); let mut last_match = 0; for (i, cap) in it { - if limit > 0 && i >= limit { - break; - } // unwrap on 0 is OK because captures only reports matches let m = cap.get(0).unwrap(); new.push_str(&text[last_match..m.start()]); rep.replace_append(&cap, &mut new); last_match = m.end(); + if limit > 0 && i >= limit - 1 { + break; + } } new.push_str(&text[last_match..]); Cow::Owned(new) |