From 4a1ae435f312e8d76558ef1e64f141ebffd15f9d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michael=20G=C3=B6hler?= Date: Sun, 17 Aug 2014 22:50:12 +0200 Subject: [PATCH] split up some headers + rename markdown_io to parser --- Makefile | 8 ++++---- include/bitops.h | 9 +++++++++ include/markdown.h | 10 +--------- include/parser.h | 12 ++++++++++++ markdown_io.c => parser.c | 3 +-- tmp.c | 2 +- 6 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 include/bitops.h create mode 100644 include/parser.h rename markdown_io.c => parser.c (98%) 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"); -- 2.20.1