mirror of https://github.com/MidnightCommander/mc
* util.c (strip_ctrl_codes): Rewrite using pointers. Fix
stripping sequences beginning with "e[". Check is_printable().
This commit is contained in:
parent
1d900645b8
commit
b5e64692df
|
@ -1,5 +1,8 @@
|
||||||
2001-08-15 Pavel Roskin <proski@gnu.org>
|
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.
|
* man2hlp.c: Remove HTML support. Remove old link support.
|
||||||
Warning fixes.
|
Warning fixes.
|
||||||
(print_string): Handle backslashes in verbatim mode too.
|
(print_string): Handle backslashes in verbatim mode too.
|
||||||
|
|
24
src/util.c
24
src/util.c
|
@ -841,28 +841,28 @@ char *skip_numbers (char *s)
|
||||||
* terminfo databases, except the Hewlett-Packard 70092 and some Wyse
|
* terminfo databases, except the Hewlett-Packard 70092 and some Wyse
|
||||||
* terminals. If I hear from a single person who uses such a terminal
|
* 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)
|
* with MC, I'll be glad to add support for it. (Dugan)
|
||||||
|
* Non-printable characters are also removed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *strip_ctrl_codes (char *s)
|
char *strip_ctrl_codes (char *s)
|
||||||
{
|
{
|
||||||
int i; /* Current length of the string's correct (stripped) prefix */
|
char *w; /* Current position where the stripped data is written */
|
||||||
int j; /* Number of control characters we have skipped so far */
|
char *r; /* Current position where the original data is read */
|
||||||
|
|
||||||
if (!s)
|
if (!s)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (i = 0, j = 0; s [i+j]; ++i)
|
for (w = s, r = s; *r; ++r)
|
||||||
if (s [i+j] != ESC_CHAR){
|
if (*r != ESC_CHAR){
|
||||||
if (j)
|
if (is_printable(*r))
|
||||||
s [i] = s [i+j];
|
*w++ = *r;
|
||||||
} else {
|
} else {
|
||||||
++j;
|
if (*(++r) == '[') {
|
||||||
if (s [i+j++] == '[')
|
while (strchr ("0123456789;?", *(++r)))
|
||||||
while (strchr ("0123456789;?", s [i+j++]))
|
|
||||||
/* Skip the control sequence's arguments */ ;
|
/* Skip the control sequence's arguments */ ;
|
||||||
--i;
|
}
|
||||||
}
|
}
|
||||||
s[i] = 0;
|
*w = 0;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue