From 0acf59403fa2a4850af40039dc6b7d04cff48643 Mon Sep 17 00:00:00 2001 From: tater Date: Sun, 24 Jun 2018 20:41:42 -0500 Subject: [PATCH] bugchasing with sloth --- Makefile | 3 +-- tdfiglet.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 21493ce..1a41f7e 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,11 @@ PROG := tdfiglet SRC := tdfiglet.c -CC := cc +CC ?= cc CFLAGS += -std=c99 -Wall UNAME := $(shell sh -c 'uname -s 2>/dev/null') ifeq ($(UNAME),Darwin) - CC := clang CFLAGS += -Wunused-result -Wunused-value LDFLAGS += -liconv endif diff --git a/tdfiglet.c b/tdfiglet.c index f91a1ee..2ce73dd 100644 --- a/tdfiglet.c +++ b/tdfiglet.c @@ -224,12 +224,20 @@ font_t exit(EX_NOINPUT); } - stat(fn, &st); + if (stat(fn, &st)) { + perror(NULL); + exit(EX_OSERR); + } len = st.st_size; map = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0); + if (!map) { + perror(NULL); + exit(EX_OSERR); + } + close(fd); if (!font) { @@ -341,7 +349,6 @@ readchar(int i, glyph_t *glyph, font_t *font) ch = ' '; row++; col = 0; - color = 0; } else { color = *p; p++;