* util.c (strip_ctrl_codes): Rewrite using pointers. Fix

stripping sequences beginning with "e[".  Check is_printable().
This commit is contained in:
Pavel Roskin 2001-08-16 03:52:51 +00:00
parent 1d900645b8
commit b5e64692df
2 changed files with 15 additions and 12 deletions

View File

@ -1,5 +1,8 @@
2001-08-15 Pavel Roskin <proski@gnu.org>
* util.c (strip_ctrl_codes): Rewrite using pointers. Fix
stripping sequences beginning with "\e[". Check is_printable().
* man2hlp.c: Remove HTML support. Remove old link support.
Warning fixes.
(print_string): Handle backslashes in verbatim mode too.

View File

@ -841,28 +841,28 @@ char *skip_numbers (char *s)
* terminfo databases, except the Hewlett-Packard 70092 and some Wyse
* terminals. If I hear from a single person who uses such a terminal
* with MC, I'll be glad to add support for it. (Dugan)
* Non-printable characters are also removed.
*/
char *strip_ctrl_codes (char *s)
{
int i; /* Current length of the string's correct (stripped) prefix */
int j; /* Number of control characters we have skipped so far */
char *w; /* Current position where the stripped data is written */
char *r; /* Current position where the original data is read */
if (!s)
return 0;
for (i = 0, j = 0; s [i+j]; ++i)
if (s [i+j] != ESC_CHAR){
if (j)
s [i] = s [i+j];
for (w = s, r = s; *r; ++r)
if (*r != ESC_CHAR){
if (is_printable(*r))
*w++ = *r;
} else {
++j;
if (s [i+j++] == '[')
while (strchr ("0123456789;?", s [i+j++]))
if (*(++r) == '[') {
while (strchr ("0123456789;?", *(++r)))
/* Skip the control sequence's arguments */ ;
--i;
}
}
s[i] = 0;
*w = 0;
return s;
}