From 3fbe6edb3f2250fcf494e70105039a4f32c52066 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 6 Apr 2021 03:20:43 +0200 Subject: Use libsimple instead of libcore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 9 ++-- backlight.c | 2 +- clock.c | 1 - common.c | 2 - common.h | 135 +++--------------------------------------------------------- config.mk | 2 +- dice.c | 3 +- 7 files changed, 12 insertions(+), 142 deletions(-) delete mode 100644 common.c diff --git a/Makefile b/Makefile index 5515f77..7e38b58 100644 --- a/Makefile +++ b/Makefile @@ -15,23 +15,20 @@ BIN_ =\ stopwatch\ timer -OBJ =\ - common.o\ - $(BIN_:=.o) - +OBJ = $(BIN_:=.o) BIN = $(BIN_:=.bin) MAN1 = $(BIN_:=.1) all: $(BIN) $(OBJ): $(@:.o=.c) $(HDR) -$(BIN): $(@:.bin=.o) common.o +$(BIN): $(@:.bin=.o) .c.o: $(CC) -c -o $@ $< $(CFLAGS) .o.bin: - $(CC) -o $@ $< common.o $(LDFLAGS) + $(CC) -o $@ $< $(LDFLAGS) large.h: large.sh ./large.sh > $@ diff --git a/backlight.c b/backlight.c index 966b973..7d74599 100644 --- a/backlight.c +++ b/backlight.c @@ -425,7 +425,7 @@ main(int argc, char *argv[]) stpcpy(p, "/brightness"); if (access(path, F_OK)) continue; - devs = erealloc2(devs, ndevs + 1, sizeof(*devs)); + devs = ereallocn(devs, ndevs + 1, sizeof(*devs), 0); devs[ndevs] = strdup(f->d_name); if (!devs[ndevs++]) eprintf("strdup:"); diff --git a/clock.c b/clock.c index 846854d..fd06edb 100644 --- a/clock.c +++ b/clock.c @@ -1,6 +1,5 @@ /* See LICENSE file for copyright and license details. */ #include "common.h" -#include USAGE("[-u | -v | -w] [-2s]"); diff --git a/common.c b/common.c deleted file mode 100644 index 72692ba..0000000 --- a/common.c +++ /dev/null @@ -1,2 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -char *argv0; diff --git a/common.h b/common.h index 0ee870c..298eff9 100644 --- a/common.h +++ b/common.h @@ -1,131 +1,8 @@ /* See LICENSE file for copyright and license details. */ -#if !defined(_XOPEN_SOURCE) -# define _XOPEN_SOURCE 700 -#elif (_XOPEN_SOURCE + 0 < 700) -# undef _XOPEN_SOURCE -# define _XOPEN_SOURCE 700 -#endif -#ifndef _BSD_SOURCE -# define _BSD_SOURCE -#endif -#ifndef _DEFAULT_SOURCE -# define _DEFAULT_SOURCE -#endif +#include +#include -#include -#include -#include - -#define malloc2 libcore_malloc2 -#define malloc3 libcore_malloc3 -#define calloc3 libcore_calloc3 -#define realloc2 libcore_realloc2 -#define realloc3 libcore_realloc3 -#define enmalloc libcore_enmalloc -#define enmalloc2 libcore_enmalloc2 -#define enmalloc3 libcore_enmalloc3 -#define encalloc libcore_encalloc -#define encalloc3 libcore_encalloc3 -#define enrealloc libcore_enrealloc -#define enrealloc2 libcore_enrealloc2 -#define enrealloc3 libcore_enrealloc3 -#define emalloc(N1) enmalloc(1, (N1)) -#define emalloc2(N1, N2) enmalloc2(1, (N1), (N2)); -#define emalloc3(N1, N2, N3) enmalloc3(1, (N1), (N2), (N3)); -#define ecalloc(N1, N2) encalloc(1, (N1), (N2)); -#define ecalloc3(N1, N2, N3) encalloc3(1, (N1), (N2), (N3)); -#define erealloc(PTR, N1) enrealloc(1, (PTR), (N1)); -#define erealloc2(PTR, N1, N2) enrealloc2(1, (PTR), (N1), (N2)); -#define erealloc3(PTR, N1, N2, N3) enrealloc3(1, (PTR), (N1), (N2), (N3)); - -#define eprintf libcore_eprintf -#define enprintf libcore_enprintf -#define weprintf libcore_weprintf - -#define fshut libcore_fshut -#define efshut libcore_efshut -#define enfshut libcore_enfshut - -#define toji libcore_toji -#define toju libcore_toju -#define tozi libcore_tozi -#define tozu libcore_tozu -#define tolli libcore_tolli -#define tollu libcore_tollu -#define toli libcore_toli -#define tolu libcore_tolu -#define toi libcore_toi -#define tou libcore_tou -#define entoji_flag libcore_entoji_flag -#define entoju_flag libcore_entoju_flag -#define entozi_flag libcore_entozi_flag -#define entozu_flag libcore_entozu_flag -#define entolli_flag libcore_entolli_flag -#define entollu_flag libcore_entollu_flag -#define entoli_flag libcore_entoli_flag -#define entolu_flag libcore_entolu_flag -#define entoi_flag libcore_entoi_flag -#define entou_flag libcore_entou_flag -#define entoji_arg libcore_entoji_arg -#define entoju_arg libcore_entoju_arg -#define entozi_arg libcore_entozi_arg -#define entozu_arg libcore_entozu_arg -#define entolli_arg libcore_entolli_arg -#define entollu_arg libcore_entollu_arg -#define entoli_arg libcore_entoli_arg -#define entolu_arg libcore_entolu_arg -#define entoi_arg libcore_entoi_arg -#define entou_arg libcore_entou_arg -#define etoji_flag(...) libcore_etoji_flag(__VA_ARGS__) -#define etoju_flag(...) libcore_etoju_flag(__VA_ARGS__) -#define etozi_flag(...) libcore_etozi_flag(__VA_ARGS__) -#define etozu_flag(...) libcore_etozu_flag(__VA_ARGS__) -#define etolli_flag(...) libcore_etolli_flag(__VA_ARGS__) -#define etollu_flag(...) libcore_etollu_flag(__VA_ARGS__) -#define etoli_flag(...) libcore_etoli_flag(__VA_ARGS__) -#define etolu_flag(...) libcore_etolu_flag(__VA_ARGS__) -#define etoi_flag(...) libcore_etoi_flag(__VA_ARGS__) -#define etou_flag(...) libcore_etou_flag(__VA_ARGS__) -#define etoji_arg(...) libcore_etoji_arg(__VA_ARGS__) -#define etoju_arg(...) libcore_etoju_arg(__VA_ARGS__) -#define etozi_arg(...) libcore_etozi_arg(__VA_ARGS__) -#define etozu_arg(...) libcore_etozu_arg(__VA_ARGS__) -#define etolli_arg(...) libcore_etolli_arg(__VA_ARGS__) -#define etollu_arg(...) libcore_etollu_arg(__VA_ARGS__) -#define etoli_arg(...) libcore_etoli_arg(__VA_ARGS__) -#define etolu_arg(...) libcore_etolu_arg(__VA_ARGS__) -#define etoi_arg(...) libcore_etoi_arg(__VA_ARGS__) -#define etou_arg(...) libcore_etou_arg(__VA_ARGS__) -#define tof libcore_tof -#define tolf libcore_tolf -#define tollf libcore_tollf -#define entof_flag libcore_entof_flag -#define entof_arg libcore_entof_arg -#define entolf_flag libcore_entolf_flag -#define entolf_arg libcore_entolf_arg -#define entollf_flag libcore_entollf_flag -#define entollf_arg libcore_entollf_arg -#define etof_flag(...) libcore_etof_flag(__VA_ARGS__) -#define etof_arg(...) libcore_etof_arg(__VA_ARGS__) -#define etolf_flag(...) libcore_etolf_flag(__VA_ARGS__) -#define etolf_arg(...) libcore_etolf_arg(__VA_ARGS__) -#define etollf_flag(...) libcore_etollf_flag(__VA_ARGS__) -#define etollf_arg(...) libcore_etollf_arg(__VA_ARGS__) - - -static inline long int -estrtol(const char *s, int base) -{ - int saved_errno = errno; - long long int ret; - char *end; - errno = 0; - ret = strtol(s, &end, base); - if (errno || *end) { - if (!errno) - errno = EINVAL; - eprintf("strtol %s:", s); - } - errno = saved_errno; - return ret; -} +#include +#include +#include +#include diff --git a/config.mk b/config.mk index 108056d..4792a0b 100644 --- a/config.mk +++ b/config.mk @@ -5,4 +5,4 @@ VIDEO_GROUP = video CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_GNU_SOURCE CFLAGS = -std=c99 -Wall -Wextra -O2 -g $(CPPFLAGS) -LDFLAGS = -lcore +LDFLAGS = -lsimple diff --git a/dice.c b/dice.c index 69fc911..3403c59 100644 --- a/dice.c +++ b/dice.c @@ -1,6 +1,5 @@ /* See LICENSE file for copyright and license details. */ #include "common.h" -#include /* TODO add support for up and down arrows to browse previous entries in the same session */ @@ -74,7 +73,7 @@ parse_dice(const char *s, struct die **dicep, size_t *ndicep) if (!isdigit(*s) && *s != '-' && *s != 'd' && *s != 'D') goto invalid; - dice = erealloc2(dice, ++ndice, sizeof(*dice)); + dice = ereallocn(dice, ++ndice, sizeof(*dice), 0); die = &dice[ndice - 1]; die->count = 1; die->min = 1; -- cgit v1.2.3-70-g09d2