summaryrefslogtreecommitdiff
path: root/src/commonmark.c
diff options
context:
space:
mode:
authorKamil Rytarowski <n54@gmx.com>2016-02-28 03:53:49 +0100
committerKamil Rytarowski <n54@gmx.com>2016-02-28 03:54:51 +0100
commit677309d11172f59044672edf112ad3a5f2eacc21 (patch)
tree46cdadf7312cc592be9ee970c6905acffee913f4 /src/commonmark.c
parente8d40d6e873f4a85696fac5da81eb9dbe7d1bc6c (diff)
Fix ctype(3) usage on NetBSD
We need to cast value passed to isspace(3) to unsigned char to explicitly prevent possibly undefined behavior. /tmp/pkgsrc-tmp/wip/cmark/work/cmark-0.24.1/src/commonmark.c: In function 'S_render_node': /tmp/pkgsrc-tmp/wip/cmark/work/cmark-0.24.1/src/commonmark.c:273:9: warning: array subscript has type 'char' [-Wchar-subscripts] (code_len > 2 && !isspace(code[0]) && ^ /tmp/pkgsrc-tmp/wip/cmark/work/cmark-0.24.1/src/commonmark.c:274:10: warning: array subscript has type 'char' [-Wchar-subscripts] !(isspace(code[code_len - 1]) && isspace(code[code_len - 2]))) && ^ /tmp/pkgsrc-tmp/wip/cmark/work/cmark-0.24.1/src/commonmark.c:274:10: warning: array subscript has type 'char' [-Wchar-subscripts] CTYPE(3) Library Functions Manual CTYPE(3) NAME isalpha, isupper, islower, isdigit, isxdigit, isalnum, isspace, ispunct, isprint, isgraph, iscntrl, isblank, toupper, tolower, - character classification and mapping functions LIBRARY Standard C Library (libc, -lc) CAVEATS The first argument of these functions is of type int, but only a very restricted subset of values are actually valid. The argument must either be the value of the macro EOF (which has a negative value), or must be a non-negative value within the range representable as unsigned char. Passing invalid values leads to undefined behavior. NetBSD 7.99 February 25, 2015 NetBSD 7.99
Diffstat (limited to 'src/commonmark.c')
-rw-r--r--src/commonmark.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/commonmark.c b/src/commonmark.c
index 60b745c..0667519 100644
--- a/src/commonmark.c
+++ b/src/commonmark.c
@@ -273,8 +273,8 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
// begin or end with a blank line, and code isn't
// first thing in a list item
if (info_len == 0 &&
- (code_len > 2 && !isspace(code[0]) &&
- !(isspace(code[code_len - 1]) && isspace(code[code_len - 2]))) &&
+ (code_len > 2 && !isspace((unsigned char)code[0]) &&
+ !(isspace((unsigned char)code[code_len - 1]) && isspace((unsigned char)code[code_len - 2]))) &&
!(node->prev == NULL && node->parent &&
node->parent->type == CMARK_NODE_ITEM)) {
LIT(" ");