]> Chaos Git - corbenik/bdfe.git/commitdiff
Hopefully fix crash on older glibc by using a custom isprint (not the best fix, but eh)
authorchaoskagami <chaos.kagami@gmail.com>
Tue, 28 Jun 2016 18:49:23 +0000 (14:49 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Tue, 28 Jun 2016 18:49:23 +0000 (14:49 -0400)
bdf.c

diff --git a/bdf.c b/bdf.c
index 83876a38e5e830cfcd9e71d13559847aa4070a1b..d9d401fee0d3b3593ccee9822a832115ea38fa66 100644 (file)
--- a/bdf.c
+++ b/bdf.c
 
 #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");