• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/gnutar-452/gnutar/lib/

Lines Matching defs:fs

62   argp_fmtstream_t fs;
64 fs = (struct argp_fmtstream *) malloc (sizeof (struct argp_fmtstream));
65 if (fs != NULL)
67 fs->stream = stream;
69 fs->lmargin = lmargin;
70 fs->rmargin = rmargin;
71 fs->wmargin = wmargin;
72 fs->point_col = 0;
73 fs->point_offs = 0;
75 fs->buf = (char *) malloc (INIT_BUF_SIZE);
76 if (! fs->buf)
78 free (fs);
79 fs = 0;
83 fs->p = fs->buf;
84 fs->end = fs->buf + INIT_BUF_SIZE;
88 return fs;
99 __argp_fmtstream_free (argp_fmtstream_t fs)
101 __argp_fmtstream_update (fs);
102 if (fs->p > fs->buf)
105 __fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf);
107 fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
110 free (fs->buf);
111 free (fs);
124 __argp_fmtstream_update (argp_fmtstream_t fs)
130 buf = fs->buf + fs->point_offs;
131 while (buf < fs->p)
135 if (fs->point_col == 0 && fs->lmargin != 0)
138 const size_t pad = fs->lmargin;
139 if (fs->p + pad < fs->end)
143 memmove (buf + pad, buf, fs->p - buf);
144 fs->p += pad; /* Compensate for bigger buffer. */
155 if (_IO_fwide (fs->stream, 0) > 0)
156 putwc_unlocked (L' ', fs->stream);
159 putc_unlocked (' ', fs->stream);
162 fs->point_col = pad;
165 len = fs->p - buf;
168 if (fs->point_col < 0)
169 fs->point_col = 0;
175 if (fs->point_col + len < fs->rmargin)
180 fs->point_col += len;
186 nl = fs->p;
188 else if (fs->point_col + (nl - buf) < (ssize_t) fs->rmargin)
192 fs->point_col = 0;
198 r = fs->rmargin - 1;
200 if (fs->wmargin < 0)
204 if (nl < fs->p)
206 memmove (buf + (r - fs->point_col), nl, fs->p - nl);
207 fs->p -= buf + (r - fs->point_col) - nl;
209 fs->point_col = 0;
217 fs->point_col += len;
218 fs->p -= fs->point_col - r;
231 p = buf + (r + 1 - fs->point_col);
249 p = buf + (r + 1 - fs->point_col);
258 fs->point_col = 0;
278 ? fs->end - nl < fs->wmargin + 1
279 : nextline - (nl + 1) < fs->wmargin)
280 && fs->p > nextline)
283 if (fs->end - fs->p > fs->wmargin + 1)
286 size_t mv = fs->p - nextline;
287 memmove (nl + 1 + fs->wmargin, nextline, mv);
288 nextline = nl + 1 + fs->wmargin;
296 __fxprintf (fs->stream, "%.*s\n",
297 (int) (nl - fs->buf), fs->buf);
299 if (nl > fs->buf)
300 fwrite_unlocked (fs->buf, 1, nl - fs->buf, fs->stream);
301 putc_unlocked ('\n', fs->stream);
304 len += buf - fs->buf;
305 nl = buf = fs->buf;
313 if (nextline - nl >= fs->wmargin
314 || (nextline == buf + len + 1 && fs->end - nextline >= fs->wmargin))
316 for (i = 0; i < fs->wmargin; ++i)
319 for (i = 0; i < fs->wmargin; ++i)
321 if (_IO_fwide (fs->stream, 0) > 0)
322 putwc_unlocked (L' ', fs->stream);
325 putc_unlocked (' ', fs->stream);
337 fs->p = nl + len;
342 fs->point_col = fs->wmargin ? fs->wmargin : -1;
347 fs->point_offs = fs->p - fs->buf;
354 __argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
356 if ((size_t) (fs->end - fs->p) < amount)
361 __argp_fmtstream_update (fs);
364 __fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf);
365 wrote = fs->p - fs->buf;
367 wrote = fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
369 if (wrote == fs->p - fs->buf)
371 fs->p = fs->buf;
372 fs->point_offs = 0;
376 fs->p -= wrote;
377 fs->point_offs -= wrote;
378 memmove (fs->buf, fs->buf + wrote, fs->p - fs->buf);
382 if ((size_t) (fs->end - fs->buf) < amount)
385 size_t old_size = fs->end - fs->buf;
389 if (new_size < old_size || ! (new_buf = realloc (fs->buf, new_size)))
395 fs->buf = new_buf;
396 fs->end = new_buf + new_size;
397 fs->p = fs->buf;
406 __argp_fmtstream_printf (struct argp_fmtstream *fs, const char *fmt, ...)
416 if (! __argp_fmtstream_ensure (fs, size_guess))
420 avail = fs->end - fs->p;
421 out = __vsnprintf (fs->p, avail, fmt, args);
428 fs->p += out;