From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#38191: incorrect text properties in result of `format' with multibyte(?) characters Date: Thu, 14 Nov 2019 14:46:49 -0800 Organization: UCLA Computer Science Department Message-ID: <2b3973a1-49fc-a6a6-2ce2-4328490e6d9d@cs.ucla.edu> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------CF987004A85517E6025E6CC5" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="258107"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 Cc: 38191-done@debbugs.gnu.org To: Paul Pogonyshev Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 14 23:48:26 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iVNuc-00151m-ND for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Nov 2019 23:48:26 +0100 Original-Received: from localhost ([::1]:34328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVNub-00084c-0O for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Nov 2019 17:48:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32826) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVNuF-00084E-At for bug-gnu-emacs@gnu.org; Thu, 14 Nov 2019 17:48:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVNuE-0004cP-B7 for bug-gnu-emacs@gnu.org; Thu, 14 Nov 2019 17:48:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54792) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iVNuE-0004cL-74 for bug-gnu-emacs@gnu.org; Thu, 14 Nov 2019 17:48:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iVNuE-0007Fh-4l for bug-gnu-emacs@gnu.org; Thu, 14 Nov 2019 17:48:02 -0500 In-Reply-To: Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Nov 2019 22:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 38191 X-GNU-PR-Package: emacs Mail-Followup-To: 38191@debbugs.gnu.org, eggert@cs.ucla.edu, pogonyshev@gmail.com Original-Received: via spool by 38191-done@debbugs.gnu.org id=D38191.157377162127793 (code D ref 38191); Thu, 14 Nov 2019 22:48:01 +0000 Original-Received: (at 38191-done) by debbugs.gnu.org; 14 Nov 2019 22:47:01 +0000 Original-Received: from localhost ([127.0.0.1]:35380 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iVNtF-0007E6-3q for submit@debbugs.gnu.org; Thu, 14 Nov 2019 17:47:01 -0500 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:57142) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iVNtC-0007Dr-5H for 38191-done@debbugs.gnu.org; Thu, 14 Nov 2019 17:46:59 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id BD58116023F; Thu, 14 Nov 2019 14:46:51 -0800 (PST) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id b2eu-4OL0HUu; Thu, 14 Nov 2019 14:46:50 -0800 (PST) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E04361605D8; Thu, 14 Nov 2019 14:46:50 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 6VHuYHlddrzb; Thu, 14 Nov 2019 14:46:50 -0800 (PST) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id C5D1B16023F; Thu, 14 Nov 2019 14:46:50 -0800 (PST) Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:171619 Archived-At: This is a multi-part message in MIME format. --------------CF987004A85517E6025E6CC5 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Thanks for reporting that. I installed the attached patch to fix it. --------------CF987004A85517E6025E6CC5 Content-Type: text/x-patch; charset=UTF-8; name="0001-Fix-byte-counting-error-in-format.patch" Content-Disposition: attachment; filename="0001-Fix-byte-counting-error-in-format.patch" Content-Transfer-Encoding: quoted-printable >From 63aafe766e7d81aa7b2e75bddf2ce3eca4611ae5 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 14 Nov 2019 14:42:39 -0800 Subject: [PATCH] =3D?UTF-8?q?Fix=3D20byte-counting=3D20error=3D20in=3D20=3D= E2=3D80=3D98for?=3D =3D?UTF-8?q?mat=3DE2=3D80=3D99?=3D MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit Problem reported by Paul Pogonyshev (Bug#38191). * src/editfns.c (styled_format): When checking for adjacent %-sequences, use byte position rather than character position. * test/src/editfns-tests.el (format-properties): Test for fix. --- src/editfns.c | 6 +++--- test/src/editfns-tests.el | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/editfns.c b/src/editfns.c index 1b33f39711..8fc866d391 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -3143,7 +3143,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, = bool message) /* The start and end bytepos in the output string. */ ptrdiff_t start, end; =20 - /* The start of the spec in the format string. */ + /* The start bytepos of the spec in the format string. */ ptrdiff_t fbeg; =20 /* Whether the argument is a string with intervals. */ @@ -3954,7 +3954,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, = bool message) { position++; if (fieldn < nspec - && position > info[fieldn].fbeg + && bytepos >=3D info[fieldn].fbeg && translated =3D=3D info[fieldn].start) { translated +=3D info[fieldn].end - info[fieldn].start; @@ -3976,7 +3976,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, = bool message) { position++; if (fieldn < nspec - && position > info[fieldn].fbeg + && bytepos >=3D info[fieldn].fbeg && translated =3D=3D info[fieldn].start) { translated +=3D info[fieldn].end - info[fieldn].start; diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index a1060808f6..238fb409f0 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el @@ -90,6 +90,10 @@ format-properties (propertize "45" 'face 'italic))) #("012345 " 0 2 (face bold) 2 4 (face underline) 4 10 (face italic)))) + ;; Bug #38191 + (should (ert-equal-including-properties + (format (propertize "=E2=80=98foo=E2=80=99 %s bar" 'face 'bol= d) "xxx") + #("=E2=80=98foo=E2=80=99 xxx bar" 0 13 (face bold)))) ;; Bug #32404 (should (ert-equal-including-properties (format (concat (propertize "%s" 'face 'bold) --=20 2.23.0 --------------CF987004A85517E6025E6CC5--