Skip to content

Missing record splitting modes #124

Description

@Alonely0

gawk/awk have different record splitting modes depending on RS, RT, and friends. I think the plumbing is done, but some modes are missing. There might be missing plumbing for RT.

Sorry for the delay, I had a deployment at work these last couple of weeks and couldn't get the time to put this together.

Docs:

https://www.gnu.org/software/gawk/manual/html_node/awk-split-records.html
https://www.gnu.org/software/gawk/manual/html_node/gawk-split-records.html

It is quite funny how we avoided the nul-adjacent pitfalls gawk warns us about by construction, since Rust uses fat pointers.

If there is any interesting code reuse from the field splitting impl, feel free to refactor/reuse it by draining symbols.rs into io.rs. IMO field splitting is mostly living in symbols.rs on parole, given it's got too much user input processing for my taste.

Relevant source files/lines:

match self.mode {
// Regex matching (GNU extension)
ExecMode::Uu | ExecMode::Gnu if first.is_none() => {
self.read_record_regex(rs_bytes, reader)
}
// Single char matching
// TODO: what if POSIX & invalid UTF-8?
_ if let Some(c) = first => {
self.symbols.rt.clone_from(&rs);
self.read_record_until_char(c, reader)
}
// Empty RS
_ => self.read_record_blank_lines(reader),
}

pub fn read_record_regex(&mut self, _rs: &[u8], mut _reader: impl BufRead) -> Result<bool> {
todo!()
}

pub fn read_record_blank_lines(&mut self, mut _reader: impl BufRead) -> Result<bool> {
todo!()
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions