diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..10b6ce8 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,10 @@ +[unstable] +build-std = [ "std", "panic_abort" ] +build-std-features = [ "panic_immediate_abort" ] + +[profile.release] +strip = true # strip symbols from the binary +opt-level = "z" # optimize for size +lto = true # link time optimization +codegen-units = 1 # decrease parallelization +panic = "abort" diff --git a/Cargo.lock b/Cargo.lock index 4fd7cf7..b5ed577 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,29 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "exit-no-std" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a608ccc67fac78c1916aa88ad75d6f6a3e353521844abce906c22a45d161d99" +dependencies = [ + "libc", + "pc-ints", + "winapi", +] + +[[package]] +name = "libc" +version = "0.2.138" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" + +[[package]] +name = "pc-ints" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "422b0cc3a966f6e0987d2f948c234585bd917a1f16df1470e60c56ad6de2c085" + [[package]] name = "serde" version = "1.0.148" @@ -12,6 +35,7 @@ checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc" name = "tomcat" version = "0.0.1" dependencies = [ + "exit-no-std", "toml", ] @@ -23,3 +47,25 @@ checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" dependencies = [ "serde", ] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index ead9c5d..35b6c44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,11 +6,5 @@ license = "AGPL-3.0-or-later" authors = [ "Emma Tebibyte " ] [dependencies] +exit-no-std = "0.1.3" toml = "0.5.9" - -[profile.release] -strip = true # strip symbols from the binary -opt-level = "z" # optimize for size -lto = true # link time optimization -codegen-units = 1 # decrease parallelization -panic = "abort" diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..5d56faf --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "nightly" diff --git a/src/main.rs b/src/main.rs index 364704c..68c0c18 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,7 +19,7 @@ use std::env; use std::fs::File; use std::io::Read; use std::path::Path; -use std::process; +use exit_no_std::exit; use std::str::FromStr; use toml::Value; @@ -29,7 +29,7 @@ fn main() { let argv0 = arguments.remove(0); if arguments[1].is_empty() { eprintln!("Usage: {} [table...].[value[index]] [file...]", argv0); - process::exit(64); // sysexits(3) EX_USAGE + exit(64); // sysexits(3) EX_USAGE } let input = &arguments[1]; let mut content = String::new(); @@ -53,7 +53,7 @@ fn main() { Ok(i) => index = i, Err(_) => { eprintln!("{}: {}: Cannot index by given value.", argv0, istr); - process::exit(65); // sysexits(3) EX_DATAERR + exit(64); // sysexits(3) EX_USAGE }, }; } @@ -75,7 +75,7 @@ fn main() { match valiter.peek() { Some(_) => { eprintln!("{}: {}: Not a table.", argv0, item); - process::exit(65); // sysexits(3) EX_DATAERR + exit(65); // sysexits(3) EX_DATAERR }, None => { match array.get(index) { @@ -86,7 +86,7 @@ fn main() { eprintln!( "{}: {:?}: No value at given index.", argv0, index ); - process::exit(65); // sysexits(3) EX_DATAERR + exit(65); // sysexits(3) EX_DATAERR }, }; }, @@ -94,7 +94,7 @@ fn main() { eprintln!( "{}: {:?}: No value at given index.", argv0, index ); - process::exit(65); // sysexits(3) EX_DATAERR + exit(65); // sysexits(3) EX_DATAERR }, }; }, @@ -108,7 +108,7 @@ fn main() { match valiter.peek() { Some(_) => { eprintln!("{}: {}: Not a table.", argv0, item); - process::exit(65); // sysexits(3) EX_DATAERR + exit(65); // sysexits(3) EX_DATAERR }, None => out.push_str(string.as_str()), }; @@ -125,7 +125,7 @@ fn main() { }, None => { eprintln!("{}: {}: No such table or key.", argv0, item); - process::exit(65); // sysexits(3) EX_DATAERR + exit(65); // sysexits(3) EX_DATAERR }, }; }