WIP: libdelimiter #172

Draft
emma wants to merge 7 commits from libdelimiter into trunk
2 changed files with 11 additions and 7 deletions
Showing only changes of commit 15039805f9 - Show all commits

View File

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

View File

@ -17,21 +17,20 @@
*/ */
use std::{ use std::{
io::{ Read, Result, stdin }, io::{ Read, Result },
mem::self, mem::self,
silt marked this conversation as resolved Outdated
Outdated
Review

self is unnecessary here and gets caught by rust-analyzer.

`self` is unnecessary here and gets caught by `rust-analyzer`.
process::ExitCode,
}; };
const BUFFER_SIZE: usize = 4096; const BUFFER_SIZE: usize = 4096;
struct Delimited { pub struct Delimited {
stream: Box<dyn Read>, stream: Box<dyn Read>,
delimiter: Vec<u8>, delimiter: Vec<u8>,
buffer: Vec<u8> buffer: Vec<u8>
} }
impl Delimited { impl Delimited {
fn new(stream: Box<dyn Read>, delimiter: &[u8]) -> Self { pub fn new(stream: Box<dyn Read>, delimiter: &[u8]) -> Self {
Delimited { Delimited {
stream, stream,
delimiter: delimiter.to_vec(), delimiter: delimiter.to_vec(),