From 31b3a2d2db158dd98da8f02e05ea348c4b564f0c Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 11 Mar 2009 13:51:50 +0000 Subject: [PATCH] catch nonprintable characters --- RichString.c | 4 +++- RichString.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/RichString.c b/RichString.c index c397f3f1..fbcb17f1 100644 --- a/RichString.c +++ b/RichString.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "debug.h" #include @@ -89,7 +90,8 @@ int RichString_findChar(RichString *this, char c, int start) { inline void RichString_appendn(RichString* this, int attrs, char* data_c, int len) { int last = MIN(RICHSTRING_MAXLEN - 1, len + this->len); for (int i = this->len, j = 0; i < last; i++, j++) - this->chstr[i] = data_c[j] | attrs; + this->chstr[i] = (isprint(data_c[j]) ? data_c[j] : '?') | attrs; + this->chstr[last] = 0; this->len = last; } diff --git a/RichString.h b/RichString.h index 7f777bba..036a24a4 100644 --- a/RichString.h +++ b/RichString.h @@ -12,6 +12,7 @@ #include #include #include +#include #include "debug.h" #include