X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=support%2FUtil%2Fdbuf_string.h;h=53187d79a4615d2c7d69623a0b9b4a73fd25dc30;hb=5cf049a9aca9a6693200563f5debc4d15f3ad21f;hp=8c4d78bb801a7fb06688bf6160201a37b50c8df5;hpb=4c527a8dc0a11d9bb33bebfe2fafa42e34b2895b;p=fw%2Fsdcc diff --git a/support/Util/dbuf_string.h b/support/Util/dbuf_string.h index 8c4d78bb..53187d79 100644 --- a/support/Util/dbuf_string.h +++ b/support/Util/dbuf_string.h @@ -1,6 +1,6 @@ /* dbuf_string.h - Append formatted string to the dynamic buffer - version 1.0.0, January 6th, 2007 + version 1.1.0, December 29th, 2007 Copyright (c) 2002-2007 Borut Razem @@ -27,6 +27,25 @@ #include #include "dbuf.h" +/* Attribute `nonnull' was valid as of gcc 3.3. */ +#ifndef ATTRIBUTE_NONNULL +# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) +# define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m))) +# else +# define ATTRIBUTE_NONNULL(m) +# endif /* GNUC >= 3.3 */ +#endif /* ATTRIBUTE_NONNULL */ + +/* The __-protected variants of `format' and `printf' attributes + are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ +#ifndef ATTRIBUTE_PRINTF +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m) +#else +# define ATTRIBUTE_PRINTF(m, n) +# endif /* GNUC >= 2.7 */ +#endif /* ATTRIBUTE_PRINTF */ + #ifdef __cplusplus extern "C" { #endif @@ -34,7 +53,8 @@ extern "C" { int dbuf_append_str(struct dbuf_s *dbuf, const char *str); int dbuf_append_char(struct dbuf_s *dbuf, char chr); int dbuf_vprintf(struct dbuf_s *dbuf, const char *format, va_list args); -int dbuf_printf (struct dbuf_s *dbuf, const char *format, ...); +int dbuf_printf (struct dbuf_s *dbuf, const char *format, ...) ATTRIBUTE_PRINTF(2, 3); +size_t dbuf_getline(struct dbuf_s *dbuf, FILE *infp); void dbuf_write (struct dbuf_s *dbuf, FILE *dest); void dbuf_write_and_destroy (struct dbuf_s *dbuf, FILE *dest);