summaryrefslogtreecommitdiff
path: root/sfeed_opml_import.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2018-09-07 19:00:57 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2018-09-07 19:00:57 +0200
commit5c5a526d0abe22cb7fc30707bd14f09d8b5d1f9c (patch)
treea6136585a4a6ab6ab4160459ee5703606b44762c /sfeed_opml_import.c
parent04a72b9634ada77f59f409989d36cb2063d93cb4 (diff)
fix many undefined behaviour in usage of ctype functions
- cast all ctype(3) function argument to (unsigned char) to avoid UB POSIX says: "The c argument is an int, the value of which the application shall ensure is a character representable as an unsigned char or equal to the value of the macro EOF. If the argument has any other value, the behavior is undefined." Many libc cast implicitly the value, but NetBSD does not, which is probably the correct thing to interpret it. - no need to cast for putchar + rename some fputc(..., stdout) to putchar POSIX says: "The fputc() function shall write the byte specified by c (converted to an unsigned char) to the output stream pointed to by stream [...]" Major thanks to Leonardo Taccari <iamleot@gmail.com> for reporting and testing it on NetBSD!
Diffstat (limited to 'sfeed_opml_import.c')
-rw-r--r--sfeed_opml_import.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sfeed_opml_import.c b/sfeed_opml_import.c
index a254733..361b80f 100644
--- a/sfeed_opml_import.c
+++ b/sfeed_opml_import.c
@@ -18,14 +18,14 @@ static void
printsafe(const char *s)
{
for (; *s; s++) {
- if (iscntrl((int)*s))
+ if (iscntrl((unsigned char)*s))
continue;
else if (*s == '\\')
fputs("\\\\", stdout);
else if (*s == '\'')
fputs("'\\''", stdout);
else
- putchar((int)*s);
+ putchar(*s);
}
}