changeset 91805:c330bf7419fd

(FETCH_STRING_CHAR_ADVANCE, FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE) (FETCH_STRING_CHAR_ADVANCE_NO_CHECK): Use SDATA and SREF. (DEC_POS, BUF_DEC_POS): Use BEG_BYTE rather than hardcoding 1.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 12 Feb 2008 21:27:54 +0000
parents d2dce25da0cb
children 6c0a55931b1c
files src/ChangeLog src/character.h
diffstat 2 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Feb 12 21:26:23 2008 +0000
+++ b/src/ChangeLog	Tue Feb 12 21:27:54 2008 +0000
@@ -1,5 +1,10 @@
 2008-02-12  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+	* character.h (FETCH_STRING_CHAR_ADVANCE)
+	(FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE)
+	(FETCH_STRING_CHAR_ADVANCE_NO_CHECK): Use SDATA and SREF.
+	(DEC_POS, BUF_DEC_POS): Use BEG_BYTE rather than hardcoding 1.
+
 	* casefiddle.c (casify_region): Only call after-change and composition
 	functions on the part of the region that was changed.
 
--- a/src/character.h	Tue Feb 12 21:26:23 2008 +0000
+++ b/src/character.h	Tue Feb 12 21:27:54 2008 +0000
@@ -385,14 +385,17 @@
       CHARIDX++;							\
       if (STRING_MULTIBYTE (STRING))					\
 	{								\
-	  unsigned char *ptr = &XSTRING (STRING)->data[BYTEIDX];	\
+	  unsigned char *ptr = &SDATA (STRING)[BYTEIDX];		\
 	  int len;							\
 									\
 	  OUTPUT = STRING_CHAR_AND_LENGTH (ptr, 0, len);		\
 	  BYTEIDX += len;						\
 	}								\
       else								\
-	OUTPUT = XSTRING (STRING)->data[BYTEIDX++];			\
+	{								\
+	  OUTPUT = SREF (STRING, BYTEIDX);				\
+	  BYTEIDX++;							\
+	}								\
     }									\
   while (0)
 
@@ -405,7 +408,7 @@
       CHARIDX++;							      \
       if (STRING_MULTIBYTE (STRING))					      \
 	{								      \
-	  unsigned char *ptr = &XSTRING (STRING)->data[BYTEIDX];	      \
+	  unsigned char *ptr = &SDATA (STRING)[BYTEIDX];		      \
 	  int len;							      \
 									      \
 	  OUTPUT = STRING_CHAR_AND_LENGTH (ptr, 0, len);		      \
@@ -413,7 +416,8 @@
 	}								      \
       else								      \
 	{								      \
-	  OUTPUT = XSTRING (STRING)->data[BYTEIDX++];			      \
+	  OUTPUT = SREF (STRING, BYTEIDX);				      \
+	  BYTEIDX++;							      \
 	  MAKE_CHAR_MULTIBYTE (OUTPUT);					      \
 	}								      \
     }									      \
@@ -425,7 +429,7 @@
 #define FETCH_STRING_CHAR_ADVANCE_NO_CHECK(OUTPUT, STRING, CHARIDX, BYTEIDX) \
   do    								     \
     {									     \
-      unsigned char *ptr = &XSTRING (STRING)->data[BYTEIDX];		     \
+      unsigned char *ptr = &SDATA (STRING)[BYTEIDX];			     \
       int len;								     \
 									     \
       OUTPUT = STRING_CHAR_AND_LENGTH (ptr, 0, len);			     \
@@ -493,9 +497,9 @@
     						\
     pos_byte--;					\
     if (pos_byte < GPT_BYTE)			\
-      p = BEG_ADDR + pos_byte - 1;		\
+      p = BEG_ADDR + pos_byte - BEG_BYTE;	\
     else					\
-      p = BEG_ADDR + GAP_SIZE + pos_byte - 1;	\
+      p = BEG_ADDR + GAP_SIZE + pos_byte - BEG_BYTE;\
     while (!CHAR_HEAD_P (*p))			\
       {						\
 	p--;					\
@@ -551,9 +555,9 @@
     unsigned char *p;							\
     pos_byte--;								\
     if (pos_byte < BUF_GPT_BYTE (buf))					\
-      p = BUF_BEG_ADDR (buf) + pos_byte - 1;				\
+      p = BUF_BEG_ADDR (buf) + pos_byte - BEG_BYTE;			\
     else								\
-      p = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos_byte - 1;	\
+      p = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos_byte - BEG_BYTE;\
     while (!CHAR_HEAD_P (*p))						\
       {									\
 	p--;								\