Skip to content

Commit

Permalink
Normalise header and define names (#109)
Browse files Browse the repository at this point in the history
* cmark -> cmark-gfm in most places

* normalize filenames, exports

* ensure some more #defines don't conflict
  • Loading branch information
Ashe Connor authored Aug 21, 2018
1 parent 9ceb8bd commit 3221400
Show file tree
Hide file tree
Showing 56 changed files with 337 additions and 338 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ if(CMAKE_MAJOR_VERSION GREATER 2)
cmake_policy(SET CMP0048 OLD)
endif()

project(cmark)
project(cmark-gfm)

include("FindAsan.cmake")

if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "Do not build in-source.\nPlease remove CMakeCache.txt and the CMakeFiles/ directory.\nThen: mkdir build ; cd build ; cmake .. ; make")
endif()

set(PROJECT_NAME "cmark")
set(PROJECT_NAME "cmark-gfm")

set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 28)
set(PROJECT_VERSION_PATCH 3)
set(PROJECT_VERSION_GFM 14)
set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.gfm.${PROJECT_VERSION_GFM} )

option(CMARK_TESTS "Build cmark tests and enable testing" ON)
option(CMARK_TESTS "Build cmark-gfm tests and enable testing" ON)
option(CMARK_STATIC "Build static libcmark-gfm library" ON)
option(CMARK_SHARED "Build shared libcmark-gfm library" ON)
option(CMARK_LIB_FUZZER "Build libFuzzer fuzzing harness" OFF)
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ mingw:
cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$(MINGW_INSTALLDIR) ;\
$(MAKE) && $(MAKE) install

man/man3/cmark-gfm.3: src/cmark.h | $(CMARK)
man/man3/cmark-gfm.3: src/cmark-gfm.h | $(CMARK)
python man/make_man_page.py $< > $@ \

archive:
Expand Down Expand Up @@ -222,5 +222,5 @@ distclean: clean
-rm -rf $(BENCHFILE) $(ALLTESTS) progit

docker:
docker build -t cmark $(CURDIR)/tools
docker run --privileged -t -i -v $(CURDIR):/src/cmark -w /src/cmark cmark /bin/bash
docker build -t cmark-gfm $(CURDIR)/tools
docker run --privileged -t -i -v $(CURDIR):/src/cmark-gfm -w /src/cmark-gfm cmark-gfm /bin/bash
2 changes: 1 addition & 1 deletion Makefile.nmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ DATADIR=data
BUILDDIR=build
INSTALLDIR=windows
SPEC=test/spec.txt
PROG=$(BUILDDIR)\src\cmark.exe
PROG=$(BUILDDIR)\src\cmark-gfm.exe
GENERATOR=NMake Makefiles

all: $(BUILDDIR)/CMakeFiles
Expand Down
4 changes: 2 additions & 2 deletions api_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ include_directories(
${PROJECT_BINARY_DIR}/extensions
)
if(CMARK_SHARED)
target_link_libraries(api_test libcmark-gfmextensions libcmark-gfm)
target_link_libraries(api_test libcmark-gfm-extensions libcmark-gfm)
else()
target_link_libraries(api_test libcmark-gfmextensions_static libcmark-gfm_static)
target_link_libraries(api_test libcmark-gfm-extensions_static libcmark-gfm_static)
endif()

# Compiler flags
Expand Down
2 changes: 1 addition & 1 deletion api_test/cplusplus.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <cstdlib>

#include "cmark.h"
#include "cmark-gfm.h"
#include "cplusplus.h"
#include "harness.h"

Expand Down
8 changes: 4 additions & 4 deletions api_test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include <string.h>

#define CMARK_NO_SHORT_NAMES
#include "cmark.h"
#include "cmark-gfm.h"
#include "node.h"
#include "../extensions/core-extensions.h"
#include "../extensions/cmark-gfm-core-extensions.h"

#include "harness.h"
#include "cplusplus.h"
Expand Down Expand Up @@ -36,8 +36,8 @@ static void test_incomplete_char(test_batch_runner *runner, const char *utf8,
static void test_continuation_byte(test_batch_runner *runner, const char *utf8);

static void version(test_batch_runner *runner) {
INT_EQ(runner, cmark_version(), CMARK_VERSION, "cmark_version");
STR_EQ(runner, cmark_version_string(), CMARK_VERSION_STRING,
INT_EQ(runner, cmark_version(), CMARK_GFM_VERSION, "cmark_version");
STR_EQ(runner, cmark_version_string(), CMARK_GFM_VERSION_STRING,
"cmark_version_string");
}

Expand Down
24 changes: 12 additions & 12 deletions extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 2.8)
set(LIBRARY "libcmark-gfmextensions")
set(STATICLIBRARY "libcmark-gfmextensions_static")
set(LIBRARY "libcmark-gfm-extensions")
set(STATICLIBRARY "libcmark-gfm-extensions_static")
set(LIBRARY_SOURCES
core-extensions.c
table.c
Expand Down Expand Up @@ -29,18 +29,18 @@ if (CMARK_SHARED)
add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES})

set_target_properties(${LIBRARY} PROPERTIES
OUTPUT_NAME "cmark-gfmextensions"
OUTPUT_NAME "cmark-gfm-extensions"
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.gfm.${PROJECT_VERSION_GFM}
VERSION ${PROJECT_VERSION})

set_property(TARGET ${LIBRARY}
APPEND PROPERTY MACOSX_RPATH true)

# Avoid name clash between PROGRAM and LIBRARY pdb files.
set_target_properties(${LIBRARY} PROPERTIES PDB_NAME cmark-gfmextensions_dll)
set_target_properties(${LIBRARY} PROPERTIES PDB_NAME cmark-gfm-extensions_dll)

generate_export_header(${LIBRARY}
BASE_NAME cmarkextensions)
BASE_NAME cmark-gfm-extensions)

list(APPEND CMARK_INSTALL ${LIBRARY})
target_link_libraries(${LIBRARY} libcmark-gfm)
Expand All @@ -56,17 +56,17 @@ if (CMARK_STATIC)

if (MSVC)
set_target_properties(${STATICLIBRARY} PROPERTIES
OUTPUT_NAME "cmark-gfmextensions_static"
OUTPUT_NAME "cmark-gfm-extensions_static"
VERSION ${PROJECT_VERSION})
else()
set_target_properties(${STATICLIBRARY} PROPERTIES
OUTPUT_NAME "cmark-gfmextensions"
OUTPUT_NAME "cmark-gfm-extensions"
VERSION ${PROJECT_VERSION})
endif(MSVC)

if (NOT CMARK_SHARED)
generate_export_header(${STATICLIBRARY}
BASE_NAME cmarkextensions)
BASE_NAME cmark-gfm-extensions)
endif()

list(APPEND CMARK_INSTALL ${STATICLIBRARY})
Expand All @@ -76,20 +76,20 @@ set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)

include (InstallRequiredSystemLibraries)
install(TARGETS ${CMARK_INSTALL}
EXPORT cmark-gfmextensions
EXPORT cmark-gfm-extensions
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
)

if (CMARK_SHARED OR CMARK_STATIC)
install(FILES
core-extensions.h
${CMAKE_CURRENT_BINARY_DIR}/cmarkextensions_export.h
cmark-gfm-core-extensions.h
${CMAKE_CURRENT_BINARY_DIR}/cmark-gfm-extensions_export.h
DESTINATION include
)

install(EXPORT cmark-gfmextensions DESTINATION lib${LIB_SUFFIX}/cmake-gfmextensions)
install(EXPORT cmark-gfm-extensions DESTINATION lib${LIB_SUFFIX}/cmake-gfm-extensions)
endif()

# Feature tests
Expand Down
6 changes: 3 additions & 3 deletions extensions/autolink.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef AUTOLINK_H
#define AUTOLINK_H
#ifndef CMARK_GFM_AUTOLINK_H
#define CMARK_GFM_AUTOLINK_H

