From: George Peter Banyard Date: Wed, 20 May 2020 15:35:42 +0000 (+0200) Subject: Fix [-Wundef] warning in GD extension X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f0dcf2ac2d8459ec1481ca256b74e4959da3979;p=php Fix [-Wundef] warning in GD extension --- diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 7f9d057106..4089e40691 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -390,7 +390,7 @@ PHP_MINIT_FUNCTION(gd) REGISTER_LONG_CONSTANT("IMG_AFFINE_SHEAR_HORIZONTAL", GD_AFFINE_SHEAR_HORIZONTAL, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMG_AFFINE_SHEAR_VERTICAL", GD_AFFINE_SHEAR_VERTICAL, CONST_CS | CONST_PERSISTENT); -#if defined(HAVE_GD_BUNDLED) +#ifdef HAVE_GD_BUNDLED REGISTER_LONG_CONSTANT("GD_BUNDLED", 1, CONST_CS | CONST_PERSISTENT); #else REGISTER_LONG_CONSTANT("GD_BUNDLED", 0, CONST_CS | CONST_PERSISTENT); @@ -467,7 +467,7 @@ PHP_RSHUTDOWN_FUNCTION(gd) } /* }}} */ -#if defined(HAVE_GD_BUNDLED) +#ifdef HAVE_GD_BUNDLED #define PHP_GD_VERSION_STRING "bundled (2.1.0 compatible)" #else # define PHP_GD_VERSION_STRING GD_VERSION_STRING @@ -482,11 +482,11 @@ PHP_MINFO_FUNCTION(gd) /* need to use a PHPAPI function here because it is external module in windows */ -#if defined(HAVE_GD_BUNDLED) +#ifdef HAVE_GD_BUNDLED php_info_print_table_row(2, "GD Version", PHP_GD_VERSION_STRING); #else php_info_print_table_row(2, "GD headers Version", PHP_GD_VERSION_STRING); -#if defined(HAVE_GD_LIBVERSION) +#ifdef HAVE_GD_LIBVERSION php_info_print_table_row(2, "GD library Version", gdVersionString()); #endif #endif @@ -516,7 +516,7 @@ PHP_MINFO_FUNCTION(gd) #ifdef HAVE_GD_JPG { php_info_print_table_row(2, "JPEG Support", "enabled"); -#if defined(HAVE_GD_BUNDLED) +#ifdef HAVE_GD_BUNDLED php_info_print_table_row(2, "libJPEG Version", gdJpegGetVersionString()); #endif } @@ -524,14 +524,14 @@ PHP_MINFO_FUNCTION(gd) #ifdef HAVE_GD_PNG php_info_print_table_row(2, "PNG Support", "enabled"); -#if defined(HAVE_GD_BUNDLED) +#ifdef HAVE_GD_BUNDLED php_info_print_table_row(2, "libPNG Version", gdPngGetVersionString()); #endif #endif php_info_print_table_row(2, "WBMP Support", "enabled"); -#if defined(HAVE_GD_XPM) +#ifdef HAVE_GD_XPM php_info_print_table_row(2, "XPM Support", "enabled"); -#if defined(HAVE_GD_BUNDLED) +#ifdef HAVE_GD_BUNDLED { char tmp[12]; snprintf(tmp, sizeof(tmp), "%d", XpmLibraryVersion()); @@ -540,7 +540,7 @@ PHP_MINFO_FUNCTION(gd) #endif #endif php_info_print_table_row(2, "XBM Support", "enabled"); -#if defined(USE_GD_JISX0208) +#ifdef USE_GD_JISX0208 php_info_print_table_row(2, "JIS-mapped Japanese Font Support", "enabled"); #endif #ifdef HAVE_GD_WEBP @@ -588,7 +588,7 @@ PHP_FUNCTION(gd_info) add_assoc_bool(return_value, "PNG Support", 0); #endif add_assoc_bool(return_value, "WBMP Support", 1); -#if defined(HAVE_GD_XPM) +#ifdef HAVE_GD_XPM add_assoc_bool(return_value, "XPM Support", 1); #else add_assoc_bool(return_value, "XPM Support", 0); @@ -609,7 +609,7 @@ PHP_FUNCTION(gd_info) #else add_assoc_bool(return_value, "TGA Read Support", 0); #endif -#if defined(USE_GD_JISX0208) +#ifdef USE_GD_JISX0208 add_assoc_bool(return_value, "JIS-mapped Japanese Font Support", 1); #else add_assoc_bool(return_value, "JIS-mapped Japanese Font Support", 0); @@ -1399,7 +1399,7 @@ PHP_FUNCTION(imagetypes) ret |= PHP_IMG_PNG; #endif ret |= PHP_IMG_WBMP; -#if defined(HAVE_GD_XPM) +#ifdef HAVE_GD_XPM ret |= PHP_IMG_XPM; #endif #ifdef HAVE_GD_WEBP @@ -1676,7 +1676,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, case PHP_GDIMG_TYPE_GD2PART: im = (*func_p)(fp, srcx, srcy, width, height); break; -#if defined(HAVE_GD_XPM) +#ifdef HAVE_GD_XPM case PHP_GDIMG_TYPE_XPM: im = gdImageCreateFromXpm(file); break; @@ -1758,7 +1758,7 @@ PHP_FUNCTION(imagecreatefromxbm) } /* }}} */ -#if defined(HAVE_GD_XPM) +#ifdef HAVE_GD_XPM /* {{{ proto resource imagecreatefromxpm(string filename) Create a new image from XPM file or URL */ PHP_FUNCTION(imagecreatefromxpm) @@ -1800,7 +1800,7 @@ PHP_FUNCTION(imagecreatefromgd2part) } /* }}} */ -#if defined(HAVE_GD_BMP) +#ifdef HAVE_GD_BMP /* {{{ proto resource imagecreatefrombmp(string filename) Create a new image from BMP file or URL */ PHP_FUNCTION(imagecreatefrombmp) @@ -1810,7 +1810,7 @@ PHP_FUNCTION(imagecreatefrombmp) /* }}} */ #endif -#if defined(HAVE_GD_TGA) +#ifdef HAVE_GD_TGA /* {{{ proto resource imagecreatefromtga(string filename) Create a new image from TGA file or URL */ PHP_FUNCTION(imagecreatefromtga) diff --git a/ext/gd/libgd/gd_tga.c b/ext/gd/libgd/gd_tga.c index 125a698f24..3f9922189a 100644 --- a/ext/gd/libgd/gd_tga.c +++ b/ext/gd/libgd/gd_tga.c @@ -168,7 +168,7 @@ int read_header_tga(gdIOCtx *ctx, oTga *tga) tga->fliph = (header[17] & 0x10) ? 1 : 0; tga->flipv = (header[17] & 0x20) ? 0 : 1; -#if DEBUG +#ifdef DEBUG printf("format bps: %i\n", tga->bits); printf("flip h/v: %i / %i\n", tga->fliph, tga->flipv); printf("alpha: %i\n", tga->alphabits); diff --git a/ext/gd/libgd/gdcache.h b/ext/gd/libgd/gdcache.h index 0c5f83d92a..07b11bd7e2 100644 --- a/ext/gd/libgd/gdcache.h +++ b/ext/gd/libgd/gdcache.h @@ -41,7 +41,7 @@ /*********************************************************/ #include -#if (!defined(__OpenBSD__)) && HAVE_MALLOC_H +#if (!defined(__OpenBSD__)) && defined(HAVE_MALLOC_H) #include #endif #ifndef NULL diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c index d68703aa32..71d32375b1 100644 --- a/ext/gd/libgd/gdft.c +++ b/ext/gd/libgd/gdft.c @@ -412,9 +412,9 @@ static void *fontFetch (char **error, void *key) for (dir = gd_strtok_r (path, PATHSEPARATOR, &strtok_ptr_path); dir; dir = gd_strtok_r (0, PATHSEPARATOR, &strtok_ptr_path)) { if (!strcmp(dir, ".")) { - #if HAVE_GETCWD + #ifdef HAVE_GETCWD dir = VCWD_GETCWD(cur_dir, MAXPATHLEN); -#elif HAVE_GETWD +#elif defined(HAVE_GETWD) dir = VCWD_GETWD(cur_dir); #endif if (!dir) {