unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Kenichi Handa <handa@m17n.org>
To: Kazuhiro Ito <kzhr@d1.dion.ne.jp>
Cc: 9389@debbugs.gnu.org
Subject: bug#9389: 23.3.50; unencodable-char-position has buffer relocation problem
Date: Sun, 11 Dec 2011 21:27:22 +0900	[thread overview]
Message-ID: <87d3bv5m51.fsf@m17n.org> (raw)
In-Reply-To: <20110828000802.B9D1B34803A@msa103.auone-net.jp> (message from Kazuhiro Ito on Sun, 28 Aug 2011 09:07:25 +0900)

In article <20110828000802.B9D1B34803A@msa103.auone-net.jp>, Kazuhiro Ito <kzhr@d1.dion.ne.jp> writes:

> When I start precompiled Windows binary with -Q and evaluate below
> code, I have unexpected result.

> (with-temp-buffer
>   (insert (make-string 16 ?A))
>   (insert #x80)
>   (unencodable-char-position 1 18 'ctext-unix))

> -> 13 (Emacs 23.1)
> -> 5  (Emacs 23.3)

> If I evaluate it twice, it returns expected result (17).

> I think the cause of the problem is similar to bug#9318.
> unencodable-char-position uses char_charset(), which could cause a
> relocation of buffes.  After using it, pointers must be updated as
> needed.

You are right.  I've just installed the attached patch
(which is a little bit different from yours).

---
Kenichi Handa
handa@m17n.org


=== modified file 'src/coding.c'
--- src/coding.c	2011-12-08 05:54:20 +0000
+++ src/coding.c	2011-12-11 11:14:15 +0000
@@ -8756,6 +8756,7 @@
     }
 
   positions = Qnil;
+  charset_map_loaded = 0;
   while (1)
     {
       int c;
@@ -8783,6 +8784,16 @@
 	}
 
       from++;
+      if (charset_map_loaded && NILP (string))
+	{
+	  p = CHAR_POS_ADDR (from);
+	  pend = CHAR_POS_ADDR (to);
+	  if (from < GPT && to >= GPT)
+	    stop = GPT_ADDR;
+	  else
+	    stop = pend;
+	  charset_map_loaded = 0;
+	}
     }
 
   return (NILP (count) ? Fcar (positions) : Fnreverse (positions));






  reply	other threads:[~2011-12-11 12:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-28  0:07 bug#9389: 23.3.50; unencodable-char-position has buffer relocation problem Kazuhiro Ito
2011-12-11 12:27 ` Kenichi Handa [this message]
2011-12-15 12:30   ` Kazuhiro Ito

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=87d3bv5m51.fsf@m17n.org \
    --to=handa@m17n.org \
    --cc=9389@debbugs.gnu.org \
    --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).