From 9dcb9e16960e48546be5c79d27db28256d71079f Mon Sep 17 00:00:00 2001 From: Ed Kellett Date: Tue, 25 Sep 2018 12:48:22 +0100 Subject: [PATCH 1/2] Fix strip_unprintable on high bit bytes --- include/inline/stringops.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/inline/stringops.h b/include/inline/stringops.h index cf5d98fb..bd930986 100644 --- a/include/inline/stringops.h +++ b/include/inline/stringops.h @@ -83,9 +83,9 @@ strip_colour(char *string) static inline char * strip_unprintable(char *string) { - char *c = string; - char *c2 = string; - char *last_non_space = NULL; + unsigned char *c = (unsigned char *)string; + unsigned char *c2 = (unsigned char *)string; + unsigned char *last_non_space = NULL; /* c is source, c2 is target */ for(; c && *c; c++) From 12b3a184bc8020d982699500fd7fa49e18bd0021 Mon Sep 17 00:00:00 2001 From: Janik Kleinhoff Date: Thu, 25 Oct 2018 20:31:46 +0000 Subject: [PATCH 2/2] strip_unprintable: clarify type conversion This type conversion is more easily shown to work as intended than the conversion introduced in 9dcb9e169. --- include/inline/stringops.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/inline/stringops.h b/include/inline/stringops.h index bd930986..b5616081 100644 --- a/include/inline/stringops.h +++ b/include/inline/stringops.h @@ -83,9 +83,9 @@ strip_colour(char *string) static inline char * strip_unprintable(char *string) { - unsigned char *c = (unsigned char *)string; - unsigned char *c2 = (unsigned char *)string; - unsigned char *last_non_space = NULL; + char *c = string; + char *c2 = string; + char *last_non_space = NULL; /* c is source, c2 is target */ for(; c && *c; c++) @@ -109,7 +109,7 @@ strip_unprintable(char *string) *c2++ = *c; break; default: - if (*c < 32) + if ((unsigned char)*c < 32) break; *c2++ = *c; last_non_space = c2;