From b018c01fad3b0c6dd9c180b3ba804baee326d9dd Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 25 Jul 2015 16:08:00 -0700 Subject: xml renderer - use sprintf to avoid strbuf_sprintf. --- src/xml.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/xml.c b/src/xml.c index 815afa5..2882f50 100644 --- a/src/xml.c +++ b/src/xml.c @@ -37,6 +37,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, bool literal = false; cmark_delim_type delim; bool entering = (ev_type == CMARK_EVENT_ENTER); + char buffer[100]; if (entering) { indent(state); @@ -44,11 +45,12 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, cmark_strbuf_puts(xml, cmark_node_get_type_string(node)); if (options & CMARK_OPT_SOURCEPOS && node->start_line != 0) { - cmark_strbuf_printf(xml, " sourcepos=\"%d:%d-%d:%d\"", - node->start_line, - node->start_column, - node->end_line, - node->end_column); + sprintf(buffer, " sourcepos=\"%d:%d-%d:%d\"", + node->start_line, + node->start_column, + node->end_line, + node->end_column); + cmark_strbuf_puts(xml, buffer); } literal = false; @@ -70,8 +72,9 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, switch (cmark_node_get_list_type(node)) { case CMARK_ORDERED_LIST: cmark_strbuf_puts(xml, " type=\"ordered\""); - cmark_strbuf_printf(xml, " start=\"%d\"", - cmark_node_get_list_start(node)); + sprintf(buffer," start=\"%d\"", + cmark_node_get_list_start(node)); + cmark_strbuf_puts(xml, buffer); delim = cmark_node_get_list_delim(node); if (delim == CMARK_PAREN_DELIM) { cmark_strbuf_puts(xml, @@ -87,13 +90,15 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, default: break; } - cmark_strbuf_printf(xml, " tight=\"%s\"", - (cmark_node_get_list_tight(node) ? - "true" : "false")); + sprintf(buffer, " tight=\"%s\"", + (cmark_node_get_list_tight(node) ? + "true" : "false")); + cmark_strbuf_puts(xml, buffer); break; case CMARK_NODE_HEADER: - cmark_strbuf_printf(xml, " level=\"%d\"", - node->as.header.level); + sprintf(buffer, " level=\"%d\"", + node->as.header.level); + cmark_strbuf_puts(xml, buffer); break; case CMARK_NODE_CODE_BLOCK: if (node->as.code.info.len > 0) { -- cgit v1.2.3