rpn(1): adds support for pledge(2)
This commit is contained in:
parent
72ef8d00bc
commit
326c8f77d1
15
src/rpn.rs
15
src/rpn.rs
|
@ -56,6 +56,12 @@ extern crate sysexits;
|
|||
|
||||
use sysexits::EX_DATAERR;
|
||||
|
||||
#[cfg(target_os="openbsd")] use sysexits::EX_OSERR;
|
||||
#[cfg(target_os="openbsd")] extern crate strerror;
|
||||
#[cfg(target_os="openbsd")] extern crate openbsd;
|
||||
#[cfg(target_os="openbsd")] use strerror::StrError;
|
||||
#[cfg(target_os="openbsd")] use openbsd::{ Promises, pledge };
|
||||
|
||||
#[derive(Clone, PartialEq, PartialOrd, Debug)]
|
||||
/* enum CalcType is a type containing operations used in the calculator */
|
||||
enum CalcType {
|
||||
|
@ -191,6 +197,15 @@ fn round_precise(value: &f64, precision: usize) -> f64 {
|
|||
|
||||
fn main() -> ExitCode {
|
||||
let argv = args().collect::<Vec<String>>();
|
||||
|
||||
if cfg!(target_os="openbsd") {
|
||||
let promises = Promises::new("stdio");
|
||||
if let Err(e) = pledge(Some(promises), None) {
|
||||
eprintln!("{}: {}", argv[0], e.strerror());
|
||||
return ExitCode::from(EX_OSERR as u8);
|
||||
}
|
||||
}
|
||||
|
||||
let mut stack = VecDeque::new();
|
||||
let mut buf = String::new();
|
||||
/* Set floating-point precision for correcting rounding errors based on
|
||||
|
|
Loading…
Reference in New Issue
Block a user