aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2020-09-27 08:26:56 +0300
committerEli Zaretskii2020-09-27 08:26:56 +0300
commit768676f74f093e75e2d7e04e18e1fd1836d1e7e9 (patch)
tree76171792901904f54cf5c3158a20ab8441f48899 /src
parent8c569683f2ee5d14040f5605fd0570b2eb009c05 (diff)
downloademacs-768676f74f093e75e2d7e04e18e1fd1836d1e7e9.tar.gz
emacs-768676f74f093e75e2d7e04e18e1fd1836d1e7e9.zip
Improve display of raw bytes in the echo-area
* src/print.c (print_object): When printing a unibyte string, convert non-ASCII bytes to their character code, before sending them to 'printchar'. (Bug#43632)
Diffstat (limited to 'src')
-rw-r--r--src/print.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/src/print.c b/src/print.c
index 0ecc98f37bf..dca095f2812 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1929,7 +1929,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1929 ptrdiff_t i, i_byte; 1929 ptrdiff_t i, i_byte;
1930 ptrdiff_t size_byte; 1930 ptrdiff_t size_byte;
1931 /* True means we must ensure that the next character we output 1931 /* True means we must ensure that the next character we output
1932 cannot be taken as part of a hex character escape. */ 1932 cannot be taken as part of a hex character escape. */
1933 bool need_nonhex = false; 1933 bool need_nonhex = false;
1934 bool multibyte = STRING_MULTIBYTE (obj); 1934 bool multibyte = STRING_MULTIBYTE (obj);
1935 1935
@@ -1976,25 +1976,29 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1976 /* If we just had a hex escape, and this character 1976 /* If we just had a hex escape, and this character
1977 could be taken as part of it, 1977 could be taken as part of it,
1978 output `\ ' to prevent that. */ 1978 output `\ ' to prevent that. */
1979 if (c_isxdigit (c)) 1979 if (c_isxdigit (c))
1980 { 1980 {
1981 if (need_nonhex) 1981 if (need_nonhex)
1982 print_c_string ("\\ ", printcharfun); 1982 print_c_string ("\\ ", printcharfun);
1983 printchar (c, printcharfun); 1983 printchar (c, printcharfun);
1984 } 1984 }
1985 else if (c == '\n' && print_escape_newlines 1985 else if (c == '\n' && print_escape_newlines
1986 ? (c = 'n', true) 1986 ? (c = 'n', true)
1987 : c == '\f' && print_escape_newlines 1987 : c == '\f' && print_escape_newlines
1988 ? (c = 'f', true) 1988 ? (c = 'f', true)
1989 : c == '\"' || c == '\\') 1989 : c == '\"' || c == '\\')
1990 { 1990 {
1991 printchar ('\\', printcharfun); 1991 printchar ('\\', printcharfun);
1992 printchar (c, printcharfun); 1992 printchar (c, printcharfun);
1993 } 1993 }
1994 else if (print_escape_control_characters && c_iscntrl (c)) 1994 else if (print_escape_control_characters && c_iscntrl (c))
1995 octalout (c, SDATA (obj), i_byte, size_byte, printcharfun); 1995 octalout (c, SDATA (obj), i_byte, size_byte, printcharfun);
1996 else 1996 else if (!multibyte
1997 printchar (c, printcharfun); 1997 && SINGLE_BYTE_CHAR_P (c)
1998 && !ASCII_CHAR_P (c))
1999 printchar (BYTE8_TO_CHAR (c), printcharfun);
2000 else
2001 printchar (c, printcharfun);
1998 need_nonhex = false; 2002 need_nonhex = false;
1999 } 2003 }
2000 } 2004 }
@@ -2024,7 +2028,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
2024 && len == size_byte); 2028 && len == size_byte);
2025 2029
2026 if (! NILP (Vprint_gensym) 2030 if (! NILP (Vprint_gensym)
2027 && !SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P (obj)) 2031 && !SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P (obj))
2028 print_c_string ("#:", printcharfun); 2032 print_c_string ("#:", printcharfun);
2029 else if (size_byte == 0) 2033 else if (size_byte == 0)
2030 { 2034 {
@@ -2047,7 +2051,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
2047 || c == ',' || c == '.' || c == '`' 2051 || c == ',' || c == '.' || c == '`'
2048 || c == '[' || c == ']' || c == '?' || c <= 040 2052 || c == '[' || c == ']' || c == '?' || c <= 040
2049 || c == NO_BREAK_SPACE 2053 || c == NO_BREAK_SPACE
2050 || confusing) 2054 || confusing)
2051 { 2055 {
2052 printchar ('\\', printcharfun); 2056 printchar ('\\', printcharfun);
2053 confusing = false; 2057 confusing = false;
@@ -2112,7 +2116,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
2112 2116
2113 if (!NILP (Vprint_circle)) 2117 if (!NILP (Vprint_circle))
2114 { 2118 {
2115 /* With the print-circle feature. */ 2119 /* With the print-circle feature. */
2116 Lisp_Object num = Fgethash (obj, Vprint_number_table, 2120 Lisp_Object num = Fgethash (obj, Vprint_number_table,
2117 Qnil); 2121 Qnil);
2118 if (FIXNUMP (num)) 2122 if (FIXNUMP (num))
@@ -2164,7 +2168,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
2164 { 2168 {
2165 int len; 2169 int len;
2166 /* We're in trouble if this happens! 2170 /* We're in trouble if this happens!
2167 Probably should just emacs_abort (). */ 2171 Probably should just emacs_abort (). */
2168 print_c_string ("#<EMACS BUG: INVALID DATATYPE ", printcharfun); 2172 print_c_string ("#<EMACS BUG: INVALID DATATYPE ", printcharfun);
2169 if (VECTORLIKEP (obj)) 2173 if (VECTORLIKEP (obj))
2170 len = sprintf (buf, "(PVEC 0x%08zx)", (size_t) ASIZE (obj)); 2174 len = sprintf (buf, "(PVEC 0x%08zx)", (size_t) ASIZE (obj));