bugchasing

This commit is contained in:
tater 2018-08-06 17:28:19 -04:00
parent 99997d2762
commit 09fbef581e
2 changed files with 14 additions and 14 deletions

View File

@ -4,7 +4,7 @@ PREFIX ?= /usr/local
FONTS := fonts/* FONTS := fonts/*
FONTDIR := $(PREFIX)/share/$(PROG)/fonts FONTDIR := $(PREFIX)/share/$(PROG)/fonts
CC ?= cc CC ?= cc
CFLAGS += -DFONT_DIR=\"$(FONTDIR)\" -std=c99 -Wall CFLAGS += -DFONT_DIR=\"$(FONTDIR)\" -std=c99 -Wall -g
UNAME := $(shell sh -c 'uname -s 2>/dev/null') UNAME := $(shell sh -c 'uname -s 2>/dev/null')
@ -19,10 +19,10 @@ default: $(SRC)
.PHONY: debug clean install .PHONY: debug clean install
install: install:
install -m 0755 -d $(PREFIX)/bin test -d $(FONTDIR) || mkdir -p $(PREFIX)/bin
install -m 0755 -d $(FONTDIR) cp $(PROG) $(PREFIX)/bin
install -m 0755 $(PROG) $(PREFIX)/bin/$(PROG) test -d $(FONTDIR) || mkdir -p $(FONTDIR)
for i in $(FONTS) ; do install -m 0644 $$i $(FONTDIR) ; done for i in $(FONTS) ; do cp -v $$i $(FONTDIR) ; done
debug: $(SRC) debug: $(SRC)
$(CC) -DDEBUG -g $(CFLAGS) $(LDFLAGS) $(SRC) -o $(PROG) $(CC) -DDEBUG -g $(CFLAGS) $(LDFLAGS) $(SRC) -o $(PROG)

View File

@ -143,10 +143,6 @@ main(int argc, char *argv[])
opt.encoding = ENC_UNICODE; opt.encoding = ENC_UNICODE;
char *fontfile = NULL; char *fontfile = NULL;
if (argc < 2) {
usage();
}
while((o = getopt(argc, argv, "f:w:j:c:e:i")) != -1) { while((o = getopt(argc, argv, "f:w:j:c:e:i")) != -1) {
switch (o) { switch (o) {
case 'f': case 'f':
@ -207,6 +203,10 @@ main(int argc, char *argv[])
argc -= optind; argc -= optind;
argv += optind; argv += optind;
if (argc < 1) {
usage();
}
if (!fontfile) { if (!fontfile) {
fontfile = DEFAULT_FONT; fontfile = DEFAULT_FONT;
} }
@ -247,7 +247,7 @@ font_t
sprintf(fn, "%s/%s", FONT_DIR, fn_arg); sprintf(fn, "%s/%s", FONT_DIR, fn_arg);
} else { } else {
fn = malloc(strlen(FONT_DIR) + strlen(fn_arg) + \ fn = malloc(strlen(FONT_DIR) + strlen(fn_arg) + \
strlen(FONT_EXT) + 1); strlen(FONT_EXT) + 2);
sprintf(fn, "%s/%s.%s", FONT_DIR, fn_arg, FONT_EXT); sprintf(fn, "%s/%s.%s", FONT_DIR, fn_arg, FONT_EXT);
} }
} else { } else {
@ -273,7 +273,7 @@ font_t
font = malloc(sizeof(font_t)); font = malloc(sizeof(font_t));
if (stat(fn, &st)) { if (fstat(fd, &st)) {
perror(NULL); perror(NULL);
exit(EX_OSERR); exit(EX_OSERR);
} }
@ -468,8 +468,8 @@ printcolor(uint8_t color)
uint8_t fg = color & 0x0f; uint8_t fg = color & 0x0f;
uint8_t bg = (color & 0xf0) >> 4; uint8_t bg = (color & 0xf0) >> 4;
/* thedraw colors DRK BRT BRT BRT RED BRT */ /* thedraw colors BRT BRT BRT BRT BRT BRT BRT BRT */
/* thedraw colors BLK BLU GRN CYN RED MAG BRN GRY GRY BLU GRN CYN RED PNK YLW WHT */ /* thedraw colors BLK BLU GRN CYN RED MAG BRN GRY BLK BLU GRN CYN RED PNK YLW WHT */
uint8_t fgacolors[] = {30, 34, 32, 36, 31, 35, 33, 37, 90, 94, 92, 96, 91, 95, 93, 97}; uint8_t fgacolors[] = {30, 34, 32, 36, 31, 35, 33, 37, 90, 94, 92, 96, 91, 95, 93, 97};
uint8_t bgacolors[] = {40, 44, 42, 46, 41, 45, 43, 47}; uint8_t bgacolors[] = {40, 44, 42, 46, 41, 45, 43, 47};
uint8_t fgmcolors[] = { 1, 2, 3, 10, 5, 6, 7, 15, 14, 12, 9, 11, 4, 13, 8, 0}; uint8_t fgmcolors[] = { 1, 2, 3, 10, 5, 6, 7, 15, 14, 12, 9, 11, 4, 13, 8, 0};
@ -495,7 +495,7 @@ printrow(const glyph_t *glyph, int row)
uint8_t lastcolor; uint8_t lastcolor;
for (i = 0; i < glyph->width; i++) { for (i = 0; i < glyph->width; i++) {
utfchar = glyph->cell[glyph->width * row + i].utfchar; utfchar = glyph->cell[glyph->width * row + i].utfchar;
color = glyph->cell[glyph->width * row + i].color; color = glyph->cell[glyph->width * row + i].color;
if (i == 0 || color != lastcolor) { if (i == 0 || color != lastcolor) {