};
/** Tie a fastbuf to a resource in the current resource pool. Returns the pointer to the same fastbuf. **/
-struct fastbuf *fb_tie(struct fastbuf *b);
+struct fastbuf *fb_tie(struct fastbuf *b); /* Tie fastbuf to a resource if there is an active pool */
/***
* === Fastbuf on files [[fbparam]]
* Use @params to select the fastbuf back-end and its parameters or
* pass NULL if you are fine with defaults.
*
- * Dies if the file does not exist.
+ * Raises `ucw.fb.open` if the file does not exist.
**/
struct fastbuf *bopen_file(const char *name, int mode, struct fb_params *params);
struct fastbuf *bopen_file_try(const char *name, int mode, struct fb_params *params); /** Like bopen_file(), but returns NULL on failure. **/
/**
* Creates a write-only fastbuf which writes into a provided memory buffer.
* The fastbuf structure is allocated by the caller and pointed to by @f.
- * An attempt to write behind the end of the buffer dies.
+ * An attempt to write behind the end of the buffer causes the `ucw.fb.write` exception.
*
* Data are written directly into the buffer, so it is not necessary to call @bflush()
* at any moment.
/**
* Reads exactly @l bytes of data into @b.
* If at the end of file, it returns 0.
- * If there are data, but less than @l, it dies.
+ * If there are data, but less than @l, it raises `ucw.fb.eof`.
*/
static inline uns breadb(struct fastbuf *f, void *b, uns l)
{
/**
* Reads a line into @b and strips trailing `\n`.
* Returns pointer to the terminating 0 or NULL on `EOF`.
- * Dies if the line is longer than @l.
+ * Raises `ucw.fb.toolong` if the line is longer than @l.
**/
char *bgets(struct fastbuf *f, char *b, uns l);
char *bgets0(struct fastbuf *f, char *b, uns l); /** The same as @bgets(), but for 0-terminated strings. **/
struct bb_t;
/**
* Read a string, strip the trailing `\n` and store it into growing buffer @b.
- * Dies if the line is longer than @limit.
+ * Raises `ucw.fb.toolong` if the line is longer than @limit.
**/
uns bgets_bb(struct fastbuf *f, struct bb_t *b, uns limit);
/**
*b++ = v;
}
if (unlikely(cnt == l))
- die("%s: Line too long", f->name);
+ bthrow(f, "toolong", "%s: Line too long", f->name);
l -= cnt;
bdirect_read_commit(f, src);
src_len = bdirect_read_prepare(f, &src);
if (cnt == buf_len)
{
if (unlikely(len == limit))
- die("%s: Line too long", f->name);
+ bthrow(f, "toolong", "%s: Line too long", f->name);
bb_do_grow(bb, len + 1);
buf = bb->ptr + len;
buf_len = MIN(bb->len, limit) - len;
b++;
}
if (unlikely(cnt == l))
- die("%s: Line too long", f->name);
+ bthrow(f, "toolong", "%s: Line too long", f->name);
l -= cnt;
bdirect_read_commit(f, src);
src_len = bdirect_read_prepare(f, &src);