changeset 20691:cf1919e207ef

(unreadchar): For unreading an ASCII char thru a buffer or marker, really decrement point or the marker position.
author Richard M. Stallman <rms@gnu.org>
date Wed, 21 Jan 1998 00:37:15 +0000
parents a51c71dd5cda
children 8af33d2de7b2
files src/lread.c
diffstat 1 files changed, 34 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lread.c	Tue Jan 20 20:09:39 1998 +0000
+++ b/src/lread.c	Wed Jan 21 00:37:15 1998 +0000
@@ -268,9 +268,41 @@
        since readchar didn't advance it when we read it.  */
     ;
   else if (BUFFERP (readcharfun))
-    readchar_backlog++;
+    {
+      if (!SINGLE_BYTE_CHAR_P (c))
+	readchar_backlog++;
+      else
+	{
+	  struct buffer *b = XBUFFER (readcharfun);
+	  int bytepos = BUF_PT_BYTE (b);
+
+	  BUF_PT (b)--;
+	  if (! NILP (b->enable_multibyte_characters))
+	    BUF_DEC_POS (b, bytepos);
+	  else
+	    bytepos--;
+
+	  BUF_PT_BYTE (b) = bytepos;
+	}
+    }
   else if (MARKERP (readcharfun))
-    readchar_backlog++;
+    {
+      if (!SINGLE_BYTE_CHAR_P (c))
+	readchar_backlog++;
+      else
+	{
+	  struct buffer *b = XMARKER (readcharfun)->buffer;
+	  int bytepos = XMARKER (readcharfun)->bytepos;
+
+	  XMARKER (readcharfun)->charpos--;
+	  if (! NILP (b->enable_multibyte_characters))
+	    BUF_DEC_POS (b, bytepos);
+	  else
+	    bytepos--;
+
+	  XMARKER (readcharfun)->bytepos = bytepos;
+	}
+    }
   else if (STRINGP (readcharfun))
     read_from_string_index--;
   else if (EQ (readcharfun, Qget_file_char))