diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-01-18 09:26:14 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2016-01-18 09:26:14 -0800 |
commit | 7e1f8b8e49ca291a7757c55a8e02fc7a85d1434c (patch) | |
tree | 1c777b0fd81cb44d2dc50a95c915491b04bf6670 /src/xml.c | |
parent | ac812214f6fa81b201b8fcf3779ed8d2c3cfacf7 (diff) | |
parent | 0b5a8193fdc7b041023e44149a1d63b95ce98bfd (diff) |
Merge branch 'master' of https://github.com/mbenelli/cmark into mbenelli-master
Diffstat (limited to 'src/xml.c')
-rw-r--r-- | src/xml.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -34,7 +34,8 @@ static int 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]; + const size_t BUFFER_SIZE = 100; + char buffer[BUFFER_SIZE]; if (entering) { indent(state); @@ -42,8 +43,9 @@ static int 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) { - sprintf(buffer, " sourcepos=\"%d:%d-%d:%d\"", node->start_line, - node->start_column, node->end_line, node->end_column); + snprintf(buffer, BUFFER_SIZE, " sourcepos=\"%d:%d-%d:%d\"", + node->start_line, node->start_column, node->end_line, + node->end_column); cmark_strbuf_puts(xml, buffer); } @@ -67,7 +69,8 @@ static int 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\""); - sprintf(buffer, " start=\"%d\"", cmark_node_get_list_start(node)); + snprintf(buffer, BUFFER_SIZE, " 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) { @@ -82,12 +85,12 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, default: break; } - sprintf(buffer, " tight=\"%s\"", - (cmark_node_get_list_tight(node) ? "true" : "false")); + snprintf(buffer, BUFFER_SIZE, " tight=\"%s\"", + (cmark_node_get_list_tight(node) ? "true" : "false")); cmark_strbuf_puts(xml, buffer); break; case CMARK_NODE_HEADING: - sprintf(buffer, " level=\"%d\"", node->as.heading.level); + snprintf(buffer, BUFFER_SIZE, " level=\"%d\"", node->as.heading.level); cmark_strbuf_puts(xml, buffer); break; case CMARK_NODE_CODE_BLOCK: |