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
This commit is contained in:
Bennet Bleßmann
2024-08-04 01:39:31 +02:00
parent 177bc16255
commit b1f057b67d
12 changed files with 104 additions and 247 deletions

208
Cargo.lock generated
View File

@@ -136,12 +136,6 @@ dependencies = [
"wait-timeout", "wait-timeout",
] ]
[[package]]
name = "atomic-waker"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.3.0" version = "1.3.0"
@@ -1055,25 +1049,6 @@ dependencies = [
"tracing", "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]] [[package]]
name = "half" name = "half"
version = "2.4.1" version = "2.4.1"
@@ -1193,29 +1168,6 @@ dependencies = [
"pin-project-lite", "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]] [[package]]
name = "httparse" name = "httparse"
version = "1.9.4" version = "1.9.4"
@@ -1254,9 +1206,9 @@ dependencies = [
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-util", "futures-util",
"h2 0.3.26", "h2",
"http 0.2.12", "http 0.2.12",
"http-body 0.4.6", "http-body",
"httparse", "httparse",
"httpdate", "httpdate",
"itoa", "itoa",
@@ -1268,77 +1220,17 @@ dependencies = [
"want", "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]] [[package]]
name = "hyper-tls" name = "hyper-tls"
version = "0.6.0" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
dependencies = [ dependencies = [
"bytes", "bytes",
"http-body-util", "hyper",
"hyper 1.4.1",
"hyper-util",
"native-tls", "native-tls",
"tokio", "tokio",
"tokio-native-tls", "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]] [[package]]
@@ -2346,23 +2238,20 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
[[package]] [[package]]
name = "reqwest" name = "reqwest"
version = "0.12.5" version = "0.11.27"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62"
dependencies = [ dependencies = [
"base64 0.22.1", "base64 0.21.7",
"bytes", "bytes",
"encoding_rs", "encoding_rs",
"futures-core", "futures-core",
"futures-util", "futures-util",
"h2 0.4.5", "h2",
"http 1.1.0", "http 0.2.12",
"http-body 1.0.1", "http-body",
"http-body-util", "hyper",
"hyper 1.4.1",
"hyper-rustls",
"hyper-tls", "hyper-tls",
"hyper-util",
"ipnet", "ipnet",
"js-sys", "js-sys",
"log", "log",
@@ -2371,7 +2260,7 @@ dependencies = [
"once_cell", "once_cell",
"percent-encoding", "percent-encoding",
"pin-project-lite", "pin-project-lite",
"rustls-pemfile", "rustls-pemfile 1.0.4",
"serde", "serde",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
@@ -2412,10 +2301,13 @@ dependencies = [
] ]
[[package]] [[package]]
name = "ripemd160" name = "ripemd"
version = "0.10.0" version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f923401a7e6614f2838037bd9bac86c003d1629446d2b5816d3159472071be4f" checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f"
dependencies = [
"digest",
]
[[package]] [[package]]
name = "roxmltree" name = "roxmltree"
@@ -2457,16 +2349,12 @@ dependencies = [
] ]
[[package]] [[package]]
name = "rustls" name = "rustls-pemfile"
version = "0.23.12" version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c"
dependencies = [ dependencies = [
"once_cell", "base64 0.21.7",
"rustls-pki-types",
"rustls-webpki",
"subtle",
"zeroize",
] ]
[[package]] [[package]]
@@ -2638,7 +2526,7 @@ dependencies = [
"regex", "regex",
"reqwest", "reqwest",
"ring", "ring",
"ripemd160", "ripemd",
"roxmltree", "roxmltree",
"rustyline", "rustyline",
"ryu", "ryu",
@@ -3052,9 +2940,9 @@ dependencies = [
[[package]] [[package]]
name = "sync_wrapper" name = "sync_wrapper"
version = "1.0.1" version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
[[package]] [[package]]
name = "system-configuration" name = "system-configuration"
@@ -3224,18 +3112,7 @@ version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f"
dependencies = [ dependencies = [
"rustls 0.22.4", "rustls",
"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-pki-types", "rustls-pki-types",
"tokio", "tokio",
] ]
@@ -3287,27 +3164,6 @@ dependencies = [
"winnow", "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]] [[package]]
name = "tower-service" name = "tower-service"
version = "0.3.2" version = "0.3.2"
@@ -3510,20 +3366,20 @@ dependencies = [
"futures-util", "futures-util",
"headers", "headers",
"http 0.2.12", "http 0.2.12",
"hyper 0.14.30", "hyper",
"log", "log",
"mime", "mime",
"mime_guess", "mime_guess",
"multer", "multer",
"percent-encoding", "percent-encoding",
"pin-project", "pin-project",
"rustls-pemfile", "rustls-pemfile 2.1.3",
"scoped-tls", "scoped-tls",
"serde", "serde",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"tokio", "tokio",
"tokio-rustls 0.25.0", "tokio-rustls",
"tokio-tungstenite", "tokio-tungstenite",
"tokio-util", "tokio-util",
"tower-service", "tower-service",
@@ -3821,9 +3677,9 @@ dependencies = [
[[package]] [[package]]
name = "winreg" name = "winreg"
version = "0.52.0" version = "0.50.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"windows-sys 0.48.0", "windows-sys 0.48.0",

View File

@@ -64,7 +64,7 @@ phf = { version = "0.11", features = ["macros"] }
rand = "0.8.5" rand = "0.8.5"
regex = "1.10.6" regex = "1.10.6"
ring = { version = "0.17.8", features = ["wasm32_unknown_unknown_js"] } ring = { version = "0.17.8", features = ["wasm32_unknown_unknown_js"] }
ripemd160 = "0.10.0" ripemd = "0.1.3"
roxmltree = "0.20.0" roxmltree = "0.20.0"
ryu = "1.0.18" ryu = "1.0.18"
select = "0.6.0" select = "0.6.0"
@@ -82,7 +82,7 @@ ctrlc = { version = "3.4.4", optional = true }
hostname = { version = "0.4.0", optional = true } hostname = { version = "0.4.0", optional = true }
libffi = { version = "3.2.0", optional = true } libffi = { version = "3.2.0", optional = true }
native-tls = { version = "0.2.12", 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 } rustyline = { version = "14.0.0", optional = true }
tokio = { version = "1.39.2", features = ["full"] } tokio = { version = "1.39.2", features = ["full"] }
warp = { version = "0.3.7", features = ["tls"], optional = true } warp = { version = "0.3.7", features = ["tls"], optional = true }

View File

@@ -18,7 +18,7 @@ use crate::machine::machine_errors::*;
use dashu::base::Abs; use dashu::base::Abs;
use dashu::base::BitTest; use dashu::base::BitTest;
use num_order::NumOrd; use num_order::NumOrd;
use ordered_float::*; use ordered_float::{Float, OrderedFloat};
use std::cell::Cell; use std::cell::Cell;
use std::cmp::{max, min, Ordering}; use std::cmp::{max, min, Ordering};

View File

@@ -150,7 +150,7 @@ impl ForeignFunctionTable {
FunctionImpl { FunctionImpl {
cif, cif,
args, 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, return_struct_name,
}, },
); );

View File

@@ -707,7 +707,7 @@ pub(crate) fn remove_constant_indices(
Some(IndexingCodePtr::DynamicExternal(_)) Some(IndexingCodePtr::DynamicExternal(_))
| Some(IndexingCodePtr::External(_)) | Some(IndexingCodePtr::External(_))
| Some(IndexingCodePtr::Fail) => { | Some(IndexingCodePtr::Fail) => {
constants.remove(&constant); constants.swap_remove(&constant);
break; break;
} }
Some(IndexingCodePtr::Internal(o)) => { Some(IndexingCodePtr::Internal(o)) => {
@@ -846,7 +846,7 @@ pub(crate) fn remove_structure_index(
match structures.get(&(name, arity)).cloned() { match structures.get(&(name, arity)).cloned() {
Some(IndexingCodePtr::DynamicExternal(_)) Some(IndexingCodePtr::DynamicExternal(_))
| Some(IndexingCodePtr::External(_)) => { | Some(IndexingCodePtr::External(_)) => {
structures.remove(&(name, arity)); structures.swap_remove(&(name, arity));
break; break;
} }
Some(IndexingCodePtr::Internal(o)) => { Some(IndexingCodePtr::Internal(o)) => {

View File

@@ -17,7 +17,7 @@ use crate::types::*;
use crate::fixnum; use crate::fixnum;
use ordered_float::*; use ordered_float::{Float, OrderedFloat};
use std::cmp; use std::cmp;
use std::convert::TryFrom; use std::convert::TryFrom;

View File

@@ -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) { 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, Some(module) => module,
None => return, 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) { 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, Some(module) => module,
None => return, None => return,
}; };
@@ -555,8 +555,10 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
} }
} }
ModuleExport::OpDecl(op_decl) => { ModuleExport::OpDecl(op_decl) => {
let op_dir_value_opt = op_dir let op_dir_value_opt = op_dir.swap_remove(&(
.remove(&(op_decl.name, fixity(op_decl.op_desc.get_spec() as u32))); op_decl.name,
fixity(op_decl.op_desc.get_spec() as u32),
));
if let Some(op_desc) = op_dir_value_opt { if let Some(op_desc) = op_dir_value_opt {
retraction_info.push_record(op_retractor(*op_decl, op_desc)); 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); 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) => { Some(mut module) => {
module.listing_src = listing_src; module.listing_src = listing_src;
module 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> { 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; let payload_compilation_target = self.payload.compilation_target;
match &payload_compilation_target { match &payload_compilation_target {
@@ -1115,7 +1117,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
module_name: Atom, module_name: Atom,
exports: IndexSet<ModuleExport>, exports: IndexSet<ModuleExport>,
) -> Result<(), SessionError> { ) -> 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 payload_compilation_target = self.payload.compilation_target;
let result = match &payload_compilation_target { let result = match &payload_compilation_target {

View File

@@ -574,7 +574,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
RetractionRecord::AddedMetaPredicate(target_module_name, key) => { RetractionRecord::AddedMetaPredicate(target_module_name, key) => {
match target_module_name { match target_module_name {
atom!("user") => { atom!("user") => {
self.wam_prelude.indices.meta_predicates.remove(&key); self.wam_prelude.indices.meta_predicates.swap_remove(&key);
} }
_ => match self _ => match self
.wam_prelude .wam_prelude
@@ -583,7 +583,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
.get_mut(&target_module_name) .get_mut(&target_module_name)
{ {
Some(ref mut module) => { Some(ref mut module) => {
module.meta_predicates.remove(&key); module.meta_predicates.swap_remove(&key);
} }
_ => { _ => {
unreachable!() unreachable!()
@@ -617,7 +617,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
} }
} }
RetractionRecord::AddedModule(module_name) => { RetractionRecord::AddedModule(module_name) => {
self.wam_prelude.indices.modules.remove(&module_name); self.wam_prelude.indices.modules.swap_remove(&module_name);
} }
RetractionRecord::ReplacedModule( RetractionRecord::ReplacedModule(
module_decl, module_decl,
@@ -713,7 +713,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
if let Some(ref mut module) = if let Some(ref mut module) =
self.wam_prelude.indices.modules.get_mut(&module_name) 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) => { 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); op_decl.insert_into_op_dir(&mut self.wam_prelude.indices.op_dir);
} }
RetractionRecord::AddedUserPredicate(key) => { 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) => { RetractionRecord::ReplacedUserPredicate(key, old_code_idx) => {
if let Some(code_idx) = self.wam_prelude.indices.code_dir.get_mut(&key) { if let Some(code_idx) = self.wam_prelude.indices.code_dir.get_mut(&key) {

View File

@@ -397,10 +397,10 @@ impl IndexStore {
key: &PredicateKey, key: &PredicateKey,
) -> Option<PredicateSkeleton> { ) -> Option<PredicateSkeleton> {
match compilation_target { match compilation_target {
CompilationTarget::User => self.extensible_predicates.remove(key), CompilationTarget::User => self.extensible_predicates.swap_remove(key),
CompilationTarget::Module(ref module_name) => { CompilationTarget::Module(ref module_name) => {
if let Some(module) = self.modules.get_mut(module_name) { if let Some(module) = self.modules.get_mut(module_name) {
module.extensible_predicates.remove(key) module.extensible_predicates.swap_remove(key)
} else { } else {
None None
} }

View File

@@ -1,6 +1,7 @@
use crate::parser::ast::*; use crate::parser::ast::*;
use crate::parser::parser::*; use crate::parser::parser::*;
use base64::Engine;
use dashu::integer::{Sign, UBig}; use dashu::integer::{Sign, UBig};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use num_order::NumOrd; use num_order::NumOrd;
@@ -72,13 +73,13 @@ use crossterm::event::{read, Event, KeyCode, KeyEvent, KeyModifiers};
#[cfg(feature = "repl")] #[cfg(feature = "repl")]
use crossterm::terminal::{disable_raw_mode, enable_raw_mode}; use crossterm::terminal::{disable_raw_mode, enable_raw_mode};
use blake2::{Blake2b, Blake2s}; use blake2::{Blake2b512, Blake2s256};
use ring::rand::{SecureRandom, SystemRandom}; use ring::rand::{SecureRandom, SystemRandom};
use ring::{digest, hkdf, hmac, pbkdf2}; use ring::{digest, hkdf, hmac, pbkdf2};
#[cfg(feature = "crypto-full")] #[cfg(feature = "crypto-full")]
use ring::aead; use ring::aead;
use ripemd160::{Digest, Ripemd160}; use ripemd::{Digest, Ripemd160};
use sha3::{Sha3_224, Sha3_256, Sha3_384, Sha3_512}; use sha3::{Sha3_224, Sha3_256, Sha3_384, Sha3_512};
use crrl::{ed25519, secp256k1, x25519}; use crrl::{ed25519, secp256k1, x25519};
@@ -3713,14 +3714,9 @@ impl Machine {
#[cfg(feature = "repl")] #[cfg(feature = "repl")]
#[inline(always)] #[inline(always)]
pub(crate) fn get_single_char(&mut self) -> CallResult { pub(crate) fn get_single_char(&mut self) -> CallResult {
let ctrl_c = KeyEvent {
code: KeyCode::Char('c'),
modifiers: KeyModifiers::CONTROL,
};
let key = get_key(); 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 stub = functor_stub(atom!("get_single_char"), 1);
let err = self.machine_st.interrupt_error(); let err = self.machine_st.interrupt_error();
let err = self.machine_st.error_form(err, stub); 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 !stream.is_stdin() && !stream.is_stdout() && !stream.is_stderr() {
if let Some(alias) = stream.options().get_alias() { 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(); let close_result = stream.close();
@@ -4301,15 +4297,14 @@ impl Machine {
let client = reqwest::Client::builder().build().unwrap(); let client = reqwest::Client::builder().build().unwrap();
// request // 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() { if !bytes.is_empty() {
*req.body_mut() = Some(reqwest::Body::from(bytes)); req = req.body(bytes);
} }
// do it! // do it!
match futures::executor::block_on(client.execute(req)) { match futures::executor::block_on(req.send()) {
Ok(resp) => { Ok(resp) => {
// status code // status code
let status = resp.status().as_u16(); let status = resp.status().as_u16();
@@ -7283,90 +7278,83 @@ impl Machine {
let ints_list = match algorithm { let ints_list = match algorithm {
atom!("sha3_224") => { atom!("sha3_224") => {
let mut context = Sha3_224::new(); let mut context = Sha3_224::new();
context.input(&bytes); context.update(&bytes);
heap_loc_as_cell!(iter_to_heap_list( heap_loc_as_cell!(iter_to_heap_list(
&mut self.machine_st.heap, &mut self.machine_st.heap,
context context
.result() .finalize()
.as_ref()
.iter() .iter()
.map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))), .map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))),
)) ))
} }
atom!("sha3_256") => { atom!("sha3_256") => {
let mut context = Sha3_256::new(); let mut context = Sha3_256::new();
context.input(&bytes); context.update(&bytes);
heap_loc_as_cell!(iter_to_heap_list( heap_loc_as_cell!(iter_to_heap_list(
&mut self.machine_st.heap, &mut self.machine_st.heap,
context context
.result() .finalize()
.as_ref()
.iter() .iter()
.map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))), .map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))),
)) ))
} }
atom!("sha3_384") => { atom!("sha3_384") => {
let mut context = Sha3_384::new(); let mut context = Sha3_384::new();
context.input(&bytes); context.update(&bytes);
heap_loc_as_cell!(iter_to_heap_list( heap_loc_as_cell!(iter_to_heap_list(
&mut self.machine_st.heap, &mut self.machine_st.heap,
context context
.result() .finalize()
.as_ref()
.iter() .iter()
.map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))), .map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))),
)) ))
} }
atom!("sha3_512") => { atom!("sha3_512") => {
let mut context = Sha3_512::new(); let mut context = Sha3_512::new();
context.input(&bytes); context.update(&bytes);
heap_loc_as_cell!(iter_to_heap_list( heap_loc_as_cell!(iter_to_heap_list(
&mut self.machine_st.heap, &mut self.machine_st.heap,
context context
.result() .finalize()
.as_ref()
.iter() .iter()
.map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))), .map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))),
)) ))
} }
atom!("blake2s256") => { atom!("blake2s256") => {
let mut context = Blake2s::new(); let mut context = Blake2s256::new();
context.input(&bytes); context.update(&bytes);
heap_loc_as_cell!(iter_to_heap_list( heap_loc_as_cell!(iter_to_heap_list(
&mut self.machine_st.heap, &mut self.machine_st.heap,
context context
.result() .finalize()
.as_ref()
.iter() .iter()
.map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))), .map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))),
)) ))
} }
atom!("blake2b512") => { atom!("blake2b512") => {
let mut context = Blake2b::new(); let mut context = Blake2b512::new();
context.input(&bytes); context.update(&bytes);
heap_loc_as_cell!(iter_to_heap_list( heap_loc_as_cell!(iter_to_heap_list(
&mut self.machine_st.heap, &mut self.machine_st.heap,
context context
.result() .finalize()
.as_ref()
.iter() .iter()
.map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))), .map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))),
)) ))
} }
atom!("ripemd160") => { atom!("ripemd160") => {
let mut context = Ripemd160::new(); let mut context = Ripemd160::new();
context.input(&bytes); context.update(&bytes);
heap_loc_as_cell!(iter_to_heap_list( heap_loc_as_cell!(iter_to_heap_list(
&mut self.machine_st.heap, &mut self.machine_st.heap,
context context
.result() .finalize()
.as_ref()
.iter() .iter()
.map(|b| fixnum_as_cell!(Fixnum::build_with(*b as i64))), .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 padding = cell_as_atom!(self.deref_register(3));
let charset = cell_as_atom!(self.deref_register(4)); let charset = cell_as_atom!(self.deref_register(4));
let config = match (padding, charset) { let b64_engine = match (padding, charset) {
(atom!("true"), atom!("standard")) => base64::STANDARD, (atom!("true"), atom!("standard")) => base64::engine::general_purpose::STANDARD,
(atom!("true"), _) => base64::URL_SAFE, (atom!("true"), _) => base64::engine::general_purpose::URL_SAFE,
(_, atom!("standard")) => base64::STANDARD_NO_PAD, (_, atom!("standard")) => base64::engine::general_purpose::STANDARD_NO_PAD,
(_, _) => base64::URL_SAFE_NO_PAD, (_, _) => base64::engine::general_purpose::URL_SAFE_NO_PAD,
}; };
if self.deref_register(1).is_var() { if self.deref_register(1).is_var() {
@@ -7950,7 +7938,8 @@ impl Machine {
.machine_st .machine_st
.value_to_str_like(self.machine_st.registers[2]) .value_to_str_like(self.machine_st.registers[2])
.unwrap(); .unwrap();
let bytes = base64::decode_config(&*b64.as_str(), config);
let bytes = b64_engine.decode(&*b64.as_str());
match bytes { match bytes {
Ok(bs) => { Ok(bs) => {
@@ -7975,7 +7964,7 @@ impl Machine {
bytes.push(c as u8); 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()); let string = self.u8s_to_string(b64.as_bytes());
unify!(self.machine_st, self.machine_st.registers[2], string); unify!(self.machine_st, self.machine_st.registers[2], string);

View File

@@ -1,5 +1,3 @@
use lexical::parse_lossy;
use crate::atom_table::*; use crate::atom_table::*;
pub use crate::machine::machine_state::*; pub use crate::machine::machine_state::*;
use crate::parser::ast::*; 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<Token, ParserError> { fn vacate_with_float(&mut self, mut token: String) -> Result<Token, ParserError> {
self.return_char(token.pop().unwrap()); self.return_char(token.pop().unwrap());
let n = parse_lossy::<f64, _>(token.as_bytes())?;
let n = parse_float_lossy(&token)?;
Ok(Token::Literal(Literal::from(float_alloc!( Ok(Token::Literal(Literal::from(float_alloc!(
n, n,
self.machine_st.arena self.machine_st.arena
@@ -756,7 +756,7 @@ impl<'a, R: CharRead> Lexer<'a, R> {
} }
} }
let n = parse_lossy::<f64, _>(token.as_bytes())?; let n = parse_float_lossy(&token)?;
Ok(Token::Literal(Literal::from(float_alloc!( Ok(Token::Literal(Literal::from(float_alloc!(
n, n,
self.machine_st.arena self.machine_st.arena
@@ -765,7 +765,7 @@ impl<'a, R: CharRead> Lexer<'a, R> {
return self.vacate_with_float(token); return self.vacate_with_float(token);
} }
} else { } else {
let n = parse_lossy::<f64, _>(token.as_bytes())?; let n = parse_float_lossy(&token)?;
Ok(Token::Literal(Literal::from(float_alloc!( Ok(Token::Literal(Literal::from(float_alloc!(
n, n,
self.machine_st.arena self.machine_st.arena
@@ -1102,3 +1102,13 @@ impl<'a, R: CharRead> Lexer<'a, R> {
} }
} }
} }
fn parse_float_lossy(token: &str) -> Result<f64, ParserError> {
const FORMAT: u128 = lexical::format::STANDARD;
let options = lexical::ParseFloatOptions::builder()
.lossy(true)
.build()
.unwrap();
let n = lexical::parse_with_options::<f64, _, FORMAT>(token.as_bytes(), &options)?;
Ok(n)
}

View File

@@ -93,8 +93,8 @@ impl Highlighter for Helper {
self.highligher.highlight(line, pos) self.highligher.highlight(line, pos)
} }
fn highlight_char(&self, line: &str, pos: usize) -> bool { fn highlight_char(&self, line: &str, pos: usize, forced: bool) -> bool {
self.highligher.highlight_char(line, pos) self.highligher.highlight_char(line, pos, forced)
} }
} }