From b1f057b67d2daa32687476cf98b8188eedaf1ad3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bennet=20Ble=C3=9Fmann?= Date: Sun, 4 Aug 2024 01:39:31 +0200 Subject: [PATCH] resolve problems from deps upgrade - downgrade reqwest to 0.11.27 - fixes problems with missmatched transitive dependencies between it and warp, mainly http - replace deprecated ripemd160 with ripemd (as specified in the formers readme) - indexmap: replace deprecated remove with functionally identical swap_remove --- Cargo.lock | 208 +++++---------------------------- Cargo.toml | 4 +- src/arithmetic.rs | 2 +- src/ffi.rs | 2 +- src/indexing.rs | 4 +- src/machine/arithmetic_ops.rs | 2 +- src/machine/load_state.rs | 16 +-- src/machine/loader.rs | 10 +- src/machine/machine_indices.rs | 4 +- src/machine/system_calls.rs | 75 +++++------- src/parser/lexer.rs | 20 +++- src/repl_helper.rs | 4 +- 12 files changed, 104 insertions(+), 247 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0bcd89b5..7366ffac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -136,12 +136,6 @@ dependencies = [ "wait-timeout", ] -[[package]] -name = "atomic-waker" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" - [[package]] name = "autocfg" version = "1.3.0" @@ -1055,25 +1049,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "h2" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" -dependencies = [ - "atomic-waker", - "bytes", - "fnv", - "futures-core", - "futures-sink", - "http 1.1.0", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "half" version = "2.4.1" @@ -1193,29 +1168,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "http-body" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" -dependencies = [ - "bytes", - "http 1.1.0", -] - -[[package]] -name = "http-body-util" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" -dependencies = [ - "bytes", - "futures-util", - "http 1.1.0", - "http-body 1.0.1", - "pin-project-lite", -] - [[package]] name = "httparse" version = "1.9.4" @@ -1254,9 +1206,9 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.3.26", + "h2", "http 0.2.12", - "http-body 0.4.6", + "http-body", "httparse", "httpdate", "itoa", @@ -1268,77 +1220,17 @@ dependencies = [ "want", ] -[[package]] -name = "hyper" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "h2 0.4.5", - "http 1.1.0", - "http-body 1.0.1", - "httparse", - "itoa", - "pin-project-lite", - "smallvec", - "tokio", - "want", -] - -[[package]] -name = "hyper-rustls" -version = "0.27.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" -dependencies = [ - "futures-util", - "http 1.1.0", - "hyper 1.4.1", - "hyper-util", - "rustls 0.23.12", - "rustls-pki-types", - "tokio", - "tokio-rustls 0.26.0", - "tower-service", -] - [[package]] name = "hyper-tls" -version = "0.6.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "http-body-util", - "hyper 1.4.1", - "hyper-util", + "hyper", "native-tls", "tokio", "tokio-native-tls", - "tower-service", -] - -[[package]] -name = "hyper-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "http 1.1.0", - "http-body 1.0.1", - "hyper 1.4.1", - "pin-project-lite", - "socket2", - "tokio", - "tower", - "tower-service", - "tracing", ] [[package]] @@ -2346,23 +2238,20 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" -version = "0.12.5" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ - "base64 0.22.1", + "base64 0.21.7", "bytes", "encoding_rs", "futures-core", "futures-util", - "h2 0.4.5", - "http 1.1.0", - "http-body 1.0.1", - "http-body-util", - "hyper 1.4.1", - "hyper-rustls", + "h2", + "http 0.2.12", + "http-body", + "hyper", "hyper-tls", - "hyper-util", "ipnet", "js-sys", "log", @@ -2371,7 +2260,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile", + "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", @@ -2412,10 +2301,13 @@ dependencies = [ ] [[package]] -name = "ripemd160" -version = "0.10.0" +name = "ripemd" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f923401a7e6614f2838037bd9bac86c003d1629446d2b5816d3159472071be4f" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest", +] [[package]] name = "roxmltree" @@ -2457,16 +2349,12 @@ dependencies = [ ] [[package]] -name = "rustls" -version = "0.23.12" +name = "rustls-pemfile" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "once_cell", - "rustls-pki-types", - "rustls-webpki", - "subtle", - "zeroize", + "base64 0.21.7", ] [[package]] @@ -2638,7 +2526,7 @@ dependencies = [ "regex", "reqwest", "ring", - "ripemd160", + "ripemd", "roxmltree", "rustyline", "ryu", @@ -3052,9 +2940,9 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "1.0.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "system-configuration" @@ -3224,18 +3112,7 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls 0.22.4", - "rustls-pki-types", - "tokio", -] - -[[package]] -name = "tokio-rustls" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" -dependencies = [ - "rustls 0.23.12", + "rustls", "rustls-pki-types", "tokio", ] @@ -3287,27 +3164,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "futures-core", - "futures-util", - "pin-project", - "pin-project-lite", - "tokio", - "tower-layer", - "tower-service", -] - -[[package]] -name = "tower-layer" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" - [[package]] name = "tower-service" version = "0.3.2" @@ -3510,20 +3366,20 @@ dependencies = [ "futures-util", "headers", "http 0.2.12", - "hyper 0.14.30", + "hyper", "log", "mime", "mime_guess", "multer", "percent-encoding", "pin-project", - "rustls-pemfile", + "rustls-pemfile 2.1.3", "scoped-tls", "serde", "serde_json", "serde_urlencoded", "tokio", - "tokio-rustls 0.25.0", + "tokio-rustls", "tokio-tungstenite", "tokio-util", "tower-service", @@ -3821,9 +3677,9 @@ dependencies = [ [[package]] name = "winreg" -version = "0.52.0" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ "cfg-if", "windows-sys 0.48.0", diff --git a/Cargo.toml b/Cargo.toml index 705c66a3..219d454b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,7 +64,7 @@ phf = { version = "0.11", features = ["macros"] } rand = "0.8.5" regex = "1.10.6" ring = { version = "0.17.8", features = ["wasm32_unknown_unknown_js"] } -ripemd160 = "0.10.0" +ripemd = "0.1.3" roxmltree = "0.20.0" ryu = "1.0.18" select = "0.6.0" @@ -82,7 +82,7 @@ ctrlc = { version = "3.4.4", optional = true } hostname = { version = "0.4.0", optional = true } libffi = { version = "3.2.0", optional = true } native-tls = { version = "0.2.12", optional = true } -reqwest = { version = "0.12.5", optional = true } +reqwest = { version = "0.11.27", optional = true } rustyline = { version = "14.0.0", optional = true } tokio = { version = "1.39.2", features = ["full"] } warp = { version = "0.3.7", features = ["tls"], optional = true } diff --git a/src/arithmetic.rs b/src/arithmetic.rs index 8044f645..59a4f4cd 100644 --- a/src/arithmetic.rs +++ b/src/arithmetic.rs @@ -18,7 +18,7 @@ use crate::machine::machine_errors::*; use dashu::base::Abs; use dashu::base::BitTest; use num_order::NumOrd; -use ordered_float::*; +use ordered_float::{Float, OrderedFloat}; use std::cell::Cell; use std::cmp::{max, min, Ordering}; diff --git a/src/ffi.rs b/src/ffi.rs index 054f98d9..04e85ab3 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -150,7 +150,7 @@ impl ForeignFunctionTable { FunctionImpl { cif, args, - code_ptr: CodePtr(code_ptr.into_raw().into_raw() as *mut _), + code_ptr: CodePtr(code_ptr.into_raw().as_raw_ptr()), return_struct_name, }, ); diff --git a/src/indexing.rs b/src/indexing.rs index 2df05530..f4cb22ae 100644 --- a/src/indexing.rs +++ b/src/indexing.rs @@ -707,7 +707,7 @@ pub(crate) fn remove_constant_indices( Some(IndexingCodePtr::DynamicExternal(_)) | Some(IndexingCodePtr::External(_)) | Some(IndexingCodePtr::Fail) => { - constants.remove(&constant); + constants.swap_remove(&constant); break; } Some(IndexingCodePtr::Internal(o)) => { @@ -846,7 +846,7 @@ pub(crate) fn remove_structure_index( match structures.get(&(name, arity)).cloned() { Some(IndexingCodePtr::DynamicExternal(_)) | Some(IndexingCodePtr::External(_)) => { - structures.remove(&(name, arity)); + structures.swap_remove(&(name, arity)); break; } Some(IndexingCodePtr::Internal(o)) => { diff --git a/src/machine/arithmetic_ops.rs b/src/machine/arithmetic_ops.rs index 0ab17712..2616e447 100644 --- a/src/machine/arithmetic_ops.rs +++ b/src/machine/arithmetic_ops.rs @@ -17,7 +17,7 @@ use crate::types::*; use crate::fixnum; -use ordered_float::*; +use ordered_float::{Float, OrderedFloat}; use std::cmp; use std::convert::TryFrom; diff --git a/src/machine/load_state.rs b/src/machine/load_state.rs index 121c0c1b..89b82f1c 100644 --- a/src/machine/load_state.rs +++ b/src/machine/load_state.rs @@ -460,7 +460,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> { } pub(super) fn remove_replaced_in_situ_module(&mut self, module_name: Atom) { - let mut removed_module = match self.wam_prelude.indices.modules.remove(&module_name) { + let mut removed_module = match self.wam_prelude.indices.modules.swap_remove(&module_name) { Some(module) => module, None => return, }; @@ -526,7 +526,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> { } pub(super) fn remove_module_exports(&mut self, module_name: Atom) { - let removed_module = match self.wam_prelude.indices.modules.remove(&module_name) { + let removed_module = match self.wam_prelude.indices.modules.swap_remove(&module_name) { Some(module) => module, None => return, }; @@ -555,8 +555,10 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> { } } ModuleExport::OpDecl(op_decl) => { - let op_dir_value_opt = op_dir - .remove(&(op_decl.name, fixity(op_decl.op_desc.get_spec() as u32))); + let op_dir_value_opt = op_dir.swap_remove(&( + op_decl.name, + fixity(op_decl.op_desc.get_spec() as u32), + )); if let Some(op_desc) = op_dir_value_opt { retraction_info.push_record(op_retractor(*op_decl, op_desc)); @@ -1017,7 +1019,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> { self.reset_in_situ_module(module_decl.clone(), &listing_src); - let mut module = match self.wam_prelude.indices.modules.remove(&module_name) { + let mut module = match self.wam_prelude.indices.modules.swap_remove(&module_name) { Some(mut module) => { module.listing_src = listing_src; module @@ -1059,7 +1061,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> { } pub(super) fn import_module(&mut self, module_name: Atom) -> Result<(), SessionError> { - if let Some(module) = self.wam_prelude.indices.modules.remove(&module_name) { + if let Some(module) = self.wam_prelude.indices.modules.swap_remove(&module_name) { let payload_compilation_target = self.payload.compilation_target; match &payload_compilation_target { @@ -1115,7 +1117,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> { module_name: Atom, exports: IndexSet, ) -> Result<(), SessionError> { - if let Some(module) = self.wam_prelude.indices.modules.remove(&module_name) { + if let Some(module) = self.wam_prelude.indices.modules.swap_remove(&module_name) { let payload_compilation_target = self.payload.compilation_target; let result = match &payload_compilation_target { diff --git a/src/machine/loader.rs b/src/machine/loader.rs index 87483dce..b3e1fdde 100644 --- a/src/machine/loader.rs +++ b/src/machine/loader.rs @@ -574,7 +574,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> { RetractionRecord::AddedMetaPredicate(target_module_name, key) => { match target_module_name { atom!("user") => { - self.wam_prelude.indices.meta_predicates.remove(&key); + self.wam_prelude.indices.meta_predicates.swap_remove(&key); } _ => match self .wam_prelude @@ -583,7 +583,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> { .get_mut(&target_module_name) { Some(ref mut module) => { - module.meta_predicates.remove(&key); + module.meta_predicates.swap_remove(&key); } _ => { unreachable!() @@ -617,7 +617,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> { } } RetractionRecord::AddedModule(module_name) => { - self.wam_prelude.indices.modules.remove(&module_name); + self.wam_prelude.indices.modules.swap_remove(&module_name); } RetractionRecord::ReplacedModule( module_decl, @@ -713,7 +713,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> { if let Some(ref mut module) = self.wam_prelude.indices.modules.get_mut(&module_name) { - module.code_dir.remove(&key); + module.code_dir.swap_remove(&key); } } RetractionRecord::ReplacedModulePredicate(module_name, key, old_code_idx) => { @@ -738,7 +738,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> { op_decl.insert_into_op_dir(&mut self.wam_prelude.indices.op_dir); } RetractionRecord::AddedUserPredicate(key) => { - self.wam_prelude.indices.code_dir.remove(&key); + self.wam_prelude.indices.code_dir.swap_remove(&key); } RetractionRecord::ReplacedUserPredicate(key, old_code_idx) => { if let Some(code_idx) = self.wam_prelude.indices.code_dir.get_mut(&key) { diff --git a/src/machine/machine_indices.rs b/src/machine/machine_indices.rs index 9dc8138e..2f259125 100644 --- a/src/machine/machine_indices.rs +++ b/src/machine/machine_indices.rs @@ -397,10 +397,10 @@ impl IndexStore { key: &PredicateKey, ) -> Option { match compilation_target { - CompilationTarget::User => self.extensible_predicates.remove(key), + CompilationTarget::User => self.extensible_predicates.swap_remove(key), CompilationTarget::Module(ref module_name) => { if let Some(module) = self.modules.get_mut(module_name) { - module.extensible_predicates.remove(key) + module.extensible_predicates.swap_remove(key) } else { None } diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 838eff21..f2b64896 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -1,6 +1,7 @@ use crate::parser::ast::*; use crate::parser::parser::*; +use base64::Engine; use dashu::integer::{Sign, UBig}; use lazy_static::lazy_static; use num_order::NumOrd; @@ -72,13 +73,13 @@ use crossterm::event::{read, Event, KeyCode, KeyEvent, KeyModifiers}; #[cfg(feature = "repl")] use crossterm::terminal::{disable_raw_mode, enable_raw_mode}; -use blake2::{Blake2b, Blake2s}; +use blake2::{Blake2b512, Blake2s256}; use ring::rand::{SecureRandom, SystemRandom}; use ring::{digest, hkdf, hmac, pbkdf2}; #[cfg(feature = "crypto-full")] use ring::aead; -use ripemd160::{Digest, Ripemd160}; +use ripemd::{Digest, Ripemd160}; use sha3::{Sha3_224, Sha3_256, Sha3_384, Sha3_512}; use crrl::{ed25519, secp256k1, x25519}; @@ -3713,14 +3714,9 @@ impl Machine { #[cfg(feature = "repl")] #[inline(always)] pub(crate) fn get_single_char(&mut self) -> CallResult { - let ctrl_c = KeyEvent { - code: KeyCode::Char('c'), - modifiers: KeyModifiers::CONTROL, - }; - let key = get_key(); - if key == ctrl_c { + if key.code == KeyCode::Char('c') && key.modifiers == KeyModifiers::CONTROL { let stub = functor_stub(atom!("get_single_char"), 1); let err = self.machine_st.interrupt_error(); let err = self.machine_st.error_form(err, stub); @@ -3815,7 +3811,7 @@ impl Machine { if !stream.is_stdin() && !stream.is_stdout() && !stream.is_stderr() { if let Some(alias) = stream.options().get_alias() { - self.indices.stream_aliases.remove(&alias); + self.indices.stream_aliases.swap_remove(&alias); } let close_result = stream.close(); @@ -4301,15 +4297,14 @@ impl Machine { let client = reqwest::Client::builder().build().unwrap(); // request - let mut req = reqwest::Request::new(method, address); + let mut req = client.request(method, address).headers(headers); - *req.headers_mut() = headers; if !bytes.is_empty() { - *req.body_mut() = Some(reqwest::Body::from(bytes)); + req = req.body(bytes); } // do it! - match futures::executor::block_on(client.execute(req)) { + match futures::executor::block_on(req.send()) { Ok(resp) => { // status code let status = resp.status().as_u16(); @@ -7283,90 +7278,83 @@ impl Machine { let ints_list = match algorithm { atom!("sha3_224") => { let mut context = Sha3_224::new(); - context.input(&bytes); + context.update(&bytes); heap_loc_as_cell!(iter_to_heap_list( &mut self.machine_st.heap, context - .result() - .as_ref() + .finalize() .iter() .map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))), )) } atom!("sha3_256") => { let mut context = Sha3_256::new(); - context.input(&bytes); + context.update(&bytes); heap_loc_as_cell!(iter_to_heap_list( &mut self.machine_st.heap, context - .result() - .as_ref() + .finalize() .iter() .map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))), )) } atom!("sha3_384") => { let mut context = Sha3_384::new(); - context.input(&bytes); + context.update(&bytes); heap_loc_as_cell!(iter_to_heap_list( &mut self.machine_st.heap, context - .result() - .as_ref() + .finalize() .iter() .map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))), )) } atom!("sha3_512") => { let mut context = Sha3_512::new(); - context.input(&bytes); + context.update(&bytes); heap_loc_as_cell!(iter_to_heap_list( &mut self.machine_st.heap, context - .result() - .as_ref() + .finalize() .iter() .map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))), )) } atom!("blake2s256") => { - let mut context = Blake2s::new(); - context.input(&bytes); + let mut context = Blake2s256::new(); + context.update(&bytes); heap_loc_as_cell!(iter_to_heap_list( &mut self.machine_st.heap, context - .result() - .as_ref() + .finalize() .iter() .map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))), )) } atom!("blake2b512") => { - let mut context = Blake2b::new(); - context.input(&bytes); + let mut context = Blake2b512::new(); + context.update(&bytes); heap_loc_as_cell!(iter_to_heap_list( &mut self.machine_st.heap, context - .result() - .as_ref() + .finalize() .iter() .map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))), )) } atom!("ripemd160") => { let mut context = Ripemd160::new(); - context.input(&bytes); + context.update(&bytes); heap_loc_as_cell!(iter_to_heap_list( &mut self.machine_st.heap, context - .result() - .as_ref() + .finalize() .iter() .map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))), )) @@ -7938,11 +7926,11 @@ impl Machine { let padding = cell_as_atom!(self.deref_register(3)); let charset = cell_as_atom!(self.deref_register(4)); - let config = match (padding, charset) { - (atom!("true"), atom!("standard")) => base64::STANDARD, - (atom!("true"), _) => base64::URL_SAFE, - (_, atom!("standard")) => base64::STANDARD_NO_PAD, - (_, _) => base64::URL_SAFE_NO_PAD, + let b64_engine = match (padding, charset) { + (atom!("true"), atom!("standard")) => base64::engine::general_purpose::STANDARD, + (atom!("true"), _) => base64::engine::general_purpose::URL_SAFE, + (_, atom!("standard")) => base64::engine::general_purpose::STANDARD_NO_PAD, + (_, _) => base64::engine::general_purpose::URL_SAFE_NO_PAD, }; if self.deref_register(1).is_var() { @@ -7950,7 +7938,8 @@ impl Machine { .machine_st .value_to_str_like(self.machine_st.registers[2]) .unwrap(); - let bytes = base64::decode_config(&*b64.as_str(), config); + + let bytes = b64_engine.decode(&*b64.as_str()); match bytes { Ok(bs) => { @@ -7975,7 +7964,7 @@ impl Machine { bytes.push(c as u8); } - let b64 = base64::encode_config(bytes, config); + let b64 = b64_engine.encode(bytes); let string = self.u8s_to_string(b64.as_bytes()); unify!(self.machine_st, self.machine_st.registers[2], string); diff --git a/src/parser/lexer.rs b/src/parser/lexer.rs index 03f472b9..06f8a326 100644 --- a/src/parser/lexer.rs +++ b/src/parser/lexer.rs @@ -1,5 +1,3 @@ -use lexical::parse_lossy; - use crate::atom_table::*; pub use crate::machine::machine_state::*; use crate::parser::ast::*; @@ -638,7 +636,9 @@ impl<'a, R: CharRead> Lexer<'a, R> { fn vacate_with_float(&mut self, mut token: String) -> Result { self.return_char(token.pop().unwrap()); - let n = parse_lossy::(token.as_bytes())?; + + let n = parse_float_lossy(&token)?; + Ok(Token::Literal(Literal::from(float_alloc!( n, self.machine_st.arena @@ -756,7 +756,7 @@ impl<'a, R: CharRead> Lexer<'a, R> { } } - let n = parse_lossy::(token.as_bytes())?; + let n = parse_float_lossy(&token)?; Ok(Token::Literal(Literal::from(float_alloc!( n, self.machine_st.arena @@ -765,7 +765,7 @@ impl<'a, R: CharRead> Lexer<'a, R> { return self.vacate_with_float(token); } } else { - let n = parse_lossy::(token.as_bytes())?; + let n = parse_float_lossy(&token)?; Ok(Token::Literal(Literal::from(float_alloc!( n, self.machine_st.arena @@ -1102,3 +1102,13 @@ impl<'a, R: CharRead> Lexer<'a, R> { } } } + +fn parse_float_lossy(token: &str) -> Result { + const FORMAT: u128 = lexical::format::STANDARD; + let options = lexical::ParseFloatOptions::builder() + .lossy(true) + .build() + .unwrap(); + let n = lexical::parse_with_options::(token.as_bytes(), &options)?; + Ok(n) +} diff --git a/src/repl_helper.rs b/src/repl_helper.rs index 96643e6c..afec4fd2 100644 --- a/src/repl_helper.rs +++ b/src/repl_helper.rs @@ -93,8 +93,8 @@ impl Highlighter for Helper { self.highligher.highlight(line, pos) } - fn highlight_char(&self, line: &str, pos: usize) -> bool { - self.highligher.highlight_char(line, pos) + fn highlight_char(&self, line: &str, pos: usize, forced: bool) -> bool { + self.highligher.highlight_char(line, pos, forced) } } -- 2.54.0