com php-src: Replace magic values with constants: ext/gd/gd.c ext/gd/php_gd.h
| From: | Christoph Michael Becker | Date: | Sat, 19 Aug 2017 12:28:22 +0000 |
| Subject: | com php-src: Replace magic values with constants: ext/gd/gd.c ext/gd/php_gd.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-99111@lists.php.net to get a copy of this message | ||
Commit: e4b9c3744c2bb7ff9b1626a1ea3b954a4cb034ca
Author: Andreas Treichel <gmblar+github@gmail.com> Sat, 19 Aug 2017 14:28:22 +0200
Parents: b6ea3ec2a1a66700bbb4faced99b4b78b4599191
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e4b9c3744c2bb7ff9b1626a1ea3b954a4cb034ca
Log:
Replace magic values with constants
Changed paths:
M ext/gd/gd.c
M ext/gd/php_gd.h
Diff:
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index 2de1a0a..e5ab805 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -1101,14 +1101,14 @@ PHP_MINIT_FUNCTION(gd)
REGISTER_INI_ENTRIES();
- REGISTER_LONG_CONSTANT("IMG_GIF", 1, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("IMG_JPG", 2, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("IMG_JPEG", 2, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("IMG_PNG", 4, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("IMG_WBMP", 8, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("IMG_XPM", 16, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("IMG_WEBP", 32, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("IMG_BMP", 64, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("IMG_GIF", PHP_IMG_GIF, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("IMG_JPG", PHP_IMG_JPG, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("IMG_JPEG", PHP_IMG_JPEG, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("IMG_PNG", PHP_IMG_PNG, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("IMG_WBMP", PHP_IMG_WBMP, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("IMG_XPM", PHP_IMG_XPM, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("IMG_WEBP", PHP_IMG_WEBP, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("IMG_BMP", PHP_IMG_BMP, CONST_CS | CONST_PERSISTENT);
/* special colours for gd */
REGISTER_LONG_CONSTANT("IMG_COLOR_TILED", gdTiled, CONST_CS | CONST_PERSISTENT);
@@ -2174,23 +2174,23 @@ PHP_FUNCTION(imagecreate)
Return the types of images supported in a bitfield - 1=GIF, 2=JPEG, 4=PNG, 8=WBMP, 16=XPM */
PHP_FUNCTION(imagetypes)
{
- int ret=0;
- ret = 1;
+ int ret = 0;
+ ret = PHP_IMG_GIF;
#ifdef HAVE_GD_JPG
- ret |= 2;
+ ret |= PHP_IMG_JPG;
#endif
#ifdef HAVE_GD_PNG
- ret |= 4;
+ ret |= PHP_IMG_PNG;
#endif
- ret |= 8;
+ ret |= PHP_IMG_WBMP;
#if defined(HAVE_GD_XPM)
- ret |= 16;
+ ret |= PHP_IMG_XPM;
#endif
#ifdef HAVE_GD_WEBP
- ret |= 32;
+ ret |= PHP_IMG_WEBP;
#endif
#ifdef HAVE_GD_BMP
- ret |= 64;
+ ret |= PHP_IMG_BMP;
#endif
if (zend_parse_parameters_none() == FAILURE) {
diff --git a/ext/gd/php_gd.h b/ext/gd/php_gd.h
index 7f94b25..253b27d 100644
--- a/ext/gd/php_gd.h
+++ b/ext/gd/php_gd.h
@@ -50,6 +50,15 @@
#define PHP_GDIMG_TYPE_WEBP 11
#define PHP_GDIMG_TYPE_BMP 12
+#define PHP_IMG_GIF 1
+#define PHP_IMG_JPG 2
+#define PHP_IMG_JPEG 2
+#define PHP_IMG_PNG 4
+#define PHP_IMG_WBMP 8
+#define PHP_IMG_XPM 16
+#define PHP_IMG_WEBP 32
+#define PHP_IMG_BMP 64
+
#ifdef PHP_WIN32
# define PHP_GD_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4