cmark

My personal build of CMark ✏️

Commit
b018c01fad3b0c6dd9c180b3ba804baee326d9dd
Parent
20ffc3898f02964356e05bb0063904c363e9582d
Author
John MacFarlane <jgm@berkeley.edu>
Date

xml renderer - use sprintf to avoid strbuf_sprintf.

Diffstat

1 file changed, 17 insertions, 12 deletions

Status File Name N° Changes Insertions Deletions
Modified src/xml.c 29 17 12
diff --git 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) {