cmark

My personal build of CMark ✏️

Commit
76b7e4241c840480beaef5ac6b711301f066251e
Parent
4dcdc715910b61a2b58f1ea8ae5f86d041e3c229
Author
Nick Wellnhofer <wellnhofer@aevum.de>
Date

Probe for stdbool.h

Let cmake create a cmark_config.h file to deal with platforms missing stdbool.h.

Diffstat

9 files changed, 18 insertions, 7 deletions

Status File Name N° Changes Insertions Deletions
Modified src/CMakeLists.txt 4 4 0
Modified src/ast.h 2 1 1
Modified src/blocks.c 2 1 1
Modified src/buffer.h 2 1 1
Modified src/cmark.c 1 0 1
Added src/config.h.in 8 8 0
Modified src/html/html.c 2 1 1
Modified src/inlines.c 2 1 1
Modified src/main.c 2 1 1
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
@@ -96,6 +96,10 @@ install(FILES cmark.h ${CMAKE_CURRENT_BINARY_DIR}/cmark_export.h
 include (CheckIncludeFile)
 CHECK_INCLUDE_FILE (stdbool.h HAVE_STDBOOL_H)
 
+CONFIGURE_FILE(
+  ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
+  ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+
 # Always compile with warnings
 if(MSVC)
   # Force to always compile with W4
diff --git a/src/ast.h b/src/ast.h
@@ -1,8 +1,8 @@
 #ifndef CMARK_AST_H
 #define CMARK_AST_H
 
-#include <stdbool.h>
 #include <stdio.h>
+#include "config.h"
 #include "buffer.h"
 #include "chunk.h"
 
diff --git a/src/blocks.c b/src/blocks.c
@@ -1,9 +1,9 @@
 #include <stdlib.h>
 #include <assert.h>
 #include <stdio.h>
-#include <stdbool.h>
 #include <ctype.h>
 
+#include "config.h"
 #include "ast.h"
 #include "cmark.h"
 #include "references.h"
diff --git a/src/buffer.h b/src/buffer.h
@@ -1,9 +1,9 @@
 #ifndef CMARK_BUFFER_H
 #define CMARK_BUFFER_H
 
-#include <stdbool.h>
 #include <stddef.h>
 #include <stdarg.h>
+#include "config.h"
 #include "cmark_export.h"
 
 typedef struct {
diff --git a/src/cmark.c b/src/cmark.c
@@ -1,7 +1,6 @@
 #include <stdlib.h>
 #include <assert.h>
 #include <stdio.h>
-#include <stdbool.h>
 #include "references.h"
 #include "html/houdini.h"
 #include "cmark.h"
diff --git a/src/config.h.in b/src/config.h.in
@@ -0,0 +1,8 @@
+#cmakedefine HAVE_STDBOOL_H
+
+#ifdef HAVE_STDBOOL_H
+  #include <stdbool.h>
+#elif !defined(__cplusplus)
+  typedef char bool;
+#endif
+
diff --git a/src/html/html.c b/src/html/html.c
@@ -1,9 +1,9 @@
 #include <stdlib.h>
 #include <stdio.h>
-#include <stdbool.h>
 #include <string.h>
 #include <assert.h>
 
+#include "config.h"
 #include "cmark.h"
 #include "buffer.h"
 #include "ast.h"
diff --git a/src/inlines.c b/src/inlines.c
@@ -1,9 +1,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
-#include <stdbool.h>
 #include <ctype.h>
 
+#include "config.h"
 #include "ast.h"
 #include "references.h"
 #include "cmark.h"
diff --git a/src/main.c b/src/main.c
@@ -2,7 +2,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
-#include <stdbool.h>
+#include "config.h"
 #include "cmark.h"
 #include "debug.h"
 #include "bench.h"