#include "core-extensions.h"
#include "cmark-gfm-core-extensions.h"

cmark_syntax_extension *create_autolink_extension(void);

Expand Down
25 changes: 25 additions & 0 deletions extensions/cmark-gfm-core-extensions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef CMARK_GFM_CORE_EXTENSIONS_H
#define CMARK_GFM_CORE_EXTENSIONS_H

#ifdef __cplusplus
extern "C" {
#endif

#include "cmark-gfm-extension_api.h"
#include "cmark-gfm-extensions_export.h"
#include <stdint.h>

CMARK_GFM_EXTENSIONS_EXPORT
void cmark_gfm_core_extensions_ensure_registered(void);

CMARK_GFM_EXTENSIONS_EXPORT
uint16_t cmark_gfm_extensions_get_table_columns(cmark_node *node);

CMARK_GFM_EXTENSIONS_EXPORT
uint8_t *cmark_gfm_extensions_get_table_alignments(cmark_node *node);

#ifdef __cplusplus
}
#endif

#endif
4 changes: 2 additions & 2 deletions extensions/core-extensions.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "core-extensions.h"
#include "cmark-gfm-core-extensions.h"
#include "autolink.h"
#include "strikethrough.h"
#include "table.h"
Expand All @@ -15,7 +15,7 @@ static int core_extensions_registration(cmark_plugin *plugin) {
return 1;
}

