From 48f7ea3f3b47aa4725519f5a7dc812ca2b07a0c7 Mon Sep 17 00:00:00 2001 From: Mitch Weaver Date: Mon, 9 Mar 2020 11:29:38 -0500 Subject: [PATCH] remove ccommon dependency remove submodule --- .gitmodules | 3 --- args.h | 7 ++++++- colors.h | 7 ++++++- draw.c | 21 +++++++++++++-------- draw.h | 10 +++++++--- main.c | 11 ++++++++--- makefile | 2 +- sub/ccommon | 1 - sub/termbox_next | 2 +- 9 files changed, 42 insertions(+), 22 deletions(-) delete mode 160000 sub/ccommon diff --git a/.gitmodules b/.gitmodules index 11c8a6c..78cd170 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "sub/termbox_next"] path = sub/termbox_next url = https://github.com/cylgom/termbox_next -[submodule "sub/ccommon"] - path = sub/ccommon - url = https://github.com/lptstr/ccommon diff --git a/args.h b/args.h index 490045c..db1dedf 100644 --- a/args.h +++ b/args.h @@ -13,12 +13,17 @@ #define ARGS_INCLUDED #include "bool.h" #include "args.h" + +#ifdef __OpenBSD__ +#include "sys/types.h" +#else #include "types.h" +#endif extern char *argv0; typedef struct Options { - usize refresh_rate; + size_t refresh_rate; bool truecolor; } Options; diff --git a/colors.h b/colors.h index 3bd8f1a..65d6b06 100644 --- a/colors.h +++ b/colors.h @@ -1,10 +1,15 @@ #ifndef COLORS_INCLUDED #define COLORS_INCLUDED -#include "types.h" #include "termbox.h" #define CLRS_LEN 13 +#ifdef __OpenBSD__ +#include "sys/types.h" +#else +#include "types.h" +#endif + #define RED 0xdd1111 #define BLACK 0x000000 #define YELLOW 0xff7700 diff --git a/draw.c b/draw.c index 5a81f51..20eebed 100644 --- a/draw.c +++ b/draw.c @@ -4,11 +4,16 @@ #include "args.h" #include "termbox.h" -#include "types.h" #include "draw.h" #include "colors.h" #include "output.h" +#ifdef __OpenBSD__ +#include "sys/types.h" +#else +#include "types.h" +#endif + // arguments extern struct Options *opts; @@ -20,8 +25,8 @@ init ( struct buffer *buf ) buf->width = tb_width(); buf->height = tb_height(); - usize len = buf->width * buf->height; - buf->buf = (u8*) malloc(len); + size_t len = buf->width * buf->height; + buf->buf = (uint8_t*) malloc(len); len -= buf->width; if (buf->buf == NULL) { @@ -42,15 +47,15 @@ init ( struct buffer *buf ) void dofire ( struct buffer *buf ) { - usize src; - usize random; - usize dest; + size_t src; + size_t random; + size_t dest; struct tb_cell *realbuf = tb_cell_buffer(); - for (usize x = 0; x < buf->width; ++x) + for (size_t x = 0; x < buf->width; ++x) { - for (usize y = 1; y < buf->height; ++y) + for (size_t y = 1; y < buf->height; ++y) { src = y * buf->width + x; random = (rand() % 7) & 3; diff --git a/draw.h b/draw.h index d91525b..974265e 100644 --- a/draw.h +++ b/draw.h @@ -1,14 +1,18 @@ #ifndef DRAW_INCLUDED #define DRAW_INCLUDED +#ifdef __OpenBSD__ +#include "sys/types.h" +#else #include "types.h" +#endif typedef struct buffer { - usize width; - usize height; + size_t width; + size_t height; - u8* buf; + uint8_t* buf; } buffer; void init ( struct buffer *buf ); diff --git a/main.c b/main.c index 180deb4..e494e36 100644 --- a/main.c +++ b/main.c @@ -3,10 +3,15 @@ #include "bool.h" #include "output.h" #include "draw.h" -#include "types.h" #include "termbox.h" #include "args.h" +#ifdef __OpenBSD__ +#include "sys/types.h" +#else +#include "types.h" +#endif + #define VERSION "0.2.0" // argument parsing (args.h) @@ -25,7 +30,7 @@ main ( int argc, char *argv[] ) // default args opts->refresh_rate = 5; opts->truecolor = FALSE; - usize output_mode = TB_OUTPUT_NORMAL; + size_t output_mode = TB_OUTPUT_NORMAL; // argument parsing argv0 = argv[0]; @@ -75,7 +80,7 @@ main ( int argc, char *argv[] ) tb_present(); // event handling - int err = (usize) tb_peek_event(&e, opts->refresh_rate); + int err = (size_t) tb_peek_event(&e, opts->refresh_rate); if (err < 0) continue; diff --git a/makefile b/makefile index 3245e26..7c17d60 100644 --- a/makefile +++ b/makefile @@ -8,7 +8,7 @@ NAME = fire WARNING = -Wall -Wextra -pedantic -Wmissing-prototypes \ -Wold-style-definition -Werror -INC = -Isub/termbox_next/src -Isub/ccommon/ +INC = -Isub/termbox_next/src CC = gcc CFLAGS = -std=c99 -O3 $(WARNING) $(INC) diff --git a/sub/ccommon b/sub/ccommon deleted file mode 160000 index 4a52d51..0000000 --- a/sub/ccommon +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4a52d5153f63b20691410debdaba619f7923e493 diff --git a/sub/termbox_next b/sub/termbox_next index 2312da1..7b85905 160000 --- a/sub/termbox_next +++ b/sub/termbox_next @@ -1 +1 @@ -Subproject commit 2312da153e44face7bb45aa2798ec284289c17ca +Subproject commit 7b85905531bf9e5908c67276dac55d3241361f20