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#58168: string-lessp glitches and inconsistencies Date: Fri, 07 Oct 2022 18:33:57 +0300 Message-ID: <83leprmyvu.fsf@gnu.org> References: <7824372D-8002-4639-8AEE-E80A6D5FEFC6@gmail.com> <877d1l55rn.fsf@gnus.org> <469814C2-197A-4BCA-8E2A-245577340C1E@gmail.com> <878rlzj1zv.fsf@gnus.org> <878rlzfylg.fsf@gnus.org> <017DAAA2-0383-4B47-855E-28348B2E9F06@gmail.com> <831qrnx1jc.fsf@gnu.org> <83k05fv9nv.fsf@gnu.org> <52286A5C-D947-4279-812E-173BB44046E1@gmail.com> <83v8oxp5lk.fsf@gnu.org> <4CFC3078-64FB-4EAC-A536-F6CBCEE2087D@gmail.com> <83mta9owal.fsf@gnu.org> <58016C43-E429-4EF1-9660-0F29CA36B6FE@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19703"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58168@debbugs.gnu.org, larsi@gnus.org To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 07 18:15:42 2022 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 1ogq0i-0004uy-F8 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 Oct 2022 18:15:40 +0200 Original-Received: from localhost ([::1]:48938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogq0h-0000cL-C1 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 Oct 2022 12:15:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogpNP-0003Ly-7J for bug-gnu-emacs@gnu.org; Fri, 07 Oct 2022 11:35:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38155) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogpNO-0008Bo-Pz for bug-gnu-emacs@gnu.org; Fri, 07 Oct 2022 11:35:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ogpNO-00069b-7e for bug-gnu-emacs@gnu.org; Fri, 07 Oct 2022 11:35: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, 07 Oct 2022 15:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58168 X-GNU-PR-Package: emacs Original-Received: via spool by 58168-submit@debbugs.gnu.org id=B58168.166515685023579 (code B ref 58168); Fri, 07 Oct 2022 15:35:02 +0000 Original-Received: (at 58168) by debbugs.gnu.org; 7 Oct 2022 15:34:10 +0000 Original-Received: from localhost ([127.0.0.1]:37230 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogpMY-00068F-A9 for submit@debbugs.gnu.org; Fri, 07 Oct 2022 11:34:10 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:51806) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogpMV-00067n-0G for 58168@debbugs.gnu.org; Fri, 07 Oct 2022 11:34:08 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:43932) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogpMP-00088n-6z; Fri, 07 Oct 2022 11:34:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=hOvr3EN8+7uOu9PVHqkXMo1/Dpg98uIZo2pdktVffjc=; b=gIFKlA0qA5OSwputuH6G wCY1xHgx4xSL7zdNeWjAKGWxT0NHiVdLJHCCmTqVMlFL8DUBkybLK7aXQV4Un3arBXr8lhOzo7Xsw dF+bGegOu72s1Cen6v58cY+ysQ/ovsr5AMwAhhEPjlohxucNcVch9DfA3cRmk1SdD26iPhe12KDZe xm0yVfZmNq2Dwi+lNPlb4J9idoYH/Bbpuf4P/kVNhAhmQY6IDtIMRsYE4hxLqBVcnUyO82tvQFRdw YaF8v/eNCxVNoMTaMpsMTlxnj5uCW5f4SpBfJXOrzeHT8OJtQiCpXlQwo4zE8zQsKeCxgLiMnnU+j eNLgmsdNJGt+TQ==; Original-Received: from [87.69.77.57] (port=4882 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogpML-0002FQ-Qk; Fri, 07 Oct 2022 11:33:59 -0400 In-Reply-To: <58016C43-E429-4EF1-9660-0F29CA36B6FE@gmail.com> (message from Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= on Fri, 7 Oct 2022 16:45:57 +0200) 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:244824 Archived-At: > From: Mattias EngdegÄrd > Date: Fri, 7 Oct 2022 16:45:57 +0200 > Cc: larsi@gnus.org, > 58168@debbugs.gnu.org > > > I don't think it matters much, because whatever we produce we cannot > > be sure it will look identical to the original format string. > > I agree. What about this patch then? > > diff --git a/src/editfns.c b/src/editfns.c > index c1414071c7..5a99a40656 100644 > --- a/src/editfns.c > +++ b/src/editfns.c > @@ -3551,10 +3551,15 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) > || float_conversion || conversion == 'i' > || conversion == 'o' || conversion == 'x' > || conversion == 'X')) > - error ("Invalid format operation %%%c", > - multibyte_format > - ? STRING_CHAR ((unsigned char *) format - 1) > - : *((unsigned char *) format - 1)); > + { > + unsigned char *p = (unsigned char *) format - 1; > + if (multibyte_format) > + error ("Invalid format operation %%%c", STRING_CHAR (p)); > + else > + error ((*p <= 127 ? "Invalid format operation %%%c" > + : "Invalid format operation char #x%02x"), > + *p); > + } > else if (! (FIXNUMP (arg) || ((BIGNUMP (arg) || FLOATP (arg)) > && conversion != 'c'))) > error ("Format specifier doesn't match argument type"); I'd prefer to show it in octal, not in hex, since that's the default in Emacs. > > A test suite doesn't have to > > assume that the internals work as they should, it should just test > > that. So testing both sounds to me better than testing just one > > assuming that this one covers both. > > I agree, we should definitely test raw bytes inserted from both unibyte and multibyte strings. The current code doesn't do that, hence my patch. > > With respect to other values there should be a reasonable qualitative difference between test cases: testing both #x80 and #xfc isn't more useful than testing the display of both the letters 'A' and 'B'. But if you think that the current code is deficient in coverage, please do propose extensions and I'll adapt the patch accordingly. I think the more values we test the better. The codepoints between #x80 and #xA0 in particular are treated differently than those above #xA0, so at least one from each range should be beneficial.