comparison libpurple/util.c @ 29958:b06f69ada7a5

Add some comments that meant something to me at some point and might conceivably mean something to someone else in the future
author Stu Tomlinson <stu@nosnilmot.com>
date Mon, 17 May 2010 00:14:22 +0000
parents 5bac51b394e6
children 844181ded506
comparison
equal deleted inserted replaced
29957:39c1720db373 29958:b06f69ada7a5
1306 Also, remember to put braces in constructs that require them for 1306 Also, remember to put braces in constructs that require them for
1307 multiple statements when using this macro. */ 1307 multiple statements when using this macro. */
1308 #define ALLOW_TAG_ALT(x, y) if(!g_ascii_strncasecmp(c, "<" x " ", strlen("<" x " "))) { \ 1308 #define ALLOW_TAG_ALT(x, y) if(!g_ascii_strncasecmp(c, "<" x " ", strlen("<" x " "))) { \
1309 const char *o = c + strlen("<" x); \ 1309 const char *o = c + strlen("<" x); \
1310 const char *p = NULL, *q = NULL, *r = NULL; \ 1310 const char *p = NULL, *q = NULL, *r = NULL; \
1311 /* o = iterating over full tag \
1312 * p = > (end of tag) \
1313 * q = start of quoted bit \
1314 * r = < inside tag \
1315 */ \
1311 GString *innards = g_string_new(""); \ 1316 GString *innards = g_string_new(""); \
1312 while(o && *o) { \ 1317 while(o && *o) { \
1313 if(!q && (*o == '\"' || *o == '\'') ) { \ 1318 if(!q && (*o == '\"' || *o == '\'') ) { \
1314 q = o; \ 1319 q = o; \
1315 } else if(q) { \ 1320 } else if(q) { \
1316 if(*o == *q) { \ 1321 if(*o == *q) { /* end of quoted bit */ \
1317 char *unescaped = g_strndup(q+1, o-q-1); \ 1322 char *unescaped = g_strndup(q+1, o-q-1); \
1318 char *escaped = g_markup_escape_text(unescaped, -1); \ 1323 char *escaped = g_markup_escape_text(unescaped, -1); \
1319 g_string_append_printf(innards, "%c%s%c", *q, escaped, *q); \ 1324 g_string_append_printf(innards, "%c%s%c", *q, escaped, *q); \
1320 g_free(unescaped); \ 1325 g_free(unescaped); \
1321 g_free(escaped); \ 1326 g_free(escaped); \
1331 } else { \ 1336 } else { \
1332 innards = g_string_append_c(innards, *o); \ 1337 innards = g_string_append_c(innards, *o); \
1333 } \ 1338 } \
1334 o++; \ 1339 o++; \
1335 } \ 1340 } \
1336 if(p && !r) { \ 1341 if(p && !r) { /* got an end of tag and no other < earlier */\
1337 if(*(p-1) != '/') { \ 1342 if(*(p-1) != '/') { \
1338 struct purple_parse_tag *pt = g_new0(struct purple_parse_tag, 1); \ 1343 struct purple_parse_tag *pt = g_new0(struct purple_parse_tag, 1); \
1339 pt->src_tag = x; \ 1344 pt->src_tag = x; \
1340 pt->dest_tag = y; \ 1345 pt->dest_tag = y; \
1341 tags = g_list_prepend(tags, pt); \ 1346 tags = g_list_prepend(tags, pt); \
1344 xhtml = g_string_append(xhtml, "<" y); \ 1349 xhtml = g_string_append(xhtml, "<" y); \
1345 xhtml = g_string_append(xhtml, innards->str); \ 1350 xhtml = g_string_append(xhtml, innards->str); \
1346 xhtml = g_string_append_c(xhtml, '>'); \ 1351 xhtml = g_string_append_c(xhtml, '>'); \
1347 } \ 1352 } \
1348 c = p + 1; \ 1353 c = p + 1; \
1349 } else { \ 1354 } else { /* got end of tag with earlier < *or* didn't get anything */ \
1350 if(xhtml) \ 1355 if(xhtml) \
1351 xhtml = g_string_append(xhtml, "&lt;"); \ 1356 xhtml = g_string_append(xhtml, "&lt;"); \
1352 if(plain) \ 1357 if(plain) \
1353 plain = g_string_append_c(plain, '<'); \ 1358 plain = g_string_append_c(plain, '<'); \
1354 c++; \ 1359 c++; \