@@@ so much mess
[mLib] / struct / dstr.h
index 3ef3051..fedc48c 100644 (file)
@@ -47,6 +47,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #ifndef MLIB_ALLOC_H
 #  include "alloc.h"
 #  include "arena.h"
 #endif
 
+#ifndef MLIB_MACROS_H
+#  include "macros.h"
+#endif
+
 /*----- Data structures ---------------------------------------------------*/
 
 typedef struct dstr {
@@ -67,6 +72,8 @@ typedef struct dstr {
 
 #define DSTR_INIT { 0, 0, 0, &arena_stdlib } /* How to initialize one */
 
+extern const struct gprintf_ops dstr_printops;
+
 /*----- Functions provided ------------------------------------------------*/
 
 /* --- @dstr_create@ --- *
@@ -141,19 +148,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 +232,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@ --- *
  *