Commit d1f267af authored by Nagy Tibor's avatar Nagy Tibor
Browse files

Work in progress

parent 07ec3b65
Pipeline #8683 failed with stages
in 9 seconds
......@@ -95,6 +95,11 @@ version = "0.1.0"
name = "crtn"
version = "0.1.0"
[[package]]
name = "either"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "getrandom"
version = "0.1.14"
......@@ -123,6 +128,14 @@ dependencies = [
"libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "itertools"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"either 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "itoa"
version = "0.4.6"
......@@ -316,6 +329,7 @@ dependencies = [
"cc 1.0.58 (registry+https://github.com/rust-lang/crates.io-index)",
"core_io 0.1.20181107",
"goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"memoffset 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -544,9 +558,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum cc 1.0.58 (registry+https://github.com/rust-lang/crates.io-index)" = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518"
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
"checksum clap 2.33.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129"
"checksum either 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
"checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
"checksum goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6a4013e9182f2345c6b7829b9ef6e670bce0dfca12c6f974457ed2160c2c7fe9"
"checksum hermit-abi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
"checksum itertools 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
"checksum itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1"
"checksum libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)" = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701"
......
......@@ -24,6 +24,7 @@ memoffset = "0.5.1"
posix-regex = { path = "posix-regex", features = ["no_std"] }
rand = { version = "0.5.5", default-features = false }
memchr = { version = "2.2.0", default-features = false }
itertools = { version = "0.9.0", default-features = false }
[dependencies.goblin]
version = "0.0.21"
......
......@@ -24,7 +24,7 @@ use crate::{
string::{self, strlen},
unistd,
},
io::{self, BufRead, LineWriter, Read, Write},
io::{self, BufRead, BufReader, Cursor, LineWriter, Read, Write},
platform::{self, errno, types::*, Pal, Sys, WriteByte},
sync::Mutex,
};
......@@ -40,10 +40,10 @@ mod getdelim;
mod ext;
mod helpers;
mod lookaheadreader;
//mod lookaheadreader;
mod printf;
mod scanf;
use lookaheadreader::LookAheadReader;
//use lookaheadreader::LookAheadReader;
static mut TMPNAM_BUF: [c_char; L_tmpnam as usize + 1] = [0; L_tmpnam as usize + 1];
enum Buffer<'a> {
......@@ -1122,6 +1122,8 @@ pub unsafe extern "C" fn vsprintf(s: *mut c_char, format: *const c_char, ap: va_
#[no_mangle]
pub unsafe extern "C" fn vfscanf(file: *mut FILE, format: *const c_char, ap: va_list) -> c_int {
let format = CStr::from_ptr(format).to_str().unwrap();
let ret = {
let mut file = (*file).lock();
if let Err(_) = file.try_set_byte_orientation_unlocked() {
......@@ -1129,7 +1131,7 @@ pub unsafe extern "C" fn vfscanf(file: *mut FILE, format: *const c_char, ap: va_
}
let f: &mut FILE = &mut *file;
let reader: LookAheadReader = f.into();
let reader = BufReader::new(f);
scanf::scanf(reader, format, ap)
};
ret
......@@ -1142,6 +1144,8 @@ pub unsafe extern "C" fn vscanf(format: *const c_char, ap: va_list) -> c_int {
#[no_mangle]
pub unsafe extern "C" fn vsscanf(s: *const c_char, format: *const c_char, ap: va_list) -> c_int {
let reader = (s as *const u8).into();
let format = CStr::from_ptr(format).to_str().unwrap();
let s = CStr::from_ptr(s).to_str().unwrap();
let reader = Cursor::new(s);
scanf::scanf(reader, format, ap)
}
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment