Move some declarations from shape.h to boxes.in.h

This resolves some otherwise circular dependencies between modules.
This commit is contained in:
Thomas Jensen 2023-11-28 22:44:21 +01:00
parent 76c4e10cd1
commit f739343c29
No known key found for this signature in database
GPG Key ID: A4ACEE270D0FB7DB
8 changed files with 41 additions and 37 deletions

View File

@ -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

View File

@ -35,6 +35,7 @@
#include "parsing.h"
#include "query.h"
#include "remove.h"
#include "shape.h"
#include "tools.h"
#include "unicode.h"

View File

@ -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;

View File

@ -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"

View File

@ -31,6 +31,7 @@
#include "parsing.h"
#include "query.h"
#include "regulex.h"
#include "shape.h"
#include "tools.h"
#include "unicode.h"

View File

@ -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);

View File

@ -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

View File

@ -28,6 +28,7 @@
#include "boxes.h"
#include "unicode.h"
#include "shape.h"
#include "tools.h"
#include "remove_test.h"
#include "global_mock.h"