Skip to content
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
1.3.2 (2020-01-09)
==================
This is a small maintenance release with some house cleaning and bug fixes.

New features:

* [FEATURE #631](https://github.com/rust-lang/regex/issues/631):
Add a `Match::range` method an a `From<Match> for Range` impl.

Bug fixes:

* [BUG #521](https://github.com/rust-lang/regex/issues/521):
Corrects `/-/.splitn("a", 2)` to return `["a"]` instead of `["a", ""]`.
* [BUG #594](https://github.com/rust-lang/regex/pull/594):
Improve error reporting when writing `\p\`.
* [BUG #627](https://github.com/rust-lang/regex/issues/627):
Corrects `/-/.split("a-")` to return `["a", ""]` instead of `["a"]`.
* [BUG #633](https://github.com/rust-lang/regex/pull/633):
Squash deprecation warnings for the `std::error::Error::description` method.


1.3.1 (2019-09-04)
==================
This is a maintenance release with no changes in order to try to work-around
Expand Down
4 changes: 2 additions & 2 deletions bench/src/ffi/tcl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

use std::mem;
use std::ptr;
use std::sync::{Once, ONCE_INIT};
use std::sync::Once;

use libc::{c_char, c_int, c_long, c_void};

// Used to initialize the TCL interpreter exactly once.
static ONCE: Once = ONCE_INIT;
static ONCE: Once = Once::new();

/// Text is a TCL string object backed by a Rust string.
///
Expand Down
9 changes: 9 additions & 0 deletions regex-syntax/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ pub enum ErrorKind {
/// `(?i)*`. It is, however, possible to create a repetition operating on
/// an empty sub-expression. For example, `()*` is still considered valid.
RepetitionMissing,
/// The Unicode class is not valid. This typically occurs when a `\p` is
/// followed by something other than a `{`.
UnicodeClassInvalid,
/// When octal support is disabled, this error is produced when an octal
/// escape is used. The octal escape is assumed to be an invocation of
/// a backreference, which is the common case.
Expand All @@ -176,6 +179,8 @@ pub enum ErrorKind {
}

impl error::Error for Error {
// TODO: Remove this method entirely on the next breaking semver release.
#[allow(deprecated)]
fn description(&self) -> &str {
use self::ErrorKind::*;
match self.kind {
Expand Down Expand Up @@ -206,6 +211,7 @@ impl error::Error for Error {
RepetitionCountInvalid => "invalid repetition count range",
RepetitionCountUnclosed => "unclosed counted repetition",
RepetitionMissing => "repetition operator missing expression",
UnicodeClassInvalid => "invalid Unicode character class",
UnsupportedBackreference => "backreferences are not supported",
UnsupportedLookAround => "look-around is not supported",
_ => unreachable!(),
Expand Down Expand Up @@ -293,6 +299,9 @@ impl fmt::Display for ErrorKind {
RepetitionMissing => {
write!(f, "repetition operator missing expression")
}
UnicodeClassInvalid => {
write!(f, "invalid Unicode character class")
}
UnsupportedBackreference => {
write!(f, "backreferences are not supported")
}
Expand Down
20 changes: 20 additions & 0 deletions regex-syntax/src/ast/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2095,6 +2095,12 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
} else {
let start = self.pos();
let c = self.char();
if c == '\\' {
return Err(self.error(
self.span_char(),
ast::ErrorKind::UnicodeClassInvalid,
));
}
self.bump_and_bump_space();
let kind = ast::ClassUnicodeKind::OneLetter(c);
(start, kind)
Expand Down Expand Up @@ -5713,6 +5719,20 @@ bar
],
}))
);
assert_eq!(
parser(r"\p\{").parse().unwrap_err(),
TestError {
span: span(2..3),
kind: ast::ErrorKind::UnicodeClassInvalid,
}
);
assert_eq!(
parser(r"\P\{").parse().unwrap_err(),
TestError {
span: span(2..3),
kind: ast::ErrorKind::UnicodeClassInvalid,
}
);
}

#[test]
Expand Down
2 changes: 2 additions & 0 deletions regex-syntax/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ impl From<hir::Error> for Error {
}

impl error::Error for Error {
// TODO: Remove this method entirely on the next breaking semver release.
#[allow(deprecated)]
fn description(&self) -> &str {
match *self {
Error::Parse(ref x) => x.description(),
Expand Down
6 changes: 6 additions & 0 deletions regex-syntax/src/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ pub enum ErrorKind {
}

impl ErrorKind {
// TODO: Remove this method entirely on the next breaking semver release.
#[allow(deprecated)]
fn description(&self) -> &str {
use self::ErrorKind::*;
match *self {
Expand All @@ -113,6 +115,8 @@ impl ErrorKind {
}

impl error::Error for Error {
// TODO: Remove this method entirely on the next breaking semver release.
#[allow(deprecated)]
fn description(&self) -> &str {
self.kind.description()
}
Expand All @@ -126,6 +130,8 @@ impl fmt::Display for Error {

impl fmt::Display for ErrorKind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// TODO: Remove this on the next breaking semver release.
#[allow(deprecated)]
f.write_str(self.description())
}
}
Expand Down
2 changes: 1 addition & 1 deletion regex-syntax/src/unicode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ enum CanonicalClassQuery {

/// Looks up a Unicode class given a query. If one doesn't exist, then
/// `None` is returned.
pub fn class<'a>(query: ClassQuery<'a>) -> Result<hir::ClassUnicode> {
pub fn class(query: ClassQuery) -> Result<hir::ClassUnicode> {
use self::CanonicalClassQuery::*;

match query.canonicalize()? {
Expand Down
17 changes: 4 additions & 13 deletions regex-syntax/src/unicode_tables/property_bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8203,12 +8203,8 @@ pub const OTHER_GRAPHEME_EXTEND: &'static [(char, char)] = &[
pub const OTHER_ID_CONTINUE: &'static [(char, char)] =
&[('·', '·'), ('·', '·'), ('፩', '፱'), ('᧚', '᧚')];

pub const OTHER_ID_START: &'static [(char, char)] = &[
('\u{1885}', '\u{1886}'),
('℘', '℘'),
('℮', '℮'),
('゛', '゜'),
];
pub const OTHER_ID_START: &'static [(char, char)] =
&[('\u{1885}', '\u{1886}'), ('℘', '℘'), ('℮', '℮'), ('゛', '゜')];

pub const OTHER_LOWERCASE: &'static [(char, char)] = &[
('ª', 'ª'),
Expand Down Expand Up @@ -8370,13 +8366,8 @@ pub const OTHER_MATH: &'static [(char, char)] = &[
('𞺫', '𞺻'),
];

pub const OTHER_UPPERCASE: &'static [(char, char)] = &[
('Ⅰ', 'Ⅿ'),
('Ⓐ', 'Ⓩ'),
('🄰', '🅉'),
('🅐', '🅩'),
('🅰', '🆉'),
];
pub const OTHER_UPPERCASE: &'static [(char, char)] =
&[('Ⅰ', 'Ⅿ'), ('Ⓐ', 'Ⓩ'), ('🄰', '🅉'), ('🅐', '🅩'), ('🅰', '🆉')];

pub const PATTERN_SYNTAX: &'static [(char, char)] = &[
('!', '/'),
Expand Down
Loading