diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2014-09-20 18:27:03 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2014-09-20 18:28:08 +0200 |
commit | b9571ec01ff2a23475ca1a8a6b9910f49206b4ff (patch) | |
tree | ab19647145c30479fe4f56860e11c52e01e34831 | |
parent | 38a0077033ebdd51f730852256352a4663b0f034 (diff) | |
download | ponymap-b9571ec01ff2a23475ca1a8a6b9910f49206b4ff.tar.gz ponymap-b9571ec01ff2a23475ca1a8a6b9910f49206b4ff.tar.xz ponymap-b9571ec01ff2a23475ca1a8a6b9910f49206b4ff.zip |
Filter out any garbage in the scan output
-rw-r--r-- | ponymap.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -1174,6 +1174,20 @@ struct node_print_data struct node_print_level **tail; ///< Where to place further levels }; +static char * +node_escape_text (const char *text) +{ + struct str filtered; + str_init (&filtered); + + char c; + while ((c = *text++)) + str_append_c (&filtered, + (isascii (c) && (isgraph (c) || c == ' ')) ? c : '.'); + + return str_steal (&filtered); +} + static void node_print_tree_level (struct node *self, struct node_print_data *data) { @@ -1191,10 +1205,12 @@ node_print_tree_level (struct node *self, struct node_print_data *data) fputs (indent.str, stdout); str_free (&indent); + char *escaped = node_escape_text (self->text); self->bold - ? print_bold (stdout, self->text) - : fputs (self->text, stdout); + ? print_bold (stdout, escaped) + : fputs (escaped, stdout); fputc ('\n', stdout); + free (escaped); struct node_print_level level; level.next = NULL; |