Mercurial > pidgin.yaz
comparison libpurple/util.c @ 27697: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 |
comparison
equal
deleted
inserted
replaced
27696:c800bdb5ebbc | 27697:d1b882345f5b |
---|---|
1407 char *src_tag; | 1407 char *src_tag; |
1408 char *dest_tag; | 1408 char *dest_tag; |
1409 gboolean ignore; | 1409 gboolean ignore; |
1410 }; | 1410 }; |
1411 | 1411 |
1412 #define ALLOW_TAG_ALT(x, y) if(!g_ascii_strncasecmp(c, "<" x " ", strlen("<" x " "))) { \ | 1412 #define ALLOW_TAG_ALT(x, y) do { \ |
1413 if(!g_ascii_strncasecmp(c, "<" x " ", strlen("<" x " "))) { \ | |
1413 const char *o = c + strlen("<" x); \ | 1414 const char *o = c + strlen("<" x); \ |
1414 const char *p = NULL, *q = NULL, *r = NULL; \ | 1415 const char *p = NULL, *q = NULL, *r = NULL; \ |
1415 GString *innards = g_string_new(""); \ | 1416 GString *innards = g_string_new(""); \ |
1416 while(o && *o) { \ | 1417 while(o && *o) { \ |
1417 if(!q && (*o == '\"' || *o == '\'') ) { \ | 1418 if(!q && (*o == '\"' || *o == '\'') ) { \ |
1478 xhtml = g_string_append(xhtml, "/>");\ | 1479 xhtml = g_string_append(xhtml, "/>");\ |
1479 } \ | 1480 } \ |
1480 c = strchr(c, '>') + 1; \ | 1481 c = strchr(c, '>') + 1; \ |
1481 continue; \ | 1482 continue; \ |
1482 } \ | 1483 } \ |
1484 } while (0); | |
1483 #define ALLOW_TAG(x) ALLOW_TAG_ALT(x, x) | 1485 #define ALLOW_TAG(x) ALLOW_TAG_ALT(x, x) |
1484 void | 1486 void |
1485 purple_markup_html_to_xhtml(const char *html, char **xhtml_out, | 1487 purple_markup_html_to_xhtml(const char *html, char **xhtml_out, |
1486 char **plain_out) | 1488 char **plain_out) |
1487 { | 1489 { |
1570 ALLOW_TAG("h3"); | 1572 ALLOW_TAG("h3"); |
1571 ALLOW_TAG("h4"); | 1573 ALLOW_TAG("h4"); |
1572 ALLOW_TAG("h5"); | 1574 ALLOW_TAG("h5"); |
1573 ALLOW_TAG("h6"); | 1575 ALLOW_TAG("h6"); |
1574 /* we only allow html to start the message */ | 1576 /* we only allow html to start the message */ |
1575 if(c == html) { | 1577 if(c == html) |
1576 ALLOW_TAG("html"); | 1578 ALLOW_TAG("html"); |
1577 } | |
1578 ALLOW_TAG_ALT("i", "em"); | 1579 ALLOW_TAG_ALT("i", "em"); |
1579 ALLOW_TAG_ALT("italic", "em"); | 1580 ALLOW_TAG_ALT("italic", "em"); |
1580 ALLOW_TAG("li"); | 1581 ALLOW_TAG("li"); |
1581 ALLOW_TAG("ol"); | 1582 ALLOW_TAG("ol"); |
1582 ALLOW_TAG("p"); | 1583 ALLOW_TAG("p"); |