X-Git-Url: https://git.distorted.org.uk/~mdw/mLib/blobdiff_plain/18c831dcd0ae4d660c70ccac69d27ed2a97851be..a89dcc03c98d7659c53f30a4f0544fe2b424b458:/struct/dstr.h diff --git a/struct/dstr.h b/struct/dstr.h index 3ef3051..1c43cb7 100644 --- a/struct/dstr.h +++ b/struct/dstr.h @@ -56,6 +56,10 @@ # include "arena.h" #endif +#ifndef MLIB_MACROS_H +# include "macros.h" +#endif + /*----- Data structures ---------------------------------------------------*/ typedef struct dstr { @@ -141,19 +145,19 @@ extern void dstr_ensure(dstr */*d*/, size_t /*sz*/); /* --- @dstr_putc@ --- * * * Arguments: @dstr *d@ = pointer to a dynamic string block - * @char ch@ = character to append + * @int ch@ = character to append * * Returns: --- * * Use: Appends a character to a string. */ -extern void dstr_putc(dstr */*d*/, char /*ch*/); +extern void dstr_putc(dstr */*d*/, int /*ch*/); #define DPUTC(d, ch) do { \ dstr *_d = (d); \ DENSURE(_d, 1); \ - _d->buf[_d->len++] = (ch); \ + *((unsigned char *)_d->buf + _d->len++) = (ch); \ } while (0) /* --- @dstr_putz@ --- * @@ -225,7 +229,8 @@ extern int dstr_vputf(dstr */*d*/, const char */*p*/, va_list */*ap*/); * itself is malicious. */ -extern int dstr_putf(dstr */*d*/, const char */*p*/, ...); +extern int PRINTF_LIKE(2, 3) + dstr_putf(dstr */*d*/, const char */*p*/, ...); /* --- @dstr_putd@ --- * *