From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.bugs Subject: bug#31837: 26.1; replace-buffer-contents doesn't work if buffer has multibyte characters Date: Sun, 1 Jul 2018 19:32:45 +0200 Message-ID: References: <7dm4li5jbmk.fsf@janestreet.com> <83tvq41m9r.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000bbe767056ff37814" X-Trace: blaine.gmane.org 1530466326 1861 195.159.176.226 (1 Jul 2018 17:32:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 1 Jul 2018 17:32:06 +0000 (UTC) Cc: 31837@debbugs.gnu.org, Milan =?UTF-8?Q?Stanojevi=C4=87?= To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 01 19:32:02 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fZgCf-0000KH-EL for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 Jul 2018 19:32:01 +0200 Original-Received: from localhost ([::1]:55095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZgEm-00026b-Mx for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 Jul 2018 13:34:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZgEg-000265-2w for bug-gnu-emacs@gnu.org; Sun, 01 Jul 2018 13:34:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fZgEd-00086t-0g for bug-gnu-emacs@gnu.org; Sun, 01 Jul 2018 13:34:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34420) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fZgEc-00086l-T2 for bug-gnu-emacs@gnu.org; Sun, 01 Jul 2018 13:34:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fZgEc-0001I7-Hi for bug-gnu-emacs@gnu.org; Sun, 01 Jul 2018 13:34:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philipp Stephani Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 01 Jul 2018 17:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31837 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 31837-submit@debbugs.gnu.org id=B31837.15304663844898 (code B ref 31837); Sun, 01 Jul 2018 17:34:02 +0000 Original-Received: (at 31837) by debbugs.gnu.org; 1 Jul 2018 17:33:04 +0000 Original-Received: from localhost ([127.0.0.1]:42317 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fZgDg-0001Gv-1o for submit@debbugs.gnu.org; Sun, 01 Jul 2018 13:33:04 -0400 Original-Received: from mail-oi0-f49.google.com ([209.85.218.49]:37389) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fZgDe-0001GQ-G3 for 31837@debbugs.gnu.org; Sun, 01 Jul 2018 13:33:02 -0400 Original-Received: by mail-oi0-f49.google.com with SMTP id k81-v6so12710039oib.4 for <31837@debbugs.gnu.org>; Sun, 01 Jul 2018 10:33:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nLMd6ozHcmd0wON1s/35vulpabYZgKfbwr1ez3WMA4Y=; b=VbzLCZgwWB9HtiX7E0a9UkKtFogGgCrN5gtbUrKw+IV9IDSiaUE2eI2RPK+XVzrXbw 8qFCGReY0wYG1OIsP6F2EgWGocABF/wOhkCusRXkiXlUwN0JI7wmk7IAJ4gLV9Zhp+Mj Atq/4S5Jmsn3Z2vtRZyg0ooNkNyqxzXmL64+CWAmuO/zAujHIMkM/SOF3AqztgBHsmX0 bSFEU/LDJQe7V3vgzuLsgR6Zla9ntlxbdlLO0MbJnVQ+ctfXvqBiaT+IzTNg8wH1Fb+3 v6gDnMFdtpVUAs8MuUpx3FMXWmtQKfKK9SEbk+khPx3PWephuPi9an1UrYc7AuEzPm84 IBtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nLMd6ozHcmd0wON1s/35vulpabYZgKfbwr1ez3WMA4Y=; b=rJhWnNZGjQyNSUn/DjU7CPD4npJ6reoBewkt5dPdopbA8nCR/JcYptJ7zJ6ECajeXm Olnm3xMRk8nuLAqJvpjoYnZr/IXtYhl8G5TmB4PTgMdSrQ4XtlOQJ2CSoxFSgwKyWPdv wO/DyC8Y+skEpNYDX1csiZbnqcqM7hNM/zKs0o+nsSxu9+GaRuJP5PTZh2q6ZK/ja7Or JpDOcj27uCJBBwkcR5/dXxroBK7SBQLZ182EAgqAnTPfdJtG1S2sk03lwLJexMtc/47I vapOSL5kophrd6JedfYIB88lRRhIwZumqHTTvVDlcUcr45zQusMBoxs+YadqTT/Ciws9 IkVQ== X-Gm-Message-State: APt69E23NJwEr1qOvgZlzZBMJyRy1DKIzY8SKrzZWU0UN4gXwqg4cvqw owz0OWCaW6PGmpo/aZmT8aFOgwQM1cv0dRtTmaw= X-Google-Smtp-Source: AAOMgpcLAt/f84N9fPT8zoogHaWvISjDFmLvfAtQxXyxw4BlJhLtj9TztQUFVMJ5Y7iyExPYSjVtwYQBuM50fTc9wVI= X-Received: by 2002:aca:808:: with SMTP id 8-v6mr13092183oii.198.1530466376868; Sun, 01 Jul 2018 10:32:56 -0700 (PDT) In-Reply-To: <83tvq41m9r.fsf@gnu.org> 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: 208.118.235.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:148057 Archived-At: --000000000000bbe767056ff37814 Content-Type: text/plain; charset="UTF-8" Eli Zaretskii schrieb am Fr., 15. Juni 2018 um 10:35 Uhr: > > > I looked at the code and it looks to me like there is a very obvious bug > > in function buffer_chars_equal in editfns.c. It calls > > BUF_FETCH_CHAR_AS_MULTIBYTE passing *character* positions, but the > > macro expects *byte* positions. (it would be nice if these char vs byte > > positions could be distinguished with types, but I'm not sure it is > > possible in C). > > > > The simple fix is to replace BUF_FETCH_CHAR_AS_MULTIBYTE with > > STRING_CHAR (BUF_CHAR_ADDRESS (buf, pos)) and this seems to work. > > Thanks, I installed a slightly different fix on the emacs-26 branch, > perhaps you could try that. Thanks a lot for finding and fixing this (rather embarrasing) bug! --000000000000bbe767056ff37814 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Eli Za= retskii <eliz@gnu.org> schrieb am= Fr., 15. Juni 2018 um 10:35=C2=A0Uhr:

> I looked at the code and it looks to me like there is a very obvious b= ug
>=C2=A0 in function buffer_chars_equal in editfns.c. It calls
>=C2=A0 BUF_FETCH_CHAR_AS_MULTIBYTE passing *character* positions, but t= he
>=C2=A0 macro expects *byte* positions. (it would be nice if these char = vs byte
>=C2=A0 positions could be distinguished with types, but I'm not sur= e it is
>=C2=A0 possible in C).
>
> The simple fix is to replace BUF_FETCH_CHAR_AS_MULTIBYTE with
>=C2=A0 STRING_CHAR (BUF_CHAR_ADDRESS (buf, pos)) and this seems to work= .

Thanks, I installed a slightly different fix on the emacs-26 branch,
perhaps you could try that.

Thanks a lot fo= r finding and fixing this (rather embarrasing) bug!=C2=A0
--000000000000bbe767056ff37814--