mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-15 01:17:45 +00:00
parse_constants.rs: stop decoding UTF-8 when parsing keywords
Unfortunately we cannot use wide string literals in match statements (not sure if there's an easy fix). Because of this, I converted the input to UTF-8 so we could use the match statement. This conversion is confusing, let's skip it.
This commit is contained in:
parent
b8189da011
commit
16fa942074
1 changed files with 20 additions and 20 deletions
|
@ -328,27 +328,27 @@ fn keyword_description(keyword: ParseKeyword) -> wcharz_t {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&wstr> for ParseKeyword {
|
impl From<&wstr> for ParseKeyword {
|
||||||
|
#[widestrs]
|
||||||
fn from(s: &wstr) -> Self {
|
fn from(s: &wstr) -> Self {
|
||||||
let s: Vec<u8> = s.encode_utf8().collect();
|
match s {
|
||||||
match unsafe { std::str::from_utf8_unchecked(&s) } {
|
_ if s == "!"L => ParseKeyword::kw_exclam,
|
||||||
"!" => ParseKeyword::kw_exclam,
|
_ if s == "and"L => ParseKeyword::kw_and,
|
||||||
"and" => ParseKeyword::kw_and,
|
_ if s == "begin"L => ParseKeyword::kw_begin,
|
||||||
"begin" => ParseKeyword::kw_begin,
|
_ if s == "builtin"L => ParseKeyword::kw_builtin,
|
||||||
"builtin" => ParseKeyword::kw_builtin,
|
_ if s == "case"L => ParseKeyword::kw_case,
|
||||||
"case" => ParseKeyword::kw_case,
|
_ if s == "command"L => ParseKeyword::kw_command,
|
||||||
"command" => ParseKeyword::kw_command,
|
_ if s == "else"L => ParseKeyword::kw_else,
|
||||||
"else" => ParseKeyword::kw_else,
|
_ if s == "end"L => ParseKeyword::kw_end,
|
||||||
"end" => ParseKeyword::kw_end,
|
_ if s == "exec"L => ParseKeyword::kw_exec,
|
||||||
"exec" => ParseKeyword::kw_exec,
|
_ if s == "for"L => ParseKeyword::kw_for,
|
||||||
"for" => ParseKeyword::kw_for,
|
_ if s == "function"L => ParseKeyword::kw_function,
|
||||||
"function" => ParseKeyword::kw_function,
|
_ if s == "if"L => ParseKeyword::kw_if,
|
||||||
"if" => ParseKeyword::kw_if,
|
_ if s == "in"L => ParseKeyword::kw_in,
|
||||||
"in" => ParseKeyword::kw_in,
|
_ if s == "not"L => ParseKeyword::kw_not,
|
||||||
"not" => ParseKeyword::kw_not,
|
_ if s == "or"L => ParseKeyword::kw_or,
|
||||||
"or" => ParseKeyword::kw_or,
|
_ if s == "switch"L => ParseKeyword::kw_switch,
|
||||||
"switch" => ParseKeyword::kw_switch,
|
_ if s == "time"L => ParseKeyword::kw_time,
|
||||||
"time" => ParseKeyword::kw_time,
|
_ if s == "while"L => ParseKeyword::kw_while,
|
||||||
"while" => ParseKeyword::kw_while,
|
|
||||||
_ => ParseKeyword::none,
|
_ => ParseKeyword::none,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue