From 1a86ad5cec263839c037a2858de78fe672df1b55 Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Sun, 28 Nov 2021 20:36:09 -0700 Subject: [PATCH] upgrade rustyline --- Cargo.lock | 149 +++++++++++++++++++++++++++++++++++------ Cargo.toml | 2 +- src/arena.rs | 37 ++++------ src/machine/streams.rs | 79 ---------------------- 4 files changed, 144 insertions(+), 123 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d5b4dc14..2de5d75c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,9 +63,9 @@ checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" [[package]] name = "bitflags" -version = "1.3.2" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "blake2" @@ -160,6 +160,17 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "clipboard-win" +version = "4.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8340083d28acb43451166543b98c838299b7e0863621be53a338adceea0ed" +dependencies = [ + "error-code", + "str-buf", + "winapi 0.3.9", +] + [[package]] name = "cloudabi" version = "0.0.3" @@ -299,6 +310,33 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[package]] +name = "error-code" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5115567ac25674e0043e472be13d14e537f37ea8aa4bdc4aef0c89add1db1ff" +dependencies = [ + "libc", + "str-buf", +] + +[[package]] +name = "fd-lock" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfc110fe50727d46a428eed832df40affe9bf74d077cac1bf3f2718e823f14c5" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "windows-sys", +] + [[package]] name = "foreign-types" version = "0.3.2" @@ -314,16 +352,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" -[[package]] -name = "fs2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" -dependencies = [ - "libc", - "winapi 0.3.9", -] - [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -607,6 +635,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +[[package]] +name = "memoffset" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +dependencies = [ + "autocfg 1.0.1", +] + [[package]] name = "mio" version = "0.6.23" @@ -692,6 +729,15 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +[[package]] +name = "nibble_vec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" +dependencies = [ + "smallvec", +] + [[package]] name = "nix" version = "0.15.0" @@ -707,14 +753,15 @@ dependencies = [ [[package]] name = "nix" -version = "0.19.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2" +checksum = "d3bb9a13fa32bc5aeb64150cd3f32d6cf4c748f8f8a417cce5d2eb976a8370ba" dependencies = [ "bitflags", "cc", "cfg-if 1.0.0", "libc", + "memoffset", ] [[package]] @@ -1027,6 +1074,16 @@ dependencies = [ "proc-macro2 1.0.32", ] +[[package]] +name = "radix_trie" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" +dependencies = [ + "endian-type", + "nibble_vec", +] + [[package]] name = "rand" version = "0.6.5" @@ -1276,19 +1333,22 @@ dependencies = [ [[package]] name = "rustyline" -version = "7.1.0" +version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8227301bfc717136f0ecbd3d064ba8199e44497a0bdd46bb01ede4387cfd2cec" +checksum = "790487c3881a63489ae77126f57048b42d62d3b2bafbf37453ea19eedb6340d6" dependencies = [ "bitflags", "cfg-if 1.0.0", + "clipboard-win", "dirs-next", - "fs2", + "fd-lock", "libc", "log", "memchr", - "nix 0.19.1", + "nix 0.22.2", + "radix_trie", "scopeguard", + "smallvec", "unicode-segmentation", "unicode-width", "utf8parse", @@ -1371,9 +1431,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.4.2" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525bc1abfda2e1998d152c45cf13e696f76d0a4972310b22fac1658b05df7c87" +checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467" dependencies = [ "bitflags", "core-foundation", @@ -1539,6 +1599,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "str-buf" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d44a3643b4ff9caf57abcee9c2c621d6c03d9135e0d8b589bd9afb5992cb176a" + [[package]] name = "string_cache" version = "0.7.5" @@ -1835,6 +1901,49 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82ca39602d5cbfa692c4b67e3bcbb2751477355141c1ed434c94da4186836ff6" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52695a41e536859d5308cc613b4a022261a274390b25bd29dfff4bf08505f3c2" + +[[package]] +name = "windows_i686_gnu" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f54725ac23affef038fecb177de6c9bf065787c2f432f79e3c373da92f3e1d8a" + +[[package]] +name = "windows_i686_msvc" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d5158a43cc43623c0729d1ad6647e62fa384a3d135fd15108d37c683461f64" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc31f409f565611535130cfe7ee8e6655d3fa99c1c61013981e491921b5ce954" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f2b8c7cbd3bfdddd9ab98769f9746a7fad1bca236554cd032b78d768bc0e89f" + [[package]] name = "ws2_32-sys" version = "0.2.1" diff --git a/Cargo.toml b/Cargo.toml index ee785cb4..6d27688a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ ordered-float = "2.1.1" phf = { version = "0.9", features = ["macros"] } ref_thread_local = "0.0.0" rug = { version = "1.12.0", optional = true } -rustyline = "7.0.0" +rustyline = "9.0.0" ring = "0.16.13" ripemd160 = "0.8.0" sha3 = "0.8.2" diff --git a/src/arena.rs b/src/arena.rs index 0d6ad6a0..7fafccb1 100644 --- a/src/arena.rs +++ b/src/arena.rs @@ -373,51 +373,42 @@ impl Arena { unsafe fn drop_slab_in_place(value: &mut AllocSlab) { match value.header.tag() { ArenaHeaderTag::Integer => { - ptr::drop_in_place(value.payload_offset() as *mut Integer); + ptr::drop_in_place(value.payload_offset::()); } ArenaHeaderTag::Rational => { - ptr::drop_in_place(value.payload_offset() as *mut Rational); + ptr::drop_in_place(value.payload_offset::()); } ArenaHeaderTag::InputFileStream => { - ptr::drop_in_place(value.payload_offset() as *mut InputFileStream); + ptr::drop_in_place(value.payload_offset::()); } ArenaHeaderTag::OutputFileStream => { - ptr::drop_in_place(value.payload_offset() as *mut OutputFileStream); + ptr::drop_in_place(value.payload_offset::()); } ArenaHeaderTag::NamedTcpStream => { - ptr::drop_in_place(value.payload_offset() as *mut NamedTcpStream); + ptr::drop_in_place(value.payload_offset::()); } ArenaHeaderTag::NamedTlsStream => { - ptr::drop_in_place(value.payload_offset() as *mut NamedTlsStream); + ptr::drop_in_place(value.payload_offset::()); } - // ArenaHeaderTag::PausedPrologStream => { - // // idea: PausedPrologStream with only the buffer of unread characters. - // // no stream to be wrapped, no nuttin'. - // ptr::drop_in_place(value.payload_offset() as *mut PausedPrologStream); - // } ArenaHeaderTag::ReadlineStream => { - ptr::drop_in_place(value.payload_offset() as *mut ReadlineStream); + ptr::drop_in_place(value.payload_offset::()); } ArenaHeaderTag::StaticStringStream => { - ptr::drop_in_place(value.payload_offset() as *mut StaticStringStream); + ptr::drop_in_place(value.payload_offset::()); } ArenaHeaderTag::ByteStream => { - ptr::drop_in_place(value.payload_offset() as *mut ByteStream); + ptr::drop_in_place(value.payload_offset::()); } ArenaHeaderTag::OssifiedOpDir => { - ptr::drop_in_place( - mem::transmute::<_, *mut OssifiedOpDir>(value.payload_offset()) - ); + ptr::drop_in_place(value.payload_offset::()); } ArenaHeaderTag::LiveLoadState | ArenaHeaderTag::InactiveLoadState => { - ptr::drop_in_place( - mem::transmute::<_, *mut LiveLoadState>(value.payload_offset()) - ); + ptr::drop_in_place(value.payload_offset::()); } ArenaHeaderTag::Dropped => { } ArenaHeaderTag::TcpListener => { - ptr::drop_in_place(value.payload_offset() as *mut TcpListener); + ptr::drop_in_place(value.payload_offset::()); } ArenaHeaderTag::F64 | ArenaHeaderTag::StandardOutputStream | ArenaHeaderTag::StandardErrorStream | ArenaHeaderTag::NullStream => { @@ -458,10 +449,10 @@ impl AllocSlab { self.header.size() as usize + mem::size_of::() } - fn payload_offset(&self) -> *const u8 { + fn payload_offset(&self) -> *mut T { let mut ptr = (self as *const AllocSlab) as usize; ptr += mem::size_of::(); - ptr as *const u8 + ptr as *mut T } } diff --git a/src/machine/streams.rs b/src/machine/streams.rs index 047f9112..1b512e51 100644 --- a/src/machine/streams.rs +++ b/src/machine/streams.rs @@ -237,11 +237,6 @@ impl Write for NamedTlsStream { } } -/* -#[derive(Debug)] -pub struct NullStream {} -*/ - #[derive(Debug)] pub struct StandardOutputStream {} @@ -375,65 +370,6 @@ macro_rules! arena_allocated_impl_for_stream { }; } -/* -pub mod testing { - use super::PausedPrologStream; - - impl PausedPrologStream { - #[allow(dead_code)] - pub fn write_test_input(&mut self, string: &str) { - self.bytes.extend(string.as_bytes().iter().rev()); - } - } -} -*/ -/* -impl ArenaAllocated for PausedPrologStream { - type PtrToAllocated = TypedArenaPtr; - - #[inline] - fn tag() -> ArenaHeaderTag { - ArenaHeaderTag::PausedPrologStream - } - - #[inline] - fn size(&self) -> usize { - mem::size_of::() - } - - #[inline] - fn copy_to_arena(self, dst: *mut Self) -> Self::PtrToAllocated { - unsafe { - ptr::write(dst, self); - TypedArenaPtr::new(dst as *mut Self) - } - } -} - -#[derive(Debug)] -pub struct PausedPrologStream { - bytes: Vec, - paused_stream: Stream, -} - -impl PausedPrologStream { - #[inline] - pub fn new() -> Self { - PausedPrologStream { - bytes: vec![], - paused_stream: Stream::Null(StreamOptions::default()), - } - } -} - -impl Read for PausedPrologStream { - #[inline] - fn read(&mut self, buf: &mut [u8]) -> std::io::Result { - self.paused_stream.read(buf) - } -} -*/ - arena_allocated_impl_for_stream!(CharReader, ByteStream); arena_allocated_impl_for_stream!(CharReader, InputFileStream); arena_allocated_impl_for_stream!(OutputFileStream, OutputFileStream); @@ -593,21 +529,6 @@ impl Stream { } } - /* - fn unpause_stream(&mut self) { - let stream_inst = match self { - Stream::PausedProlog(paused) if paused.bytes.is_empty() => { - mem::replace(&mut paused.paused_stream, Stream::Null(StreamOptions::default())) - } - _ => { - return; - } - }; - - *self = stream_inst; - } - */ - #[inline] pub(crate) fn add_lines_read(&mut self, incr_num_lines_read: usize) { match self { -- 2.54.0