Merge pull request #422 from stsquad/remove-ctrl-squash-space

* lib/mu-str.c: squash white space ctrl chars to spaces (#390)
This commit is contained in:
Dirk-Jan C. Binnema
2014-05-13 23:02:26 -07:00

View File

@ -1056,16 +1056,20 @@ mu_str_remove_ctrl_in_place (char *str)
if (!iscntrl(*cur))
continue;
/* control char detected... */
if (isspace(*cur)) {
/* squash special white space into a simple space */
*cur = ' ';
} else {
/* remove other control characters */
gstr = g_string_sized_new (strlen (str));
for (cur = str; *cur; ++cur)
if (!iscntrl (*cur))
g_string_append_c (gstr, *cur);
memcpy (str, gstr->str, gstr->len); /* fits */
g_string_free (gstr, TRUE);
break;
}
}
return str;
}