smu

Simple markup processor
git clone https://git.sinitax.com/codemadness/smu
Log | Files | Refs | README | LICENSE | Upstream | sfeed.txt

commit 6c46ee93c22968979bf5a6d5024c42247ec6ffeb
parent 37f6db9f41353d1f93c9a56f06333f2c5223c7c9
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Tue, 11 May 2021 02:21:20 +0200

fix undefined behaviour, cast for ctype functions

Diffstat:
Msmu.c | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/smu.c b/smu.c @@ -166,11 +166,11 @@ dohtml(const char *begin, const char *end, int newblock) if (nohtml || begin + 2 >= end) return 0; p = begin; - if (p[0] != '<' || !isalpha(p[1])) + if (p[0] != '<' || !isalpha((unsigned char)p[1])) return 0; p++; tag = p; - for (; isalnum(*p) && p < end; p++) + for (; isalnum((unsigned char)*p) && p < end; p++) ; tagend = p; if (p > end || tag == tagend) @@ -296,11 +296,11 @@ dolink(const char *begin, const char *end, int newblock) sep = p[0]; /* separator: can be " or ' */ title = p + 1; /* strip trailing whitespace */ - for (linkend = p; linkend > link && isspace(*(linkend - 1)); linkend--) + for (linkend = p; linkend > link && isspace((unsigned char)*(linkend - 1)); linkend--) ; for (titleend = title; titleend < q && *titleend != sep; titleend++) ; - for (p = titleend + 1; p < end && isspace(*p); p++) + for (p = titleend + 1; p < end && isspace((unsigned char)*p); p++) ; /* image dimensions */ if (*p == '=') { @@ -311,7 +311,7 @@ dolink(const char *begin, const char *end, int newblock) } } else { /* strip trailing whitespace */ - for (linkend = q; linkend > link && isspace(*(linkend - 1)); linkend--) + for (linkend = q; linkend > link && isspace((unsigned char)*(linkend - 1)); linkend--) ; }