mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 15:14:44 +00:00
Simplify match statement in escape_string_script
This commit is contained in:
parent
334946af61
commit
30fbd4280d
1 changed files with 20 additions and 23 deletions
|
@ -308,33 +308,30 @@ fn escape_string_script(input: &wstr, flags: EscapeFlags) -> WString {
|
|||
}
|
||||
out.push(c);
|
||||
}
|
||||
_ => {
|
||||
'\x00'..='\x19' => {
|
||||
let cval = u32::from(c);
|
||||
if cval < 32 {
|
||||
need_escape = true;
|
||||
need_complex_escape = true;
|
||||
need_escape = true;
|
||||
need_complex_escape = true;
|
||||
|
||||
if symbolic {
|
||||
out.push(char::from_u32(0x2400 + cval).unwrap());
|
||||
continue;
|
||||
}
|
||||
|
||||
if cval < 27 && cval != 0 {
|
||||
out.push('\\');
|
||||
out.push('c');
|
||||
out.push(char::from_u32(u32::from(b'a') + cval - 1).unwrap());
|
||||
continue;
|
||||
}
|
||||
|
||||
let nibble = cval % 16;
|
||||
out.push('\\');
|
||||
out.push('x');
|
||||
out.push(if cval > 15 { '1' } else { '0' });
|
||||
out.push(char::from_digit(nibble, 16).unwrap());
|
||||
} else {
|
||||
out.push(c);
|
||||
if symbolic {
|
||||
out.push(char::from_u32(0x2400 + cval).unwrap());
|
||||
continue;
|
||||
}
|
||||
|
||||
if cval < 27 && cval != 0 {
|
||||
out.push('\\');
|
||||
out.push('c');
|
||||
out.push(char::from_u32(u32::from(b'a') + cval - 1).unwrap());
|
||||
continue;
|
||||
}
|
||||
|
||||
let nibble = cval % 16;
|
||||
out.push('\\');
|
||||
out.push('x');
|
||||
out.push(if cval > 15 { '1' } else { '0' });
|
||||
out.push(char::from_digit(nibble, 16).unwrap());
|
||||
}
|
||||
_ => out.push(c),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue