From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Schwab Newsgroups: gmane.emacs.bugs Subject: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result Date: Wed, 24 Aug 2011 19:59:34 +0200 Message-ID: References: <20110818090129.DC129360038@msa102.auone-net.jp> <20110819134637.9727A34803A@msa103.auone-net.jp> <877h67vkpf.fsf@stupidchicken.com> <20110821001726.D29052C037@msa104.auone-net.jp> <20110824093755.8E190360038@msa102.auone-net.jp> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1314208839 1310 80.91.229.12 (24 Aug 2011 18:00:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 24 Aug 2011 18:00:39 +0000 (UTC) Cc: Chong Yidong , 9318@debbugs.gnu.org To: Kazuhiro Ito Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Aug 24 20:00:35 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QwHkf-0008GU-Pg for geb-bug-gnu-emacs@m.gmane.org; Wed, 24 Aug 2011 20:00:34 +0200 Original-Received: from localhost ([::1]:52489 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwHkf-0005b5-BI for geb-bug-gnu-emacs@m.gmane.org; Wed, 24 Aug 2011 14:00:33 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:53869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwHkb-0005ay-KQ for bug-gnu-emacs@gnu.org; Wed, 24 Aug 2011 14:00:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QwHka-00041d-6g for bug-gnu-emacs@gnu.org; Wed, 24 Aug 2011 14:00:29 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44939) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwHka-00041Y-3L for bug-gnu-emacs@gnu.org; Wed, 24 Aug 2011 14:00:28 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QwHn3-0007F0-Ux; Wed, 24 Aug 2011 14:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andreas Schwab Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Aug 2011 18:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9318 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 9318-submit@debbugs.gnu.org id=B9318.131420893627780 (code B ref 9318); Wed, 24 Aug 2011 18:03:01 +0000 Original-Received: (at 9318) by debbugs.gnu.org; 24 Aug 2011 18:02:16 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QwHmK-0007E1-0A for submit@debbugs.gnu.org; Wed, 24 Aug 2011 14:02:16 -0400 Original-Received: from mail-out.m-online.net ([212.18.0.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QwHmG-0007Dq-JV for 9318@debbugs.gnu.org; Wed, 24 Aug 2011 14:02:14 -0400 Original-Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 32753188A190; Wed, 24 Aug 2011 19:59:35 +0200 (CEST) Original-Received: from localhost (dynscan1.mnet-online.de [192.168.8.164]) by mail.m-online.net (Postfix) with ESMTP id C7C401C0014B; Wed, 24 Aug 2011 19:59:35 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Original-Received: from mail.mnet-online.de ([192.168.8.180]) by localhost (dynscan1.mail.m-online.net [192.168.8.164]) (amavisd-new, port 10024) with ESMTP id owPUZQOK6m-q; Wed, 24 Aug 2011 19:59:34 +0200 (CEST) Original-Received: from igel.home (ppp-88-217-126-207.dynamic.mnet-online.de [88.217.126.207]) by mail.mnet-online.de (Postfix) with ESMTP; Wed, 24 Aug 2011 19:59:34 +0200 (CEST) Original-Received: by igel.home (Postfix, from userid 501) id 47C0DCA293; Wed, 24 Aug 2011 19:59:34 +0200 (CEST) X-Yow: Does that mean I'm not a well-adjusted person?? In-Reply-To: <20110824093755.8E190360038@msa102.auone-net.jp> (Kazuhiro Ito's message of "Wed, 24 Aug 2011 18:37:24 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Wed, 24 Aug 2011 14:03:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 140.186.70.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:50299 Archived-At: Kazuhiro Ito writes: > I think relocation of buffer may cause the problem. Does that help? diff --git a/src/coding.c b/src/coding.c index 65c8a76..f34a023 100644 --- a/src/coding.c +++ b/src/coding.c @@ -915,8 +915,8 @@ record_conversion_result (struct coding_system *coding, } } -/* This wrapper macro is used to preserve validity of pointers into - buffer text across calls to decode_char, which could cause +/* These wrapper macros are used to preserve validity of pointers into + buffer text across calls to decode_char/encode_char, which could cause relocation of buffers if it loads a charset map, because loading a charset map allocates large structures. */ #define CODING_DECODE_CHAR(coding, src, src_base, src_end, charset, code, c) \ @@ -935,6 +935,21 @@ record_conversion_result (struct coding_system *coding, src_end += offset; \ } \ } while (0) +#define CODING_ENCODE_CHAR(coding, dst, dst_end, charset, c, code) \ + do { \ + charset_map_loaded = 0; \ + code = ENCODE_CHAR (charset, c); \ + if (charset_map_loaded) \ + { \ + const unsigned char *orig = coding->destination; \ + EMACS_INT offset; \ + \ + coding_set_destination (coding); \ + offset = coding->destination - orig; \ + dst += offset; \ + dst_end += offset; \ + } \ + } while (0) /* If there are at least BYTES length of room at dst, allocate memory @@ -2652,7 +2667,7 @@ encode_coding_emacs_mule (struct coding_system *coding) { charset = CHARSET_FROM_ID (preferred_charset_id); if (CHAR_CHARSET_P (c, charset)) - code = ENCODE_CHAR (charset, c); + CODING_ENCODE_CHAR (coding, dst, dst_end, charset, c, code); else charset = char_charset (c, charset_list, &code); } @@ -4185,7 +4200,8 @@ decode_coding_iso_2022 (struct coding_system *coding) #define ENCODE_ISO_CHARACTER(charset, c) \ do { \ - int code = ENCODE_CHAR ((charset), (c)); \ + int code; \ + CODING_ENCODE_CHAR (coding, dst, dst_end, charset, c, code); \ \ if (CHARSET_DIMENSION (charset) == 1) \ ENCODE_ISO_CHARACTER_DIMENSION1 ((charset), code); \ Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."