Skip to content

Commit

Permalink
Merge branch 'pull-request/2695'
Browse files Browse the repository at this point in the history
* pull-request/2695:
  Replace magic values with constants
  • Loading branch information
cmb69 committed Aug 19, 2017
2 parents 6f55fe0 + e4b9c37 commit 504bf11
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
32 changes: 16 additions & 16 deletions ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions ext/gd/php_gd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 504bf11

Please sign in to comment.