changeset 23565:077655e1e014

(Fsubst_char_in_region): Fix previous change. (Ftranslate_region): Fix previous change.
author Kenichi Handa <handa@m17n.org>
date Wed, 28 Oct 1998 07:52:13 +0000
parents 6eb3e346d1fd
children 25baa4bda79d
files src/editfns.c
diffstat 1 files changed, 12 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/editfns.c	Wed Oct 28 07:52:13 1998 +0000
+++ b/src/editfns.c	Wed Oct 28 07:52:13 1998 +0000
@@ -2042,13 +2042,11 @@
 	      pos_byte_next = CHAR_TO_BYTE (pos);
 	      if (pos_byte_next > pos_byte)
 		/* Before combining happened.  We should not increment
-		   POS because now it points the next character.  */
-		pos_byte = pos_byte_next;
+		   POS.  So, to cancel the later increment of POS,
+		   decrease it now.  */
+		pos--;
 	      else
-		{
-		  pos++;
-		  INC_POS (pos_byte_next);
-		}
+		INC_POS (pos_byte_next);
 		
 	      if (! NILP (noundo))
 		current_buffer->undo_list = tem;
@@ -2060,15 +2058,10 @@
 	      if (NILP (noundo))
 		record_change (pos, 1);
 	      for (i = 0; i < len; i++) *p++ = tostr[i];
-	      pos_byte = pos_byte_next;
-	      pos++;
 	    }
 	}
-      else
-	{
-	  pos_byte = pos_byte_next;
-	  pos++;
-	}
+      pos_byte = pos_byte_next;
+      pos++;
     }
 
   if (changed)
@@ -2141,36 +2134,23 @@
 		  pos_byte_next = CHAR_TO_BYTE (pos);
 		  if (pos_byte_next > pos_byte)
 		    /* Before combining happened.  We should not
-		       increment POS because now it points the next
-		       character.  */
-		    pos_byte = pos_byte_next;
+		       increment POS.  So, to cancel the later
+		       increment of POS, we decrease it now.  */
+		    pos--;
 		  else
-		    {
-		      pos++;
-		      INC_POS (pos_byte_next);
-		    }
+		    INC_POS (pos_byte_next);
 		}
 	      else
 		{
 		  record_change (pos, 1);
 		  *p = nc;
 		  signal_after_change (pos, 1, 1);
-		  pos_byte++;
-		  pos++;
 		}
 	      ++cnt;
 	    }
-	  else
-	    {
-	      pos_byte++;
-	      pos++;
-	    }
 	}
-      else
-	{
-	  pos_byte += len;
-	  pos++;
-	}
+      pos_byte = pos_byte_next;
+      pos++;
     }
 
   return make_number (cnt);