fix a char signedness bug such that this testing code becomes able
authorschwarze <schwarze@openbsd.org>
Tue, 14 May 2024 00:31:48 +0000 (00:31 +0000)
committerschwarze <schwarze@openbsd.org>
Tue, 14 May 2024 00:31:48 +0000 (00:31 +0000)
to display the contents of databases containing UTF-8 strings
on signed char architectures:
for example on i386 and amd64, UTF-8 bytes are negative...

regress/usr.bin/mandoc/db/dbm_dump/dbm_dump.c

index 22761e2..f4e967e 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dbm_dump.c,v 1.2 2016/08/30 22:20:03 schwarze Exp $ */
+/*     $OpenBSD: dbm_dump.c,v 1.3 2024/05/14 00:31:48 schwarze Exp $ */
 /*
  * Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
  *
@@ -196,7 +196,7 @@ dump_str(const char **cp)
                printf("(NULL)");
                return;
        }
-       if (**cp <= (char)NAME_MASK) {
+       if ((unsigned char)**cp <= NAME_MASK) {
                putchar('[');
                if (**cp & NAME_FILE)
                        putchar('f');