6 void strbuf_init(struct strbuf *sb) {
8 sb->eof = sb->alloc = sb->len = 0;
11 static void strbuf_begin(struct strbuf *sb) {
16 static void inline strbuf_add(struct strbuf *sb, int ch) {
17 if (sb->alloc <= sb->len) {
18 sb->alloc = sb->alloc * 3 / 2 + 16;
19 sb->buf = xrealloc(sb->buf, sb->alloc);
21 sb->buf[sb->len++] = ch;
24 static void strbuf_end(struct strbuf *sb) {
28 void read_line(struct strbuf *sb, FILE *fp, int term) {
35 while ((ch = fgetc(fp)) != EOF) {
40 if (ch == EOF && sb->len == 0)