aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt20
-rw-r--r--src/buffer.c3
-rw-r--r--src/cmark_ctype.c2
-rw-r--r--src/cmark_ctype.h13
-rw-r--r--src/config.h.in6
-rw-r--r--src/html.c5
-rw-r--r--src/main.c9
-rw-r--r--src/man.c4
-rw-r--r--src/xml.c5
9 files changed, 41 insertions, 26 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 87651bc..b4a0fe8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -47,24 +47,6 @@ set(PROGRAM_SOURCES
include_directories(. ${CMAKE_CURRENT_BINARY_DIR})
-set(RE2C re2c)
-if (MSVC)
- file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR} DOS_CURRENT_SOURCE_DIR)
- add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/scanners.c
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scanners.re
- COMMAND ${RE2C} --case-insensitive -b -i
- --no-generation-date
- -o ${DOS_CURRENT_SOURCE_DIR}\\scanners.c
- ${DOS_CURRENT_SOURCE_DIR}\\scanners.re )
-else(MSVC)
- add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/scanners.c
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scanners.re
- COMMAND ${RE2C} --case-insensitive -b -i
- --no-generation-date
- -o ${CMAKE_CURRENT_SOURCE_DIR}/scanners.c
- ${CMAKE_CURRENT_SOURCE_DIR}/scanners.re )
-endif(MSVC)
-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libcmark.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libcmark.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcmark.pc
@@ -117,6 +99,7 @@ install(FILES cmark.h ${CMAKE_CURRENT_BINARY_DIR}/cmark_export.h
# Feature tests
include(CheckIncludeFile)
include(CheckCSourceCompiles)
+include(CheckSymbolExists)
CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
CHECK_C_SOURCE_COMPILES(
"int main() { __builtin_expect(0,0); return 0; }"
@@ -125,6 +108,7 @@ CHECK_C_SOURCE_COMPILES("
int f(void) __attribute__ (());
int main() { return 0; }
" HAVE___ATTRIBUTE__)
+CHECK_SYMBOL_EXISTS(va_copy stdarg.h HAVE_VA_COPY)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
diff --git a/src/buffer.c b/src/buffer.c
index b508310..87d817b 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "config.h"
#include "cmark_ctype.h"
#include "buffer.h"
@@ -175,6 +176,8 @@ int cmark_strbuf_vprintf(cmark_strbuf *buf, const char *format, va_list ap)
format, args
);
+ va_end(args);
+
if (len < 0) {
free(buf->ptr);
buf->ptr = cmark_strbuf__oom;
diff --git a/src/cmark_ctype.c b/src/cmark_ctype.c
index 8805b9a..a3871a8 100644
--- a/src/cmark_ctype.c
+++ b/src/cmark_ctype.c
@@ -1,5 +1,7 @@
#include <stdint.h>
+#include "cmark_ctype.h"
+
/** 1 = space, 2 = punct, 3 = digit, 4 = alpha, 0 = other
*/
static const int8_t cmark_ctype_class[256] = {
diff --git a/src/cmark_ctype.h b/src/cmark_ctype.h
index 7423f80..f803946 100644
--- a/src/cmark_ctype.h
+++ b/src/cmark_ctype.h
@@ -1,3 +1,10 @@
+#ifndef CMARK_CMARK_CTYPE_H
+#define CMARK_CMARK_CTYPE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/** Locale-independent versions of functions from ctype.h.
* We want cmark to behave the same no matter what the system locale.
*/
@@ -9,3 +16,9 @@ int cmark_ispunct(char c);
int cmark_isalnum(char c);
int cmark_isdigit(char c);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/config.h.in b/src/config.h.in
index 5294bc9..c1e9597 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -15,3 +15,9 @@
#else
#define CMARK_ATTRIBUTE(list)
#endif
+
+#cmakedefine HAVE_VA_COPY
+
+#ifndef HAVE_VA_COPY
+ #define va_copy(dest, src) ((dest) = (src))
+#endif
diff --git a/src/html.c b/src/html.c
index 67c93e9..bb04458 100644
--- a/src/html.c
+++ b/src/html.c
@@ -50,10 +50,9 @@ S_render_sourcepos(cmark_node *node, cmark_strbuf *html, long options) {
}
static int
-S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate,
- long options)
+S_render_node(cmark_node *node, cmark_event_type ev_type,
+ struct render_state *state, long options)
{
- struct render_state *state = vstate;
cmark_node *parent;
cmark_node *grandparent;
cmark_strbuf *html = state->html;
diff --git a/src/main.c b/src/main.c
index b2027ee..e849b82 100644
--- a/src/main.c
+++ b/src/main.c
@@ -7,6 +7,11 @@
#include "debug.h"
#include "bench.h"
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ #include <io.h>
+ #include <fcntl.h>
+#endif
+
typedef enum {
FORMAT_NONE,
FORMAT_HTML,
@@ -58,6 +63,10 @@ int main(int argc, char *argv[])
writer_format writer = FORMAT_HTML;
long options = CMARK_OPT_DEFAULT;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ _setmode(_fileno(stdout), _O_BINARY);
+#endif
+
parser = cmark_parser_new();
files = (int *)malloc(argc * sizeof(*files));
diff --git a/src/man.c b/src/man.c
index 1b45f8b..176081f 100644
--- a/src/man.c
+++ b/src/man.c
@@ -43,9 +43,9 @@ struct render_state {
};
static int
-S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
+S_render_node(cmark_node *node, cmark_event_type ev_type,
+ struct render_state *state)
{
- struct render_state *state = vstate;
cmark_node *tmp;
cmark_strbuf *man = state->man;
int list_number;
diff --git a/src/xml.c b/src/xml.c
index c0f9d4e..b012886 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -35,10 +35,9 @@ static inline void indent(struct render_state *state)
}
static int
-S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate,
- long options)
+S_render_node(cmark_node *node, cmark_event_type ev_type,
+ struct render_state *state, long options)
{
- struct render_state *state = vstate;
cmark_strbuf *xml = state->xml;
bool literal = false;