changeset 27621:d1b882345f5b

Surround this macro in do { } while (0); so that callers don't need to remember that it needs to be surrounded in braces. I think the do-while isn't strictly necessary, as I think you can have braces where ever you want, but everytime I see someone else use this technique they always have the do-while
author Mark Doliner <mark@kingant.net>
date Sun, 19 Jul 2009 16:31:32 +0000
parents c800bdb5ebbc
children 3edd01d04004 2cd9560f9795
files libpurple/util.c
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/util.c	Sun Jul 19 16:28:32 2009 +0000
+++ b/libpurple/util.c	Sun Jul 19 16:31:32 2009 +0000
@@ -1409,7 +1409,8 @@
 	gboolean ignore;
 };
 
-#define ALLOW_TAG_ALT(x, y) if(!g_ascii_strncasecmp(c, "<" x " ", strlen("<" x " "))) { \
+#define ALLOW_TAG_ALT(x, y) do { \
+					if(!g_ascii_strncasecmp(c, "<" x " ", strlen("<" x " "))) { \
 						const char *o = c + strlen("<" x); \
 						const char *p = NULL, *q = NULL, *r = NULL; \
 						GString *innards = g_string_new(""); \
@@ -1480,6 +1481,7 @@
 						c = strchr(c, '>') + 1; \
 						continue; \
 					} \
+				} while (0);
 #define ALLOW_TAG(x) ALLOW_TAG_ALT(x, x)
 void
 purple_markup_html_to_xhtml(const char *html, char **xhtml_out,
@@ -1572,9 +1574,8 @@
 				ALLOW_TAG("h5");
 				ALLOW_TAG("h6");
 				/* we only allow html to start the message */
-				if(c == html) {
+				if(c == html)
 					ALLOW_TAG("html");
-				}
 				ALLOW_TAG_ALT("i", "em");
 				ALLOW_TAG_ALT("italic", "em");
 				ALLOW_TAG("li");