Skip to content

Commit 4e2afe7

Browse files
committed
Remove wtf8 dependency
1 parent dc98ea6 commit 4e2afe7

4 files changed

Lines changed: 8 additions & 17 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

parser/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ num-bigint = "0.2"
1818
num-traits = "0.2"
1919
unic-emoji-char = "0.9"
2020
unic-ucd-ident = "0.9"
21-
wtf8 = "0.0.3"

parser/src/lexer.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::location::Location;
88
use num_bigint::BigInt;
99
use num_traits::identities::Zero;
1010
use num_traits::Num;
11+
use std::char;
1112
use std::cmp::Ordering;
1213
use std::collections::HashMap;
1314
use std::str::FromStr;
@@ -442,22 +443,22 @@ where
442443

443444
fn unicode_literal(&mut self, literal_number: usize) -> Result<char, LexicalError> {
444445
let mut p: u32 = 0u32;
445-
let unicode_error = Err(LexicalError {
446+
let unicode_error = LexicalError {
446447
error: LexicalErrorType::UnicodeError,
447448
location: self.get_pos(),
448-
});
449+
};
449450
for i in 1..=literal_number {
450451
match self.next_char() {
451452
Some(c) => match c.to_digit(16) {
452453
Some(d) => p += d << ((literal_number - i) * 4),
453-
None => return unicode_error,
454+
None => return Err(unicode_error),
454455
},
455-
None => return unicode_error,
456+
None => return Err(unicode_error),
456457
}
457458
}
458-
match wtf8::CodePoint::from_u32(p) {
459-
Some(cp) => Ok(cp.to_char_lossy()),
460-
None => unicode_error,
459+
match p {
460+
0xD800..=0xDFFF => Ok(std::char::REPLACEMENT_CHARACTER),
461+
_ => std::char::from_u32(p).ok_or(unicode_error),
461462
}
462463
}
463464

vm/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ maplit = "1.0"
6363
bitflags = "1.1"
6464
libc = "0.2"
6565
nix = "0.16.0"
66-
wtf8 = "0.0.3"
6766
arr_macro = "0.1.2"
6867
csv = "1.1.1"
6968
paste = "0.1"

0 commit comments

Comments
 (0)