changeset 131:cbfad4fb80c8

Buf: remove buf_puts and add printf format
author David Demelier <markand@malikania.fr>
date Sun, 11 Mar 2012 23:37:57 +0100
parents 1513cf3a985e
children bdd511d1a556
files buf.c buf.h
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/buf.c	Fri Mar 09 19:31:51 2012 +0100
+++ b/buf.c	Sun Mar 11 23:37:57 2012 +0100
@@ -158,7 +158,7 @@
 int
 buf_puts(struct buf *buf, const char *str)
 {
-	return buf_printf(buf, "%s", str);
+	return buf_cat(buf, str);
 }
 
 /*
--- a/buf.h	Fri Mar 09 19:31:51 2012 +0100
+++ b/buf.h	Sun Mar 11 23:37:57 2012 +0100
@@ -29,6 +29,12 @@
 #define BUF_DEFAULT_BSIZE	128
 #endif
 
+#ifdef __GNUC__
+#  define _buf_at_printf(i1, i2)	__attribute__ ((format (printf, i1, i2)))
+#else
+#  define _buf_at_printf(i1, i2)
+#endif
+
 enum {
 	BUF_AUTO	= 0,		/* string grows automatically */
 	BUF_FIXED	= (1 << 0),	/* fixed size string */
@@ -52,9 +58,8 @@
 int	buf_ncat(struct buf *, const char *, size_t);
 int	buf_copy(struct buf *, const char *);
 int	buf_vprintf(struct buf *, const char *, va_list);
-int	buf_printf(struct buf *, const char *, ...);
+int	buf_printf(struct buf *, const char *, ...) _buf_at_printf(2, 3);
 int	buf_putc(struct buf *, int);
-int	buf_puts(struct buf *, const char *);
 void	buf_clear(struct buf *);
 void	buf_free(struct buf *);