• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/doc_cmds-49/makewhatis/

Lines Matching refs:sbuf

80 struct sbuf {
87 * Removes the last amount characters from the sbuf.
89 #define sbuf_retract(sbuf, amount) \
90 ((sbuf)->end -= (amount))
92 * Returns the length of the sbuf content.
94 #define sbuf_length(sbuf) \
95 ((sbuf)->end - (sbuf)->content)
119 static struct sbuf *whatis_proto;
120 static struct sbuf *whatis_final;
199 * Reset an sbuf's length to 0.
202 sbuf_clear(struct sbuf *sbuf)
204 sbuf->end = sbuf->content;
208 * Allocate a new sbuf.
210 static struct sbuf *
213 struct sbuf *sbuf = (struct sbuf *) malloc(sizeof(struct sbuf));
214 sbuf->content = (char *) malloc(LINE_ALLOC);
215 sbuf->last = sbuf->content + LINE_ALLOC - 1;
216 sbuf_clear(sbuf);
217 return sbuf;
221 * Ensure that there is enough room in the sbuf for nchars more characters.
224 sbuf_need(struct sbuf *sbuf, int nchars)
230 while (sbuf->end + nchars > sbuf->last) {
231 size = sbuf->last + 1 - sbuf->content;
233 cntsize = sbuf->end - sbuf->content;
236 memcpy(new_content, sbuf->content, cntsize);
237 free(sbuf->content);
238 sbuf->content = new_content;
239 sbuf->end = new_content + cntsize;
240 sbuf->last = new_content + size - 1;
245 * Appends a string of a given length to the sbuf.
248 sbuf_append(struct sbuf *sbuf, const char *text, int length)
251 sbuf_need(sbuf, length);
252 memcpy(sbuf->end, text, length);
253 sbuf->end += length;
258 * Appends a null-terminated string to the sbuf.
261 sbuf_append_str(struct sbuf *sbuf, char *text)
263 sbuf_append(sbuf, text, strlen(text));
267 * Appends an edited null-terminated string to the sbuf.
270 sbuf_append_edited(struct sbuf *sbuf, char *text, edited_copy copy)
274 sbuf_need(sbuf, length);
275 sbuf->end = copy(text, sbuf->end, length);
280 * Strips any of a set of chars from the end of the sbuf.
283 sbuf_strip(struct sbuf *sbuf, const char *set)
285 while (sbuf->end > sbuf->content && strchr(set, sbuf->end[-1]) != NULL)
286 sbuf->end--;
290 * Returns the null-terminated string built by the sbuf.
293 sbuf_content(struct sbuf *sbuf)
295 *sbuf->end = '\0';
296 return sbuf->content;