diff --git a/src/Makefile b/src/Makefile index 7686418..8e03ff1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -107,7 +107,7 @@ parser.c parser.h: parser.y lex.yy.h | check_dir lex.yy.c lex.yy.h: lexer.l | check_dir $(LEX) --header-file=lex.yy.h $< -boxes.o: boxes.c boxes.h cmdline.h discovery.h generate.h input.h list.h parsing.h query.h remove.h tools.h unicode.h config.h | check_dir +boxes.o: boxes.c boxes.h cmdline.h discovery.h generate.h input.h list.h parsing.h query.h remove.h shape.h tools.h unicode.h config.h | check_dir bxstring.o: bxstring.c bxstring.h tools.h unicode.h config.h | check_dir cmdline.o: cmdline.c cmdline.h boxes.h discovery.h query.h tools.h config.h | check_dir detect.o: detect.c detect.h boxes.h bxstring.h shape.h tools.h config.h | check_dir @@ -115,8 +115,8 @@ discovery.o: discovery.c discovery.h boxes.h tools.h unicode.h config.h | check_ generate.o: generate.c generate.h boxes.h shape.h tools.h unicode.h config.h | check_dir input.o: input.c boxes.h input.h regulex.h tools.h unicode.h config.h | check_dir lex.yy.o: lex.yy.c parser.h boxes.h parsing.h tools.h shape.h unicode.h config.h | check_dir -list.o: list.c list.h boxes.h bxstring.h parsing.h query.h tools.h unicode.h config.h | check_dir -parsecode.o: parsecode.c parsecode.h discovery.h lex.yy.h parsing.h parser.h query.h regulex.h tools.h unicode.h config.h | check_dir +list.o: list.c list.h boxes.h bxstring.h parsing.h query.h shape.h tools.h unicode.h config.h | check_dir +parsecode.o: parsecode.c parsecode.h discovery.h lex.yy.h parsing.h parser.h query.h regulex.h shape.h tools.h unicode.h config.h | check_dir parser.o: parser.c boxes.h bxstring.h lex.yy.h parsecode.h parser.h parsing.h shape.h tools.h unicode.h config.h | check_dir parsing.o: parsing.c parsing.h bxstring.h parser.h lex.yy.h boxes.h tools.h config.h | check_dir query.o: query.c query.h boxes.h list.h tools.h config.h | check_dir diff --git a/src/boxes.c b/src/boxes.c index 4a64423..12fb716 100644 --- a/src/boxes.c +++ b/src/boxes.c @@ -35,6 +35,7 @@ #include "parsing.h" #include "query.h" #include "remove.h" +#include "shape.h" #include "tools.h" #include "unicode.h" diff --git a/src/boxes.in.h b/src/boxes.in.h index ca27bc3..6205f8d 100644 --- a/src/boxes.in.h +++ b/src/boxes.in.h @@ -20,7 +20,7 @@ #ifndef BOXES_H #define BOXES_H -#define DEBUG 1 +/* #define DEBUG 1 */ /* #define REGEXP_DEBUG 1 */ /* #define PARSER_DEBUG 1 */ /* #define LEXER_DEBUG 1 */ @@ -31,7 +31,6 @@ #include "bxstring.h" #include "regulex.h" -#include "shape.h" @@ -67,6 +66,37 @@ #define BLEF 3 +typedef enum { + NW, NNW, N, NNE, NE, ENE, E, ESE, SE, SSE, S, SSW, SW, WSW, W, WNW +} shape_t; + + +typedef struct { + shape_t name; + char **chars; + bxstr_t **mbcs; + size_t height; + size_t width; + + /** elastic is used only in original definition */ + int elastic; + + /** For each shape line 0..height-1, a flag which is 1 if all shapes to the left of this shape are blank on the + * same shape line. Always 1 if the shape is part of the left (west) box side. */ + int *blank_leftward; + + /** For each shape line 0..height-1, a flag which is 1 if all shapes to the right of this shape are blank on the + * same shape line. Always 1 if the shape is part of the right (east) box side. */ + int *blank_rightward; +} sentry_t; + +#define SENTRY_INITIALIZER (sentry_t) {NW, NULL, NULL, 0, 0, 0, NULL, NULL} + +#define NUM_SHAPES 16 +#define NUM_SIDES 4 +#define NUM_CORNERS 4 + + typedef struct { bxstr_t *search; bxstr_t *repstr; diff --git a/src/list.c b/src/list.c index dee046d..21f68e9 100644 --- a/src/list.c +++ b/src/list.c @@ -27,6 +27,7 @@ #include "bxstring.h" #include "parsing.h" #include "query.h" +#include "shape.h" #include "tools.h" #include "list.h" #include "unicode.h" diff --git a/src/parsecode.c b/src/parsecode.c index 3b2497c..55c0927 100644 --- a/src/parsecode.c +++ b/src/parsecode.c @@ -31,6 +31,7 @@ #include "parsing.h" #include "query.h" #include "regulex.h" +#include "shape.h" #include "tools.h" #include "unicode.h" diff --git a/src/shape.h b/src/shape.h index a40c4cf..15accff 100644 --- a/src/shape.h +++ b/src/shape.h @@ -20,21 +20,14 @@ #ifndef SHAPE_H #define SHAPE_H +#include "boxes.h" #include "bxstring.h" -typedef enum { - NW, NNW, N, NNE, NE, ENE, E, ESE, SE, SSE, S, SSW, SW, WSW, W, WNW -} shape_t; - extern char *shape_name[]; -#define NUM_SHAPES 16 - #define SHAPES_PER_SIDE 5 #define CORNERS_PER_SIDE 2 -#define NUM_SIDES 4 -#define NUM_CORNERS 4 extern shape_t north_side[SHAPES_PER_SIDE]; /* groups of shapes, clockwise */ extern shape_t east_side[SHAPES_PER_SIDE]; @@ -45,29 +38,6 @@ extern shape_t corners[NUM_CORNERS]; extern shape_t *sides[NUM_SIDES]; -typedef struct { - shape_t name; - char **chars; - bxstr_t **mbcs; - size_t height; - size_t width; - - /** elastic is used only in original definition */ - int elastic; - - /** For each shape line 0..height-1, a flag which is 1 if all shapes to the left of this shape are blank on the - * same shape line. Always 1 if the shape is part of the left (west) box side. */ - int *blank_leftward; - - /** For each shape line 0..height-1, a flag which is 1 if all shapes to the right of this shape are blank on the - * same shape line. Always 1 if the shape is part of the right (east) box side. */ - int *blank_rightward; -} sentry_t; - -#define SENTRY_INITIALIZER (sentry_t) {NW, NULL, NULL, 0, 0, 0, NULL, NULL} - - - int genshape (const size_t width, const size_t height, char ***chars, bxstr_t ***mbcs); void freeshape (sentry_t *shape); diff --git a/utest/Makefile b/utest/Makefile index f81156e..d3bed44 100644 --- a/utest/Makefile +++ b/utest/Makefile @@ -71,7 +71,7 @@ bxstring_test.o: bxstring_test.c bxstring_test.h boxes.h bxstring.h global_mock. cmdline_test.o: cmdline_test.c cmdline_test.h boxes.h cmdline.h global_mock.h tools.h config.h | check_dir tools_test.o: tools_test.c tools_test.h tools.h unicode.h config.h | check_dir regulex_test.o: regulex_test.c regulex_test.h boxes.h global_mock.h regulex.h config.h | check_dir -remove_test.o: remove_test.c remove_test.h boxes.h remove.h tools.h unicode.h global_mock.h utest_tools.h config.h | check_dir +remove_test.o: remove_test.c remove_test.h boxes.h remove.h shape.h tools.h unicode.h global_mock.h utest_tools.h config.h | check_dir main.o: main.c bxstring_test.h cmdline_test.h global_mock.h tools_test.h regulex_test.h unicode_test.h config.h | check_dir unicode_test.o: unicode_test.c unicode_test.h boxes.h tools.h unicode.h config.h | check_dir utest_tools.o: utest_tools.c utest_tools.h config.h | check_dir diff --git a/utest/remove_test.c b/utest/remove_test.c index 14183e7..35ddc67 100644 --- a/utest/remove_test.c +++ b/utest/remove_test.c @@ -28,6 +28,7 @@ #include "boxes.h" #include "unicode.h" +#include "shape.h" #include "tools.h" #include "remove_test.h" #include "global_mock.h"