void core_extensions_ensure_registered(void) {
void cmark_gfm_core_extensions_ensure_registered(void) {
static int registered = 0;

if (!registered) {
Expand Down
25 changes: 0 additions & 25 deletions extensions/core-extensions.h

This file was deleted.

2 changes: 1 addition & 1 deletion extensions/ext_scanners.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "chunk.h"
#include "cmark.h"
#include "cmark-gfm.h"

#ifdef __cplusplus
extern "C" {
Expand Down
6 changes: 3 additions & 3 deletions extensions/strikethrough.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef STRIKETHROUGH_H
#define STRIKETHROUGH_H
#ifndef CMARK_GFM_STRIKETHROUGH_H
#define CMARK_GFM_STRIKETHROUGH_H

#include "core-extensions.h"
#include "cmark-gfm-core-extensions.h"

extern cmark_node_type CMARK_NODE_STRIKETHROUGH;
cmark_syntax_extension *create_strikethrough_extension(void);
Expand Down
6 changes: 3 additions & 3 deletions extensions/table.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <cmark_extension_api.h>
#include <cmark-gfm-extension_api.h>
#include <html.h>
#include <inlines.h>
#include <parser.h>
Expand Down Expand Up @@ -685,14 +685,14 @@ cmark_syntax_extension *create_table_extension(void) {
return self;
}

uint16_t cmarkextensions_get_table_columns(cmark_node *node) {
uint16_t cmark_gfm_extensions_get_table_columns(cmark_node *node) {
if (node->type != CMARK_NODE_TABLE)
return 0;

return ((node_table *)node->as.opaque)->n_columns;
}

uint8_t *cmarkextensions_get_table_alignments(cmark_node *node) {
uint8_t *cmark_gfm_extensions_get_table_alignments(cmark_node *node) {
if (node->type != CMARK_NODE_TABLE)
return 0;

Expand Down
6 changes: 3 additions & 3 deletions extensions/table.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef TABLE_H
#define TABLE_H
#ifndef CMARK_GFM_TABLE_H
#define CMARK_GFM_TABLE_H

#include "core-extensions.h"
#include "cmark-gfm-core-extensions.h"


extern cmark_node_type CMARK_NODE_TABLE, CMARK_NODE_TABLE_ROW,
Expand Down
6 changes: 3 additions & 3 deletions extensions/tagfilter.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef TAGFILTER_H
#define TAGFILTER_H
#ifndef CMARK_GFM_TAGFILTER_H
#define CMARK_GFM_TAGFILTER_H

#include "core-extensions.h"
#include "cmark-gfm-core-extensions.h"

cmark_syntax_extension *create_tagfilter_extension(void);

Expand Down
4 changes: 2 additions & 2 deletions man/make_man_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def md2man(text):
comment_start_re = re.compile('^\/\*\* ?')
comment_delim_re = re.compile('^[/ ]\** ?')
comment_end_re = re.compile('^ \**\/')
function_re = re.compile('^ *(?:CMARK_EXPORT\s+)?(?P<type>(?:const\s+)?\w+(?:\s*[*])?)\s*(?P<name>\w+)\s*\((?P<args>[^)]*)\)')
function_re = re.compile('^ *(?:CMARK_GFM_EXPORT\s+)?(?P<type>(?:const\s+)?\w+(?:\s*[*])?)\s*(?P<name>\w+)\s*\((?P<args>[^)]*)\)')
blank_re = re.compile('^\s*$')
macro_re = re.compile('CMARK_EXPORT *')
macro_re = re.compile('CMARK_GFM_EXPORT *')
typedef_start_re = re.compile('typedef.*{$')
typedef_end_re = re.compile('}')
single_quote_re = re.compile("(?<!\w)'([^']+)'(?!\w)")
Expand Down
2 changes: 1 addition & 1 deletion man/man3/cmark-gfm.3
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH cmark-gfm 3 "August 08, 2018" "LOCAL" "Library Functions Manual"
.TH cmark-gfm 3 "August 21, 2018" "LOCAL" "Library Functions Manual"
.SH
NAME
.PP
Expand Down
20 changes: 10 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ include(GNUInstallDirs)
set(LIBRARY "libcmark-gfm")
set(STATICLIBRARY "libcmark-gfm_static")
set(HEADERS
cmark.h
cmark_extension_api.h
cmark-gfm.h
cmark-gfm-extension_api.h
parser.h
buffer.h
node.h
Expand Down Expand Up @@ -69,18 +69,18 @@ include_directories(
${PROJECT_BINARY_DIR}/extensions
)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmark_version.h.in
${CMAKE_CURRENT_BINARY_DIR}/cmark_version.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmark-gfm_version.h.in
${CMAKE_CURRENT_BINARY_DIR}/cmark-gfm_version.h)

include (GenerateExportHeader)

add_executable(${PROGRAM} ${PROGRAM_SOURCES})
add_compiler_export_flags()

if(CMARK_SHARED)
target_link_libraries(${PROGRAM} libcmark-gfmextensions libcmark-gfm)
target_link_libraries(${PROGRAM} libcmark-gfm-extensions libcmark-gfm)
elseif(CMARK_STATIC)
target_link_libraries(${PROGRAM} libcmark-gfmextensions_static libcmark-gfm_static)
target_link_libraries(${PROGRAM} libcmark-gfm-extensions_static libcmark-gfm_static)
endif()

# Disable the PUBLIC declarations when compiling the executable:
Expand Down Expand Up @@ -171,10 +171,10 @@ if(CMARK_SHARED OR CMARK_STATIC)
DESTINATION ${libdir}/pkgconfig)

install(FILES
cmark.h
cmark_extension_api.h
${CMAKE_CURRENT_BINARY_DIR}/cmark_export.h
${CMAKE_CURRENT_BINARY_DIR}/cmark_version.h
cmark-gfm.h
cmark-gfm-extension_api.h
${CMAKE_CURRENT_BINARY_DIR}/cmark-gfm_export.h
${CMAKE_CURRENT_BINARY_DIR}/cmark-gfm_version.h
DESTINATION include
)

Expand Down
4 changes: 2 additions & 2 deletions src/arena.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "cmark.h"
#include "cmark_extension_api.h"
#include "cmark-gfm.h"
#include "cmark-gfm-extension_api.h"

static struct arena_chunk {
size_t sz, used;
Expand Down
Loading

0 comments on commit 3221400

Please sign in to comment.