Lines Matching refs:sbuf

61 struct sbuf {  struct
68 #define sbuf_retract(sbuf, amount) ((sbuf)->end -= (amount)) argument
70 #define sbuf_length(sbuf) ((sbuf)->end - (sbuf)->content) argument
79 static struct sbuf *whatis_proto;
80 static struct sbuf *whatis_final;
147 sbuf_clear(struct sbuf *sbuf) in sbuf_clear() argument
150 sbuf->end = sbuf->content; in sbuf_clear()
156 static struct sbuf *
159 struct sbuf *sbuf; in new_sbuf() local
161 if ((sbuf = malloc(sizeof (struct sbuf))) == NULL) in new_sbuf()
163 if ((sbuf->content = (char *)malloc(LINE_ALLOC)) == NULL) in new_sbuf()
165 sbuf->last = sbuf->content + LINE_ALLOC - 1; in new_sbuf()
166 sbuf_clear(sbuf); in new_sbuf()
168 return (sbuf); in new_sbuf()
176 sbuf_need(struct sbuf *sbuf, int nchars) in sbuf_need() argument
187 if (sbuf->end + nchars > sbuf->last) { in sbuf_need()
188 size = sbuf->last + 1 - sbuf->content; in sbuf_need()
190 cntsize = sbuf->end - sbuf->content; in sbuf_need()
192 if ((new_content = realloc(sbuf->content, size)) == NULL) { in sbuf_need()
198 sbuf->content = new_content; in sbuf_need()
199 sbuf->end = new_content + cntsize; in sbuf_need()
200 sbuf->last = new_content + size - 1; in sbuf_need()
208 sbuf_append(struct sbuf *sbuf, const char *text, int length) in sbuf_append() argument
211 sbuf_need(sbuf, length); in sbuf_append()
212 (void) memcpy(sbuf->end, text, length); in sbuf_append()
213 sbuf->end += length; in sbuf_append()
221 sbuf_append_str(struct sbuf *sbuf, char *text) in sbuf_append_str() argument
224 sbuf_append(sbuf, text, strlen(text)); in sbuf_append_str()
231 sbuf_append_edited(struct sbuf *sbuf, char *text, edited_copy copy) in sbuf_append_edited() argument
236 sbuf_need(sbuf, length); in sbuf_append_edited()
237 sbuf->end = copy(text, sbuf->end, length); in sbuf_append_edited()
245 sbuf_strip(struct sbuf *sbuf, const char *set) in sbuf_strip() argument
248 while (sbuf->end > sbuf->content && strchr(set, sbuf->end[-1]) != NULL) in sbuf_strip()
249 sbuf->end--; in sbuf_strip()
256 sbuf_content(struct sbuf *sbuf) in sbuf_content() argument
259 *sbuf->end = '\0'; in sbuf_content()
260 return (sbuf->content); in sbuf_content()