From e7e2436c9b5f7ec7fda5c69fe63653e8b69265fc Mon Sep 17 00:00:00 2001 From: Henri Sivonen Date: Wed, 18 Sep 2019 08:28:04 +0000 Subject: [PATCH] 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 --- Cargo.lock | 22 +++---- intl/Encoding.h | 9 ++- js/src/rust/shared/Cargo.toml | 2 +- .../rust/encoding_c/.cargo-checksum.json | 2 +- third_party/rust/encoding_c/Cargo.toml | 4 +- third_party/rust/encoding_c/README.md | 4 ++ .../rust/encoding_c/include/encoding_rs.h | 8 +-- .../rust/encoding_c/include/encoding_rs_cpp.h | 8 +-- third_party/rust/encoding_c/src/lib.rs | 8 +-- .../rust/encoding_rs/.cargo-checksum.json | 2 +- third_party/rust/encoding_rs/Cargo.toml | 2 +- third_party/rust/encoding_rs/README.md | 8 +++ .../encoding_rs/generate-encoding-data.py | 62 +++++++---------- third_party/rust/encoding_rs/src/lib.rs | 49 ++++++-------- third_party/rust/encoding_rs/src/mem.rs | 6 +- third_party/rust/encoding_rs/src/variant.rs | 66 ++++++++----------- 16 files changed, 118 insertions(+), 144 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5d8b6e1836b6..d1c28e344f65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" diff --git a/intl/Encoding.h b/intl/Encoding.h index 6463575966d8..769721a363dd 100644 --- a/intl/Encoding.h +++ b/intl/Encoding.h @@ -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. * diff --git a/js/src/rust/shared/Cargo.toml b/js/src/rust/shared/Cargo.toml index 5234934c3bfc..a6c2322de2ce 100644 --- a/js/src/rust/shared/Cargo.toml +++ b/js/src/rust/shared/Cargo.toml @@ -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" } diff --git a/third_party/rust/encoding_c/.cargo-checksum.json b/third_party/rust/encoding_c/.cargo-checksum.json index bd08131dfd0d..853fdd35c137 100644 --- a/third_party/rust/encoding_c/.cargo-checksum.json +++ b/third_party/rust/encoding_c/.cargo-checksum.json @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/third_party/rust/encoding_c/Cargo.toml b/third_party/rust/encoding_c/Cargo.toml index c0580e48767a..cfba9e119048 100644 --- a/third_party/rust/encoding_c/Cargo.toml +++ b/third_party/rust/encoding_c/Cargo.toml @@ -12,7 +12,7 @@ [package] name = "encoding_c" -version = "0.9.4" +version = "0.9.5" authors = ["Henri Sivonen "] 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"] diff --git a/third_party/rust/encoding_c/README.md b/third_party/rust/encoding_c/README.md index 7082ee227f53..a3935ebf04a0 100644 --- a/third_party/rust/encoding_c/README.md +++ b/third_party/rust/encoding_c/README.md @@ -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. diff --git a/third_party/rust/encoding_c/include/encoding_rs.h b/third_party/rust/encoding_c/include/encoding_rs.h index 979d0a0ea1eb..05536a658852 100644 --- a/third_party/rust/encoding_c/include/encoding_rs.h +++ b/third_party/rust/encoding_c/include/encoding_rs.h @@ -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. /// diff --git a/third_party/rust/encoding_c/include/encoding_rs_cpp.h b/third_party/rust/encoding_c/include/encoding_rs_cpp.h index 0f812624f61a..d3d8bc34af42 100644 --- a/third_party/rust/encoding_c/include/encoding_rs_cpp.h +++ b/third_party/rust/encoding_c/include/encoding_rs_cpp.h @@ -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. * diff --git a/third_party/rust/encoding_c/src/lib.rs b/third_party/rust/encoding_c/src/lib.rs index b77b5626a233..a8727bc3f394 100644 --- a/third_party/rust/encoding_c/src/lib.rs +++ b/third_party/rust/encoding_c/src/lib.rs @@ -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. /// diff --git a/third_party/rust/encoding_rs/.cargo-checksum.json b/third_party/rust/encoding_rs/.cargo-checksum.json index 809c61ff84e6..2a8177a44805 100644 --- a/third_party/rust/encoding_rs/.cargo-checksum.json +++ b/third_party/rust/encoding_rs/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"CONTRIBUTING.md":"06c26277e8dbd3f57be2eb51b5e3285dc1cbbf8c11326df413868ae702e6a61c","COPYRIGHT":"8b98376eb373dcf81950474efe34b5576a8171460dff500cc58a1ed8d160cd57","Cargo.toml":"0207d1664a21a5e0f9538ddd4496b51984cffbd546412862140fa6a55ea09562","Ideas.md":"b7452893f500163868d8de52c09addaf91e1632454ed02e892c467ed7ec39dbd","LICENSE-APACHE":"cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","LICENSE-MIT":"f2ad48641d9c997d9ae3b95d93d1cd6e1ab12ab4c44de89937c7bfabbd076a4a","README.md":"fa305764ebe515291cfb9deb185df80857ad54d031afb02fc2c4465996caa081","build.rs":"9276ee24ef71433d46323c15296b3fbbb29c0b37c4b1ca45416587f14ba8e777","doc/Big5.txt":"f73a2edc5cb6c2d140ba6e07f4542e1c4a234950378acde1df93480f0ca0be0b","doc/EUC-JP.txt":"ee2818b907d0137f40a9ab9fd525fc700a44dbdddb6cf0c157a656566bae4bf1","doc/EUC-KR.txt":"71d9e2ccf3b124e8bdfb433c8cf2773fd878077038d0cec3c7237a50f4a78a30","doc/GBK.txt":"c1b522b5a799884e5001da661f42c5a8f4d0acb9ef1d74b206f22b5f65365606","doc/IBM866.txt":"a5a433e804d0f83af785015179fbc1d9b0eaf1f7960efcd04093e136b51fbd0e","doc/ISO-2022-JP.txt":"af86684f5a8f0e2868d7b2c292860140c3d2e5527530ca091f1b28198e8e2fe6","doc/ISO-8859-10.txt":"6d3949ad7c81ca176895101ed81a1db7df1060d64e262880b94bd31bb344ab4d","doc/ISO-8859-13.txt":"3951dd89cf93f7729148091683cf8511f4529388b7dc8dcd0d62eaed55be93fa","doc/ISO-8859-14.txt":"3d330784a0374fd255a38b47949675cc7168c800530534b0a01cac6edc623adc","doc/ISO-8859-15.txt":"24b1084aab5127a85aab99153f86e24694d0a3615f53b5ce23683f97cf66c47a","doc/ISO-8859-16.txt":"ce0272559b92ba76d7a7e476f6424ae4a5cc72e75b183611b08392e44add4d25","doc/ISO-8859-2.txt":"18ceff88c13d1b5ba455a3919b1e3de489045c4c3d2dd7e8527c125c75d54aad","doc/ISO-8859-3.txt":"21798404c68f4f5db59223362f24999da96968c0628427321fccce7d2849a130","doc/ISO-8859-4.txt":"d27f6520c6c5bfbcc19176b71d081cdb3bccde1622bb3e420d5680e812632d53","doc/ISO-8859-5.txt":"a10ec8d6ea7a78ad15da7275f6cb1a3365118527e28f9af6d0d5830501303f3a","doc/ISO-8859-6.txt":"ccda8a2efc96115336bdd77776637b9712425e44fbcf745353b9057fbef144e7","doc/ISO-8859-7.txt":"17900fa1f27a445958f0a77d7d9056be375a6bd7ee4492aa680c7c1500bab85e","doc/ISO-8859-8-I.txt":"8357555646d54265a9b9ffa3e68b08d132312f1561c60108ff9b8b1167b6ecf2","doc/ISO-8859-8.txt":"72cd6f3afb7b4a9c16a66a362473315770b7755d72c86c870e52fc3eba86c8af","doc/KOI8-R.txt":"839cf19a38da994488004ed7814b1f6151640156a9a2af02bf2efca745fb5966","doc/KOI8-U.txt":"0cc76624ed1f024183e2298b7e019957da2c70c8ca06e0fc4e6f353f50a5054f","doc/Shift_JIS.txt":"34c49141818cb9ddbcf59cc858f78a79be8ad148d563f26415108ae1f148443f","doc/UTF-16BE.txt":"e2e280d8acbaa6d2a6b3569d60e17500a285f2baa0df3363dd85537cd5a1ef8f","doc/UTF-16LE.txt":"70bdc170e3fc5298ba68f10125fb5eeb8b077036cc96bb4416c4de396f6d76c1","doc/UTF-8.txt":"ea7bae742e613010ced002cf4b601a737d2203fad65e115611451bc4428f548a","doc/gb18030.txt":"dc71378a8f07a2d8659f69ee81fb8791fef56ba86f124b429978285237bb4a7b","doc/macintosh.txt":"57491e53866711b4672d9b9ff35380b9dac9e0d8e3d6c20bdd6140603687c023","doc/replacement.txt":"4b6c3bbd7999d9d4108a281594bd02d13607e334a95465afff8c2c08d395f0e4","doc/windows-1250.txt":"61296bb6a21cdab602300d32ecfba434cb82de5ac3bc88d58710d2f125e28d39","doc/windows-1251.txt":"7deea1c61dea1485c8ff02db2c7d578db7a9aab63ab1cfd02ec04b515864689e","doc/windows-1252.txt":"933ef3bdddfce5ee132b9f1a1aa8b47423d2587bbe475b19028d0a6d38e180b6","doc/windows-1253.txt":"1a38748b88e99071a5c7b3d5456ead4caedeabab50d50d658be105bc113714de","doc/windows-1254.txt":"f8372f86c6f8d642563cd6ddc025260553292a39423df1683a98670bd7bf2b47","doc/windows-1255.txt":"4e5852494730054e2da258a74e1b9d780abbcdd8ce22ebc218ca2efe9e90493d","doc/windows-1256.txt":"c0879c5172abedead302a406e8f60d9cd9598694a0ffa4fd288ffe4fef7b8ea1","doc/windows-1257.txt":"c28a0c9f964fcb2b46d21f537c402446501a2800670481d6abf9fd9e9018d523","doc/windows-1258.txt":"5019ae4d61805c79aacbf17c93793342dbb098d65a1837783bc3e2c6d6a23602","doc/windows-874.txt":"4ef0e4501c5feba8b17aee1818602ed44b36ca8475db771ce2fc16d392cabecc","doc/x-mac-cyrillic.txt":"58be154d8a888ca3d484b83b44f749823ef339ab27f14d90ca9a856f5050a8bd","doc/x-user-defined.txt":"f9cd07c4321bf5cfb0be4bdddd251072999b04a6cf7a6f5bc63709a84e2c1ffc","generate-encoding-data.py":"1a041a29a8503ecdca0a85119b931793a0d6301acf1b1d107a11089814ba1606","rustfmt.toml":"85c1a3b4382fd89e991cbb81b70fb52780472edc064c963943cdaaa56e0a2030","src/ascii.rs":"800cfbe3036d0c97ce27e07a4fd05edbcb7354ebec20903d81c76136d734931c","src/big5.rs":"ae801a92f7b8218eb488ac030958c7b0e54b01bef1645a0f56f1c1172288fbd5","src/data.rs":"9544c019c7360a669bd3adaa90b70331124abd1df59841db66e74912bcdb96a5","src/euc_jp.rs":"881f670679362372ecb744f75533ca2c7020372abaf22ce1d8a57b5b3ecc4d81","src/euc_kr.rs":"f14f520134d2969361d7fe721cc1b4118660afe91d1972f9ee5518605084edbe","src/gb18030.rs":"15466e6f3d9a27d0f6ee41057977f6bc43d624c3267de56d8aefcbb8cbb883ad","src/handles.rs":"0646bd091892ff7a76f34efccda4e5ddabe1e624e890baa9fdc9d48011d2d38b","src/iso_2022_jp.rs":"4a9e0c9702e00d4df08cf4a090f23b314fe3548ca5634a21faa0e641fdda387e","src/lib.rs":"8245420b2d0e72019f9dcc71c1a97adc313339d3f76abf15d00f80d1eb678d91","src/macros.rs":"c7a019fd81d31de77569036ac36fd4e404b3f20144bbf79747faf4ea21538d09","src/mem.rs":"d2852f5d28aa892c0ea707ba13efcf8b0354a94cb18e8c799d32bb1b8138d1a4","src/replacement.rs":"182c2093a6edb162183ca5990554fd7b199d3011924a8d80d894ba98ee7c479e","src/shift_jis.rs":"98decc3cc76f224adbe24b8114ff966cb48ac92abeee5c0ef81d28cec033df55","src/simd_funcs.rs":"63df317a3a8edac708196546d02b2070ecfb8d1d0a2aa16db33d13803572b2fc","src/single_byte.rs":"ddd8162b8d0f1256fd5da1d8e203110265887f8a3f75ebe6af9310a06a8cd39f","src/test_data/big5_in.txt":"4c5a8691f8dc717311889c63894026d2fb62725a86c4208ca274a9cc8d42a503","src/test_data/big5_in_ref.txt":"99d399e17750cf9c7cf30bb253dbfe35b81c4fcbdead93cfa48b1429213473c7","src/test_data/big5_out.txt":"6193ca97c297aa20e09396038d18e938bb7ea331c26f0f2454097296723a0b13","src/test_data/big5_out_ref.txt":"36567691f557df144f6cc520015a87038dfa156f296fcf103b56ae9a718be1fc","src/test_data/euc_kr_in.txt":"c86a7224f3215fa0d04e685622a752fdc72763e8ae076230c7fd62de57ec4074","src/test_data/euc_kr_in_ref.txt":"1f419f4ca47d708b54c73c461545a022ae2e20498fdbf8005a483d752a204883","src/test_data/euc_kr_out.txt":"e7f32e026f70be1e1b58e0047baf7d3d2c520269c4f9b9992e158b4decb0a1a3","src/test_data/euc_kr_out_ref.txt":"c9907857980b20b8e9e3b584482ed6567a2be6185d72237b6322f0404944924e","src/test_data/gb18030_in.txt":"ab7231b2d3e9afacdbd7d7f3b9e5361a7ff9f7e1cfdb4f3bd905b9362b309e53","src/test_data/gb18030_in_ref.txt":"dc5069421adca2043c55f5012b55a76fdff651d22e6e699fd0978f8d5706815c","src/test_data/gb18030_out.txt":"f0208d527f5ca63de7d9a0323be8d5cf12d8a104b2943d92c2701f0c3364dac1","src/test_data/gb18030_out_ref.txt":"6819fe47627e4ea01027003fc514b9f21a1322e732d7f1fb92cc6c5455bc6c07","src/test_data/iso_2022_jp_in.txt":"cd24bbdcb1834e25db54646fbf4c41560a13dc7540f6be3dba4f5d97d44513af","src/test_data/iso_2022_jp_in_ref.txt":"3dc4e6a5e06471942d086b16c9440945e78415f6f3f47e43717e4bc2eac2cdf5","src/test_data/iso_2022_jp_out.txt":"9b6f015329dda6c3f9ee5ce6dbd6fa9c89acc21283e886836c78b8d833480c21","src/test_data/iso_2022_jp_out_ref.txt":"78cb260093a20116ad9a42f43b05d1848c5ab100b6b9a850749809e943884b35","src/test_data/jis0208_in.txt":"6df3030553ffb0a6615bb33dc8ea9dca6d9623a9028e2ffec754ce3c3da824cc","src/test_data/jis0208_in_ref.txt":"3dc4e6a5e06471942d086b16c9440945e78415f6f3f47e43717e4bc2eac2cdf5","src/test_data/jis0208_out.txt":"4ec24477e1675ce750733bdc3c5add1cd27b6bd4ce1f09289564646e9654e857","src/test_data/jis0208_out_ref.txt":"c3e1cef5032b2b1d93a406f31ff940c4e2dfe8859b8b17ca2761fee7a75a0e48","src/test_data/jis0212_in.txt":"c011f0dd72bd7c8cd922df9374ef8d2769a77190514c77f6c62b415852eeb9fe","src/test_data/jis0212_in_ref.txt":"7d9458b3d2f73e7092a7f505c08ce1d233dde18aa679fbcf9889256239cc9e06","src/test_data/shift_jis_in.txt":"02e389ccef0dd2122e63f503899402cb7f797912c2444cc80ab93131116c5524","src/test_data/shift_jis_in_ref.txt":"512f985950ca902e643c88682dba9708b7c38d3c5ec2925168ab00ac94ab19f9","src/test_data/shift_jis_out.txt":"5fbc44da7bf639bf6cfe0fa1fd3eba7102b88f81919c9ea991302712f69426fb","src/test_data/shift_jis_out_ref.txt":"466322c6fed8286c64582731755290c2296508efdd258826e6279686649b481f","src/test_labels_names.rs":"c962c7aeac3d9ef2aca70c9e21983b231d4cf998cb06879374b0401e5149d1da","src/testing.rs":"b299d27055f3b068de66cc10a75c024b881c48bc093627c01e0b1f8bd7d94666","src/utf_16.rs":"1ec4e1c8ed7e42e4de401c6d0f64c2835bd80c2a306f358959957d30e6ff1501","src/utf_8.rs":"6f81c1db0236e09eb66d6aefcf9819e9a01ab9faed0324e6c7c0446179f97c01","src/variant.rs":"8aae8aaf58f75a981e7dff4319f6eb81727e027eebf16efc5d58d39ec2572915","src/x_user_defined.rs":"da51def859b870ced29cb87987f02d27b220eac0f222876cb72a1dc616f9d8ec"},"package":"79906e1ad1f7f8bc48864fcc6ffd58336fb5992e627bf61928099cb25fdf4314"} \ No newline at end of file +{"files":{"CONTRIBUTING.md":"06c26277e8dbd3f57be2eb51b5e3285dc1cbbf8c11326df413868ae702e6a61c","COPYRIGHT":"8b98376eb373dcf81950474efe34b5576a8171460dff500cc58a1ed8d160cd57","Cargo.toml":"c54b7fec7ce9828c773bce592cbbbd5759f09ad47210611c2244253d1e5e7365","Ideas.md":"b7452893f500163868d8de52c09addaf91e1632454ed02e892c467ed7ec39dbd","LICENSE-APACHE":"cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","LICENSE-MIT":"f2ad48641d9c997d9ae3b95d93d1cd6e1ab12ab4c44de89937c7bfabbd076a4a","README.md":"beee7c9756aa9a2889dd26c2bec6eac7d23ba3f3372bdd38ab103faef4b4798c","build.rs":"9276ee24ef71433d46323c15296b3fbbb29c0b37c4b1ca45416587f14ba8e777","doc/Big5.txt":"f73a2edc5cb6c2d140ba6e07f4542e1c4a234950378acde1df93480f0ca0be0b","doc/EUC-JP.txt":"ee2818b907d0137f40a9ab9fd525fc700a44dbdddb6cf0c157a656566bae4bf1","doc/EUC-KR.txt":"71d9e2ccf3b124e8bdfb433c8cf2773fd878077038d0cec3c7237a50f4a78a30","doc/GBK.txt":"c1b522b5a799884e5001da661f42c5a8f4d0acb9ef1d74b206f22b5f65365606","doc/IBM866.txt":"a5a433e804d0f83af785015179fbc1d9b0eaf1f7960efcd04093e136b51fbd0e","doc/ISO-2022-JP.txt":"af86684f5a8f0e2868d7b2c292860140c3d2e5527530ca091f1b28198e8e2fe6","doc/ISO-8859-10.txt":"6d3949ad7c81ca176895101ed81a1db7df1060d64e262880b94bd31bb344ab4d","doc/ISO-8859-13.txt":"3951dd89cf93f7729148091683cf8511f4529388b7dc8dcd0d62eaed55be93fa","doc/ISO-8859-14.txt":"3d330784a0374fd255a38b47949675cc7168c800530534b0a01cac6edc623adc","doc/ISO-8859-15.txt":"24b1084aab5127a85aab99153f86e24694d0a3615f53b5ce23683f97cf66c47a","doc/ISO-8859-16.txt":"ce0272559b92ba76d7a7e476f6424ae4a5cc72e75b183611b08392e44add4d25","doc/ISO-8859-2.txt":"18ceff88c13d1b5ba455a3919b1e3de489045c4c3d2dd7e8527c125c75d54aad","doc/ISO-8859-3.txt":"21798404c68f4f5db59223362f24999da96968c0628427321fccce7d2849a130","doc/ISO-8859-4.txt":"d27f6520c6c5bfbcc19176b71d081cdb3bccde1622bb3e420d5680e812632d53","doc/ISO-8859-5.txt":"a10ec8d6ea7a78ad15da7275f6cb1a3365118527e28f9af6d0d5830501303f3a","doc/ISO-8859-6.txt":"ccda8a2efc96115336bdd77776637b9712425e44fbcf745353b9057fbef144e7","doc/ISO-8859-7.txt":"17900fa1f27a445958f0a77d7d9056be375a6bd7ee4492aa680c7c1500bab85e","doc/ISO-8859-8-I.txt":"8357555646d54265a9b9ffa3e68b08d132312f1561c60108ff9b8b1167b6ecf2","doc/ISO-8859-8.txt":"72cd6f3afb7b4a9c16a66a362473315770b7755d72c86c870e52fc3eba86c8af","doc/KOI8-R.txt":"839cf19a38da994488004ed7814b1f6151640156a9a2af02bf2efca745fb5966","doc/KOI8-U.txt":"0cc76624ed1f024183e2298b7e019957da2c70c8ca06e0fc4e6f353f50a5054f","doc/Shift_JIS.txt":"34c49141818cb9ddbcf59cc858f78a79be8ad148d563f26415108ae1f148443f","doc/UTF-16BE.txt":"e2e280d8acbaa6d2a6b3569d60e17500a285f2baa0df3363dd85537cd5a1ef8f","doc/UTF-16LE.txt":"70bdc170e3fc5298ba68f10125fb5eeb8b077036cc96bb4416c4de396f6d76c1","doc/UTF-8.txt":"ea7bae742e613010ced002cf4b601a737d2203fad65e115611451bc4428f548a","doc/gb18030.txt":"dc71378a8f07a2d8659f69ee81fb8791fef56ba86f124b429978285237bb4a7b","doc/macintosh.txt":"57491e53866711b4672d9b9ff35380b9dac9e0d8e3d6c20bdd6140603687c023","doc/replacement.txt":"4b6c3bbd7999d9d4108a281594bd02d13607e334a95465afff8c2c08d395f0e4","doc/windows-1250.txt":"61296bb6a21cdab602300d32ecfba434cb82de5ac3bc88d58710d2f125e28d39","doc/windows-1251.txt":"7deea1c61dea1485c8ff02db2c7d578db7a9aab63ab1cfd02ec04b515864689e","doc/windows-1252.txt":"933ef3bdddfce5ee132b9f1a1aa8b47423d2587bbe475b19028d0a6d38e180b6","doc/windows-1253.txt":"1a38748b88e99071a5c7b3d5456ead4caedeabab50d50d658be105bc113714de","doc/windows-1254.txt":"f8372f86c6f8d642563cd6ddc025260553292a39423df1683a98670bd7bf2b47","doc/windows-1255.txt":"4e5852494730054e2da258a74e1b9d780abbcdd8ce22ebc218ca2efe9e90493d","doc/windows-1256.txt":"c0879c5172abedead302a406e8f60d9cd9598694a0ffa4fd288ffe4fef7b8ea1","doc/windows-1257.txt":"c28a0c9f964fcb2b46d21f537c402446501a2800670481d6abf9fd9e9018d523","doc/windows-1258.txt":"5019ae4d61805c79aacbf17c93793342dbb098d65a1837783bc3e2c6d6a23602","doc/windows-874.txt":"4ef0e4501c5feba8b17aee1818602ed44b36ca8475db771ce2fc16d392cabecc","doc/x-mac-cyrillic.txt":"58be154d8a888ca3d484b83b44f749823ef339ab27f14d90ca9a856f5050a8bd","doc/x-user-defined.txt":"f9cd07c4321bf5cfb0be4bdddd251072999b04a6cf7a6f5bc63709a84e2c1ffc","generate-encoding-data.py":"b523b9f00711976357db0b735d15863b9d0559c90946136e874bda0b68fd5479","rustfmt.toml":"85c1a3b4382fd89e991cbb81b70fb52780472edc064c963943cdaaa56e0a2030","src/ascii.rs":"800cfbe3036d0c97ce27e07a4fd05edbcb7354ebec20903d81c76136d734931c","src/big5.rs":"ae801a92f7b8218eb488ac030958c7b0e54b01bef1645a0f56f1c1172288fbd5","src/data.rs":"9544c019c7360a669bd3adaa90b70331124abd1df59841db66e74912bcdb96a5","src/euc_jp.rs":"881f670679362372ecb744f75533ca2c7020372abaf22ce1d8a57b5b3ecc4d81","src/euc_kr.rs":"f14f520134d2969361d7fe721cc1b4118660afe91d1972f9ee5518605084edbe","src/gb18030.rs":"15466e6f3d9a27d0f6ee41057977f6bc43d624c3267de56d8aefcbb8cbb883ad","src/handles.rs":"0646bd091892ff7a76f34efccda4e5ddabe1e624e890baa9fdc9d48011d2d38b","src/iso_2022_jp.rs":"4a9e0c9702e00d4df08cf4a090f23b314fe3548ca5634a21faa0e641fdda387e","src/lib.rs":"71f7edef4325d3982b582fcdaf929cbd08e2c9d7bab2c0e9166d1f99e88e1bcd","src/macros.rs":"c7a019fd81d31de77569036ac36fd4e404b3f20144bbf79747faf4ea21538d09","src/mem.rs":"ae6792b9be8b2103541cc789dfc8796e7f3307716d0ce918b563d61b000188ad","src/replacement.rs":"182c2093a6edb162183ca5990554fd7b199d3011924a8d80d894ba98ee7c479e","src/shift_jis.rs":"98decc3cc76f224adbe24b8114ff966cb48ac92abeee5c0ef81d28cec033df55","src/simd_funcs.rs":"63df317a3a8edac708196546d02b2070ecfb8d1d0a2aa16db33d13803572b2fc","src/single_byte.rs":"ddd8162b8d0f1256fd5da1d8e203110265887f8a3f75ebe6af9310a06a8cd39f","src/test_data/big5_in.txt":"4c5a8691f8dc717311889c63894026d2fb62725a86c4208ca274a9cc8d42a503","src/test_data/big5_in_ref.txt":"99d399e17750cf9c7cf30bb253dbfe35b81c4fcbdead93cfa48b1429213473c7","src/test_data/big5_out.txt":"6193ca97c297aa20e09396038d18e938bb7ea331c26f0f2454097296723a0b13","src/test_data/big5_out_ref.txt":"36567691f557df144f6cc520015a87038dfa156f296fcf103b56ae9a718be1fc","src/test_data/euc_kr_in.txt":"c86a7224f3215fa0d04e685622a752fdc72763e8ae076230c7fd62de57ec4074","src/test_data/euc_kr_in_ref.txt":"1f419f4ca47d708b54c73c461545a022ae2e20498fdbf8005a483d752a204883","src/test_data/euc_kr_out.txt":"e7f32e026f70be1e1b58e0047baf7d3d2c520269c4f9b9992e158b4decb0a1a3","src/test_data/euc_kr_out_ref.txt":"c9907857980b20b8e9e3b584482ed6567a2be6185d72237b6322f0404944924e","src/test_data/gb18030_in.txt":"ab7231b2d3e9afacdbd7d7f3b9e5361a7ff9f7e1cfdb4f3bd905b9362b309e53","src/test_data/gb18030_in_ref.txt":"dc5069421adca2043c55f5012b55a76fdff651d22e6e699fd0978f8d5706815c","src/test_data/gb18030_out.txt":"f0208d527f5ca63de7d9a0323be8d5cf12d8a104b2943d92c2701f0c3364dac1","src/test_data/gb18030_out_ref.txt":"6819fe47627e4ea01027003fc514b9f21a1322e732d7f1fb92cc6c5455bc6c07","src/test_data/iso_2022_jp_in.txt":"cd24bbdcb1834e25db54646fbf4c41560a13dc7540f6be3dba4f5d97d44513af","src/test_data/iso_2022_jp_in_ref.txt":"3dc4e6a5e06471942d086b16c9440945e78415f6f3f47e43717e4bc2eac2cdf5","src/test_data/iso_2022_jp_out.txt":"9b6f015329dda6c3f9ee5ce6dbd6fa9c89acc21283e886836c78b8d833480c21","src/test_data/iso_2022_jp_out_ref.txt":"78cb260093a20116ad9a42f43b05d1848c5ab100b6b9a850749809e943884b35","src/test_data/jis0208_in.txt":"6df3030553ffb0a6615bb33dc8ea9dca6d9623a9028e2ffec754ce3c3da824cc","src/test_data/jis0208_in_ref.txt":"3dc4e6a5e06471942d086b16c9440945e78415f6f3f47e43717e4bc2eac2cdf5","src/test_data/jis0208_out.txt":"4ec24477e1675ce750733bdc3c5add1cd27b6bd4ce1f09289564646e9654e857","src/test_data/jis0208_out_ref.txt":"c3e1cef5032b2b1d93a406f31ff940c4e2dfe8859b8b17ca2761fee7a75a0e48","src/test_data/jis0212_in.txt":"c011f0dd72bd7c8cd922df9374ef8d2769a77190514c77f6c62b415852eeb9fe","src/test_data/jis0212_in_ref.txt":"7d9458b3d2f73e7092a7f505c08ce1d233dde18aa679fbcf9889256239cc9e06","src/test_data/shift_jis_in.txt":"02e389ccef0dd2122e63f503899402cb7f797912c2444cc80ab93131116c5524","src/test_data/shift_jis_in_ref.txt":"512f985950ca902e643c88682dba9708b7c38d3c5ec2925168ab00ac94ab19f9","src/test_data/shift_jis_out.txt":"5fbc44da7bf639bf6cfe0fa1fd3eba7102b88f81919c9ea991302712f69426fb","src/test_data/shift_jis_out_ref.txt":"466322c6fed8286c64582731755290c2296508efdd258826e6279686649b481f","src/test_labels_names.rs":"c962c7aeac3d9ef2aca70c9e21983b231d4cf998cb06879374b0401e5149d1da","src/testing.rs":"b299d27055f3b068de66cc10a75c024b881c48bc093627c01e0b1f8bd7d94666","src/utf_16.rs":"1ec4e1c8ed7e42e4de401c6d0f64c2835bd80c2a306f358959957d30e6ff1501","src/utf_8.rs":"6f81c1db0236e09eb66d6aefcf9819e9a01ab9faed0324e6c7c0446179f97c01","src/variant.rs":"3d81a104eb07a87efc9daf295a53bbe66b85b0df478c14d5aad216f0df5f5a28","src/x_user_defined.rs":"da51def859b870ced29cb87987f02d27b220eac0f222876cb72a1dc616f9d8ec"},"package":"87240518927716f79692c2ed85bfe6e98196d18c6401ec75355760233a7e12e9"} \ No newline at end of file diff --git a/third_party/rust/encoding_rs/Cargo.toml b/third_party/rust/encoding_rs/Cargo.toml index b686866fabd7..64d2631a49dd 100644 --- a/third_party/rust/encoding_rs/Cargo.toml +++ b/third_party/rust/encoding_rs/Cargo.toml @@ -12,7 +12,7 @@ [package] name = "encoding_rs" -version = "0.8.19" +version = "0.8.20" authors = ["Henri Sivonen "] description = "A Gecko-oriented implementation of the Encoding Standard" homepage = "https://docs.rs/encoding_rs/" diff --git a/third_party/rust/encoding_rs/README.md b/third_party/rust/encoding_rs/README.md index f9a9ecbf861d..3f6a9ec9dcc0 100644 --- a/third_party/rust/encoding_rs/README.md +++ b/third_party/rust/encoding_rs/README.md @@ -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`. diff --git a/third_party/rust/encoding_rs/generate-encoding-data.py b/third_party/rust/encoding_rs/generate-encoding-data.py index dd6556c2151b..cecb88e684de 100644 --- a/third_party/rust/encoding_rs/generate-encoding-data.py +++ b/third_party/rust/encoding_rs/generate-encoding-data.py @@ -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 { + 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)) } } diff --git a/third_party/rust/encoding_rs/src/lib.rs b/third_party/rust/encoding_rs/src/lib.rs index 17ac25dd1fc7..5aadbf4c0f39 100644 --- a/third_party/rust/encoding_rs/src/lib.rs +++ b/third_party/rust/encoding_rs/src/lib.rs @@ -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 { 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); } } diff --git a/third_party/rust/encoding_rs/src/mem.rs b/third_party/rust/encoding_rs/src/mem.rs index ab8f10ba5615..8c82704d7e04 100644 --- a/third_party/rust/encoding_rs/src/mem.rs +++ b/third_party/rust/encoding_rs/src/mem.rs @@ -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, diff --git a/third_party/rust/encoding_rs/src/variant.rs b/third_party/rust/encoding_rs/src/variant.rs index c70bd431be7e..6c1dfeb6333e 100644 --- a/third_party/rust/encoding_rs/src/variant.rs +++ b/third_party/rust/encoding_rs/src/variant.rs @@ -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 { + 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!() + } } }