diff options
author | sskaje <sskaje@gmail.com> | 2017-01-03 18:42:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-03 18:42:27 +0800 |
commit | 4935f795e84e07bfe5deee46bd5f8046c89d5574 (patch) | |
tree | f1aa4245784cbcce930c6b81a48ccd37089ae931 /ext/standard/pack.c | |
parent | 788a2d0226f64b80142dd66f4731003ed4acb4f8 (diff) | |
parent | 0788f3ed3c66db12187500fe089fb9cb5528783b (diff) | |
download | php-git-4935f795e84e07bfe5deee46bd5f8046c89d5574.tar.gz |
Merge branch 'master' into master
Diffstat (limited to 'ext/standard/pack.c')
-rw-r--r-- | ext/standard/pack.c | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/ext/standard/pack.c b/ext/standard/pack.c index a450ec9525..6feb1e5a5c 100644 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@ -28,13 +28,6 @@ #ifdef PHP_WIN32 #define O_RDONLY _O_RDONLY #include "win32/param.h" -#elif defined(NETWARE) -#ifdef USE_WINSOCK -#include <novsock2.h> -#else -#include <sys/socket.h> -#endif -#include <sys/param.h> #else #include <sys/param.h> #endif @@ -92,7 +85,7 @@ static int little_endian_longlong_map[8]; */ static void php_pack(zval *val, size_t size, int *map, char *output) { - int i; + size_t i; char *v; convert_to_long_ex(val); @@ -236,19 +229,21 @@ static double php_pack_parse_double(int is_little_endian, void * src) PHP_FUNCTION(pack) { zval *argv = NULL; - int num_args = 0, i; + int num_args = 0; + size_t i; int currentarg; char *format; size_t formatlen; char *formatcodes; int *formatargs; - int formatcount = 0; + size_t formatcount = 0; int outputpos = 0, outputsize = 0; zend_string *output; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s*", &format, &formatlen, &argv, &num_args) == FAILURE) { - return; - } + ZEND_PARSE_PARAMETERS_START(1, -1) + Z_PARAM_STRING(format, formatlen) + Z_PARAM_VARIADIC('*', argv, num_args) + ZEND_PARSE_PARAMETERS_END(); /* We have a maximum of <formatlen> format codes to deal with */ formatcodes = safe_emalloc(formatlen, sizeof(*formatcodes), 0); @@ -466,7 +461,7 @@ PHP_FUNCTION(pack) case 'a': case 'A': case 'Z': { - int arg_cp = (code != 'Z') ? arg : MAX(0, arg - 1); + size_t arg_cp = (code != 'Z') ? arg : MAX(0, arg - 1); zend_string *str = zval_get_string(&argv[currentarg++]); @@ -488,7 +483,7 @@ PHP_FUNCTION(pack) char *v = ZSTR_VAL(str); outputpos--; - if(arg > ZSTR_LEN(str)) { + if ((size_t)arg > ZSTR_LEN(str)) { php_error_docref(NULL, E_WARNING, "Type %c: not enough characters in string", code); arg = ZSTR_LEN(str); } @@ -691,7 +686,7 @@ static zend_long php_unpack(char *data, size_t size, int issigned, int *map) { zend_long result; char *cresult = (char *) &result; - int i; + size_t i; result = issigned ? -1 : 0; @@ -726,10 +721,12 @@ PHP_FUNCTION(unpack) int i; zend_long offset = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|l", &formatarg, - &inputarg, &offset) == FAILURE) { - return; - } + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(formatarg) + Z_PARAM_STR(inputarg) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(offset) + ZEND_PARSE_PARAMETERS_END(); format = ZSTR_VAL(formatarg); formatlen = ZSTR_LEN(formatarg); @@ -903,7 +900,7 @@ PHP_FUNCTION(unpack) switch ((int) type) { case 'a': { /* a will not strip any trailing whitespace or null padding */ - size_t len = inputlen - inputpos; /* Remaining string */ + zend_long len = inputlen - inputpos; /* Remaining string */ /* If size was given take minimum of len and size */ if ((size >= 0) && (len > size)) { @@ -945,7 +942,7 @@ PHP_FUNCTION(unpack) case 'Z': { /* Z will strip everything after the first null character */ char pad = '\0'; - size_t s, + zend_long s, len = inputlen - inputpos; /* Remaining string */ /* If size was given take minimum of len and size */ @@ -969,11 +966,11 @@ PHP_FUNCTION(unpack) case 'h': case 'H': { - size_t len = (inputlen - inputpos) * 2; /* Remaining */ + zend_long len = (inputlen - inputpos) * 2; /* Remaining */ int nibbleshift = (type == 'h') ? 0 : 4; int first = 1; char *buf; - size_t ipos, opos; + zend_long ipos, opos; /* If size was given take minimum of len and size */ if (size >= 0 && len > (size * 2)) { |