From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#58168: string-lessp glitches and inconsistencies Date: Fri, 7 Oct 2022 16:45:57 +0200 Message-ID: <58016C43-E429-4EF1-9660-0F29CA36B6FE@gmail.com> 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> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_49F19CD3-9AB4-4BC2-A6BC-6AAABFF7F850" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32425"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58168@debbugs.gnu.org, larsi@gnus.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 07 17:31:26 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 1ogpJs-0008HB-JI for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 Oct 2022 17:31:24 +0200 Original-Received: from localhost ([::1]:48942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogpJr-0006fK-Ab for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 Oct 2022 11:31:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogocw-0008WP-Vk for bug-gnu-emacs@gnu.org; Fri, 07 Oct 2022 10:47:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37968) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogocw-0000EA-32 for bug-gnu-emacs@gnu.org; Fri, 07 Oct 2022 10:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ogocv-0004mQ-Ld for bug-gnu-emacs@gnu.org; Fri, 07 Oct 2022 10:47:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 07 Oct 2022 14:47:01 +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.166515396718310 (code B ref 58168); Fri, 07 Oct 2022 14:47:01 +0000 Original-Received: (at 58168) by debbugs.gnu.org; 7 Oct 2022 14:46:07 +0000 Original-Received: from localhost ([127.0.0.1]:37046 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogoc3-0004lG-2P for submit@debbugs.gnu.org; Fri, 07 Oct 2022 10:46:07 -0400 Original-Received: from mail-lf1-f51.google.com ([209.85.167.51]:42735) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogoc1-0004kW-Gk for 58168@debbugs.gnu.org; Fri, 07 Oct 2022 10:46:06 -0400 Original-Received: by mail-lf1-f51.google.com with SMTP id m19so6261380lfq.9 for <58168@debbugs.gnu.org>; Fri, 07 Oct 2022 07:46:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:from:to:cc:subject:date:message-id:reply-to; bh=bVjbX7wCqekXSbl9n8efT0XWrn5vUHHvDJS6IbW2X/E=; b=aJrYUCWe/cZ/AhVz/W9pi72/54Pagrfn0olzT4FS2AXHa8jC6iBY3QGSaCGrPKo+ch +8JNbKbhB0vp5iZTlMDBZka3kudYNtcOuud5t2GcAyZYjfarXmmp8oGjdsQojreffPB7 +tV9m6UZfgulKrBIlQOfFaRsrcW5th+Lj4EAthS3zcajYm3ul5+UK9MFmK2ldlMziLGz 1YXJLs5oW4OkgiNG3BQcCOpiTKOYBt9tMleQ05SX6U/6vsPuIyUcoDifW3zUtEAwjc2R uNJ3F0ZQKzk3V5HujAW1TYEQu1k9tlqWHo7oK4F1IUW4cHViB1B5oT2on9YHJaI8oUgP pz0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bVjbX7wCqekXSbl9n8efT0XWrn5vUHHvDJS6IbW2X/E=; b=sFuxjVsyJ6dj8r9Ls9Lc/Euq5zqglYIaTcP3c2XjrSTqsZ58UbwbO2AOb9roio5BYw B/e7V1mJw//qO2QQ+HV1YV+tkM3eiRP32eD6387NdkrdZcv4CZ0wOKMQQ/Fw2C13gCi5 PTwWCu51Yg3YN16hN9C2tbxPE0pv28L5KCmxQqROOPITG8F23E9zT6an+wbgRhFhuiwt fg98ZjVsedxDuA/MXuyhGu4Aj4jAkV4Y3gcha1swVHCVzjN7hVs9nflrK8Bs0SgZqKRh +Gu7WDEyWTfRx6Au+U13LH+/qagvdXb/SYe+ZUuYpGTN6ctwHRI8PModPnoKXdMSvJfM fVHg== X-Gm-Message-State: ACrzQf1PWiEGKskXtTpMZLnpPJeuly2apcZw4Cg7U8wSAPv8z5eG9Fdb pqV3aHsslvZ6FrN9PveImC0= X-Google-Smtp-Source: AMsMyM4+lg1LIPSnEYrqI+euMWXxy2UCMcKsSCFutWqCXwb56ePk6VjBJtO8xD+/XHOfHYURVhUmEw== X-Received: by 2002:a05:6512:3f3:b0:4a2:6245:4265 with SMTP id n19-20020a05651203f300b004a262454265mr1954760lfq.209.1665153959115; Fri, 07 Oct 2022 07:45:59 -0700 (PDT) Original-Received: from smtpclient.apple (c188-150-171-209.bredband.tele2.se. [188.150.171.209]) by smtp.gmail.com with ESMTPSA id 14-20020a2e154e000000b0026dcf238c50sm286503ljv.127.2022.10.07.07.45.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Oct 2022 07:45:58 -0700 (PDT) In-Reply-To: <83mta9owal.fsf@gnu.org> X-Mailer: Apple Mail (2.3654.120.0.1.13) 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:244820 Archived-At: --Apple-Mail=_49F19CD3-9AB4-4BC2-A6BC-6AAABFF7F850 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii 6 okt. 2022 kl. 16.34 skrev Eli Zaretskii : > 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? --Apple-Mail=_49F19CD3-9AB4-4BC2-A6BC-6AAABFF7F850 Content-Disposition: attachment; filename=format-error.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="format-error.diff" Content-Transfer-Encoding: 7bit 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"); --Apple-Mail=_49F19CD3-9AB4-4BC2-A6BC-6AAABFF7F850 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Not very important, but at least it should be a (minor) improvement. > 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. --Apple-Mail=_49F19CD3-9AB4-4BC2-A6BC-6AAABFF7F850--