6 quote() encodes a box as per rfc 821 and rfc 822,
7 while trying to do as little quoting as possible.
8 no, 821 and 822 don't have the same encoding. they're not even close.
9 no special encoding here for bytes above 127.
12 static char ok[128] = {
13 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
14 ,0,7,0,7,7,7,7,7,0,0,7,7,0,7,7,7 ,7,7,7,7,7,7,7,7,7,7,0,0,0,7,0,7
15 ,0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 ,7,7,7,7,7,7,7,7,7,7,7,0,0,0,7,7
16 ,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 ,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0
19 static int doit(saout,sain)
27 if (!stralloc_ready(saout,sain->len * 2 + 2)) return 0;
30 for (i = 0;i < sain->len;++i)
33 if ((ch == '\r') || (ch == '\n') || (ch == '"') || (ch == '\\'))
52 if (uch >= 128) return 1;
53 if (!ok[uch]) return 1;
55 if (s[0] == '.') return 1;
56 if (s[n - 1] == '.') return 1;
57 for (i = 0;i < n - 1;++i) if (s[i] == '.') if (s[i + 1] == '.') return 1;
65 if (quote_need(sain->s,sain->len)) return doit(saout,sain);
66 return stralloc_copy(saout,sain);
69 static stralloc foo = {0};
77 if (!stralloc_copys(&foo,s)) return 0;
78 if (!s[j]) return quote(sa,&foo);
80 if (!quote(sa,&foo)) return 0;
81 return stralloc_cats(sa,s + j);