mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 21:28:55 +00:00
Bug 1581509 - Update encoding_rs to 0.8.20. r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D46000 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
200b29fbf4
commit
e7e2436c9b
22
Cargo.lock
generated
22
Cargo.lock
generated
@ -956,10 +956,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "encoding_c"
|
||||
version = "0.9.4"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"encoding_rs 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -967,21 +967,21 @@ name = "encoding_c_mem"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"encoding_rs 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encoding_glue"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"encoding_rs 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nserror 0.1.0",
|
||||
"nsstring 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encoding_rs"
|
||||
version = "0.8.19"
|
||||
version = "0.8.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1487,7 +1487,7 @@ name = "jsrust_shared"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"baldrdash 0.1.0",
|
||||
"encoding_c 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding_c 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding_c_mem 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mozilla-central-workspace-hack 0.1.0",
|
||||
]
|
||||
@ -1990,7 +1990,7 @@ name = "nsstring"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding_rs 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2739,7 +2739,7 @@ name = "shift_or_euc"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"encoding_rs 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@ -2748,7 +2748,7 @@ name = "shift_or_euc_c"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"encoding_rs 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"shift_or_euc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@ -3818,9 +3818,9 @@ dependencies = [
|
||||
"checksum dtoa-short 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "068d4026697c1a18f0b0bb8cfcad1b0c151b90d8edb9bf4c235ad68128920d1d"
|
||||
"checksum dwrote 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bd1369e02db5e9b842a9b67bce8a2fcc043beafb2ae8a799dd482d46ea1ff0d"
|
||||
"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
|
||||
"checksum encoding_c 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a388c1f7db016b361d6dc2ce8d1f979db686ea934073550f0f7b3583456e44f0"
|
||||
"checksum encoding_c 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "496d019370fbe1b5b2c4e9ade3d644ffa8ae3a0d9097c4aec2bc7636d47d8304"
|
||||
"checksum encoding_c_mem 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "af4f65ffc57f1abd3d901cf5a2bc88230d7c2a0f9ae5f93d9908eb98ee3b733c"
|
||||
"checksum encoding_rs 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)" = "79906e1ad1f7f8bc48864fcc6ffd58336fb5992e627bf61928099cb25fdf4314"
|
||||
"checksum encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)" = "87240518927716f79692c2ed85bfe6e98196d18c6401ec75355760233a7e12e9"
|
||||
"checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3"
|
||||
"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3"
|
||||
"checksum euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c4786521fec183792e755bf32cd0188e4e7628c6d0fcfd51426435b9081a106"
|
||||
|
@ -1028,15 +1028,14 @@ class Decoder final {
|
||||
* Checks for compatibility with storing Unicode scalar values as unsigned
|
||||
* bytes taking into account the state of the decoder.
|
||||
*
|
||||
* Returns `mozilla::Nothing()` if the decoder is still waiting for (parts of) a
|
||||
* potential BOM.
|
||||
* Returns `mozilla::Nothing()` if the decoder is not in a neutral state,
|
||||
* including waiting for the BOM, or if the encoding is never
|
||||
* Latin1-byte-compatible.
|
||||
*
|
||||
* Otherwise returns the index of the first byte whose unsigned value doesn't
|
||||
* directly correspond to the decoded Unicode scalar value, or the length
|
||||
* of the input if all bytes in the input decode directly to scalar values
|
||||
* corresponding to the unsigned byte values. (This is always returns zero
|
||||
* for UTF-16LE, UTF-16BE, and replacement. It's also zero when a multibyte
|
||||
* decoder is in the middle of a multibyte sequence.)
|
||||
* corresponding to the unsigned byte values.
|
||||
*
|
||||
* Does not change the state of the decoder.
|
||||
*
|
||||
|
@ -10,7 +10,7 @@ path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
baldrdash = { path = "../../wasm/cranelift", optional = true }
|
||||
encoding_c = "0.9.4"
|
||||
encoding_c = "0.9.5"
|
||||
encoding_c_mem = "0.2.4"
|
||||
mozilla-central-workspace-hack = { path = "../../../../build/workspace-hack" }
|
||||
|
||||
|
@ -1 +1 @@
|
||||
{"files":{"CONTRIBUTING.md":"8cd9262df951c4b42078aa55064ca3b8ef2676c06b8fc7c281c02ee3f1ae04a8","COPYRIGHT":"65fb11bb8d2aac1ea00620273e0595ff71f4a335d25b67acbccbaa1b9ad5a409","Cargo.toml":"1da47e467bb67f62b0759a15fdbdadb07df158894f4d417f0f3c4b1a4af28a26","LICENSE-APACHE":"cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","LICENSE-MIT":"90df74ddb43e7f5aa5068890eacc151ecca7c997c9515cf17aea30b8734075bf","README.md":"034844deaf8eb6ff4ced15357269d143825bd60b6eac4037922f3bf315bbf360","build-disabled.rs":"d65ed45d33ce834ab9f9f7c5f308e0a72605aa34ede6dca45a2077a2deee5cfa","include/encoding_rs.h":"5738d06a1c047401b52be79a486f82f1d8f88d9491c2f67ca3c73fec2bc4695a","include/encoding_rs_cpp.h":"9dd8e9b89fcec2918a4b3d4ae8bad521a67adddc20ba66be8545b6e84f559e17","include/encoding_rs_statics.h":"05561c00809483282daab356113c67c31ff5df5bbe4dbfd79a7fa56cf36bbea7","src/lib.rs":"6000c4e83a57bcbf92d702218fcb486813fe3d3851491c98c98f84bc5661567f"},"package":"a388c1f7db016b361d6dc2ce8d1f979db686ea934073550f0f7b3583456e44f0"}
|
||||
{"files":{"CONTRIBUTING.md":"8cd9262df951c4b42078aa55064ca3b8ef2676c06b8fc7c281c02ee3f1ae04a8","COPYRIGHT":"65fb11bb8d2aac1ea00620273e0595ff71f4a335d25b67acbccbaa1b9ad5a409","Cargo.toml":"343cbfe33de588a1b4c35f5ce9408c59357cafd5e18dc3c125a425ad6b0fe502","LICENSE-APACHE":"cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","LICENSE-MIT":"90df74ddb43e7f5aa5068890eacc151ecca7c997c9515cf17aea30b8734075bf","README.md":"bd791ef0b76a03355f0184c2b9711ced65404bcc7a658c0f6bfe5331efc776dd","build-disabled.rs":"d65ed45d33ce834ab9f9f7c5f308e0a72605aa34ede6dca45a2077a2deee5cfa","include/encoding_rs.h":"f420db39328d2be8c6ba454dfebc6396a99952d4c1d5f93c88c3f06a81e30bff","include/encoding_rs_cpp.h":"8d9d836b538360a5ef897dbae78d6ad8eff4d0a1bb9b2e74223b8ebf221b9b2f","include/encoding_rs_statics.h":"05561c00809483282daab356113c67c31ff5df5bbe4dbfd79a7fa56cf36bbea7","src/lib.rs":"c8dc89717920bba7bf934bc714d72c601f6d652745f492563ee43ae774434f87"},"package":"496d019370fbe1b5b2c4e9ade3d644ffa8ae3a0d9097c4aec2bc7636d47d8304"}
|
4
third_party/rust/encoding_c/Cargo.toml
vendored
4
third_party/rust/encoding_c/Cargo.toml
vendored
@ -12,7 +12,7 @@
|
||||
|
||||
[package]
|
||||
name = "encoding_c"
|
||||
version = "0.9.4"
|
||||
version = "0.9.5"
|
||||
authors = ["Henri Sivonen <hsivonen@hsivonen.fi>"]
|
||||
description = "C API for encoding_rs"
|
||||
homepage = "https://docs.rs/encoding_c/"
|
||||
@ -22,7 +22,7 @@ keywords = ["ffi", "capi", "encoding", "unicode", "charset"]
|
||||
license = "MIT/Apache-2.0"
|
||||
repository = "https://github.com/hsivonen/encoding_c"
|
||||
[dependencies.encoding_rs]
|
||||
version = "0.8.19"
|
||||
version = "0.8.20"
|
||||
|
||||
[features]
|
||||
fast-big5-hanzi-encode = ["encoding_rs/fast-big5-hanzi-encode"]
|
||||
|
4
third_party/rust/encoding_c/README.md
vendored
4
third_party/rust/encoding_c/README.md
vendored
@ -38,6 +38,10 @@ wrappers.
|
||||
|
||||
## Release Notes
|
||||
|
||||
### 0.9.5
|
||||
|
||||
* Adjust documentation for encoding_rs 0.8.20.
|
||||
|
||||
### 0.9.4
|
||||
|
||||
* Fix bogus C header.
|
||||
|
@ -505,15 +505,13 @@ uint32_t decoder_decode_to_utf16_without_replacement(
|
||||
/// Checks for compatibility with storing Unicode scalar values as unsigned
|
||||
/// bytes taking into account the state of the decoder.
|
||||
///
|
||||
/// Returns `SIZE_MAX` if the decoder is still waiting for (parts of) a
|
||||
/// potential BOM.
|
||||
/// Returns `SIZE_MAX` if the decoder is not in a neutral state, including waiting
|
||||
/// for the BOM or if the encoding is never Latin-byte-compatible.
|
||||
///
|
||||
/// Otherwise returns the index of the first byte whose unsigned value doesn't
|
||||
/// directly correspond to the decoded Unicode scalar value, or the length
|
||||
/// of the input if all bytes in the input decode directly to scalar values
|
||||
/// corresponding to the unsigned byte values. (This is always returns zero
|
||||
/// for UTF-16LE, UTF-16BE, and replacement. It's also zero when a multibyte
|
||||
/// decoder is in the middle of a multibyte sequence.)
|
||||
/// corresponding to the unsigned byte values.
|
||||
///
|
||||
/// Does not change the state of the decoder.
|
||||
///
|
||||
|
@ -285,15 +285,13 @@ class Decoder final {
|
||||
* Checks for compatibility with storing Unicode scalar values as unsigned
|
||||
* bytes taking into account the state of the decoder.
|
||||
*
|
||||
* Returns `std::nullopt` if the decoder is still waiting for (parts of) a
|
||||
* potential BOM.
|
||||
* Returns `std::nullopt` if the decoder is not in a neutral state, including
|
||||
* waiting for the BOM or if the encoding is never Latin-byte-compatible.
|
||||
*
|
||||
* Otherwise returns the index of the first byte whose unsigned value doesn't
|
||||
* directly correspond to the decoded Unicode scalar value, or the length
|
||||
* of the input if all bytes in the input decode directly to scalar values
|
||||
* corresponding to the unsigned byte values. (This is always returns zero
|
||||
* for UTF-16LE, UTF-16BE, and replacement. It's also zero when a multibyte
|
||||
* decoder is in the middle of a multibyte sequence.)
|
||||
* corresponding to the unsigned byte values.
|
||||
*
|
||||
* Does not change the state of the decoder.
|
||||
*
|
||||
|
8
third_party/rust/encoding_c/src/lib.rs
vendored
8
third_party/rust/encoding_c/src/lib.rs
vendored
@ -911,15 +911,13 @@ pub unsafe extern "C" fn decoder_decode_to_utf16_without_replacement(
|
||||
/// Checks for compatibility with storing Unicode scalar values as unsigned
|
||||
/// bytes taking into account the state of the decoder.
|
||||
///
|
||||
/// Returns `SIZE_MAX` if the decoder is still waiting for (parts of) a potential
|
||||
/// BOM.
|
||||
/// Returns `SIZE_MAX` if the decoder is not in a neutral state, including waiting
|
||||
/// for the BOM or if the encoding is never Latin-byte-compatible.
|
||||
///
|
||||
/// Otherwise returns the index of the first byte whose unsigned value doesn't
|
||||
/// directly correspond to the decoded Unicode scalar value, or the length
|
||||
/// of the input if all bytes in the input decode directly to scalar values
|
||||
/// corresponding to the unsigned byte values. (This is always returns zero
|
||||
/// for UTF-16LE, UTF-16BE, and replacement. It's also zero when a multibyte
|
||||
/// decoder is in the middle of a multibyte sequence.)
|
||||
/// corresponding to the unsigned byte values.
|
||||
///
|
||||
/// Does not change the state of the decoder.
|
||||
///
|
||||
|
File diff suppressed because one or more lines are too long
2
third_party/rust/encoding_rs/Cargo.toml
vendored
2
third_party/rust/encoding_rs/Cargo.toml
vendored
@ -12,7 +12,7 @@
|
||||
|
||||
[package]
|
||||
name = "encoding_rs"
|
||||
version = "0.8.19"
|
||||
version = "0.8.20"
|
||||
authors = ["Henri Sivonen <hsivonen@hsivonen.fi>"]
|
||||
description = "A Gecko-oriented implementation of the Encoding Standard"
|
||||
homepage = "https://docs.rs/encoding_rs/"
|
||||
|
8
third_party/rust/encoding_rs/README.md
vendored
8
third_party/rust/encoding_rs/README.md
vendored
@ -417,6 +417,14 @@ To regenerate the generated code:
|
||||
|
||||
## Release Notes
|
||||
|
||||
### 0.8.20
|
||||
|
||||
* Make `Decoder::latin1_byte_compatible_up_to` return `None` in more
|
||||
cases to make the method actually useful. While this could be argued
|
||||
to be a breaking change due to the bug fix changing semantics, it does
|
||||
not break callers that had to handle the `None` case in a reasonable
|
||||
way anyway.
|
||||
|
||||
### 0.8.19
|
||||
|
||||
* Removed a bunch of bound checks in `convert_str_to_utf16`.
|
||||
|
@ -1274,65 +1274,53 @@ write_variant_method("decode_to_utf8_raw", True, [("src", "&[u8]"),
|
||||
|
||||
variant_file.write('''
|
||||
|
||||
pub fn latin1_byte_compatible_up_to(&self, buffer: &[u8]) -> usize {
|
||||
if let Some(n) = match *self {
|
||||
VariantDecoder::SingleByte(ref v) => Some(v.latin1_byte_compatible_up_to(buffer)),
|
||||
pub fn latin1_byte_compatible_up_to(&self, buffer: &[u8]) -> Option<usize> {
|
||||
match *self {
|
||||
VariantDecoder::SingleByte(ref v) => {
|
||||
return Some(v.latin1_byte_compatible_up_to(buffer));
|
||||
}
|
||||
VariantDecoder::Utf8(ref v) => {
|
||||
if v.in_neutral_state() {
|
||||
None
|
||||
} else {
|
||||
Some(0)
|
||||
if !v.in_neutral_state() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
VariantDecoder::Gb18030(ref v) => {
|
||||
if v.in_neutral_state() {
|
||||
None
|
||||
} else {
|
||||
Some(0)
|
||||
if !v.in_neutral_state() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
VariantDecoder::Big5(ref v) => {
|
||||
if v.in_neutral_state() {
|
||||
None
|
||||
} else {
|
||||
Some(0)
|
||||
if !v.in_neutral_state() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
VariantDecoder::EucJp(ref v) => {
|
||||
if v.in_neutral_state() {
|
||||
None
|
||||
} else {
|
||||
Some(0)
|
||||
if !v.in_neutral_state() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
VariantDecoder::Iso2022Jp(ref v) => {
|
||||
if v.in_neutral_state() {
|
||||
Some(Encoding::iso_2022_jp_ascii_valid_up_to(buffer))
|
||||
} else {
|
||||
Some(0)
|
||||
return Some(Encoding::iso_2022_jp_ascii_valid_up_to(buffer));
|
||||
}
|
||||
return None;
|
||||
}
|
||||
VariantDecoder::ShiftJis(ref v) => {
|
||||
if v.in_neutral_state() {
|
||||
None
|
||||
} else {
|
||||
Some(0)
|
||||
if !v.in_neutral_state() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
VariantDecoder::EucKr(ref v) => {
|
||||
if v.in_neutral_state() {
|
||||
None
|
||||
} else {
|
||||
Some(0)
|
||||
if !v.in_neutral_state() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
VariantDecoder::UserDefined(_) => None,
|
||||
VariantDecoder::Replacement(_) | VariantDecoder::Utf16(_) => Some(0),
|
||||
} {
|
||||
n
|
||||
} else {
|
||||
Encoding::ascii_valid_up_to(buffer)
|
||||
}
|
||||
VariantDecoder::UserDefined(_) => {}
|
||||
VariantDecoder::Replacement(_) | VariantDecoder::Utf16(_) => {
|
||||
return None;
|
||||
}
|
||||
};
|
||||
Some(Encoding::ascii_valid_up_to(buffer))
|
||||
}
|
||||
}
|
||||
|
||||
|
49
third_party/rust/encoding_rs/src/lib.rs
vendored
49
third_party/rust/encoding_rs/src/lib.rs
vendored
@ -11,7 +11,7 @@
|
||||
feature = "cargo-clippy",
|
||||
allow(doc_markdown, inline_always, new_ret_no_self)
|
||||
)]
|
||||
#![doc(html_root_url = "https://docs.rs/encoding_rs/0.8.19")]
|
||||
#![doc(html_root_url = "https://docs.rs/encoding_rs/0.8.20")]
|
||||
|
||||
//! encoding_rs is a Gecko-oriented Free Software / Open Source implementation
|
||||
//! of the [Encoding Standard](https://encoding.spec.whatwg.org/) in Rust.
|
||||
@ -4212,15 +4212,13 @@ impl Decoder {
|
||||
/// Checks for compatibility with storing Unicode scalar values as unsigned
|
||||
/// bytes taking into account the state of the decoder.
|
||||
///
|
||||
/// Returns `None` if the decoder is still waiting for (parts of) a potential
|
||||
/// BOM.
|
||||
/// Returns `None` if the decoder is not in a neutral state, including waiting
|
||||
/// for the BOM or if the encoding is never Latin-byte-compatible.
|
||||
///
|
||||
/// Otherwise returns the index of the first byte whose unsigned value doesn't
|
||||
/// directly correspond to the decoded Unicode scalar value, or the length
|
||||
/// of the input if all bytes in the input decode directly to scalar values
|
||||
/// corresponding to the unsigned byte values. (This is always returns zero
|
||||
/// for UTF-16LE, UTF-16BE, and replacement. It's also zero when a multibyte
|
||||
/// decoder is in the middle of a multibyte sequence.)
|
||||
/// corresponding to the unsigned byte values.
|
||||
///
|
||||
/// Does not change the state of the decoder.
|
||||
///
|
||||
@ -4230,7 +4228,9 @@ impl Decoder {
|
||||
/// Available via the C wrapper.
|
||||
pub fn latin1_byte_compatible_up_to(&self, bytes: &[u8]) -> Option<usize> {
|
||||
match self.life_cycle {
|
||||
DecoderLifeCycle::Converting => Some(self.variant.latin1_byte_compatible_up_to(bytes)),
|
||||
DecoderLifeCycle::Converting => {
|
||||
return self.variant.latin1_byte_compatible_up_to(bytes);
|
||||
}
|
||||
DecoderLifeCycle::Finished => panic!("Must not use a decoder that has finished."),
|
||||
_ => None,
|
||||
}
|
||||
@ -5760,13 +5760,10 @@ mod tests {
|
||||
.unwrap(),
|
||||
1
|
||||
);
|
||||
assert_eq!(
|
||||
REPLACEMENT
|
||||
.new_decoder_without_bom_handling()
|
||||
.latin1_byte_compatible_up_to(buffer)
|
||||
.unwrap(),
|
||||
0
|
||||
);
|
||||
assert!(REPLACEMENT
|
||||
.new_decoder_without_bom_handling()
|
||||
.latin1_byte_compatible_up_to(buffer)
|
||||
.is_none());
|
||||
assert_eq!(
|
||||
SHIFT_JIS
|
||||
.new_decoder_without_bom_handling()
|
||||
@ -5781,20 +5778,14 @@ mod tests {
|
||||
.unwrap(),
|
||||
1
|
||||
);
|
||||
assert_eq!(
|
||||
UTF_16BE
|
||||
.new_decoder_without_bom_handling()
|
||||
.latin1_byte_compatible_up_to(buffer)
|
||||
.unwrap(),
|
||||
0
|
||||
);
|
||||
assert_eq!(
|
||||
UTF_16LE
|
||||
.new_decoder_without_bom_handling()
|
||||
.latin1_byte_compatible_up_to(buffer)
|
||||
.unwrap(),
|
||||
0
|
||||
);
|
||||
assert!(UTF_16BE
|
||||
.new_decoder_without_bom_handling()
|
||||
.latin1_byte_compatible_up_to(buffer)
|
||||
.is_none());
|
||||
assert!(UTF_16LE
|
||||
.new_decoder_without_bom_handling()
|
||||
.latin1_byte_compatible_up_to(buffer)
|
||||
.is_none());
|
||||
assert_eq!(
|
||||
ISO_2022_JP
|
||||
.new_decoder_without_bom_handling()
|
||||
@ -6019,6 +6010,6 @@ mod tests {
|
||||
let _ = decoder.decode_to_utf16(b"\xBB\xBF", &mut output, false);
|
||||
assert_eq!(decoder.latin1_byte_compatible_up_to(buffer), Some(1));
|
||||
let _ = decoder.decode_to_utf16(b"\xEF", &mut output, false);
|
||||
assert_eq!(decoder.latin1_byte_compatible_up_to(buffer), Some(0));
|
||||
assert_eq!(decoder.latin1_byte_compatible_up_to(buffer), None);
|
||||
}
|
||||
}
|
||||
|
6
third_party/rust/encoding_rs/src/mem.rs
vendored
6
third_party/rust/encoding_rs/src/mem.rs
vendored
@ -2468,17 +2468,17 @@ mod tests {
|
||||
0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0x2603u16,
|
||||
0xD83Du16, 0xDCA9u16, 0x00B6u16,
|
||||
];
|
||||
assert_eq!(utf16_valid_up_to(&valid[..]), 16);;
|
||||
assert_eq!(utf16_valid_up_to(&valid[..]), 16);
|
||||
let lone_high = vec![
|
||||
0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16,
|
||||
0x2603u16, 0xD83Du16, 0x00B6u16,
|
||||
];
|
||||
assert_eq!(utf16_valid_up_to(&lone_high[..]), 14);;
|
||||
assert_eq!(utf16_valid_up_to(&lone_high[..]), 14);
|
||||
let lone_low = vec![
|
||||
0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16,
|
||||
0x2603u16, 0xDCA9u16, 0x00B6u16,
|
||||
];
|
||||
assert_eq!(utf16_valid_up_to(&lone_low[..]), 14);;
|
||||
assert_eq!(utf16_valid_up_to(&lone_low[..]), 14);
|
||||
let lone_high_at_end = vec![
|
||||
0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16,
|
||||
0x2603u16, 0x00B6u16, 0xD83Du16,
|
||||
|
66
third_party/rust/encoding_rs/src/variant.rs
vendored
66
third_party/rust/encoding_rs/src/variant.rs
vendored
@ -159,65 +159,53 @@ impl VariantDecoder {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn latin1_byte_compatible_up_to(&self, buffer: &[u8]) -> usize {
|
||||
if let Some(n) = match *self {
|
||||
VariantDecoder::SingleByte(ref v) => Some(v.latin1_byte_compatible_up_to(buffer)),
|
||||
pub fn latin1_byte_compatible_up_to(&self, buffer: &[u8]) -> Option<usize> {
|
||||
match *self {
|
||||
VariantDecoder::SingleByte(ref v) => {
|
||||
return Some(v.latin1_byte_compatible_up_to(buffer));
|
||||
}
|
||||
VariantDecoder::Utf8(ref v) => {
|
||||
if v.in_neutral_state() {
|
||||
None
|
||||
} else {
|
||||
Some(0)
|
||||
if !v.in_neutral_state() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
VariantDecoder::Gb18030(ref v) => {
|
||||
if v.in_neutral_state() {
|
||||
None
|
||||
} else {
|
||||
Some(0)
|
||||
if !v.in_neutral_state() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
VariantDecoder::Big5(ref v) => {
|
||||
if v.in_neutral_state() {
|
||||
None
|
||||
} else {
|
||||
Some(0)
|
||||
if !v.in_neutral_state() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
VariantDecoder::EucJp(ref v) => {
|
||||
if v.in_neutral_state() {
|
||||
None
|
||||
} else {
|
||||
Some(0)
|
||||
if !v.in_neutral_state() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
VariantDecoder::Iso2022Jp(ref v) => {
|
||||
if v.in_neutral_state() {
|
||||
Some(Encoding::iso_2022_jp_ascii_valid_up_to(buffer))
|
||||
} else {
|
||||
Some(0)
|
||||
return Some(Encoding::iso_2022_jp_ascii_valid_up_to(buffer));
|
||||
}
|
||||
return None;
|
||||
}
|
||||
VariantDecoder::ShiftJis(ref v) => {
|
||||
if v.in_neutral_state() {
|
||||
None
|
||||
} else {
|
||||
Some(0)
|
||||
if !v.in_neutral_state() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
VariantDecoder::EucKr(ref v) => {
|
||||
if v.in_neutral_state() {
|
||||
None
|
||||
} else {
|
||||
Some(0)
|
||||
if !v.in_neutral_state() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
VariantDecoder::UserDefined(_) => None,
|
||||
VariantDecoder::Replacement(_) | VariantDecoder::Utf16(_) => Some(0),
|
||||
} {
|
||||
n
|
||||
} else {
|
||||
Encoding::ascii_valid_up_to(buffer)
|
||||
}
|
||||
VariantDecoder::UserDefined(_) => {}
|
||||
VariantDecoder::Replacement(_) | VariantDecoder::Utf16(_) => {
|
||||
return None;
|
||||
}
|
||||
};
|
||||
Some(Encoding::ascii_valid_up_to(buffer))
|
||||
}
|
||||
}
|
||||
|
||||
@ -397,7 +385,9 @@ impl VariantEncoding {
|
||||
VariantEncoding::ShiftJis => ShiftJisEncoder::new(encoding),
|
||||
VariantEncoding::EucKr => EucKrEncoder::new(encoding),
|
||||
VariantEncoding::UserDefined => UserDefinedEncoder::new(encoding),
|
||||
VariantEncoding::Utf16Be | VariantEncoding::Replacement | VariantEncoding::Utf16Le => unreachable!(),
|
||||
VariantEncoding::Utf16Be | VariantEncoding::Replacement | VariantEncoding::Utf16Le => {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user