From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#44155: Print integers as characters Date: Sun, 25 Oct 2020 19:22:46 +0200 Message-ID: <83mu0afcex.fsf@gnu.org> References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11260"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 44155@debbugs.gnu.org, schwab@linux-m68k.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 25 18:24:09 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kWjkX-0002oN-BF for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 25 Oct 2020 18:24:09 +0100 Original-Received: from localhost ([::1]:34932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kWjkW-0006zM-DW for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 25 Oct 2020 13:24:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kWjkQ-0006z2-NP for bug-gnu-emacs@gnu.org; Sun, 25 Oct 2020 13:24:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54246) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kWjkQ-00005y-EB for bug-gnu-emacs@gnu.org; Sun, 25 Oct 2020 13:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kWjkQ-0007ng-AW for bug-gnu-emacs@gnu.org; Sun, 25 Oct 2020 13:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Oct 2020 17:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44155 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 44155-submit@debbugs.gnu.org id=B44155.160364658429917 (code B ref 44155); Sun, 25 Oct 2020 17:24:02 +0000 Original-Received: (at 44155) by debbugs.gnu.org; 25 Oct 2020 17:23:04 +0000 Original-Received: from localhost ([127.0.0.1]:37559 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kWjjU-0007mS-DK for submit@debbugs.gnu.org; Sun, 25 Oct 2020 13:23:04 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:39776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kWjjT-0007ll-CM for 44155@debbugs.gnu.org; Sun, 25 Oct 2020 13:23:03 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:38097) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kWjjM-0008Qh-M4; Sun, 25 Oct 2020 13:22:56 -0400 Original-Received: from [176.228.60.248] (port=4819 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kWjjM-0004Yl-0G; Sun, 25 Oct 2020 13:22:56 -0400 In-Reply-To: <87d0172yev.fsf@mail.linkov.net> (message from Juri Linkov on Sat, 24 Oct 2020 22:53:44 +0300) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:191523 Archived-At: > From: Juri Linkov > Date: Sat, 24 Oct 2020 22:53:44 +0300 > Cc: 44155@debbugs.gnu.org > > + EMACS_INT c = XFIXNUM (obj); There's no need to use EMACS_INT, a character code is at most 22 bits, so it always fits into an 'int'. > + if (EQ (Vinteger_output_format, Qt) && CHARACTERP (obj) && c < 4194176) ^^^^^^^ Please use MAX_5_BYTE_CHAR here. Or, better yet, CHAR_BYTE8_P. And, btw, why not allow raw bytes here as well? is there some problem? > + { > + printchar ('?', printcharfun); > + > + if (escapeflag > + && (c == ';' || c == '(' || c == ')' || c == '{' || c == '}' > + || c == '[' || c == ']' || c == '\"' || c == '\'' || c == '\\')) > + printchar ('\\', printcharfun); > + print_string (Fchar_to_string (obj), printcharfun); Why are you using print_string here instead of printchar? IOW, what is the difference between printing a backslash and printing any other character, that you can use printchar for the former, but not for the latter? > + else if (INTEGERP (Vinteger_output_format) > + && XFIXNUM (Vinteger_output_format) == 16 && c >= 0) If you really want to allow Vinteger_output_format to be a bignum, you cannot use XFIXNUM with it, you need to use integer_to_intmax or somesuch. Otherwise, you should use FIXNUMP instead of INTEGERP. > + DEFVAR_LISP ("integer-output-format", Vinteger_output_format, > + doc: /* The format used to print integers. > +When 't', print integers as characters. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ But only integers that are small enough, yes? > +When a number 16, print numbers in hex format. This immediately begs the question: why cannot the value be 8 or 2? Thanks. P.S. This will eventually need a NEWS entry.