bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#44155: Print integers as characters


From: Eli Zaretskii
Subject: bug#44155: Print integers as characters
Date: Sun, 01 Nov 2020 17:13:46 +0200

> From: Juri Linkov <juri@linkov.net>
> Cc: Eli Zaretskii <eliz@gnu.org>,  44155@debbugs.gnu.org,
>   schwab@linux-m68k.org
> 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

If a test fails, it is better to fix the test and not make the code
less powerful, don't you agree?

To produce 4194176 from ?\200, one way is this:

  (decode-char 'eight-bit ?\200)

Can't this be used in the test?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]