From: Andreas Schwab <schwab@linux-m68k.org>
To: Kazuhiro Ito <kzhr@d1.dion.ne.jp>
Cc: Chong Yidong <cyd@stupidchicken.com>, 9318@debbugs.gnu.org
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 [thread overview]
Message-ID: <m24o16pu61.fsf@igel.home> (raw)
In-Reply-To: <20110824093755.8E190360038@msa102.auone-net.jp> (Kazuhiro Ito's message of "Wed, 24 Aug 2011 18:37:24 +0900")
Kazuhiro Ito <kzhr@d1.dion.ne.jp> 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."
next prev parent reply other threads:[~2011-08-24 17:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-18 9:01 bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result on on Windows Kazuhiro Ito
2011-08-18 9:48 ` Andreas Schwab
2011-08-18 21:33 ` Kazuhiro Ito
2011-08-19 13:46 ` bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result Kazuhiro Ito
2011-08-20 21:26 ` Chong Yidong
2011-08-21 0:17 ` Kazuhiro Ito
2011-08-24 9:37 ` Kazuhiro Ito
2011-08-24 12:06 ` Eli Zaretskii
2011-08-25 9:49 ` Kazuhiro Ito
2011-08-24 17:59 ` Andreas Schwab [this message]
2011-08-25 9:54 ` Kazuhiro Ito
2011-08-26 11:41 ` Kazuhiro Ito
2011-08-28 0:04 ` Kazuhiro Ito
2011-08-30 23:30 ` Kazuhiro Ito
2011-12-01 1:56 ` Kenichi Handa
2011-12-05 7:10 ` Kenichi Handa
2011-12-05 11:31 ` Kazuhiro Ito
2011-12-05 9:11 ` Paul Eggert
2011-12-06 0:30 ` Kenichi Handa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m24o16pu61.fsf@igel.home \
--to=schwab@linux-m68k.org \
--cc=9318@debbugs.gnu.org \
--cc=cyd@stupidchicken.com \
--cc=kzhr@d1.dion.ne.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).