From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andrew Hyatt Newsgroups: gmane.emacs.bugs Subject: bug#5251: 23.1; problem in decode_eol of coding.c Date: Tue, 16 Feb 2016 22:41:32 -0500 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1455680543 12506 80.91.229.3 (17 Feb 2016 03:42:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 17 Feb 2016 03:42:23 +0000 (UTC) Cc: 5251@debbugs.gnu.org To: Toru TSUNEYOSHI Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Feb 17 04:42:12 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aVt0D-0006uY-O5 for geb-bug-gnu-emacs@m.gmane.org; Wed, 17 Feb 2016 04:42:10 +0100 Original-Received: from localhost ([::1]:53316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVt0D-0003cz-1l for geb-bug-gnu-emacs@m.gmane.org; Tue, 16 Feb 2016 22:42:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVt09-0003cf-RB for bug-gnu-emacs@gnu.org; Tue, 16 Feb 2016 22:42:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVt06-0006g5-JC for bug-gnu-emacs@gnu.org; Tue, 16 Feb 2016 22:42:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40053) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVt06-0006g0-Fv for bug-gnu-emacs@gnu.org; Tue, 16 Feb 2016 22:42:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aVt06-0002gQ-BA for bug-gnu-emacs@gnu.org; Tue, 16 Feb 2016 22:42:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Andrew Hyatt Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 17 Feb 2016 03:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5251 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 5251-submit@debbugs.gnu.org id=B5251.145568050210289 (code B ref 5251); Wed, 17 Feb 2016 03:42:02 +0000 Original-Received: (at 5251) by debbugs.gnu.org; 17 Feb 2016 03:41:42 +0000 Original-Received: from localhost ([127.0.0.1]:38727 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aVszm-0002ft-Dg for submit@debbugs.gnu.org; Tue, 16 Feb 2016 22:41:42 -0500 Original-Received: from mail-qk0-f170.google.com ([209.85.220.170]:34319) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aVszl-0002fg-1z for 5251@debbugs.gnu.org; Tue, 16 Feb 2016 22:41:41 -0500 Original-Received: by mail-qk0-f170.google.com with SMTP id x1so1674865qkc.1 for <5251@debbugs.gnu.org>; Tue, 16 Feb 2016 19:41:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=UZUjubXNO9rsbmQkUAnfN8KMDDOEZ8saAbOqDhce/2M=; b=FHdGAnmnCe4L8ApCozgMKJUMRSw5nlhJNphrWwScqRpOJSxfJiT29ymNI/iz79BLOT qf4q0KdcGx6+VjI6tX9c5OQynOnBR0imcPkmif9nVo3iUex/s454zZDwgdn+zRfExDIN TZGHj/1Rx5SNn7TUbRCvaAIx0qFanqqa9vd8pvIWE6xf4notoyDdGg3lv/VDpN06lr1L z+q+B1z71cLt9TZVz94+wG97Jy4nPy/t5jnlecgr3DO3E4zIXOwaXIMXHmvQgsDU4UDj rXrPC74r81VZHA3H31Mh1Vb1EBo18d8JHpl5qI/eQIo52tDvRcr5OaaDGJlSKEdXdYE0 rhxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type :content-transfer-encoding; bh=UZUjubXNO9rsbmQkUAnfN8KMDDOEZ8saAbOqDhce/2M=; b=AK2zDRhZBr7aN+XBHd3xdtlmwCRTkMU28haKgDWKyndzmlI6OPGK/J//3QHeirjWhq 1CmjAbvHH1abJwRAy2vuVWBWuVA9bQ6XsPFcunhaNsMJK5rDabp1JlScNBxX6pHMzaT0 vyp0IkTJx8E2vCPSMLIQsmERrTvZJou+eKhI+GMVs69bcqx8mjxgTi2jtGCP1DH67mmj 62x/PUBWtceswl8rH/HWHOWLZvq0PUAtWmCo3YLU2Iax++55pF3X/caVqGfvU0yolhzO fkdnH50Bp6oSrvVvcIZcDMxvtcTIaZUtDCxxwy2s7uW0PsYVPErBIABfqILZjfI17HrS zfJQ== X-Gm-Message-State: AG10YOReDeCW98dgz+cXUeBMi4GZUH/KObUQ8rrxDnUVcwcaQW2t0Oxq/PwSk1Iy2yJ+RQ== X-Received: by 10.55.75.212 with SMTP id y203mr32887104qka.3.1455680495731; Tue, 16 Feb 2016 19:41:35 -0800 (PST) Original-Received: from Andrews-MacBook-Pro.local.ahyatt-laptop (cpe-74-73-128-199.nyc.res.rr.com. [74.73.128.199]) by smtp.gmail.com with ESMTPSA id b111sm14533716qge.47.2016.02.16.19.41.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Feb 2016 19:41:33 -0800 (PST) In-Reply-To: (Toru TSUNEYOSHI's message of "Sun, 20 Dec 2009 17:57:09 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (darwin) 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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:113167 Archived-At: I can verify that this issue still happens in Emacs 25. This simple fix seems to have slipped by unnoticed many years ago, hopefully someone that is qualified to comment on the patch will see it now. BTW, this seems like a nice thing to unit test with ert, if a fix does take place. Toru TSUNEYOSHI writes: > In GNU Emacs 23.1, there is a problem in decode_eol of coding.c. > > In buffer of which enable-multibyte-characters is nil, > the function `decode-coding-region' should delete the character '^M' > (code: 0x0d) at the end of line, > in case that the function parameter `coding-system' is *-dos (and > the variable `inhibit-eol-conversion' is nil). > But, in practice, the function doesn't delete all of the character '^M'. > > You can watch the problem with the following. > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > (progn > (pop-to-buffer (generate-new-buffer-name "*scratch*")) > (set-buffer-multibyte nil) > (insert (encode-coding-string "=E3=81=82" 'euc-jp) "\xd" "\n") > (read-char "(press any key)") > (decode-coding-region (point-min) (point-max) 'euc-jp-dos) > (read-char "doesn't delete all of the character '^M'. (press any key)") > (set-buffer-multibyte t)) > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > I made a patch to fix the problem. Please check it. > > --- coding.c.orig 2009-07-08 12:09:16.000000000 +0900 > +++ coding.c 2009-12-20 16:36:45.887121600 +0900 > @@ -6598,7 +6598,8 @@ > { > int pos_byte =3D coding->dst_pos_byte; > int pos =3D coding->dst_pos; > - int pos_end =3D pos + coding->produced_char - 1; > + int pos_end =3D pos + (coding->dst_multibyte > + ? coding->produced_char : coding->produced) - 1; >=20=20 > while (pos < pos_end) > {