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!() |
|
} |
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 forRT.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.rsintoio.rs. IMO field splitting is mostly living insymbols.rson parole, given it's got too much user input processing for my taste.Relevant source files/lines:
awk/interpreter/src/vm/io.rs
Lines 84 to 97 in 41ce9a7
awk/interpreter/src/vm/io.rs
Lines 100 to 102 in 41ce9a7
awk/interpreter/src/vm/io.rs
Lines 133 to 135 in 41ce9a7