From 7382fd5eba48107a8190bd2d6232cc3b6e20d8fc Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 7 Jun 2015 16:52:44 +0200 Subject: Convert code base to strbuf_t There are probably a couple of places I missed. But this will only be a problem if we use a 64-bit bufsize_t at some point. Then, we'll get warnings from -Wshorten-64-to-32. --- src/html.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/html.c') diff --git a/src/html.c b/src/html.c index d3f9fc7..317eb45 100644 --- a/src/html.c +++ b/src/html.c @@ -11,20 +11,20 @@ // Functions to convert cmark_nodes to HTML strings. -static void escape_html(cmark_strbuf *dest, const unsigned char *source, int length) +static void escape_html(cmark_strbuf *dest, const unsigned char *source, bufsize_t length) { if (length < 0) length = strlen((char *)source); - houdini_escape_html0(dest, source, (size_t)length, 0); + houdini_escape_html0(dest, source, length, 0); } -static void escape_href(cmark_strbuf *dest, const unsigned char *source, int length) +static void escape_href(cmark_strbuf *dest, const unsigned char *source, bufsize_t length) { if (length < 0) length = strlen((char *)source); - houdini_escape_href(dest, source, (size_t)length); + houdini_escape_href(dest, source, length); } static inline void cr(cmark_strbuf *html) @@ -165,7 +165,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, S_render_sourcepos(node, html, options); cmark_strbuf_puts(html, ">"); } else { - int first_tag = 0; + bufsize_t first_tag = 0; while (first_tag < node->as.code.info.len && node->as.code.info.data[first_tag] != ' ') { first_tag += 1; -- cgit v1.2.3 From 9087645812433abdc51eb7bb82ade8c3c3bccfa5 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 7 Jun 2015 17:34:34 +0200 Subject: Avoid strlen in html.c --- src/html.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'src/html.c') diff --git a/src/html.c b/src/html.c index 317eb45..a30bbca 100644 --- a/src/html.c +++ b/src/html.c @@ -13,20 +13,9 @@ static void escape_html(cmark_strbuf *dest, const unsigned char *source, bufsize_t length) { - if (length < 0) - length = strlen((char *)source); - houdini_escape_html0(dest, source, length, 0); } -static void escape_href(cmark_strbuf *dest, const unsigned char *source, bufsize_t length) -{ - if (length < 0) - length = strlen((char *)source); - - houdini_escape_href(dest, source, length); -} - static inline void cr(cmark_strbuf *html) { if (html->size && html->ptr[html->size - 1] != '\n') @@ -261,8 +250,8 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, case CMARK_NODE_LINK: if (entering) { cmark_strbuf_puts(html, "as.link.url.data, - node->as.link.url.len); + houdini_escape_href(html, node->as.link.url.data, + node->as.link.url.len); if (node->as.link.title.len) { cmark_strbuf_puts(html, "\" title=\""); @@ -279,8 +268,8 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, case CMARK_NODE_IMAGE: if (entering) { cmark_strbuf_puts(html, "as.link.url.data, - node->as.link.url.len); + houdini_escape_href(html, node->as.link.url.data, + node->as.link.url.len); cmark_strbuf_puts(html, "\" alt=\""); state->plain = node; -- cgit v1.2.3