From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: handa Newsgroups: gmane.emacs.bugs Subject: bug#23814: 24.5; bug of hz coding-system Date: Wed, 27 Jul 2016 00:09:24 +0900 Message-ID: <87r3agbfmj.fsf@gnu.org> References: <877fdiu3xz.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1469545827 31763 80.91.229.3 (26 Jul 2016 15:10:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 26 Jul 2016 15:10:27 +0000 (UTC) Cc: 23814@debbugs.gnu.org To: ynyaaa@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jul 26 17:10: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 1bS3zq-0004Nq-5r for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 Jul 2016 17:10:14 +0200 Original-Received: from localhost ([::1]:40449 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bS3zp-0005vb-Fe for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 Jul 2016 11:10:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bS3zi-0005tw-HI for bug-gnu-emacs@gnu.org; Tue, 26 Jul 2016 11:10:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bS3ze-0008C6-83 for bug-gnu-emacs@gnu.org; Tue, 26 Jul 2016 11:10:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54156) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bS3ze-0008C2-4x for bug-gnu-emacs@gnu.org; Tue, 26 Jul 2016 11:10:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bS3ze-0007nQ-2a for bug-gnu-emacs@gnu.org; Tue, 26 Jul 2016 11:10:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: handa Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Jul 2016 15:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23814 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23814-submit@debbugs.gnu.org id=B23814.146954579329949 (code B ref 23814); Tue, 26 Jul 2016 15:10:02 +0000 Original-Received: (at 23814) by debbugs.gnu.org; 26 Jul 2016 15:09:53 +0000 Original-Received: from localhost ([127.0.0.1]:38260 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bS3zQ-0007mt-Fr for submit@debbugs.gnu.org; Tue, 26 Jul 2016 11:09:53 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:54390) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bS3zL-0007mc-00 for 23814@debbugs.gnu.org; Tue, 26 Jul 2016 11:09:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bS3zE-00082x-Vh for 23814@debbugs.gnu.org; Tue, 26 Jul 2016 11:09:37 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:41082) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bS3zB-00081Z-6A; Tue, 26 Jul 2016 11:09:33 -0400 Original-Received: from fl1-61-203-105-252.iba.mesh.ad.jp ([61.203.105.252]:57872 helo=shatin) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bS3zA-000123-Ds; Tue, 26 Jul 2016 11:09:32 -0400 Original-Received: from handa by shatin with local (Exim 4.86_2) (envelope-from ) id 1bS3z3-0001xQ-2H; Wed, 27 Jul 2016 00:09:25 +0900 In-Reply-To: <87twffigzv.fsf@gmail.com> (ynyaaa@gmail.com) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:121556 Archived-At: In article <87twffigzv.fsf@gmail.com>, ynyaaa@gmail.com writes: > But I found other bugs about decodings of "~" escape. > "~~" and "~{!!~}" should be encoded and decoded as below. > "~~" -> "~~~~" -> "~~" > "~{!!~}" -> "~~{!!~~}" -> "~{!!~}" > In really they are encoded properly, but decoded in wrong way. > (decode-coding-string (encode-coding-string "~~" 'hz) 'hz) >>> "~" > (decode-coding-string (encode-coding-string "~{!!~}" 'hz) 'hz) >>> #("\x3000" 0 1 (charset chinese-gb2312)) Thank you for finding those bugs. Could you please try the attached patch instead? --- K. Handa handa@gnu.org diff --git a/lisp/language/china-util.el b/lisp/language/china-util.el index e531640..9abdae1 100644 --- a/lisp/language/china-util.el +++ b/lisp/language/china-util.el @@ -95,7 +95,12 @@ decode-hz-region (goto-char (point-min)) (while (search-forward "~" nil t) (setq ch (following-char)) - (if (or (= ch ?\n) (= ch ?~)) (delete-char -1))) + (if (= ch ?{) + (search-forward "~}" nil 'move) + (when (or (= ch ?\n) (= ch ?~)) + (delete-char -1) + (put-text-property (point) (1+ (point)) 'hz-decoded t) + (forward-char 1)))) ;; "^zW...\n" -> Chinese GB2312 ;; "~{...~}" -> Chinese GB2312 @@ -104,6 +109,8 @@ decode-hz-region (while (re-search-forward hz/zw-start-gb nil t) (setq pos (match-beginning 0) ch (char-after pos)) + (if (and (= ch ?~) (get-text-property pos 'hz-decoded)) + (forward-char 1) ;; Record the first position to start conversion. (or beg (setq beg pos)) (end-of-line) @@ -122,9 +129,10 @@ decode-hz-region t) (delete-char -2)) (setq end (point)) - (translate-region pos (point) hz-set-msb-table)))) + (translate-region pos (point) hz-set-msb-table))))) (if beg (decode-coding-region beg end 'euc-china))) + (remove-text-properties (point-min) (point-max) '(hz-decoded nil)) (- (point-max) (point-min))))) ;;;###autoload @@ -142,6 +150,7 @@ encode-hz-region (save-restriction (narrow-to-region beg end) + (put-text-property beg end 'charset 'chinese-gb2312) ;; "~" -> "~~" (goto-char (point-min)) (while (search-forward "~" nil t) (insert ?~))