chore(src/compiler/msvc): replace rust-encoding with encoding-rs ...

... since former is unmaintained
This commit is contained in:
liushuyu 2024-01-05 18:15:43 -07:00 коммит произвёл Sylvestre Ledru
Родитель b260af4802
Коммит 556303635a
3 изменённых файлов: 16 добавлений и 74 удалений

66
Cargo.lock сгенерированный
Просмотреть файл

@ -657,70 +657,6 @@ version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "encoding"
version = "0.2.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec"
dependencies = [
"encoding-index-japanese",
"encoding-index-korean",
"encoding-index-simpchinese",
"encoding-index-singlebyte",
"encoding-index-tradchinese",
]
[[package]]
name = "encoding-index-japanese"
version = "1.20141219.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91"
dependencies = [
"encoding_index_tests",
]
[[package]]
name = "encoding-index-korean"
version = "1.20141219.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81"
dependencies = [
"encoding_index_tests",
]
[[package]]
name = "encoding-index-simpchinese"
version = "1.20141219.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7"
dependencies = [
"encoding_index_tests",
]
[[package]]
name = "encoding-index-singlebyte"
version = "1.20141219.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a"
dependencies = [
"encoding_index_tests",
]
[[package]]
name = "encoding-index-tradchinese"
version = "1.20141219.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18"
dependencies = [
"encoding_index_tests",
]
[[package]]
name = "encoding_index_tests"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
[[package]] [[package]]
name = "encoding_rs" name = "encoding_rs"
version = "0.8.33" version = "0.8.33"
@ -2404,7 +2340,7 @@ dependencies = [
"clap", "clap",
"daemonize", "daemonize",
"directories", "directories",
"encoding", "encoding_rs",
"env_logger", "env_logger",
"filetime", "filetime",
"flate2", "flate2",

Просмотреть файл

@ -35,7 +35,7 @@ bytes = "1"
chrono = "0.4" chrono = "0.4"
clap = { version = "4.3.24", features = ["derive", "env", "wrap_help"] } clap = { version = "4.3.24", features = ["derive", "env", "wrap_help"] }
directories = "5.0.1" directories = "5.0.1"
encoding = "0.2" encoding_rs = "0.8"
env_logger = "0.10" env_logger = "0.10"
filetime = "0.2" filetime = "0.2"
flate2 = { version = "1.0", optional = true, default-features = false, features = [ flate2 = { version = "1.0", optional = true, default-features = false, features = [

Просмотреть файл

@ -1213,13 +1213,16 @@ where
let mut buf = Vec::new(); let mut buf = Vec::new();
reader.read_to_end(&mut buf)?; reader.read_to_end(&mut buf)?;
let (result, _) = encoding::decode( let (result, _, has_error) = encoding_rs::WINDOWS_1252.decode(&buf);
&buf,
encoding::DecoderTrap::Strict,
encoding::all::ISO_8859_1,
);
result.map_err(|err| io::Error::new(io::ErrorKind::Other, err.into_owned())) if has_error {
Err(io::Error::new(
io::ErrorKind::InvalidData,
"failed to decode text",
))
} else {
Ok(result.to_string())
}
} }
/// An iterator over the arguments in a Windows command line. /// An iterator over the arguments in a Windows command line.
@ -2289,9 +2292,12 @@ mod test {
.unwrap(); .unwrap();
let cmd_file_path = td.path().join("foo"); let cmd_file_path = td.path().join("foo");
{ {
use encoding::{all::UTF_16LE, EncoderTrap::Strict, Encoding}; use encoding_rs::UTF_16LE;
let mut file = File::create(&cmd_file_path).unwrap(); let mut file = File::create(&cmd_file_path).unwrap();
let content = UTF_16LE.encode("-c foo€.c -o foo.o", Strict).unwrap(); let (content, _, has_error) = UTF_16LE.encode("-c foo€.c -o foo.o");
if has_error {
panic!("Failed to encode as UTF-16LE");
}
file.write_all(&[0xFF, 0xFE]).unwrap(); // little endian BOM file.write_all(&[0xFF, 0xFE]).unwrap(); // little endian BOM
file.write_all(&content).unwrap(); file.write_all(&content).unwrap();
} }