Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
fbacfecce8
|
|||
|
579ff65b67
|
|||
|
334433536b
|
|||
|
e9058803d3
|
|||
|
71d4d6ba05
|
|||
|
821f5d09e9
|
|||
|
a4a556a5b6
|
@@ -39,7 +39,7 @@ fn main() {
|
|||||||
let mut d = '\u{1E}'.to_string(); /* ASCII record separator */
|
let mut d = '\u{1E}'.to_string(); /* ASCII record separator */
|
||||||
let mut optind = 1;
|
let mut optind = 1;
|
||||||
|
|
||||||
if cfg!(target_os="openbsd") {
|
#[cfg(target_os="openbsd")] {
|
||||||
let promises = Promises::new("stdio proc exec");
|
let promises = Promises::new("stdio proc exec");
|
||||||
if let Err(e) = pledge(Some(promises), None) {
|
if let Err(e) = pledge(Some(promises), None) {
|
||||||
eprintln!("{}: {}", argv[0], e.strerror());
|
eprintln!("{}: {}", argv[0], e.strerror());
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ fn main() -> ExitCode {
|
|||||||
return ExitCode::from(EX_USAGE as u8);
|
return ExitCode::from(EX_USAGE as u8);
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg!(target_os="openbsd") {
|
#[cfg(target_os="openbsd")] {
|
||||||
let promises = Promises::new("stdio");
|
let promises = Promises::new("stdio");
|
||||||
if let Err(e) = pledge(Some(promises), None) {
|
if let Err(e) = pledge(Some(promises), None) {
|
||||||
eprintln!("{}: {}", argv[0], e.strerror());
|
eprintln!("{}: {}", argv[0], e.strerror());
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ fn usage(s: &str) -> ExitCode {
|
|||||||
fn main() -> ExitCode {
|
fn main() -> ExitCode {
|
||||||
let argv = args().collect::<Vec<String>>();
|
let argv = args().collect::<Vec<String>>();
|
||||||
|
|
||||||
if cfg!(target_os="openbsd") {
|
#[cfg(target_os="openbsd")] {
|
||||||
let promises = Promises::new("stdio");
|
let promises = Promises::new("stdio");
|
||||||
if let Err(e) = pledge(Some(promises), None) {
|
if let Err(e) = pledge(Some(promises), None) {
|
||||||
eprintln!("{}: {}", argv[0], e.strerror());
|
eprintln!("{}: {}", argv[0], e.strerror());
|
||||||
|
|||||||
44
src/mm.rs
44
src/mm.rs
@@ -51,8 +51,8 @@ fn main() -> ExitCode {
|
|||||||
let argv = args().collect::<Vec<_>>();
|
let argv = args().collect::<Vec<_>>();
|
||||||
let usage = format!("Usage: {} [-aetu] [-i input] [-o output]", argv[0]);
|
let usage = format!("Usage: {} [-aetu] [-i input] [-o output]", argv[0]);
|
||||||
|
|
||||||
if cfg!(target_os="openbsd") {
|
#[cfg(target_os="openbsd")] {
|
||||||
let promises = Promises::new("rpath stdio unveil");
|
let promises = Promises::new("cpath rpath stdio unveil wpath");
|
||||||
if let Err(e) = pledge(Some(promises), None) {
|
if let Err(e) = pledge(Some(promises), None) {
|
||||||
eprintln!("{}: {}", argv[0], e.strerror());
|
eprintln!("{}: {}", argv[0], e.strerror());
|
||||||
return ExitCode::from(EX_OSERR as u8);
|
return ExitCode::from(EX_OSERR as u8);
|
||||||
@@ -76,29 +76,11 @@ fn main() -> ExitCode {
|
|||||||
Ok("t") => t = false,
|
Ok("t") => t = false,
|
||||||
Ok("i") => { /* add inputs */
|
Ok("i") => { /* add inputs */
|
||||||
let input = opt.arg().unwrap();
|
let input = opt.arg().unwrap();
|
||||||
|
|
||||||
if cfg!(target_os="openbsd") {
|
|
||||||
let perms = UnveilPerms::new(vec!['r']);
|
|
||||||
if let Err(e) = unveil(Some(&input), Some(perms)) {
|
|
||||||
eprintln!("{}: {}", argv[0], e.strerror());
|
|
||||||
return ExitCode::from(EX_OSERR as u8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ins.push(input);
|
ins.push(input);
|
||||||
mode = Some(In); /* latest argument == -i */
|
mode = Some(In); /* latest argument == -i */
|
||||||
},
|
},
|
||||||
Ok("o") => { /* add output */
|
Ok("o") => { /* add output */
|
||||||
let output = opt.arg().unwrap();
|
let output = opt.arg().unwrap();
|
||||||
|
|
||||||
if cfg!(target_os="openbsd") {
|
|
||||||
let perms = UnveilPerms::new(vec!['w', 'c']);
|
|
||||||
if let Err(e) = unveil(Some(&output), Some(perms)) {
|
|
||||||
eprintln!("{}: {}", argv[0], e.strerror());
|
|
||||||
return ExitCode::from(EX_OSERR as u8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
outs.push(output);
|
outs.push(output);
|
||||||
mode = Some(Out); /* latest argument == -o */
|
mode = Some(Out); /* latest argument == -o */
|
||||||
},
|
},
|
||||||
@@ -124,7 +106,25 @@ fn main() -> ExitCode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg!(target_os="openbsd") {
|
#[cfg(target_os="openbsd")] {
|
||||||
|
for input in &ins {
|
||||||
|
let perms = UnveilPerms::new(vec!['r']);
|
||||||
|
|
||||||
|
if let Err(e) = unveil(Some(&input), Some(perms)) {
|
||||||
|
eprintln!("{}: {}", argv[0], e.strerror());
|
||||||
|
return ExitCode::from(EX_OSERR as u8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for output in &outs {
|
||||||
|
let perms = UnveilPerms::new(vec!['c', 'w']);
|
||||||
|
|
||||||
|
if let Err(e) = unveil(Some(&output), Some(perms)) {
|
||||||
|
eprintln!("{}: {}", argv[0], e.strerror());
|
||||||
|
return ExitCode::from(EX_OSERR as u8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Err(e) = unveil(None, None) {
|
if let Err(e) = unveil(None, None) {
|
||||||
eprintln!("{}: {}", argv[0], e.strerror());
|
eprintln!("{}: {}", argv[0], e.strerror());
|
||||||
return ExitCode::from(EX_OSERR as u8);
|
return ExitCode::from(EX_OSERR as u8);
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ fn round_precise(value: &f64, precision: usize) -> f64 {
|
|||||||
fn main() -> ExitCode {
|
fn main() -> ExitCode {
|
||||||
let argv = args().collect::<Vec<String>>();
|
let argv = args().collect::<Vec<String>>();
|
||||||
|
|
||||||
if cfg!(target_os="openbsd") {
|
#[cfg(target_os="openbsd")] {
|
||||||
let promises = Promises::new("stdio");
|
let promises = Promises::new("stdio");
|
||||||
if let Err(e) = pledge(Some(promises), None) {
|
if let Err(e) = pledge(Some(promises), None) {
|
||||||
eprintln!("{}: {}", argv[0], e.strerror());
|
eprintln!("{}: {}", argv[0], e.strerror());
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ fn usage(s: &str) -> ExitCode {
|
|||||||
fn main() -> ExitCode {
|
fn main() -> ExitCode {
|
||||||
let argv = args().collect::<Vec<String>>();
|
let argv = args().collect::<Vec<String>>();
|
||||||
|
|
||||||
if cfg!(target_os="openbsd") {
|
#[cfg(target_os="openbsd")] {
|
||||||
let promises = Promises::new("stdio");
|
let promises = Promises::new("stdio");
|
||||||
if let Err(e) = pledge(Some(promises), None) {
|
if let Err(e) = pledge(Some(promises), None) {
|
||||||
return oserr(&argv[0], e);
|
return oserr(&argv[0], e);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ dj_tests: dj_help dj_full dj_null # dj_skip_stdin
|
|||||||
dj_full: $(BIN)/dj /dev/full
|
dj_full: $(BIN)/dj /dev/full
|
||||||
case "$$(uname)" in \
|
case "$$(uname)" in \
|
||||||
Linux) \
|
Linux) \
|
||||||
$(BIN)/dj -Hi /dev/zero -o /dev/full 2>&1 \
|
! $(BIN)/dj -Hi /dev/zero -o /dev/full 2>&1 \
|
||||||
| tee /dev/stderr \
|
| tee /dev/stderr \
|
||||||
| xargs -I out test '1+0 > 0+0; 1024 > 0' = out \
|
| xargs -I out test '1+0 > 0+0; 1024 > 0' = out \
|
||||||
;; \
|
;; \
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2024 E$(NAME)a Tebibyte <e$(NAME)a@tebibyte.media>
|
# Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
|
||||||
# SPDX-License-Identifier: FSFAP
|
# SPDX-License-Identifier: FSFAP
|
||||||
#
|
#
|
||||||
# Copying and distribution of this file, with or without modification, are
|
# Copying and distribution of this file, with or without modification, are
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
# notice are preserved. This file is offered as-is, without any warranty.
|
# notice are preserved. This file is offered as-is, without any warranty.
|
||||||
|
|
||||||
.PHONY: mm_tests
|
.PHONY: mm_tests
|
||||||
mm_tests: mm_args mm_help mm_stderr
|
mm_tests: mm_args mm_help mm_stderr mm_remaining
|
||||||
|
|
||||||
.PHONY: mm_none
|
.PHONY: mm_none
|
||||||
mm_none: $(BIN)/mm
|
mm_none: $(BIN)/mm
|
||||||
@@ -25,3 +25,10 @@ mm_help: $(BIN)/mm
|
|||||||
# check if stderr is empty upon specifying -e
|
# check if stderr is empty upon specifying -e
|
||||||
mm_stderr: $(BIN)/mm
|
mm_stderr: $(BIN)/mm
|
||||||
test "$$(printf 'test\n' | $(BIN)/mm -e 2>&1 >/dev/null )" = "test"
|
test "$$(printf 'test\n' | $(BIN)/mm -e 2>&1 >/dev/null )" = "test"
|
||||||
|
|
||||||
|
.PHONY: mm_remaining
|
||||||
|
# check to make sure remaining arguments are used
|
||||||
|
mm_remaining: $(BIN)/mm
|
||||||
|
test "$$($(BIN)/mm -i README COPYING)" = "$$(cat README COPYING)"
|
||||||
|
$(BIN)/mm -i README -o /tmp/mm_test0 /tmp/mm_test1
|
||||||
|
diff /tmp/mm_test0 /tmp/mm_test1
|
||||||
|
|||||||
@@ -32,11 +32,29 @@ npc_ascii: npc_ascii_controls npc_ascii_symbols npc_ascii_uppers # \
|
|||||||
.PHONY: npc_ascii_controls
|
.PHONY: npc_ascii_controls
|
||||||
# (control characters)
|
# (control characters)
|
||||||
npc_ascii_controls:
|
npc_ascii_controls:
|
||||||
|
# The following test prints the bytes 0x00 (inclusive) through 0x20
|
||||||
|
# (exclusive) and pipes them through npc(1). npc(1) should then replace all
|
||||||
|
# non-printing, non-space (in the isspace(3p) sense) characters with their
|
||||||
|
# graphical carat-char counterparts (see the npc(1) man page). The head(1p)
|
||||||
|
# invocation then strips off everything past the first line (or past the
|
||||||
|
# first newline byte, 0x0A) and xargs(1p) is used to test(1p) the output
|
||||||
|
# against the known good answer.
|
||||||
|
|
||||||
|
# Immediately before that newline, 0x09 is printed - in ASCII, the
|
||||||
|
# horizontal tab. If xargs' -I option is used, tr(1p) should used to delete
|
||||||
|
# that tab. If the tab is left as part of input, OpenBSD's xargs(1)
|
||||||
|
# implementation has been observed to strip it along with the other
|
||||||
|
# trailing whitespace (the newline), but Busybox's and GNU's xargs(1)
|
||||||
|
# implementations have been observed to leave the tab in. All three
|
||||||
|
# implementations strip off the trailing tab if `-I` is not used. The POSIX
|
||||||
|
# specification for `-I` is ambiguous as to which behavior is correct.
|
||||||
|
# This comment is the result of much bewilderment and debugging.
|
||||||
|
|
||||||
# ASCII 0x00 to 0x0a (before the newline, due to xargs(1p) issues)
|
# ASCII 0x00 to 0x0a (before the newline, due to xargs(1p) issues)
|
||||||
awk 'BEGIN{ for (i = 0; i < 32; ++i) printf("%c", i); }' \
|
awk 'BEGIN{ for (i = 0; i < 32; ++i) printf("%c", i); }' \
|
||||||
| $(BIN)/npc \
|
| $(BIN)/npc \
|
||||||
| head -n 1 \
|
| head -n 1 \
|
||||||
| xargs -I out test "^@^A^B^C^D^E^F^G^H" = out
|
| xargs test "^@^A^B^C^D^E^F^G^H" =
|
||||||
|
|
||||||
# ASCII 0x0a (otherwise the head|tail sequence won't work) to 0x1f
|
# ASCII 0x0a (otherwise the head|tail sequence won't work) to 0x1f
|
||||||
awk 'BEGIN{ for (i = 0; i < 32; ++i) printf("%c", i); print }' \
|
awk 'BEGIN{ for (i = 0; i < 32; ++i) printf("%c", i); print }' \
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ rpn_mul: $(BIN)/rpn
|
|||||||
.PHONY: rpn_div
|
.PHONY: rpn_div
|
||||||
rpn_div: $(BIN)/rpn
|
rpn_div: $(BIN)/rpn
|
||||||
test "$$($(BIN)/rpn 12 5 /)" = 2.4
|
test "$$($(BIN)/rpn 12 5 /)" = 2.4
|
||||||
test "$$($(BIN)/rpn 3 0 /)" -eq inf
|
test "$$($(BIN)/rpn 3 0 /)" = inf
|
||||||
|
|
||||||
.PHONY: rpn_mod
|
.PHONY: rpn_mod
|
||||||
rpn_mod: $(BIN)/rpn
|
rpn_mod: $(BIN)/rpn
|
||||||
|
|||||||
Reference in New Issue
Block a user