Subject: Re: bug#44155: Print integers as characters

From: Juri Linkov <[email-masked]>
Date: Sun, 01 Nov 2020 09:58:25 +0200

> New test fails on some systems.
>
>       (equal
>        (-1 0 1 80 4194175 128 255 4194304)
>        (-1 0 1 80 4194175 4194176 4194303 4194304))
>       :value nil :explanation
>       (list-elt 5
>                 (different-atoms
>                  (128 "#x80" "?")
>                  (4194176 "#x3fff80" "?\200")))))

This is because 4194176 is printed as ?\200 that is parsed as 128.

This patch should fix test failures by printing integers
for ambiguous characters.  I'm sure no user would complain
that numbers between 4194176 and 4194303 are printed as integers.

diff --git a/src/print.c b/src/print.c
index fa65a3cb26..49daf753bd 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1912,7 +1912,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
 	intmax_t i;
 
 	if (EQ (Vinteger_output_format, Qt) && CHARACTERP (obj)
-	    && (c = XFIXNUM (obj)))
+	    && (c = XFIXNUM (obj)) && ! CHAR_BYTE8_P (c))
 	  {
 	    printchar ('?', printcharfun);
 	    if (escapeflag