[cairo] [PATCH 6/8] Don't use bare #if on possibly undefined preprocessor symbols

Behdad Esfahbod behdad at behdad.org
Sun Aug 13 01:50:04 PDT 2006


On Sun, 2006-08-13 at 01:57 -0400, Pavel Roskin wrote:
> From: Pavel Roskin <proski at gnu.org>
> 
> When testing for symbols from Autoconf-generated config.h, we should
> test for is whether the symbol is defined.

This one I wanted to do too, but Carl doesn't like it.  The problem with
using ifdef of course is that defining something to zero doesn't turn it
off.  I decided to take the warning flag out of my environment instead.

behdad


> Signed-off-by: Pavel Roskin <proski at gnu.org>
> ---
> 
>  pixman/src/pixman.h         |    6 +++---
>  src/cairo-ft-font.c         |   12 ++++++------
>  src/cairo-wideint-private.h |   10 +++++-----
>  src/cairo-wideint.c         |    8 ++++----
>  src/cairo-xlib-screen.c     |    2 +-
>  src/cairoint.h              |    4 ++--
>  test/buffer-diff.c          |    2 +-
>  test/cairo-test.c           |    6 +++---
>  test/cairo-test.h           |    8 ++++----
>  test/pdf-features.c         |    4 ++--
>  test/ps-features.c          |    4 ++--
>  test/pthread-show-text.c    |    4 ++--
>  test/read-png.c             |    8 ++++----
>  13 files changed, 39 insertions(+), 39 deletions(-)
> 
> diff --git a/pixman/src/pixman.h b/pixman/src/pixman.h
> index 57b317a..a083f78 100644
> --- a/pixman/src/pixman.h
> +++ b/pixman/src/pixman.h
> @@ -78,11 +78,11 @@ #ifdef HAVE_CONFIG_H
>  # include "config.h"
>  #endif
>  
> -#if   HAVE_STDINT_H
> +#ifdef HAVE_STDINT_H
>  # include <stdint.h>
> -#elif HAVE_INTTYPES_H
> +#elif defined(HAVE_INTTYPES_H)
>  # include <inttypes.h>
> -#elif HAVE_SYS_INT_TYPES_H
> +#elif defined(HAVE_SYS_INT_TYPES_H)
>  # include <sys/int_types.h>
>  #elif defined(_MSC_VER)
>    typedef __int8 int8_t;
> diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
> index be9db5b..096c869 100644
> --- a/src/cairo-ft-font.c
> +++ b/src/cairo-ft-font.c
> @@ -49,7 +49,7 @@ #include FT_FREETYPE_H
>  #include FT_OUTLINE_H
>  #include FT_IMAGE_H
>  #include FT_TRUETYPE_TABLES_H
> -#if HAVE_FT_GLYPHSLOT_EMBOLDEN
> +#ifdef HAVE_FT_GLYPHSLOT_EMBOLDEN
>  #include FT_SYNTHESIS_H
>  #endif
>  
> @@ -654,7 +654,7 @@ _cairo_ft_unscaled_font_set_scale (cairo
>  	pixel_width = pixel_height = 0;
>  
>  	for (i = 0; i < unscaled->face->num_fixed_sizes; i++) {
> -#if HAVE_FT_BITMAP_SIZE_Y_PPEM
> +#ifdef HAVE_FT_BITMAP_SIZE_Y_PPEM
>  	    double size = unscaled->face->available_sizes[i].y_ppem / 64.;
>  #else
>  	    double size = unscaled->face->available_sizes[i].height;
> @@ -666,7 +666,7 @@ #endif
>  		best_i = i;
>  	    }
>  	}
> -#if HAVE_FT_BITMAP_SIZE_Y_PPEM
> +#ifdef HAVE_FT_BITMAP_SIZE_Y_PPEM
>  	error = FT_Set_Char_Size (unscaled->face,
>  				  unscaled->face->available_sizes[best_i].x_ppem,
>  				  unscaled->face->available_sizes[best_i].y_ppem,
> @@ -1794,7 +1794,7 @@ _cairo_ft_scaled_glyph_init (void			*abs
>  
>      glyph = face->glyph;
>  
> -#if HAVE_FT_GLYPHSLOT_EMBOLDEN
> +#ifdef HAVE_FT_GLYPHSLOT_EMBOLDEN
>      /*
>       * embolden glyphs if requested
>       */
> @@ -1933,7 +1933,7 @@ #endif
>  		cairo_ft_scaled_font_unlock_face (abstract_font);
>  		return CAIRO_STATUS_NO_MEMORY;
>  	    }
> -#if HAVE_FT_GLYPHSLOT_EMBOLDEN
> +#ifdef HAVE_FT_GLYPHSLOT_EMBOLDEN
>  	    /*
>  	     * embolden glyphs if requested
>  	     */
> @@ -2012,7 +2012,7 @@ _cairo_ft_load_truetype_table (void	    
>      if (_cairo_ft_scaled_font_is_vertical (&scaled_font->base))
>          return CAIRO_INT_STATUS_UNSUPPORTED;
>  
> -#if HAVE_FT_LOAD_SFNT_TABLE
> +#ifdef HAVE_FT_LOAD_SFNT_TABLE
>      face = _cairo_ft_unscaled_font_lock_face (unscaled);
>      if (!face)
>  	return CAIRO_STATUS_NO_MEMORY;
> diff --git a/src/cairo-wideint-private.h b/src/cairo-wideint-private.h
> index 1841a44..e5b0978 100644
> --- a/src/cairo-wideint-private.h
> +++ b/src/cairo-wideint-private.h
> @@ -37,11 +37,11 @@
>  #ifndef CAIRO_WIDEINT_H
>  #define CAIRO_WIDEINT_H
>  
> -#if   HAVE_STDINT_H
> +#ifdef HAVE_STDINT_H
>  # include <stdint.h>
> -#elif HAVE_INTTYPES_H
> +#elif defined(HAVE_INTTYPES_H)
>  # include <inttypes.h>
> -#elif HAVE_SYS_INT_TYPES_H
> +#elif defined(HAVE_SYS_INT_TYPES_H)
>  # include <sys/int_types.h>
>  #elif defined(_MSC_VER)
>    typedef __int8 int8_t;
> @@ -76,7 +76,7 @@ #endif
>  
>  #define I cairo_private
>  
> -#if !HAVE_UINT64_T
> +#ifndef HAVE_UINT64_T
>  
>  typedef struct _cairo_uint64 {
>      uint32_t	lo, hi;
> @@ -195,7 +195,7 @@ _cairo_int64_divrem (cairo_int64_t num, 
>   * on ia64
>   */
>  
> -#if !HAVE_UINT128_T
> +#ifndef HAVE_UINT128_T
>  
>  typedef struct cairo_uint128 {
>      cairo_uint64_t	lo, hi;
> diff --git a/src/cairo-wideint.c b/src/cairo-wideint.c
> index da68f1b..8057eec 100644
> --- a/src/cairo-wideint.c
> +++ b/src/cairo-wideint.c
> @@ -35,7 +35,7 @@
>  
>  #include "cairoint.h"
>  
> -#if HAVE_UINT64_T
> +#ifdef HAVE_UINT64_T
>  
>  #define _cairo_uint32s_to_uint64(h,l) ((uint64_t) (h) << 32 | (l))
>  
> @@ -315,7 +315,7 @@ _cairo_int64_divrem (cairo_int64_t num, 
>      return qr;
>  }
>  
> -#if HAVE_UINT128_T
> +#ifdef HAVE_UINT128_T
>  
>  cairo_uquorem128_t
>  _cairo_uint128_divrem (cairo_uint128_t num, cairo_uint128_t den)
> @@ -393,7 +393,7 @@ _cairo_uint128_sub (cairo_uint128_t a, c
>      return s;
>  }
>  
> -#if HAVE_UINT64_T
> +#ifdef HAVE_UINT64_T
>  
>  #define uint64_lo32(i)	((i) & 0xffffffff)
>  #define uint64_hi32(i)	((i) >> 32)
> @@ -576,7 +576,7 @@ _cairo_uint128_eq (cairo_uint128_t a, ca
>  	    _cairo_uint64_eq (a.lo, b.lo));
>  }
>  
> -#if HAVE_UINT64_T
> +#ifdef HAVE_UINT64_T
>  #define _cairo_msbset64(q)  (q & ((uint64_t) 1 << 63))
>  #else
>  #define _cairo_msbset64(q)  (q.hi & ((uint32_t) 1 << 31))
> diff --git a/src/cairo-xlib-screen.c b/src/cairo-xlib-screen.c
> index cbdb540..c85f222 100644
> --- a/src/cairo-xlib-screen.c
> +++ b/src/cairo-xlib-screen.c
> @@ -377,7 +377,7 @@ _cairo_xlib_screen_reset_static_data (vo
>  {
>      _cairo_xlib_screen_info_reset ();
>  
> -#if HAVE_XRMFINALIZE
> +#ifdef HAVE_XRMFINALIZE
>      XrmFinalize ();
>  #endif
>  
> diff --git a/src/cairoint.h b/src/cairoint.h
> index 034463a..f19ff1e 100644
> --- a/src/cairoint.h
> +++ b/src/cairoint.h
> @@ -46,7 +46,7 @@
>  #ifndef _CAIROINT_H_
>  #define _CAIROINT_H_
>  
> -#if HAVE_CONFIG_H
> +#ifdef HAVE_CONFIG_H
>  #include "config.h"
>  #endif
>  
> @@ -133,7 +133,7 @@ #else
>  #define INLINE
>  #endif
>  
> -#if HAVE_PTHREAD_H
> +#ifdef HAVE_PTHREAD_H
>  # include <pthread.h>
>  # define CAIRO_MUTEX_DECLARE(name) static pthread_mutex_t name = PTHREAD_MUTEX_INITIALIZER
>  #define CAIRO_MUTEX_DECLARE_GLOBAL(name) pthread_mutex_t name = PTHREAD_MUTEX_INITIALIZER
> diff --git a/test/buffer-diff.c b/test/buffer-diff.c
> index 5463c29..41c316d 100644
> --- a/test/buffer-diff.c
> +++ b/test/buffer-diff.c
> @@ -23,7 +23,7 @@
>   *
>   * Author: Richard D. Worth <richard at theworths.org> */
>  
> -#if HAVE_CONFIG_H
> +#ifdef HAVE_CONFIG_H
>  #include "config.h"
>  #endif
>  
> diff --git a/test/cairo-test.c b/test/cairo-test.c
> index 2fd6508..b8fb8d7 100644
> --- a/test/cairo-test.c
> +++ b/test/cairo-test.c
> @@ -23,7 +23,7 @@
>   * Author: Carl D. Worth <cworth at cworth.org>
>   */
>  
> -#if HAVE_CONFIG_H
> +#ifdef HAVE_CONFIG_H
>  #include "config.h"
>  #endif
>  
> @@ -39,7 +39,7 @@ #include <unistd.h>
>  #endif
>  #include <errno.h>
>  #include <string.h>
> -#if HAVE_FCFINI
> +#ifdef HAVE_FCFINI
>  #include <fontconfig/fontconfig.h>
>  #endif
>  
> @@ -2016,7 +2016,7 @@ #endif
>  
>      free (targets_to_test);
>  
> -#if HAVE_FCFINI
> +#ifdef HAVE_FCFINI
>      FcFini ();
>  #endif
>  
> diff --git a/test/cairo-test.h b/test/cairo-test.h
> index 8402d13..878eceb 100644
> --- a/test/cairo-test.h
> +++ b/test/cairo-test.h
> @@ -26,7 +26,7 @@
>  #ifndef _CAIRO_TEST_H_
>  #define _CAIRO_TEST_H_
>  
> -#if HAVE_CONFIG_H
> +#ifdef HAVE_CONFIG_H
>  #include "config.h"
>  #endif
>  
> @@ -36,11 +36,11 @@ #include <cairo.h>
>  
>  CAIRO_BEGIN_DECLS
>  
> -#if   HAVE_STDINT_H
> +#ifdef HAVE_STDINT_H
>  # include <stdint.h>
> -#elif HAVE_INTTYPES_H
> +#elif defined(HAVE_INTTYPES_H)
>  # include <inttypes.h>
> -#elif HAVE_SYS_INT_TYPES_H
> +#elif defined(HAVE_SYS_INT_TYPES_H
>  # include <sys/int_types.h>
>  #elif defined(_MSC_VER)
>  typedef __int8 int8_t;
> diff --git a/test/pdf-features.c b/test/pdf-features.c
> index f790499..23116a2 100644
> --- a/test/pdf-features.c
> +++ b/test/pdf-features.c
> @@ -26,7 +26,7 @@
>  #include <stdio.h>
>  #include <cairo.h>
>  #include <cairo-pdf.h>
> -#if HAVE_FCFINI
> +#ifdef HAVE_FCFINI
>  #include <fontconfig/fontconfig.h>
>  #endif
>  
> @@ -142,7 +142,7 @@ main (void)
>  
>      cairo_debug_reset_static_data ();
>  
> -#if HAVE_FCFINI
> +#ifdef HAVE_FCFINI
>      FcFini ();
>  #endif
>  
> diff --git a/test/ps-features.c b/test/ps-features.c
> index e2882ff..3d11002 100644
> --- a/test/ps-features.c
> +++ b/test/ps-features.c
> @@ -26,7 +26,7 @@
>  #include <stdio.h>
>  #include <cairo.h>
>  #include <cairo-ps.h>
> -#if HAVE_FCFINI
> +#ifdef HAVE_FCFINI
>  #include <fontconfig/fontconfig.h>
>  #endif
>  
> @@ -156,7 +156,7 @@ main (void)
>  
>      cairo_debug_reset_static_data ();
>  
> -#if HAVE_FCFINI
> +#ifdef HAVE_FCFINI
>      FcFini ();
>  #endif
>  
> diff --git a/test/pthread-show-text.c b/test/pthread-show-text.c
> index d04de8b..a47c4bc 100644
> --- a/test/pthread-show-text.c
> +++ b/test/pthread-show-text.c
> @@ -35,7 +35,7 @@ #include "xmalloc.h"
>  #include <string.h>
>  #include <stdlib.h>
>  #include <pthread.h>
> -#if HAVE_FCFINI
> +#ifdef HAVE_FCFINI
>  #include <fontconfig/fontconfig.h>
>  #endif
>  
> @@ -102,7 +102,7 @@ main (int argc, char *argv[])
>      free (pthread);
>  
>      cairo_debug_reset_static_data ();
> -#if HAVE_FCFINI
> +#ifdef HAVE_FCFINI
>      FcFini ();
>  #endif
>  
> diff --git a/test/read-png.c b/test/read-png.c
> index bb02e50..54efffd 100644
> --- a/test/read-png.c
> +++ b/test/read-png.c
> @@ -25,15 +25,15 @@
>   * Author: Carl D. Worth <cworth at isi.edu>
>   */
>  
> -#if HAVE_CONFIG_H
> +#ifdef HAVE_CONFIG_H
>  #include "config.h"
>  #endif
>  
> -#if   HAVE_STDINT_H
> +#ifdef HAVE_STDINT_H
>  # include <stdint.h>
> -#elif HAVE_INTTYPES_H
> +#elif defined(HAVE_INTTYPES_H)
>  # include <inttypes.h>
> -#elif HAVE_SYS_INT_TYPES_H
> +#elif defined(HAVE_SYS_INT_TYPES_H)
>  # include <sys/int_types.h>
>  #elif defined(_MSC_VER)
>    typedef __int8 int8_t;
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://cairographics.org/cgi-bin/mailman/listinfo/cairo
-- 
behdad
http://behdad.org/

"Commandment Three says Do Not Kill, Amendment Two says Blood Will Spill"
        -- Dan Bern, "New American Language"



More information about the cairo mailing list