Makefile: better deps; fop(1), hru(1), strerror(3): changed strerror wrapper function name

This commit is contained in:
Emma Tebibyte 2024-03-02 10:16:32 -07:00
parent 898044cd43
commit c392dbc680
Signed by untrusted user: emma
GPG Key ID: 06FA419A1698C270
4 changed files with 8 additions and 8 deletions

View File

@ -58,7 +58,7 @@ build/o/libstrerror.rlib: build src/strerror.rs
$(RUSTC) $(RUSTFLAGS) --crate-type=lib -o $@ \
src/strerror.rs
build/o/libsysexits.rlib: build
build/o/libsysexits.rlib: build include/sysexits.h
# bandage solution until bindgen(1) gets stdin support
printf '#define EXIT_FAILURE 1\n' | cat - include/sysexits.h \
> build/include/sysexits.h

View File

@ -27,7 +27,7 @@ extern crate strerror;
extern crate sysexits;
use getopt::{ Opt, Parser };
use strerror::c_error;
use strerror::raw_message;
use sysexits::{ EX_DATAERR, EX_IOERR, EX_UNAVAILABLE, EX_USAGE };
fn main() {
@ -77,7 +77,7 @@ fn main() {
.stdout(Stdio::piped())
.spawn()
.unwrap_or_else( |e| {
eprintln!("{}: {}: {}", argv[0], argv[command_arg], c_error(e));
eprintln!("{}: {}: {}", argv[0], argv[command_arg], raw_message(e));
exit(EX_UNAVAILABLE);
});
@ -96,7 +96,7 @@ fn main() {
}
let output = spawned.wait_with_output().unwrap_or_else(|e| {
eprintln!("{}: {}: {}", argv[0], argv[command_arg], c_error(e));
eprintln!("{}: {}: {}", argv[0], argv[command_arg], raw_message(e));
exit(EX_IOERR);
});
@ -114,7 +114,7 @@ fn main() {
stdout().write_all(
fields.join(&d.to_string()).as_bytes()
).unwrap_or_else(|e| {
eprintln!("{}: {}", argv[0], c_error(e));
eprintln!("{}: {}", argv[0], raw_message(e));
exit(EX_IOERR);
});
}

View File

@ -26,7 +26,7 @@ use std::{
extern crate strerror;
extern crate sysexits;
use strerror::c_error;
use strerror::raw_message;
use sysexits::{ EX_DATAERR, EX_IOERR, EX_SOFTWARE };
const LIST: [(u32, &str); 10] = [
@ -100,7 +100,7 @@ fn main() -> ExitCode {
stdout().write_all(format!("{} {}\n", out, si_prefix).as_bytes())
.unwrap_or_else(|e| {
eprintln!("{}: {}", argv[0], c_error(e));
eprintln!("{}: {}", argv[0], raw_message(e));
exit(EX_IOERR);
});
}

View File

@ -13,7 +13,7 @@ use std::ffi::{ c_int, c_char, CStr };
extern "C" { fn strerror(errnum: c_int) -> *mut c_char; }
/* wrapper function for use in Rust */
pub fn c_error(err: std::io::Error) -> String {
pub fn raw_message(err: std::io::Error) -> String {
/* Get the raw OS error. If its None, what the hell is going on‽ */
let error = err.raw_os_error().unwrap_or_else(|| { panic!() }) as c_int;