summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-08-10 20:19:09 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-08-10 20:19:09 -0700
commit735098e097ad62bdc4b1121c6c0c983eb7483485 (patch)
treea858fedc30e6149ed430784942413a2b06741ec9 /src
parenta541e39f69cfa75422fbe70c59c2ac40fbdbe1d7 (diff)
parentce0e58469f7c4abf3f51bde6d3298215d6ef99d1 (diff)
Merge pull request #76 from kainjow/msvc-warnings
Fix some MSVC warnings
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rwxr-xr-xsrc/blocks.c2
-rw-r--r--src/buffer.c2
-rw-r--r--src/buffer.h6
-rw-r--r--src/chunk.h20
-rw-r--r--src/config.h.in8
-rw-r--r--src/html.c4
-rwxr-xr-xsrc/inlines.c6
-rw-r--r--src/iterator.c2
-rw-r--r--src/node.c4
-rwxr-xr-xsrc/utf8.c8
11 files changed, 36 insertions, 28 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 67d7b72..f619453 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -155,7 +155,7 @@ if(MSVC)
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
endif()
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127 /wd4244 /wd4267 /wd4706 /wd4800 /D_CRT_SECURE_NO_WARNINGS")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4706 /D_CRT_SECURE_NO_WARNINGS")
elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=c99 -pedantic")
endif()
diff --git a/src/blocks.c b/src/blocks.c
index 6d3053b..49ac273 100755
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -774,7 +774,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
container->as.code.fenced = true;
container->as.code.fence_char = peek_at(&input, parser->first_nonspace);
container->as.code.fence_length = matched;
- container->as.code.fence_offset = parser->first_nonspace - parser->offset;
+ container->as.code.fence_offset = (int8_t)(parser->first_nonspace - parser->offset);
container->as.code.info = cmark_chunk_literal("");
S_advance_offset(parser, &input,
parser->first_nonspace + matched - parser->offset,
diff --git a/src/buffer.c b/src/buffer.c
index 26dfb8e..a89c82e 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -133,7 +133,7 @@ void cmark_strbuf_sets(cmark_strbuf *buf, const char *string) {
void cmark_strbuf_putc(cmark_strbuf *buf, int c) {
S_strbuf_grow_by(buf, 1);
- buf->ptr[buf->size++] = c;
+ buf->ptr[buf->size++] = (unsigned char)(c & 0xFF);
buf->ptr[buf->size] = '\0';
}
diff --git a/src/buffer.h b/src/buffer.h
index e99db72..88b79f3 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -48,7 +48,7 @@ unsigned char *cmark_strbuf_detach(cmark_strbuf *buf);
void cmark_strbuf_copy_cstr(char *data, bufsize_t datasize,
const cmark_strbuf *buf);
-static inline const char *cmark_strbuf_cstr(const cmark_strbuf *buf) {
+CMARK_INLINE const char *cmark_strbuf_cstr(const cmark_strbuf *buf) {
return (char *)buf->ptr;
}
@@ -75,14 +75,14 @@ void cmark_strbuf_unescape(cmark_strbuf *s);
/* Print error and abort. */
void cmark_strbuf_overflow_err(void);
-static inline bufsize_t cmark_strbuf_check_bufsize(size_t size) {
+CMARK_INLINE bufsize_t cmark_strbuf_check_bufsize(size_t size) {
if (size > BUFSIZE_MAX) {
cmark_strbuf_overflow_err();
}
return (bufsize_t)size;
}
-static inline bufsize_t cmark_strbuf_safe_strlen(const char *str) {
+CMARK_INLINE bufsize_t cmark_strbuf_safe_strlen(const char *str) {
return cmark_strbuf_check_bufsize(strlen(str));
}
diff --git a/src/chunk.h b/src/chunk.h
index db1bf0d..90cf568 100644
--- a/src/chunk.h
+++ b/src/chunk.h
@@ -16,7 +16,7 @@ typedef struct {
bufsize_t alloc; // also implies a NULL-terminated string
} cmark_chunk;
-static inline void cmark_chunk_free(cmark_chunk *c) {
+CMARK_INLINE void cmark_chunk_free(cmark_chunk *c) {
if (c->alloc)
free(c->data);
@@ -25,7 +25,7 @@ static inline void cmark_chunk_free(cmark_chunk *c) {
c->len = 0;
}
-static inline void cmark_chunk_ltrim(cmark_chunk *c) {
+CMARK_INLINE void cmark_chunk_ltrim(cmark_chunk *c) {
assert(!c->alloc);
while (c->len && cmark_isspace(c->data[0])) {
@@ -34,7 +34,7 @@ static inline void cmark_chunk_ltrim(cmark_chunk *c) {
}
}
-static inline void cmark_chunk_rtrim(cmark_chunk *c) {
+CMARK_INLINE void cmark_chunk_rtrim(cmark_chunk *c) {
while (c->len > 0) {
if (!cmark_isspace(c->data[c->len - 1]))
break;
@@ -43,19 +43,19 @@ static inline void cmark_chunk_rtrim(cmark_chunk *c) {
}
}
-static inline void cmark_chunk_trim(cmark_chunk *c) {
+CMARK_INLINE void cmark_chunk_trim(cmark_chunk *c) {
cmark_chunk_ltrim(c);
cmark_chunk_rtrim(c);
}
-static inline bufsize_t cmark_chunk_strchr(cmark_chunk *ch, int c,
+CMARK_INLINE bufsize_t cmark_chunk_strchr(cmark_chunk *ch, int c,
bufsize_t offset) {
const unsigned char *p =
(unsigned char *)memchr(ch->data + offset, c, ch->len - offset);
return p ? (bufsize_t)(p - ch->data) : ch->len;
}
-static inline const char *cmark_chunk_to_cstr(cmark_chunk *c) {
+CMARK_INLINE const char *cmark_chunk_to_cstr(cmark_chunk *c) {
unsigned char *str;
if (c->alloc) {
@@ -74,7 +74,7 @@ static inline const char *cmark_chunk_to_cstr(cmark_chunk *c) {
return (char *)str;
}
-static inline void cmark_chunk_set_cstr(cmark_chunk *c, const char *str) {
+CMARK_INLINE void cmark_chunk_set_cstr(cmark_chunk *c, const char *str) {
if (c->alloc) {
free(c->data);
}
@@ -90,19 +90,19 @@ static inline void cmark_chunk_set_cstr(cmark_chunk *c, const char *str) {
}
}
-static inline cmark_chunk cmark_chunk_literal(const char *data) {
+CMARK_INLINE cmark_chunk cmark_chunk_literal(const char *data) {
bufsize_t len = data ? cmark_strbuf_safe_strlen(data) : 0;
cmark_chunk c = {(unsigned char *)data, len, 0};
return c;
}
-static inline cmark_chunk cmark_chunk_dup(const cmark_chunk *ch, bufsize_t pos,
+CMARK_INLINE cmark_chunk cmark_chunk_dup(const cmark_chunk *ch, bufsize_t pos,
bufsize_t len) {
cmark_chunk c = {ch->data + pos, len, 0};
return c;
}
-static inline cmark_chunk cmark_chunk_buf_detach(cmark_strbuf *buf) {
+CMARK_INLINE cmark_chunk cmark_chunk_buf_detach(cmark_strbuf *buf) {
cmark_chunk c;
c.len = buf->size;
diff --git a/src/config.h.in b/src/config.h.in
index 5294bc9..a392111 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -15,3 +15,11 @@
#else
#define CMARK_ATTRIBUTE(list)
#endif
+
+#ifndef CMARK_INLINE
+ #ifdef _MSC_VER
+ #define CMARK_INLINE __inline
+ #else
+ #define CMARK_INLINE static inline
+ #endif
+#endif
diff --git a/src/html.c b/src/html.c
index e365c8c..dfe2aec 100644
--- a/src/html.c
+++ b/src/html.c
@@ -130,12 +130,12 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
case CMARK_NODE_HEADER:
if (entering) {
cr(html);
- start_header[2] = '0' + node->as.header.level;
+ start_header[2] = (char)('0' + node->as.header.level);
cmark_strbuf_puts(html, start_header);
S_render_sourcepos(node, html, options);
cmark_strbuf_putc(html, '>');
} else {
- end_header[3] = '0' + node->as.header.level;
+ end_header[3] = (char)('0' + node->as.header.level);
cmark_strbuf_puts(html, end_header);
cmark_strbuf_puts(html, ">\n");
}
diff --git a/src/inlines.c b/src/inlines.c
index f8a2cfc..3275ddd 100755
--- a/src/inlines.c
+++ b/src/inlines.c
@@ -1034,13 +1034,13 @@ static int parse_inline(subject *subj, cmark_node *parent, int options) {
case '_':
case '\'':
case '"':
- new_inl = handle_delim(subj, c, options & CMARK_OPT_SMART);
+ new_inl = handle_delim(subj, c, (options & CMARK_OPT_SMART) != 0);
break;
case '-':
- new_inl = handle_hyphen(subj, options & CMARK_OPT_SMART);
+ new_inl = handle_hyphen(subj, (options & CMARK_OPT_SMART) != 0);
break;
case '.':
- new_inl = handle_period(subj, options & CMARK_OPT_SMART);
+ new_inl = handle_period(subj, (options & CMARK_OPT_SMART) != 0);
break;
case '[':
advance(subj);
diff --git a/src/iterator.c b/src/iterator.c
index 81b6f48..19dfff8 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -31,7 +31,7 @@ cmark_iter *cmark_iter_new(cmark_node *root) {
void cmark_iter_free(cmark_iter *iter) { free(iter); }
static bool S_is_leaf(cmark_node *node) {
- return (1 << node->type) & S_leaf_mask;
+ return ((1 << node->type) & S_leaf_mask) != 0;
}
cmark_event_type cmark_iter_next(cmark_iter *iter) {
diff --git a/src/node.c b/src/node.c
index ad12d63..46d234a 100644
--- a/src/node.c
+++ b/src/node.c
@@ -426,7 +426,7 @@ int cmark_node_set_list_tight(cmark_node *node, int tight) {
}
if (node->type == CMARK_NODE_LIST) {
- node->as.list.tight = tight;
+ node->as.list.tight = tight == 1;
return 1;
} else {
return 0;
@@ -717,7 +717,7 @@ int cmark_node_check(cmark_node *node, FILE *out) {
}
cur = node;
- while (true) {
+ for (;;) {
if (cur->first_child) {
if (cur->first_child->prev != NULL) {
S_print_error(out, cur->first_child, "prev");
diff --git a/src/utf8.c b/src/utf8.c
index a742a75..319539d 100755
--- a/src/utf8.c
+++ b/src/utf8.c
@@ -191,10 +191,10 @@ void cmark_utf8proc_encode_char(int32_t uc, cmark_strbuf *buf) {
assert(uc >= 0);
if (uc < 0x80) {
- dst[0] = uc;
+ dst[0] = (uint8_t)(uc);
len = 1;
} else if (uc < 0x800) {
- dst[0] = 0xC0 + (uc >> 6);
+ dst[0] = (uint8_t)(0xC0 + (uc >> 6));
dst[1] = 0x80 + (uc & 0x3F);
len = 2;
} else if (uc == 0xFFFF) {
@@ -204,12 +204,12 @@ void cmark_utf8proc_encode_char(int32_t uc, cmark_strbuf *buf) {
dst[0] = 0xFE;
len = 1;
} else if (uc < 0x10000) {
- dst[0] = 0xE0 + (uc >> 12);
+ dst[0] = (uint8_t)(0xE0 + (uc >> 12));
dst[1] = 0x80 + ((uc >> 6) & 0x3F);
dst[2] = 0x80 + (uc & 0x3F);
len = 3;
} else if (uc < 0x110000) {
- dst[0] = 0xF0 + (uc >> 18);
+ dst[0] = (uint8_t)(0xF0 + (uc >> 18));
dst[1] = 0x80 + ((uc >> 12) & 0x3F);
dst[2] = 0x80 + ((uc >> 6) & 0x3F);
dst[3] = 0x80 + (uc & 0x3F);