[PATCH v2 21/22] html: add html_attrf to output an attribute value from a format string

John Keeping john at keeping.me.uk
Sun Apr 7 16:26:50 CEST 2013


Signed-off-by: John Keeping <john at keeping.me.uk>
---
 html.c | 13 +++++++++++++
 html.h |  3 +++
 2 files changed, 16 insertions(+)

diff --git a/html.c b/html.c
index cac1ed3..f7772dc 100644
--- a/html.c
+++ b/html.c
@@ -170,6 +170,19 @@ void html_ntxt(int len, const char *txt)
 		html("...");
 }
 
+void html_attrf(const char *fmt, ...)
+{
+	va_list ap;
+	struct strbuf sb = STRBUF_INIT;
+
+	va_start(ap, fmt);
+	strbuf_vaddf(&sb, fmt, ap);
+	va_end(ap);
+
+	html_attr(sb.buf);
+	strbuf_release(&sb);
+}
+
 void html_attr(const char *txt)
 {
 	const char *t = txt;
diff --git a/html.h b/html.h
index 6886a46..be3b311 100644
--- a/html.h
+++ b/html.h
@@ -15,6 +15,9 @@ extern void html_txtf(const char *format,...);
 __attribute__((format (printf,1,0)))
 extern void html_vtxtf(const char *format, va_list ap);
 
+__attribute__((format (printf,1,2)))
+extern void html_attrf(const char *format,...);
+
 extern void html_status(int code, const char *msg, int more_headers);
 extern void html_txt(const char *txt);
 extern void html_ntxt(int len, const char *txt);
-- 
1.8.2.692.g17a9715





More information about the CGit mailing list