Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-08-21 16:03:55 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2021-08-22 01:09:57 +0300
commit74c4f356aee9c64978a881e5760055d0e3510a6a (patch)
treeaac8d2936542b32caabed72f493d82a53b003369 /editors
parent08ad934ac4e341c35497497f4d617a514de524a1 (diff)
vi: code shrink print_literal()
Simplify the function print_literal() which is used to format a string that may contain unprintable characters or control characters. - Unprintable characters were being displayed in normal text rather than the bold used for the rest of the message. This doesn't seem particularly helpful and it upsets the calculation of the width of the message in show_status_line(). Use '?' rather than '.' for unprintable characters. - Newlines in the string were displayed as both '^J' and '$', which is somewhat redundant. function old new delta not_implemented 199 108 -91 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-91) Total: -91 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r--editors/vi.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/editors/vi.c b/editors/vi.c
index eee5e0ed2..e4ba2b2b0 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -1377,21 +1377,14 @@ static void print_literal(char *buf, const char *s)
char *d;
unsigned char c;
- buf[0] = '\0';
if (!s[0])
s = "(NULL)";
d = buf;
for (; *s; s++) {
- int c_is_no_print;
-
c = *s;
- c_is_no_print = (c & 0x80) && !Isprint(c);
- if (c_is_no_print) {
- strcpy(d, ESC_NORM_TEXT);
- d += sizeof(ESC_NORM_TEXT)-1;
- c = '.';
- }
+ if ((c & 0x80) && !Isprint(c))
+ c = '?';
if (c < ' ' || c == 0x7f) {
*d++ = '^';
c |= '@'; // 0x40
@@ -1400,14 +1393,6 @@ static void print_literal(char *buf, const char *s)
}
*d++ = c;
*d = '\0';
- if (c_is_no_print) {
- strcpy(d, ESC_BOLD_TEXT);
- d += sizeof(ESC_BOLD_TEXT)-1;
- }
- if (*s == '\n') {
- *d++ = '$';
- *d = '\0';
- }
if (d - buf > MAX_INPUT_LEN - 10) // paranoia
break;
}