From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jim Meyering Newsgroups: gmane.emacs.devel Subject: [PATCH] Use "do...while (0)", not "if (1)..else" in macro definitions. Date: Mon, 28 Jan 2008 14:19:56 +0100 Message-ID: <877ihu84ub.fsf@rho.meyering.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1201526420 26100 80.91.229.12 (28 Jan 2008 13:20:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 28 Jan 2008 13:20:20 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 28 14:20:41 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JJTua-0002Ti-FA for ged-emacs-devel@m.gmane.org; Mon, 28 Jan 2008 14:20:32 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JJTu9-0007ag-Fz for ged-emacs-devel@m.gmane.org; Mon, 28 Jan 2008 08:20:05 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JJTu5-0007aY-DS for emacs-devel@gnu.org; Mon, 28 Jan 2008 08:20:01 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JJTu3-0007a0-Nf for emacs-devel@gnu.org; Mon, 28 Jan 2008 08:20:00 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JJTu3-0007Zw-H6 for emacs-devel@gnu.org; Mon, 28 Jan 2008 08:19:59 -0500 Original-Received: from smtp3-g19.free.fr ([212.27.42.29]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JJTu3-0004xY-64 for emacs-devel@gnu.org; Mon, 28 Jan 2008 08:19:59 -0500 Original-Received: from smtp3-g19.free.fr (localhost.localdomain [127.0.0.1]) by smtp3-g19.free.fr (Postfix) with ESMTP id 6ED9317B5AD for ; Mon, 28 Jan 2008 14:19:57 +0100 (CET) Original-Received: from mx.meyering.net (mx.meyering.net [82.230.74.64]) by smtp3-g19.free.fr (Postfix) with ESMTP id 5023917B5A2 for ; Mon, 28 Jan 2008 14:19:57 +0100 (CET) Original-Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id BECBB28855 for ; Mon, 28 Jan 2008 14:19:56 +0100 (CET) Original-Lines: 143 X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:87706 Archived-At: 2008-01-28 Jim Meyering 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. * charset.h (FETCH_STRING_CHAR_ADVANCE): Likewise. (FETCH_STRING_CHAR_ADVANCE_NO_CHECK): Likewise. (FETCH_CHAR_ADVANCE): Likewise. Signed-off-by: Jim Meyering --- src/buffer.h | 4 ++-- src/charset.h | 14 +++++++------- src/syntax.h | 8 ++++---- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/buffer.h b/src/buffer.h index 24c6fc5..2423357 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -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. */ diff --git a/src/charset.h b/src/charset.h index de7a16a..6e60ae1 100644 --- a/src/charset.h +++ b/src/charset.h @@ -582,7 +582,7 @@ extern int iso_charset_table[2][2][128]; we increment them past the character fetched. */ #define FETCH_STRING_CHAR_ADVANCE(OUTPUT, STRING, CHARIDX, BYTEIDX) \ -if (1) \ +do \ { \ CHARIDX++; \ if (STRING_MULTIBYTE (STRING)) \ @@ -597,17 +597,17 @@ if (1) \ else \ OUTPUT = SREF (STRING, BYTEIDX++); \ } \ -else +while (0) /* Like FETCH_STRING_CHAR_ADVANCE but assume STRING is multibyte. */ #define FETCH_STRING_CHAR_ADVANCE_NO_CHECK(OUTPUT, STRING, CHARIDX, BYTEIDX) \ -if (1) \ +do \ { \ const unsigned char *fetch_string_char_ptr = SDATA (STRING) + BYTEIDX; \ int fetch_string_char_space_left = SBYTES (STRING) - BYTEIDX; \ int actual_len; \ - \ + \ OUTPUT \ = STRING_CHAR_AND_LENGTH (fetch_string_char_ptr, \ fetch_string_char_space_left, actual_len); \ @@ -615,13 +615,13 @@ if (1) \ BYTEIDX += actual_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)) \ @@ -639,7 +639,7 @@ if (1) \ BYTEIDX++; \ } \ } \ -else +while (0) /* Return the length of the multi-byte form at string STR of length LEN. */ diff --git a/src/syntax.h b/src/syntax.h index b3980c3..809990b 100644 --- a/src/syntax.h +++ b/src/syntax.h @@ -283,7 +283,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; \ @@ -296,7 +296,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. @@ -306,7 +306,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)) \ @@ -341,7 +341,7 @@ if (1) \ + (COUNT > 0 ? 0 : -1)), \ COUNT, 1, gl_state.object); \ } \ -else +while (0) struct gl_state_s { -- 1.5.4.rc5.1.g0fa73