[FFmpeg-devel] [PATCH 4/5] ffprobe: switch from static function to av_xml_escape_str

Rodger Combs rodger.combs at gmail.com
Fri Jul 17 04:04:42 CEST 2015


---
 ffprobe.c | 25 +++----------------------
 1 file changed, 3 insertions(+), 22 deletions(-)

diff --git a/ffprobe.c b/ffprobe.c
index 3e5324e..cc7c9b9 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -1543,24 +1543,6 @@ static av_cold int xml_init(WriterContext *wctx)
     return 0;
 }
 
-static const char *xml_escape_str(AVBPrint *dst, const char *src, void *log_ctx)
-{
-    const char *p;
-
-    for (p = src; *p; p++) {
-        switch (*p) {
-        case '&' : av_bprintf(dst, "%s", "&");  break;
-        case '<' : av_bprintf(dst, "%s", "<");   break;
-        case '>' : av_bprintf(dst, "%s", ">");   break;
-        case '"' : av_bprintf(dst, "%s", """); break;
-        case '\'': av_bprintf(dst, "%s", "'"); break;
-        default: av_bprint_chars(dst, *p, 1);
-        }
-    }
-
-    return dst->str;
-}
-
 #define XML_INDENT() printf("%*c", xml->indent_level * 4, ' ')
 
 static void xml_print_section_header(WriterContext *wctx)
@@ -1633,13 +1615,12 @@ static void xml_print_str(WriterContext *wctx, const char *key, const char *valu
     if (section->flags & SECTION_FLAG_HAS_VARIABLE_FIELDS) {
         XML_INDENT();
         printf("<%s key=\"%s\"",
-               section->element_name, xml_escape_str(&buf, key, wctx));
-        av_bprint_clear(&buf);
-        printf(" value=\"%s\"/>\n", xml_escape_str(&buf, value, wctx));
+               section->element_name, av_xml_escape_str(&buf, key));
+        printf(" value=\"%s\"/>\n", av_xml_escape_str(&buf, value));
     } else {
         if (wctx->nb_item[wctx->level])
             printf(" ");
-        printf("%s=\"%s\"", key, xml_escape_str(&buf, value, wctx));
+        printf("%s=\"%s\"", key, av_xml_escape_str(&buf, value));
     }
 
     av_bprint_finalize(&buf, NULL);
-- 
2.4.1



More information about the ffmpeg-devel mailing list