mirror of https://github.com/djcb/mu.git
* Merge branch 'master' of github.com:djcb/mu
This commit is contained in:
commit
92be7368c8
22
lib/mu-str.c
22
lib/mu-str.c
|
@ -1056,15 +1056,19 @@ mu_str_remove_ctrl_in_place (char *str)
|
|||
if (!iscntrl(*cur))
|
||||
continue;
|
||||
|
||||
/* control char detected... */
|
||||
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;
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue