summaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2022-03-28 18:36:20 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2022-03-28 18:36:20 +0200
commit880256b8bfde746cd54993f3abcb4dc648895af7 (patch)
treec68d1aca780ef63cabb57e30c16e75e7b910c3e5 /util.h
parenta58fa45f25da4f18d7b8c1a815884f67b965406f (diff)
compatibility: replace iscntrl with own ISCNTRL macro
It is unspecified if the C locale iscntrl is compatible with ASCII or not. Noticed when testing on OpenBSD 3.8 which uses extended ASCII and also uses the C1 range for control-characters. This breaks support with UTF-8. Reference: https://en.wikipedia.org/wiki/C0_and_C1_control_codes#C1_control_codes_for_general_use C1 table. Force an own definition of an ASCII-compatible control-character range since sfeed expects input to be UTF-8 (or converted from iconv) and so output to be UTF-8 aswell.
Diffstat (limited to 'util.h')
-rw-r--r--util.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/util.h b/util.h
index 7923cdc..c68cef4 100644
--- a/util.h
+++ b/util.h
@@ -8,6 +8,9 @@
#define unveil(p1,p2) 0
#endif
+/* control-character in the ASCII range 0-127: compatible with UTF-8 */
+#define ISCNTRL(c) ((c) < ' ' || (c) == 0x7f)
+
#undef strcasestr
char *strcasestr(const char *, const char *);
#undef strlcat