Commit 31b3a2d2 authored by Hisham Muhammad's avatar Hisham Muhammad
Browse files

catch nonprintable characters

parent 385a7dbe
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <curses.h> #include <curses.h>
#include <ctype.h>
#include "debug.h" #include "debug.h"
#include <assert.h> #include <assert.h>
...@@ -89,7 +90,8 @@ int RichString_findChar(RichString *this, char c, int start) { ...@@ -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) { inline void RichString_appendn(RichString* this, int attrs, char* data_c, int len) {
int last = MIN(RICHSTRING_MAXLEN - 1, len + this->len); int last = MIN(RICHSTRING_MAXLEN - 1, len + this->len);
for (int i = this->len, j = 0; i < last; i++, j++) 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->chstr[last] = 0;
this->len = last; this->len = last;
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <curses.h> #include <curses.h>
#include <ctype.h>
#include "debug.h" #include "debug.h"
#include <assert.h> #include <assert.h>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment