yac
/
yacexits
Archived
3
0
Fork 0

Compare commits

...

2 Commits

Author SHA1 Message Date
Emma Tebibyte 61884116e8
removed references to error module 2023-03-30 23:41:40 -04:00
Emma Tebibyte dcd4b76fbc
Revert "added YacError type, returned from rust_main()"
This reverts commit 87abddd277.
2023-03-30 23:38:37 -04:00
4 changed files with 9 additions and 18 deletions

View File

@ -15,5 +15,6 @@ libc-print = "0.1.21"
bindgen = "0.63.0"
[features]
default = [ "entry" ]
default = [ "entry", "errors"]
entry = []
errors = []

View File

@ -49,9 +49,7 @@
*/
mod args;
mod errors;
pub use args::Args;
pub use errors::*;
use crate::{
exit,
@ -86,7 +84,7 @@ pub unsafe fn c_str_to_rust_unchecked(ptr: *const u8) -> &'static str {
}
extern "Rust" {
fn rust_main(args: args::Args) -> Result<u32, YacError>;
fn rust_main(args: args::Args) -> Result<u32, (alloc::string::String, u32)>;
}
#[doc(hidden)]
@ -102,11 +100,11 @@ pub unsafe extern fn main(argc: c_int, argv: *const *const u8) -> c_int {
libc_eprintln!("Unable to ascertain argv[0].");
exit(71);
});
rust_main(args).unwrap_or_else(|err| {
if err.code == EX_USAGE {
libc_eprintln!("Usage: {} {}", argv0, err.message);
} else { libc_eprintln!("{}: {}", argv0, err.message); }
err.code
rust_main(args).unwrap_or_else(|(err, code)| {
if code == EX_USAGE {
libc_eprintln!("Usage: {} {}", argv0, err);
} else { libc_eprintln!("{}: {}", argv0, err); }
code
}) as _
},
Err(_) => {

View File

@ -31,10 +31,3 @@ impl From<YacError> for (String, u32) {
(err.message, err.code)
}
}
impl From<(String, u32)> for YacError {
fn from(err: (String, u32)) -> Self {
let (message, code) = err;
YacError { message, code }
}
}

View File

@ -73,8 +73,7 @@ extern crate core;
#[cfg(feature = "entry")]
mod entry;
#[cfg(feature = "entry")]
pub use entry::*;
pub use entry::Args;
pub fn exit(code: u32) -> ! {
unsafe { libc::exit(code as i32 as libc::c_int); }