fish-shell/fish-rust
Mahmoud Al-Qudsi 76dc849fca Warn about unescape_string_xxx() behavior (and tweak slightly)
The type system no longer guarantees that the input string is nul-terminated,
meaning accessing beyond the range-checked `i` a char-at-a-time is no longer
safe. (In C++, we would either be using a plain C string which is always
nul-terminated or we would be using (w)string::cstr() which similarly grants
access to its nul-terminated buffer.)

Aside from that, there's no need to explicitly check `if c2 == '\0'` because
'\0' is not a valid hex digit so the `?` tacked on to `convert_hex_digit(c2)?`
will abort and return `None` anyway.

convert_hex_digit() is not appreciably faster than char::to_digit(16) and makes
the code less maintainable since it encodes certain assumptions; since it's also
not used consistently just drop it in favor of the std fn.

Since the output string (per the decode logic) is always shorter than or equal
to the input string, just reserve the input string size upfront to prevent vec
reallocations.
2023-04-23 15:04:37 -05:00
..
src Warn about unescape_string_xxx() behavior (and tweak slightly) 2023-04-23 15:04:37 -05:00
widestring-suffix Initial Rust commit 2023-02-02 19:34:47 -07:00
build.rs Port AST to Rust 2023-04-16 17:46:56 +02:00
Cargo.lock Env stubs for path port 2023-04-21 13:57:29 +02:00
Cargo.toml Env stubs for path port 2023-04-21 13:57:29 +02:00