From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#23595: 25.1.50; file with chinese/japanse chars, vc-diff fails (HG, Git, RCS) Date: Tue, 24 May 2016 23:51:33 -0700 Organization: UCLA Computer Science Department Message-ID: <57454B75.6070506@cs.ucla.edu> References: <87bn3z4l9i.fsf@mat.ucm.es> <1444321464004323@web25h.yandex.ru> <83h9do67pp.fsf@gnu.org> <21f6198c-a2fc-365f-caf7-79fad5027f1c@yandex.ru> <32b48032-8b30-d1d4-259c-8715aad3e7b8@cs.ucla.edu> <86c6d05c-a37f-e223-d0d2-af63d09ed0cc@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050309080908060600070203" X-Trace: ger.gmane.org 1464159147 13468 80.91.229.3 (25 May 2016 06:52:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 May 2016 06:52:27 +0000 (UTC) Cc: oub@mat.ucm.es, 23595@debbugs.gnu.org To: Dmitry Gutov , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed May 25 08:52:16 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 1b5Sfv-00088H-Ig for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 May 2016 08:52:15 +0200 Original-Received: from localhost ([::1]:57756 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Sfu-0000Nk-IY for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 May 2016 02:52:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Sfo-0000Mt-Oq for bug-gnu-emacs@gnu.org; Wed, 25 May 2016 02:52:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5Sfi-0002OZ-Py for bug-gnu-emacs@gnu.org; Wed, 25 May 2016 02:52:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52844) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Sfi-0002OV-Ml for bug-gnu-emacs@gnu.org; Wed, 25 May 2016 02:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1b5Sfi-00025S-Gq for bug-gnu-emacs@gnu.org; Wed, 25 May 2016 02:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 May 2016 06:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23595 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23595-submit@debbugs.gnu.org id=B23595.14641591037998 (code B ref 23595); Wed, 25 May 2016 06:52:02 +0000 Original-Received: (at 23595) by debbugs.gnu.org; 25 May 2016 06:51:43 +0000 Original-Received: from localhost ([127.0.0.1]:36948 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b5SfO-00024w-T0 for submit@debbugs.gnu.org; Wed, 25 May 2016 02:51:43 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:58477) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b5SfN-00024j-FO for 23595@debbugs.gnu.org; Wed, 25 May 2016 02:51:41 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0E647161371; Tue, 24 May 2016 23:51:35 -0700 (PDT) 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 mWtS7tCiw71B; Tue, 24 May 2016 23:51:34 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1843D161380; Tue, 24 May 2016 23:51:34 -0700 (PDT) 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 BiTDQYg2RdUR; Tue, 24 May 2016 23:51:34 -0700 (PDT) Original-Received: from [192.168.1.9] (unknown [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E5AB4161371; Tue, 24 May 2016 23:51:33 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 In-Reply-To: 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:118651 Archived-At: This is a multi-part message in MIME format. --------------050309080908060600070203 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Dmitry Gutov wrote: > - Shouldn't that change be in vc-coding-system-for-diff? > - It seems to try to fix a separate issue (whether all files use the sa= me coding > system). Yes. For emacs-25 that's probably too much, as you suggest. So we can fix= the=20 problem in vc-coding-system-for-diff. Revised (more-conservative) patch a= ttached. > - Like Eli pointed out, (coding-system-get coding-system-for-read > :ascii-compatible-p) should work about as well. Why doesn't it? It doesn't work for EBCDIC. > As an aside, how did you manage to create a patch that's using tabs for > indentation, with indent-tabs-mode bound to nil in .dir-locals.el? That= 's > troubling. I override that setting, as I find it annoying in too many cases. It's ju= st a=20 minor annoyance, but there it is. --------------050309080908060600070203 Content-Type: text/x-diff; name="0001-Fix-vc-diff-problems-with-UTF-16.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Fix-vc-diff-problems-with-UTF-16.patch" =46rom 4b608d04b5c71a580a962b014c0399d0c917d9ab Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 24 May 2016 22:28:44 -0700 Subject: [PATCH] Fix vc-diff problems with UTF-16 Problem with UTF-16 reported by Uwe Brauer (Bug#23595). There are similar problems with EBCDIC or with other coding systems differing greatly from ASCII. * lisp/vc/vc.el (vc-coding-system-for-diff): Require the file's coding system to be compatible-enough with ASCII so that messages like "Binary files differ" are not misdecoded. --- lisp/vc/vc.el | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index af875e8..0dbdcb0 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1601,18 +1601,31 @@ vc-coding-system-inherit-eol (defun vc-coding-system-for-diff (file) "Return the coding system for reading diff output for FILE." (or coding-system-for-read - ;; if we already have this file open, - ;; use the buffer's coding system - (let ((buf (find-buffer-visiting file))) - (when buf (with-current-buffer buf + (let ((coding + (or + ;; If we already have this file open, + ;; try the buffer's coding system. + (let ((buf (find-buffer-visiting file))) + (when buf + (with-current-buffer buf (if vc-coding-system-inherit-eol buffer-file-coding-system ;; Don't inherit the EOL part of the coding-system, ;; because some Diff tools may choose to use ;; a different one. bug#4451. (coding-system-base buffer-file-coding-system))))) - ;; otherwise, try to find one based on the file name - (car (find-operation-coding-system 'insert-file-contents file)) + ;; Otherwise, try to find one based on the file name. + (car (find-operation-coding-system 'insert-file-contents + file))))) + ;; Use the files' coding system only if it is compatible + ;; enough with ASCII. If the files' coding system is UTF-16, + ;; diff likely outputs something like "Binary files differ" in + ;; ASCII, which would be misdecoded by UTF-16. + (when (and coding + (let ((samp "Binary files differ")) + (string-equal samp (decode-coding-string + samp coding t)))) + last-coding-system-used)) ;; and a final fallback 'undecided)) =20 --=20 2.5.5 --------------050309080908060600070203--