From 90f4342678b51614409f5adb51f63549eec13cf1 Mon Sep 17 00:00:00 2001 From: david parsons Date: Wed, 27 May 2020 14:30:31 -0700 Subject: [PATCH] split pgm_options into itself + flagprocs so that the new flag set/clear functions can be placed into the library w/o bringing in the rest of pgm_options --- Makefile.in | 3 ++- cmake/CMakeLists.txt | 1 + flagprocs.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ pgm_options.c | 30 -------------------------- 4 files changed, 53 insertions(+), 31 deletions(-) create mode 100644 flagprocs.c diff --git a/Makefile.in b/Makefile.in index ca519b0..9361ad9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -28,7 +28,7 @@ OBJS=mkdio.o markdown.o dumptree.o generate.o \ resource.o docheader.o version.o toc.o css.o \ xml.o Csio.o xmlpage.o basename.o emmatch.o \ github_flavoured.o setup.o tags.o html5.o \ - @AMALLOC@ @H1TITLE@ flags.o v2compat.o + @AMALLOC@ @H1TITLE@ flags.o v2compat.o flagprocs.o TESTFRAMEWORK=echo cols branch pandoc_headers # modules that markdown, makepage, mkd2html, &tc use @@ -174,6 +174,7 @@ emmatch.o: emmatch.c config.h cstring.h amalloc.h markdown.h generate.o: generate.c config.h cstring.h amalloc.h markdown.h main.o: main.c config.h amalloc.h pgm_options.o: pgm_options.c pgm_options.h config.h amalloc.h +flagprocs.o: flagprocs.c pgm_options.h markdown.h config.h amalloc.h makepage.o: makepage.c markdown.o: markdown.c config.h cstring.h amalloc.h markdown.h mkd2html.o: mkd2html.c config.h mkdio.h cstring.h amalloc.h diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index a48b26a..ec56974 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -150,6 +150,7 @@ add_library(libmarkdown "${_ROOT}/blocktags" "${_ROOT}/tags.c" "${_ROOT}/html5.c" "${_ROOT}/v2compat.c" + "${_ROOT}/flagprocs.c" "${_ROOT}/flags.c") set_target_properties(libmarkdown PROPERTIES diff --git a/flagprocs.c b/flagprocs.c new file mode 100644 index 0000000..b99713e --- /dev/null +++ b/flagprocs.c @@ -0,0 +1,50 @@ +/* markdown: a C implementation of John Gruber's Markdown markup language. + * + * Copyright (C) 2007-2011 David L Parsons. + * The redistribution terms are provided in the COPYRIGHT file that must + * be distributed with this source code. + */ + +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "markdown.h" +#include "amalloc.h" + +#if HAVE_LIBGEN_H +#include +#endif + +void +mkd_set_flag_num(mkd_flag_t *p, unsigned long bit) +{ + if ( p && (bit < MKD_NR_FLAGS) ) + set_mkd_flag(p, bit); +} + + +void +mkd_clr_flag_num(mkd_flag_t *p, unsigned long bit) +{ + if ( p && (bit < MKD_NR_FLAGS) ) + clear_mkd_flag(p, bit); +} + + +void +mkd_set_flag_bitmap(mkd_flag_t *p, long bits) +{ + int i; + + if ( p == 0 ) + return; + + for (i=0; i < 8*sizeof(long) && i < MKD_NR_FLAGS; i++) + if ( bits & (1<