Makefile, libdelimit: update for including libdelimit in utilities

This commit is contained in:
Emma Tebibyte 2025-10-28 14:08:17 -06:00
parent 31b424d205
commit 15039805f9
Signed by: emma
GPG Key ID: 427287A2F16F44FA
2 changed files with 11 additions and 7 deletions

View File

@ -30,7 +30,8 @@ SYSEXITS != printf '\043include <sysexits.h>\n' | cpp -M - | tr ' ' '\n' \
CC ?= cc
RUSTC ?= rustc
RUSTFLAGS += --extern getopt=build/o/libgetopt.rlib \
RUSTFLAGS += --extern delimit=build/o/libdelimit.rlib \
--extern getopt=build/o/libgetopt.rlib \
--extern strerror=build/o/libstrerror.rlib \
--extern sysexits=build/o/libsysexits.rlib
CFLAGS += -I$(SYSEXITS)
@ -88,8 +89,12 @@ docs: docs/ build
include $(OS_INCLUDE)
.PHONY: rustlibs
rustlibs: build/o/libgetopt.rlib build/o/libstrerror.rlib \
build/o/libsysexits.rlib $(OSLIB)
rustlibs: build/o/libdelimit.rlib build/o/libgetopt.rlib \
build/o/libstrerror.rlib build/o/libsysexits.rlib $(OSLIB)
build/o/libdelimit.rlib: build src/libdelimit.rs
$(RUSTC) $(RUSTFLAGS) --crate-type=lib --crate-name=delimit \
-o $@ src/libdelimit.rs
build/o/libgetopt.rlib: build src/libgetopt.rs
$(RUSTC) $(RUSTFLAGS) --crate-type=lib --crate-name=getopt \

View File

@ -17,21 +17,20 @@
*/
use std::{
io::{ Read, Result, stdin },
io::{ Read, Result },
mem::self,
process::ExitCode,
};
const BUFFER_SIZE: usize = 4096;
struct Delimited {
pub struct Delimited {
stream: Box<dyn Read>,
delimiter: Vec<u8>,
buffer: Vec<u8>
}
impl Delimited {
fn new(stream: Box<dyn Read>, delimiter: &[u8]) -> Self {
pub fn new(stream: Box<dyn Read>, delimiter: &[u8]) -> Self {
Delimited {
stream,
delimiter: delimiter.to_vec(),