Lines Matching refs:f

123 bc_file_flushErr(BcFile* restrict f, BcFlushType type)
132 if (fflush(f->f) == EOF) s = BC_STATUS_ERROR_FATAL;
138 if (f->len)
147 if (f->buf[f->len - 1] != '\n' &&
154 for (i = f->len - 2; i < f->len && f->buf[i] != '\n'; --i)
162 bc_vec_string(&vm->history.extras, f->len - i, f->buf + i);
173 s = bc_file_output(f->fd, f->buf, f->len);
174 f->len = 0;
184 bc_file_flush(BcFile* restrict f, BcFlushType type)
191 s = bc_file_flushErr(f, type);
204 else if (!f->errors_fatal)
218 bc_file_write(BcFile* restrict f, BcFlushType type, const char* buf, size_t n)
225 if (n > f->cap - f->len)
227 bc_file_flush(f, type);
228 assert(!f->len);
233 if (BC_UNLIKELY(n > f->cap - f->len))
235 BcStatus s = bc_file_output(f->fd, buf, n);
247 else if (!f->errors_fatal)
258 memcpy(f->buf + f->len, buf, n);
259 f->len += n;
268 bc_file_printf(BcFile* restrict f, const char* fmt, ...)
276 bc_file_vprintf(f, fmt, args);
283 bc_file_vprintf(BcFile* restrict f, const char* fmt, va_list args)
296 r = vfprintf(f->f, fmt, args);
305 if (!f->errors_fatal)
338 bc_file_write(f, bc_flush_none, ptr, len);
349 bc_file_putchar(f, bc_flush_none, uc);
355 bc_file_puts(f, bc_flush_none, s);
366 bc_file_putchar(f, bc_flush_none, '-');
371 if (!d) bc_file_putchar(f, bc_flush_none, '0');
375 bc_file_puts(f, bc_flush_none, buf);
392 if (!ull) bc_file_putchar(f, bc_flush_none, '0');
396 bc_file_puts(f, bc_flush_none, buf);
406 if (ptr[0]) bc_file_puts(f, bc_flush_none, ptr);
413 bc_file_puts(BcFile* restrict f, BcFlushType type, const char* str)
419 bc_file_printf(f, "%s", str);
421 bc_file_write(f, type, str, strlen(str));
426 bc_file_putchar(BcFile* restrict f, BcFlushType type, uchar c)
434 if (BC_ERR(fputc(c, f->f) == EOF))
437 if (f->f == stderr) exit(BC_STATUS_ERROR_FATAL);
444 if (f->len == f->cap) bc_file_flush(f, type);
446 assert(f->len < f->cap);
448 f->buf[f->len] = (char) c;
449 f->len += 1;
459 bc_file_init(BcFile* f, FILE* file, bool errors_fatal)
462 f->f = file;
463 f->errors_fatal = errors_fatal;
469 bc_file_init(BcFile* f, int fd, char* buf, size_t cap, bool errors_fatal)
473 f->fd = fd;
474 f->buf = buf;
475 f->len = 0;
476 f->cap = cap;
477 f->errors_fatal = errors_fatal;
483 bc_file_free(BcFile* f)
486 bc_file_flush(f, bc_flush_none);