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" bindgen = "0.63.0"
[features] [features]
default = [ "entry" ] default = [ "entry", "errors"]
entry = [] entry = []
errors = []

View File

@ -49,9 +49,7 @@
*/ */
mod args; mod args;
mod errors;
pub use args::Args; pub use args::Args;
pub use errors::*;
use crate::{ use crate::{
exit, exit,
@ -86,7 +84,7 @@ pub unsafe fn c_str_to_rust_unchecked(ptr: *const u8) -> &'static str {
} }
extern "Rust" { 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)] #[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]."); libc_eprintln!("Unable to ascertain argv[0].");
exit(71); exit(71);
}); });
rust_main(args).unwrap_or_else(|err| { rust_main(args).unwrap_or_else(|(err, code)| {
if err.code == EX_USAGE { if code == EX_USAGE {
libc_eprintln!("Usage: {} {}", argv0, err.message); libc_eprintln!("Usage: {} {}", argv0, err);
} else { libc_eprintln!("{}: {}", argv0, err.message); } } else { libc_eprintln!("{}: {}", argv0, err); }
err.code code
}) as _ }) as _
}, },
Err(_) => { Err(_) => {

View File

@ -31,10 +31,3 @@ impl From<YacError> for (String, u32) {
(err.message, err.code) (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")] #[cfg(feature = "entry")]
mod entry; mod entry;
#[cfg(feature = "entry")] pub use entry::Args;
pub use entry::*;
pub fn exit(code: u32) -> ! { pub fn exit(code: u32) -> ! {
unsafe { libc::exit(code as i32 as libc::c_int); } unsafe { libc::exit(code as i32 as libc::c_int); }