lib/mu-str.c: squash white space ctrl chars to spaces
When processing multiple lines for a subject line separated by TAB characters we don't want to eliminate the control character totally but replace it with a simple space. I've left the control handling as before for non-white space characters. Signed-off-by: Alex Bennée <alex@bennee.com>
This commit is contained in:
@ -1056,16 +1056,20 @@ mu_str_remove_ctrl_in_place (char *str)
|
|||||||
if (!iscntrl(*cur))
|
if (!iscntrl(*cur))
|
||||||
continue;
|
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));
|
gstr = g_string_sized_new (strlen (str));
|
||||||
for (cur = str; *cur; ++cur)
|
for (cur = str; *cur; ++cur)
|
||||||
if (!iscntrl (*cur))
|
if (!iscntrl (*cur))
|
||||||
g_string_append_c (gstr, *cur);
|
g_string_append_c (gstr, *cur);
|
||||||
memcpy (str, gstr->str, gstr->len); /* fits */
|
memcpy (str, gstr->str, gstr->len); /* fits */
|
||||||
g_string_free (gstr, TRUE);
|
g_string_free (gstr, TRUE);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user