~/bend-docscommunity

text.bend checks

raw source on the hub · import 0xfd64aefef43747d3eaeea50c10a112e5/text.bend as Text

Text: lines out of a byte stream, and header-safe strings. SMTP is a line protocol: every command and reply line ends in CRLF, and a CR or LF smuggled into a field would start a new command or header.

1 import
import Base

Types

type Line source · line 8 · raw

Data

A cut of a buffer: the first complete line and the rest, or the whole buffer back when no line is complete yet.

Definitions

def Text.done source · line 16 · raw

@acc:String -> String

A line read backwards, its CR dropped, put back in order.

def Text.line source · line 26 · raw

@s:String -> @acc:String -> Line

The first LF-terminated line of s; Need{""} when there is none.

def Text.cut.fin source · line 35 · raw

@l:Line -> @buf:String -> Line

def Text.cut source · line 43 · raw

@+buf:String -> Line

The first line of buf and the rest, or Need{buf}.

def Text.is_nl source · line 49 · raw

@c:Char -> Bool

def Text.clean.put source · line 54 · raw

@nl:Bool -> @c:Char -> @rest:String -> String

def Text.clean source · line 62 · raw

@s:String -> String

s without its CRs and LFs: safe inside one command or header line.

def Text.has_nl source · line 70 · raw

@s:String -> Bool

Whether s holds a CR or an LF.

def Text.onto source · line 79 · raw

@acc:String -> @tail:String -> String

acc reversed in front of tail: the last step of a tail-recursive builder (a non-tail recursion costs a frame per char in Bend).