diff options
author | Andrew Gallant <jamslam@gmail.com> | 2016-09-16 18:12:00 -0400 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2016-09-16 18:12:00 -0400 |
commit | d22a3ca3e57dc5c28bfb161fc6a0d54856e0f486 (patch) | |
tree | 0323ad1eeb3e940621ad1e45dbe7bc8272d26d8a | |
parent | e9ec52b7f99c402d407610e43b8333b7081ce7ea (diff) |
Improve the "bad literal" error message.
Incidentally, this was done by using the Debug impl for `char` instead
of the Display impl. Cute.
Fixes #5.
-rw-r--r-- | grep/src/lib.rs | 2 | ||||
-rw-r--r-- | grep/src/nonl.rs | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/grep/src/lib.rs b/grep/src/lib.rs index 68f95a4f..7526621d 100644 --- a/grep/src/lib.rs +++ b/grep/src/lib.rs @@ -62,7 +62,7 @@ impl fmt::Display for Error { match *self { Error::Regex(ref err) => err.fmt(f), Error::LiteralNotAllowed(chr) => { - write!(f, "Literal '{}' not allowed.", chr) + write!(f, "Literal {:?} not allowed.", chr) } Error::__Nonexhaustive => unreachable!(), } diff --git a/grep/src/nonl.rs b/grep/src/nonl.rs index e4dad13f..16fc103d 100644 --- a/grep/src/nonl.rs +++ b/grep/src/nonl.rs @@ -10,6 +10,10 @@ use {Error, Result}; /// If `byte` is not an ASCII character (i.e., greater than `0x7F`), then this /// function panics. pub fn remove(expr: Expr, byte: u8) -> Result<Expr> { + // TODO(burntsushi): There is a bug in this routine where only `\n` is + // handled correctly. Namely, `AnyChar` and `AnyByte` need to be translated + // to proper character classes instead of the special `AnyCharNoNL` and + // `AnyByteNoNL` classes. use syntax::Expr::*; assert!(byte <= 0x7F); let chr = byte as char; |