[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] _rl_untranslate_macro_value with meta control chars
From: |
Grisha Levit |
Subject: |
[PATCH] _rl_untranslate_macro_value with meta control chars |
Date: |
Thu, 3 Aug 2023 06:24:25 -0400 |
When printing a macro, any character with the 8th bit set will be printed
as `\M-' followed by the literal "unmetafied" character, even if the latter
is a control character:
$ bind '"_": "\201"'; bind -s | cat -v
"_": "\M-^A"
Or is a null byte:
$ bind '"1PI": "π"'; bind -s
"1PI": "\M-O\M-"
$ bind '"2PI": "ππ"'; bind -s
"2PI": "\M-O\M-"
---
diff --git a/lib/readline/bind.c b/lib/readline/bind.c
index a8b139f0..4811370b 100644
--- a/lib/readline/bind.c
+++ b/lib/readline/bind.c
@@ -732,7 +732,7 @@ _rl_untranslate_macro_value (char *seq, int use_escapes)
char *ret, *r, *s;
int c;
- r = ret = (char *)xmalloc (7 * strlen (seq) + 1);
+ r = ret = (char *)xmalloc (10 * strlen (seq) + 1);
for (s = seq; *s; s++)
{
c = *s;
@@ -743,7 +743,8 @@ _rl_untranslate_macro_value (char *seq, int use_escapes)
*r++ = '-';
c = UNMETA (c);
}
- else if (c == ESC)
+
+ if (c == ESC)
{
*r++ = '\\';
c = 'e';
@@ -768,12 +769,7 @@ _rl_untranslate_macro_value (char *seq, int use_escapes)
c = '?';
}
- if (c == ESC)
- {
- *r++ = '\\';
- c = 'e';
- }
- else if (c == '\\' || c == '"')
+ if (c == '\\' || c == '"')
*r++ = '\\';
*r++ = (unsigned char)c;
- [PATCH] _rl_untranslate_macro_value with meta control chars,
Grisha Levit <=