X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fdriver.c;h=b9e4b785290d38f77cab652e26996b833a7217a7;hb=dbe1d88697fe0b37bc1cc5b0bcbacc2d3f26c1f1;hp=6e60258329469ed6303c62b63809703e988e62ce;hpb=e4a03dc0ca94ad2d9ca9b74b7ce16405b40b844f;p=pspp diff --git a/src/output/driver.c b/src/output/driver.c index 6e60258329..b9e4b78529 100644 --- a/src/output/driver.c +++ b/src/output/driver.c @@ -21,6 +21,8 @@ #include #include +#include +#include #include #include #include @@ -489,3 +491,24 @@ output_driver_parse_option (const char *option, struct string_map *options) char *value = xmemdup0 (equals + 1, strlen (equals + 1)); string_map_insert_nocopy (options, key, value); } + +/* Extracts the actual text content from the given Pango MARKUP and returns it + as as a malloc()'d string. */ +char * +output_get_text_from_markup (const char *markup) +{ + xmlDoc *doc = xmlReadMemory (markup, strlen (markup), "noname.xml", "UTF-8", + (XML_PARSE_NOERROR | XML_PARSE_NOWARNING + | XML_PARSE_NONET | XML_PARSE_NOCDATA)); + if (!doc) + return xstrdup (markup); + + char *content = CHAR_CAST (char *, + xmlNodeGetContent (xmlDocGetRootElement (doc))); + if (!content) + content = xstrdup (markup); + + xmlFreeDoc (doc); + + return content; +}