From: Michael Göhler Date: Sun, 17 Aug 2014 20:50:12 +0000 (+0200) Subject: split up some headers + rename markdown_io to parser X-Git-Url: https://git.danieliu.xyz/?p=smdp.git;a=commitdiff_plain;h=4a1ae435f312e8d76558ef1e64f141ebffd15f9d split up some headers + rename markdown_io to parser --- diff --git a/Makefile b/Makefile index ee57e1d..ec4c76e 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -tmp: tmp.c cstring.o markdown.o markdown_io.o - cc -g -o tmp tmp.c cstring.o markdown.o markdown_io.o +tmp: tmp.c cstring.o markdown.o parser.o + cc -g -o tmp tmp.c cstring.o markdown.o parser.o -markdown_io.o: markdown_io.c cstring.o markdown.o - cc -g -c markdown_io.c -o markdown_io.o -lmarkdown +parser.o: parser.c cstring.o markdown.o + cc -g -c parser.c -o parser.o -lmarkdown markdown.o: markdown.c cstring.o cc -g -c markdown.c -o markdown.o -lcstring diff --git a/include/bitops.h b/include/bitops.h new file mode 100644 index 0000000..e18f3b0 --- /dev/null +++ b/include/bitops.h @@ -0,0 +1,9 @@ +#if !defined( BITOPS_H ) +#define BITOPS_H + +#define SET_BIT(var, pos) ((var) |= (1<<(pos))) +#define CLEAR_BIT(var, pos) ((var) &= (~(1<<(pos)))) +#define TOGGLE_BIT(var, pos) ((var) ^= (1<<(pos))) +#define CHECK_BIT(var, pos) ((var) & (1<<(pos))) + +#endif // !defined( BITOPS_H ) diff --git a/include/markdown.h b/include/markdown.h index 9c29d86..b26765e 100644 --- a/include/markdown.h +++ b/include/markdown.h @@ -7,11 +7,7 @@ */ #include "cstring.h" - -#define SET_BIT(var, pos) ((var) |= (1<<(pos))) -#define CLEAR_BIT(var, pos) ((var) &= (~(1<<(pos)))) -#define TOGGLE_BIT(var, pos) ((var) ^= (1<<(pos))) -#define CHECK_BIT(var, pos) ((var) & (1<<(pos))) +#include "bitops.h" enum line_bitmask { IS_H1, @@ -46,9 +42,5 @@ line_t *next_line(line_t *prev); page_t *new_page(); page_t *next_page(page_t *prev); document_t *new_document(); -int is_utf8(char ch); -int next_nonblank(cstring_t *text, int i); -int next_blank(cstring_t *text, int i); -document_t *markdown_load(FILE *input); #endif // !defined( MARKDOWN_H ) diff --git a/include/parser.h b/include/parser.h new file mode 100644 index 0000000..7ade17c --- /dev/null +++ b/include/parser.h @@ -0,0 +1,12 @@ +#if !defined( PARSER_H ) +#define PARSER_H + +#include "markdown.h" + +document_t *markdown_load(FILE *input); +int markdown_analyse(cstring_t *text); +int is_utf8(char ch); +int next_nonblank(cstring_t *text, int i); +int next_blank(cstring_t *text, int i); + +#endif // !defined( PARSER_H ) diff --git a/markdown_io.c b/parser.c similarity index 98% rename from markdown_io.c rename to parser.c index 7c80695..0343509 100644 --- a/markdown_io.c +++ b/parser.c @@ -1,8 +1,7 @@ #include #include -#include "include/cstring.h" -#include "include/markdown.h" +#include "include/parser.h" document_t *markdown_load(FILE *input) { diff --git a/tmp.c b/tmp.c index bcb624e..eeec4a4 100644 --- a/tmp.c +++ b/tmp.c @@ -4,7 +4,7 @@ #include #include -#include "include/markdown.h" +#include "include/parser.h" void usage() { fprintf(stderr, "Usage: tmp [OPTION]... [FILE]\n");