From 2dd6c0ded7a65fee58a8fbff5f62891d5484b778 Mon Sep 17 00:00:00 2001 From: emma Date: Sun, 2 Jun 2024 19:05:30 -0600 Subject: [PATCH 1/2] fop(1): adds the ability to use any string as a delimiter --- src/fop.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/fop.rs b/src/fop.rs index b829602..d28a7b0 100644 --- a/src/fop.rs +++ b/src/fop.rs @@ -32,18 +32,12 @@ use sysexits::{ EX_DATAERR, EX_IOERR, EX_UNAVAILABLE, EX_USAGE }; fn main() { let argv = args().collect::>(); - let mut d = '␞'; + let mut d = "␞".to_owned(); let mut arg_parser = Parser::new(&argv, "d:"); while let Some(opt) = arg_parser.next() { match opt { - Ok(Opt('d', Some(arg))) => { - let arg_char = arg.chars().collect::>(); - if arg_char.len() > 1 { - eprintln!("{}: {}: Not a character.", argv[0], arg); - exit(EX_USAGE); - } else { d = arg_char[0]; } - }, + Ok(Opt('d', Some(arg))) => d = arg, _ => {}, }; } @@ -63,7 +57,7 @@ fn main() { let mut buf = String::new(); let _ = stdin().read_to_string(&mut buf); - let mut fields = buf.split(d).collect::>(); + let mut fields = buf.split(&d).collect::>(); let opts = argv .iter() From 3392d64e440b8911a51bfead6c73fb5c4fe3f452 Mon Sep 17 00:00:00 2001 From: emma Date: Wed, 5 Jun 2024 17:25:22 -0600 Subject: [PATCH 2/2] fop(1): literal record separator --- src/fop.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fop.rs b/src/fop.rs index d28a7b0..1cc8152 100644 --- a/src/fop.rs +++ b/src/fop.rs @@ -32,7 +32,7 @@ use sysexits::{ EX_DATAERR, EX_IOERR, EX_UNAVAILABLE, EX_USAGE }; fn main() { let argv = args().collect::>(); - let mut d = "␞".to_owned(); + let mut d = 0x1E.to_string(); let mut arg_parser = Parser::new(&argv, "d:"); while let Some(opt) = arg_parser.next() {