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#43439: [PATCH] doprnt improvements Date: Fri, 18 Sep 2020 10:30:44 +0300 Message-ID: <838sd75yor.fsf@gnu.org> References: <20200916015051.20517-1-eggert@cs.ucla.edu> <83o8m57oq7.fsf@gnu.org> <31fb34a7-26c3-552d-e8d4-74624455ffcb@cs.ucla.edu> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39878"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 43439@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 18 09:33:45 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 1kJAtt-000AHe-Hz for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 18 Sep 2020 09:33:45 +0200 Original-Received: from localhost ([::1]:55502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJAts-0006xC-GW for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 18 Sep 2020 03:33:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJArJ-0005MC-Ex for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2020 03:31:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57226) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kJArG-0004LB-54 for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2020 03:31:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kJArG-0005rl-1U for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2020 03:31: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: Fri, 18 Sep 2020 07:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43439 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 43439-submit@debbugs.gnu.org id=B43439.160041425122524 (code B ref 43439); Fri, 18 Sep 2020 07:31:01 +0000 Original-Received: (at 43439) by debbugs.gnu.org; 18 Sep 2020 07:30:51 +0000 Original-Received: from localhost ([127.0.0.1]:40539 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJAr4-0005rE-TW for submit@debbugs.gnu.org; Fri, 18 Sep 2020 03:30:51 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:57756) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJAr3-0005r0-9N for 43439@debbugs.gnu.org; Fri, 18 Sep 2020 03:30:50 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:57485) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJAqw-0004Di-Pa; Fri, 18 Sep 2020 03:30:43 -0400 Original-Received: from [176.228.60.248] (port=1552 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kJAql-00023z-Dz; Fri, 18 Sep 2020 03:30:37 -0400 In-Reply-To: <31fb34a7-26c3-552d-e8d4-74624455ffcb@cs.ucla.edu> (message from Paul Eggert on Wed, 16 Sep 2020 15:09:50 -0700) 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:188269 Archived-At: > Cc: 43439@debbugs.gnu.org > From: Paul Eggert > Date: Wed, 16 Sep 2020 15:09:50 -0700 > > On 9/16/20 7:58 AM, Eli Zaretskii wrote: > > > Emacs traditionally supports strings with > > embedded null characters, and this feature is in line with that. It > > is true that it is currently unused, but why is it a good idea to > > remove it? > > It's a good idea not only because the feature is currently unused and its > support complicates and adds bugs to the code, but also because it would be a > bad idea to ever use the feature. > > The Emacs feature is for Lisp strings. Emacs does not (and for API reasons, it > cannot practically) rely on embedded NULs in C strings. Among other things, if > we tried to use C-style printf formats with embedded NULs, GCC's warnings about > formats not matching their arguments would stop working. These GCC warnings are > quite useful for preventing bugs in Emacs's C code and have helped to catch many > such bugs, and we should not give them up. How about a compromise: we modify doprint to exit when either it finds NUL or reaches the character specified by FORMAT_END? This will allow us to keep some of the feature, and I think the amount of changes will be smaller. It should also not be much slower than what you propose. > More generally, the vestigial support for NULs and %S in doprnt's C formats > dates back to long ago, before GCC warned about these features. I understand your desire to have GCC warnings about this, but GCC is a tool, it shouldn't dictate what features we keep and which ones we drop. We should do it the other way around. doprnt callers don't change much, so the GCC diagnostic features are not very important in this case. Thanks.