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.
This commit is contained in:
Raymond Pasco 2016-02-29 16:57:16 -05:00
parent 9a0167c99c
commit 64f7f58143

View File

@ -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/*}
^- *