]> git.lizzy.rs Git - rust.git/commitdiff
std::ascii: Fix is_digit() and is_control()
authorEric Biggers <ebiggers3@gmail.com>
Wed, 27 Nov 2013 02:13:25 +0000 (20:13 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Wed, 27 Nov 2013 02:13:25 +0000 (20:13 -0600)
is_digit() incorrectly returned false for '0'.
is_control() incorrectly returned true for ' ' (space).

src/libstd/ascii.rs

index 18b6a1ef52a00da0bc94438095a2a9d2e378ad9e..d62a03a5ad47beaffa8a193e82601554672f66a6 100644 (file)
@@ -67,7 +67,7 @@ pub fn is_alpha(&self) -> bool {
     /// Check if the character is a number (0-9)
     #[inline]
     pub fn is_digit(&self) -> bool {
-        self.chr >= 0x31 && self.chr <= 0x39
+        self.chr >= 0x30 && self.chr <= 0x39
     }
 
     /// Check if the character is a letter or number
@@ -85,7 +85,7 @@ pub fn is_blank(&self) -> bool {
     /// Check if the character is a control character
     #[inline]
     pub fn is_control(&self) -> bool {
-        self.chr <= 0x20 || self.chr == 0x7F
+        self.chr < 0x20 || self.chr == 0x7F
     }
 
     /// Checks if the character is printable (except space)