(scan_lists): Follow coding convention.
[bpt/emacs.git] / src / character.h
index 1e4a120..41cc8d7 100644 (file)
@@ -1,7 +1,7 @@
 /* Header for multibyte character handler.
    Copyright (C) 1995, 1997, 1998 Electrotechnical Laboratory, JAPAN.
      Licensed to the Free Software Foundation.
-   Copyright (C) 2003, 2006
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H13PRO009
 
@@ -9,7 +9,7 @@ This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -18,9 +18,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+along with GNU Emacs; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
 #ifndef EMACS_CHARACTER_H
 #define EMACS_CHARACTER_H
@@ -380,32 +380,35 @@ extern char unibyte_has_multibyte_table[256];
    we increment them past the character fetched.  */
 
 #define FETCH_STRING_CHAR_ADVANCE(OUTPUT, STRING, CHARIDX, BYTEIDX)    \
-  if (1)                                                               \
+  do                                                                    \
     {                                                                  \
       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++;                                                    \
+       }                                                               \
     }                                                                  \
-  else
+  while (0)
 
 /* Like FETCH_STRING_CHAR_ADVANCE but return a multibyte character eve
    if STRING is unibyte.  */
 
 #define FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE(OUTPUT, STRING, CHARIDX, BYTEIDX) \
-  if (1)                                                                     \
+  do                                                                          \
     {                                                                        \
       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,33 +416,34 @@ extern char unibyte_has_multibyte_table[256];
        }                                                                     \
       else                                                                   \
        {                                                                     \
-         OUTPUT = XSTRING (STRING)->data[BYTEIDX++];                         \
+         OUTPUT = SREF (STRING, BYTEIDX);                                    \
+         BYTEIDX++;                                                          \
          MAKE_CHAR_MULTIBYTE (OUTPUT);                                       \
        }                                                                     \
     }                                                                        \
-  else
+  while (0)
 
 
 /* Like FETCH_STRING_CHAR_ADVANCE but assumes STRING is multibyte.  */
 
 #define FETCH_STRING_CHAR_ADVANCE_NO_CHECK(OUTPUT, STRING, CHARIDX, BYTEIDX) \
-  if (1)                                                                    \
+  do                                                                        \
     {                                                                       \
-      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;                                                       \
       CHARIDX++;                                                            \
     }                                                                       \
-  else
+  while (0)
 
 
 /* Like FETCH_STRING_CHAR_ADVANCE but fetch character from the current
    buffer.  */
 
 #define FETCH_CHAR_ADVANCE(OUTPUT, CHARIDX, BYTEIDX)           \
-  if (1)                                                       \
+  do                                                           \
     {                                                          \
       CHARIDX++;                                               \
       if (!NILP (current_buffer->enable_multibyte_characters)) \
@@ -456,13 +460,13 @@ extern char unibyte_has_multibyte_table[256];
          BYTEIDX++;                                            \
        }                                                       \
     }                                                          \
-  else
+  while (0)
 
 
 /* Like FETCH_CHAR_ADVANCE but assumes the current buffer is multibyte.  */
 
 #define FETCH_CHAR_ADVANCE_NO_CHECK(OUTPUT, CHARIDX, BYTEIDX)  \
-  if (1)                                                       \
+  do                                                           \
     {                                                          \
       unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX);            \
       int len;                                                 \
@@ -471,7 +475,7 @@ extern char unibyte_has_multibyte_table[256];
       BYTEIDX += len;                                          \
       CHARIDX++;                                               \
     }                                                          \
-  else
+  while (0)
 
 
 /* Increase the buffer byte position POS_BYTE of the current buffer to
@@ -493,9 +497,9 @@ extern char unibyte_has_multibyte_table[256];
                                                \
     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 @@ extern char unibyte_has_multibyte_table[256];
     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--;                                                            \