From e241c5b56674e0b56b46e708602169d4948044a8 Mon Sep 17 00:00:00 2001 From: chaoskagami Date: Tue, 28 Jun 2016 14:49:23 -0400 Subject: [PATCH] Hopefully fix crash on older glibc by using a custom isprint (not the best fix, but eh) --- bdf.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bdf.c b/bdf.c index 83876a3..d9d401f 100644 --- a/bdf.c +++ b/bdf.c @@ -36,6 +36,15 @@ #include "bdf.h" +static int printable(unsigned character) { + // This is a workaround for older glibc - isprint doesn't + // return the needed results (and it's only standard behavior for 0-255 anyways) + + if (character < 0x20 || character == 0x7f || character > 0xff) + return 0; + return 1; +} + // check if 'buf' starts with 'key' and store pointer to the argument static char *key_arg(char *buf, const char *key, char **arg) { @@ -266,12 +275,12 @@ bdfe_t *bdf_convert(const char *name, unsigned gmin, unsigned gmax, unsigned asc printf("0x%02X,", gout[i]); } printf(" /* %5d", idx); - if (isprint(idx)) + if (printable(idx)) printf(" '%c'", idx); printf(" */\n"); } else { - printf("/* %5d '%c' |", idx, isprint(idx) ? idx : ' '); + printf("/* %5d '%c' |", idx, printable(idx) ? idx : ' '); for(i = 0; i < gw; i++) printf("%d", i); printf("| */\n"); -- 2.39.5