]> git.eshelyaron.com Git - emacs.git/commitdiff
Use "do...while (0)", not "if (1)..else" in macro definitions.
authorJan Djärv <jan.h.d@swipnet.se>
Thu, 7 Feb 2008 12:47:00 +0000 (12:47 +0000)
committerJan Djärv <jan.h.d@swipnet.se>
Thu, 7 Feb 2008 12:47:00 +0000 (12:47 +0000)
src/ChangeLog
src/buffer.h
src/syntax.h

index 9fcc90c2391d5ff5b2be5a3d1155e651c53dcfb9..396ce321f725ecb7954d4da81a20dacb2e21cac9 100644 (file)
@@ -1,3 +1,13 @@
+2008-02-07  Jim Meyering  <meyering@redhat.com>
+
+        Use "do...while (0)", not "if (1)..else" in macro definitions.
+        The latter provokes a warning from gcc about the empty else, when
+        followed by ";".  Also, without that trailing semicolon, it would
+        silently swallow up any following statement.
+        * syntax.h (SETUP_SYNTAX_TABLE):
+        (SETUP_SYNTAX_TABLE_FOR_OBJECT): Likewise.
+        * buffer.h (DECODE_POSITION): Likewise.
+
 2008-02-07  Jim Meyering  <meyering@redhat.com>
 
        * lread.c [lint]: Don't include <sys/inode.h>.
index 87d646f35fece83f5cef10318e65a4e543a4a4db..8345c8fa06f6927007915987634cee6bd423e502 100644 (file)
@@ -266,7 +266,7 @@ extern void enlarge_buffer_text P_ ((struct buffer *, int));
    and store the charpos in CHARPOS and the bytepos in BYTEPOS.  */
 
 #define DECODE_POSITION(charpos, bytepos, pos)                 \
-if (1)                                                         \
+do                                                             \
   {                                                            \
     Lisp_Object __pos = (pos);                                 \
     if (NUMBERP (__pos))                                       \
@@ -282,7 +282,7 @@ if (1)                                                              \
     else                                                       \
       wrong_type_argument (Qinteger_or_marker_p, __pos);       \
   }                                                            \
-else
+while (0)
 
 /* Return the address of byte position N in current buffer.  */
 
index 5a5a8a96da3843b1e73bd83a0dc51a843f4b49aa..1138dca98870a5b547631bb106105f0153b6a6dc 100644 (file)
@@ -256,7 +256,7 @@ extern char syntax_code_spec[16];
  */
 
 #define SETUP_SYNTAX_TABLE(FROM, COUNT)                                        \
-if (1)                                                                 \
+do                                                                     \
   {                                                                    \
     gl_state.b_property = BEGV;                                                \
     gl_state.e_property = ZV + 1;                                      \
@@ -269,7 +269,7 @@ if (1)                                                                      \
         update_syntax_table ((COUNT) > 0 ? (FROM) : (FROM) - 1, (COUNT),\
                             1, Qnil);                                  \
   }                                                                    \
-else
+while (0)
 
 /* Same as above, but in OBJECT.  If OBJECT is nil, use current buffer.
    If it is t, ignore properties altogether.
@@ -279,7 +279,7 @@ else
    So if it is a buffer, we set the offset field to BEGV.  */
 
 #define SETUP_SYNTAX_TABLE_FOR_OBJECT(OBJECT, FROM, COUNT)             \
-if (1)                                                                 \
+do                                                                     \
   {                                                                    \
     gl_state.object = (OBJECT);                                                \
     if (BUFFERP (gl_state.object))                                     \
@@ -314,7 +314,7 @@ if (1)                                                                      \
                            + (COUNT > 0 ? 0 :  -1)),                   \
                           COUNT, 1, gl_state.object);                  \
   }                                                                    \
-else
+while (0)
 
 struct gl_state_s
 {