From 64f7f581439790b77215e382271cecd61c9a3107 Mon Sep 17 00:00:00 2001 From: Raymond Pasco Date: Mon, 29 Feb 2016 16:57:16 -0500 Subject: [PATCH] Add ++lune/++nule Unix textfile arms ++lune parses a cord to a list of lines, which must all be terminated by a newline. The cord can be the empty string; this gives an empty list of zero lines. Make sure to validate that any cords you use ++lune on are either the empty string or end in a final newline; noeol textfiles are invalid and you must use ++lore on them. ++nule is the inverse operation to ++lune; it takes a list of cords and joins them into a single cord, with each line in the list terminated by a newline character. This list can be empty, which will produce the empty cord. --- arvo/hoon.hoon | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index 7c5f93d45..9b2af2f9e 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -4819,6 +4819,38 @@ $(i +(i), tez t.tez, our i.tez) $(i +(i), tez t.tez, our (cat 3 (cat 3 our 10) i.tez)) :: +++ lune :: cord by unix line + ~/ %lune + |= txt/@t + ?~ txt + ^- (list @t) ~ + =+ [byt=(rip 3 txt) len=(met 3 txt)] + =| {lin/(list @t) off/@} + ^- (list @t) + %- flop + |- ^+ lin + ?: =(off len) + ~| %noeol !! + ?: =((snag off byt) 10) + ?: =(+(off) len) + [(rep 3 (scag off byt)) lin] + %= $ + lin [(rep 3 (scag off byt)) lin] + byt (slag +(off) byt) + len (sub len +(off)) + off 0 + == + $(off +(off)) +:: +++ nule :: lines to unix cord + ~/ %nule + |= lin/(list @t) + ^- @t + %+ can 3 + %+ turn lin + |= t/@t + [+((met 3 t)) (cat 3 t 10)] +:: ++ lump :: apply patch |= {don/udon src/*} ^- *