Browse Source

ZEND_INT_FMT and some more for ext/standard

pull/536/merge
Anatol Belski 13 years ago
parent
commit
a218f8f3a4
  1. 8
      ext/standard/dns.c
  2. 4
      ext/standard/dns_win32.c
  3. 6
      ext/standard/file.c
  4. 8
      ext/standard/fsock.c
  5. 4
      ext/standard/ftp_fopen_wrapper.c
  6. 6
      ext/standard/http.c
  7. 2
      ext/standard/info.c
  8. 4
      ext/standard/mail.c
  9. 14
      ext/standard/password.c
  10. 10
      ext/standard/php_fopen_wrapper.c
  11. 2
      ext/standard/proc_open.c
  12. 4
      ext/standard/rand.c
  13. 8
      ext/standard/streamsfuncs.c
  14. 12
      ext/standard/string.c
  15. 8
      ext/standard/var.c

8
ext/standard/dns.c

@ -749,13 +749,13 @@ PHP_FUNCTION(dns_get_record)
if (!raw) {
if ((type_param & ~PHP_DNS_ALL) && (type_param != PHP_DNS_ANY)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type '%ld' not supported", type_param);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type '" ZEND_INT_FMT "' not supported", type_param);
RETURN_FALSE;
}
} else {
if ((type_param < 1) || (type_param > 0xFFFF)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"Numeric DNS record type must be between 1 and 65535, '%ld' given", type_param);
"Numeric DNS record type must be between 1 and 65535, '" ZEND_INT_FMT "' given", type_param);
RETURN_FALSE;
}
}
@ -771,11 +771,11 @@ PHP_FUNCTION(dns_get_record)
* - In case of raw mode, we query only the requestd type instead of looping type by type
* before going with the additional info stuff.
*/
php_cli_server_send_error_page
if (raw) {
type = -1;
} else if (type_param == PHP_DNS_ANY) {
type = PHP_DNS_NUM_TYPES + 1;
type = PHP_DNS_NUM_TYPES + 1;php_cli_server_send_error_page
} else {
type = 0;
}

4
ext/standard/dns_win32.c

@ -370,13 +370,13 @@ PHP_FUNCTION(dns_get_record)
if (!raw) {
if ((type_param & ~PHP_DNS_ALL) && (type_param != PHP_DNS_ANY)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type '%ld' not supported", type_param);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type '" ZEND_INT_FMT "' not supported", type_param);
RETURN_FALSE;
}
} else {
if ((type_param < 1) || (type_param > 0xFFFF)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"Numeric DNS record type must be between 1 and 65535, '%ld' given", type_param);
"Numeric DNS record type must be between 1 and 65535, '" ZEND_INT_FMT "' given", type_param);
RETURN_FALSE;
}
}

6
ext/standard/file.c

@ -730,7 +730,7 @@ PHP_FUNCTION(file)
return;
}
if (flags < 0 || flags > (PHP_FILE_USE_INCLUDE_PATH | PHP_FILE_IGNORE_NEW_LINES | PHP_FILE_SKIP_EMPTY_LINES | PHP_FILE_NO_DEFAULT_CONTEXT)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "'%ld' flag is not supported", flags);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "'" ZEND_INT_FMT "' flag is not supported", flags);
RETURN_FALSE;
}
@ -1255,7 +1255,7 @@ PHPAPI PHP_FUNCTION(rewind)
PHPAPI PHP_FUNCTION(ftell)
{
zval *arg1;
long ret;
php_int_t ret;
php_stream *stream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) {
@ -1951,7 +1951,7 @@ PHP_FUNCTION(fgetcsv)
/* first section exactly as php_fgetss */
long len = 0;
php_int_t len = 0;
size_t buf_len;
char *buf;
php_stream *stream;

8
ext/standard/fsock.c

@ -42,7 +42,7 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
php_stream *stream = NULL;
int err;
char *hostname = NULL;
long hostname_len;
zend_str_size_long hostname_len;
char *errstr = NULL;
RETVAL_FALSE;
@ -52,11 +52,11 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
}
if (persistent) {
spprintf(&hashkey, 0, "pfsockopen__%s:%ld", host, port);
spprintf(&hashkey, 0, "pfsockopen__%s:" ZEND_INT_FMT, host, port);
}
if (port > 0) {
hostname_len = spprintf(&hostname, 0, "%s:%ld", host, port);
hostname_len = spprintf(&hostname, 0, "%s:" ZEND_INT_FMT, host, port);
} else {
hostname_len = host_len;
hostname = host;
@ -83,7 +83,7 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
efree(hostname);
}
if (stream == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to connect to %s:%ld (%s)", host, port, errstr == NULL ? "Unknown error" : errstr);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to connect to %s:" ZEND_INT_FMT " (%s)", host, port, errstr == NULL ? "Unknown error" : errstr);
}
if (hashkey) {

4
ext/standard/ftp_fopen_wrapper.c

@ -532,10 +532,10 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *pa
php_stream_context_get_option(context, "ftp", "resume_pos", &tmpzval) == SUCCESS &&
Z_TYPE_PP(tmpzval) == IS_LONG &&
Z_LVAL_PP(tmpzval) > 0) {
php_stream_printf(stream TSRMLS_CC, "REST %ld\r\n", Z_LVAL_PP(tmpzval));
php_stream_printf(stream TSRMLS_CC, "REST " ZEND_INT_FMT "\r\n", Z_LVAL_PP(tmpzval));
result = GET_FTP_RESULT(stream);
if (result < 300 || result > 399) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Unable to resume from offset %ld", Z_LVAL_PP(tmpzval));
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Unable to resume from offset " ZEND_INT_FMT, Z_LVAL_PP(tmpzval));
goto errexit;
}
}

6
ext/standard/http.c

@ -111,7 +111,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
*p = '\0';
} else {
/* Is an integer key */
ekey_len = spprintf(&ekey, 0, "%ld", idx);
ekey_len = spprintf(&ekey, 0, ZEND_UINT_FMT, idx);
newprefix_len = key_prefix_len + num_prefix_len + ekey_len + key_suffix_len + 3 /* %5B */;
newprefix = emalloc(newprefix_len + 1);
p = newprefix;
@ -163,7 +163,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
if (num_prefix) {
smart_str_appendl(formstr, num_prefix, num_prefix_len);
}
ekey_len = spprintf(&ekey, 0, "%ld", idx);
ekey_len = spprintf(&ekey, 0, ZEND_UINT_FMT, idx);
smart_str_appendl(formstr, ekey, ekey_len);
efree(ekey);
}
@ -179,7 +179,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
break;
case IS_LONG:
case IS_BOOL:
ekey_len = spprintf(&ekey, 0, "%ld", Z_LVAL_PP(zdata));
ekey_len = spprintf(&ekey, 0, ZEND_INT_FMT, Z_LVAL_PP(zdata));
break;
case IS_DOUBLE:
ekey_len = spprintf(&ekey, 0, "%.*G", (int) EG(precision), Z_DVAL_PP(zdata));

2
ext/standard/info.c

@ -222,7 +222,7 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
}
break;
case HASH_KEY_IS_LONG:
php_info_printf("%ld", num_key);
php_info_printf(ZEND_INT_FMT, num_key);
break;
}
php_info_print("\"]");

4
ext/standard/mail.c

@ -284,9 +284,9 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
php_basename(tmp, strlen(tmp), NULL, 0,&f, &f_len TSRMLS_CC);
if (headers != NULL) {
spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s\n%s", php_getuid(TSRMLS_C), f, headers);
spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_INT_FMT ":%s\n%s", php_getuid(TSRMLS_C), f, headers);
} else {
spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s\n", php_getuid(TSRMLS_C), f);
spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_INT_FMT ":%s\n", php_getuid(TSRMLS_C), f);
}
efree(f);
}

14
ext/standard/password.c

@ -197,8 +197,8 @@ PHP_FUNCTION(password_get_info)
switch (algo) {
case PHP_PASSWORD_BCRYPT:
{
long cost = PHP_PASSWORD_BCRYPT_COST;
sscanf(hash, "$2y$%ld$", &cost);
php_int_t cost = PHP_PASSWORD_BCRYPT_COST;
sscanf(hash, "$2y$" ZEND_INT_FMT "$", &cost);
add_assoc_long(options, "cost", cost);
}
break;
@ -241,7 +241,7 @@ PHP_FUNCTION(password_needs_rehash)
switch (algo) {
case PHP_PASSWORD_BCRYPT:
{
long new_cost = PHP_PASSWORD_BCRYPT_COST, cost = 0;
php_int_t new_cost = PHP_PASSWORD_BCRYPT_COST, cost = 0;
if (options && zend_symtable_find(options, "cost", sizeof("cost"), (void **) &option_buffer) == SUCCESS) {
if (Z_TYPE_PP(option_buffer) != IS_LONG) {
@ -255,7 +255,7 @@ PHP_FUNCTION(password_needs_rehash)
}
}
sscanf(hash, "$2y$%ld$", &cost);
sscanf(hash, "$2y$" ZEND_INT_FMT "$", &cost);
if (cost != new_cost) {
RETURN_TRUE;
}
@ -321,7 +321,7 @@ PHP_FUNCTION(password_hash)
switch (algo) {
case PHP_PASSWORD_BCRYPT:
{
long cost = PHP_PASSWORD_BCRYPT_COST;
php_int_t cost = PHP_PASSWORD_BCRYPT_COST;
if (options && zend_symtable_find(options, "cost", 5, (void **) &option_buffer) == SUCCESS) {
if (Z_TYPE_PP(option_buffer) != IS_LONG) {
@ -336,7 +336,7 @@ PHP_FUNCTION(password_hash)
}
if (cost < 4 || cost > 31) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid bcrypt cost parameter specified: %ld", cost);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid bcrypt cost parameter specified: " ZEND_INT_FMT, cost);
RETURN_NULL();
}
@ -348,7 +348,7 @@ PHP_FUNCTION(password_hash)
break;
case PHP_PASSWORD_UNKNOWN:
default:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown password hashing algorithm: %ld", algo);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown password hashing algorithm: " ZEND_INT_FMT, algo);
RETURN_NULL();
}

10
ext/standard/php_fopen_wrapper.c

@ -178,7 +178,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
int mode_rw = 0;
php_stream * stream = NULL;
char *p, *token, *pathdup;
long max_memory;
php_int_t max_memory;
FILE *file = NULL;
if (!strncasecmp(path, "php://", 6)) {
@ -190,7 +190,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
max_memory = PHP_STREAM_MAX_MEM;
if (!strncasecmp(path, "/maxmemory:", 11)) {
path += 11;
max_memory = strtol(path, NULL, 10);
max_memory = ZEND_STRTOL(path, NULL, 10);
if (max_memory < 0) {
php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Max memory must be >= 0");
return NULL;
@ -285,7 +285,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
} else if (!strncasecmp(path, "fd/", 3)) {
const char *start;
char *end;
long fildes_ori;
php_int_t fildes_ori;
int dtablesize;
if (strcmp(sapi_module.name, "cli")) {
@ -303,7 +303,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
}
start = &path[3];
fildes_ori = strtol(start, &end, 10);
fildes_ori = ZEND_STRTOL(start, &end, 10);
if (end == start || *end != '\0') {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC,
"php://fd/ stream must be specified in the form php://fd/<orig fd>");
@ -325,7 +325,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
fd = dup(fildes_ori);
if (fd == -1) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC,
"Error duping file descriptor %ld; possibly it doesn't exist: "
"Error duping file descriptor " ZEND_INT_FMT "; possibly it doesn't exist: "
"[%d]: %s", fildes_ori, errno, strerror(errno));
return NULL;
}

2
ext/standard/proc_open.c

@ -552,7 +552,7 @@ PHP_FUNCTION(proc_open)
#else
descriptors[ndesc].childend = dup(fd);
if (descriptors[ndesc].childend < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to dup File-Handle for descriptor %ld - %s", nindex, strerror(errno));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to dup File-Handle for descriptor " ZEND_UINT_FMT " - %s", nindex, strerror(errno));
goto exit_fail;
}
#endif

4
ext/standard/rand.c

@ -319,7 +319,7 @@ PHP_FUNCTION(mt_rand)
if (zend_parse_parameters(argc TSRMLS_CC, "ii", &min, &max) == FAILURE) {
return;
} else if (max < min) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "max(%ld) is smaller than min(%ld)", max, min);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "max(" ZEND_INT_FMT ") is smaller than min(" ZEND_INT_FMT ")", max, min);
RETURN_FALSE;
}
}
@ -336,7 +336,7 @@ PHP_FUNCTION(mt_rand)
* Update:
* I talked with Cokus via email and it won't ruin the algorithm
*/
number = (long) (php_mt_rand(TSRMLS_C) >> 1);
number = (php_int_t) (php_mt_rand(TSRMLS_C) >> 1);
if (argc == 2) {
RAND_RANGE(number, min, max, PHP_MT_RAND_MAX);
}

8
ext/standard/streamsfuncs.c

@ -431,7 +431,7 @@ PHP_FUNCTION(stream_get_contents)
if (seek_res != 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"Failed to seek to position %ld in the stream", desiredpos);
"Failed to seek to position " ZEND_INT_FMT " in the stream", desiredpos);
RETURN_FALSE;
}
}
@ -464,7 +464,7 @@ PHP_FUNCTION(stream_copy_to_stream)
php_stream_from_zval(dest, &zdest);
if (pos > 0 && php_stream_seek(src, pos, SEEK_SET) < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", pos);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position " ZEND_INT_FMT " in the stream", pos);
RETURN_FALSE;
}
@ -1446,7 +1446,7 @@ PHP_FUNCTION(stream_set_chunk_size)
}
if (csize <= 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The chunk size must be a positive integer, given %ld", csize);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The chunk size must be a positive integer, given " ZEND_INT_FMT, csize);
RETURN_FALSE;
}
/* stream.chunk_size is actually a size_t, but php_stream_set_option
@ -1462,7 +1462,7 @@ PHP_FUNCTION(stream_set_chunk_size)
ret = php_stream_set_option(stream, PHP_STREAM_OPTION_SET_CHUNK_SIZE, (int)csize, NULL);
RETURN_LONG(ret > 0 ? (long)ret : (long)EOF);
RETURN_LONG(ret > 0 ? (php_int_t)ret : (php_int_t)EOF);
}
/* }}} */

12
ext/standard/string.c

@ -696,7 +696,7 @@ PHP_FUNCTION(nl_langinfo)
#endif
break;
default:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Item '%ld' is not valid", item);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Item '" ZEND_INT_FMT "' is not valid", item);
RETURN_FALSE;
}
/* }}} */
@ -1146,7 +1146,7 @@ PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value TSRMLS_DC)
case IS_LONG: {
char stmp[MAX_LENGTH_OF_LONG + 1];
str_len = slprintf(stmp, sizeof(stmp), "%ld", Z_LVAL_PP(tmp));
str_len = slprintf(stmp, sizeof(stmp), ZEND_INT_FMT, Z_LVAL_PP(tmp));
smart_str_appendl(&implstr, stmp, str_len);
}
break;
@ -2900,7 +2900,7 @@ static PATNREPL *php_strtr_array_prepare_repls(zend_str_size_int slen, HashTable
switch (zend_hash_get_current_key_ex(pats, &string_key, &string_key_len, &num_key, 0, &hpos)) {
case HASH_KEY_IS_LONG:
string_key_len = 1 + zend_spprintf(&string_key, 0, "%ld", (long)num_key);
string_key_len = 1 + zend_spprintf(&string_key, 0, ZEND_INT_FMT, (php_int_t)num_key);
zend_llist_add_element(*allocs, &string_key);
/* break missing intentionally */
@ -5160,7 +5160,7 @@ PHP_FUNCTION(substr_count)
}
if (offset > haystack_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset value %ld exceeds string length", offset);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset value " ZEND_INT_FMT " exceeds string length", offset);
RETURN_FALSE;
}
p += offset;
@ -5172,7 +5172,7 @@ PHP_FUNCTION(substr_count)
RETURN_FALSE;
}
if (length > (haystack_len - offset)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length value %ld exceeds string length", length);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length value " ZEND_INT_FMT " exceeds string length", length);
RETURN_FALSE;
}
endp = p + length;
@ -5403,7 +5403,7 @@ PHP_FUNCTION(str_word_count)
/* nothing to be done */
break;
default:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid format value %ld", type);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid format value " ZEND_INT_FMT, type);
RETURN_FALSE;
}

8
ext/standard/var.c

@ -157,7 +157,7 @@ head_done:
break;
case IS_RESOURCE: {
const char *type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC);
php_printf("%sresource(%ld) of type (%s)\n", COMMON, Z_LVAL_PP(struc), type_name ? type_name : "Unknown");
php_printf("%sresource(" ZEND_INT_FMT ") of type (%s)\n", COMMON, Z_LVAL_PP(struc), type_name ? type_name : "Unknown");
break;
}
default:
@ -193,7 +193,7 @@ static int zval_array_element_dump(zval **zv TSRMLS_DC, int num_args, va_list ar
level = va_arg(args, int);
if (hash_key->nKeyLength == 0) { /* numeric key */
php_printf("%*c[%ld]=>\n", level + 1, ' ', hash_key->h);
php_printf("%*c[" ZEND_UINT_FMT "]=>\n", level + 1, ' ', hash_key->h);
} else { /* string key */
/* XXX: perphaps when we are inside the class we should permit access to
* private & protected values
@ -218,7 +218,7 @@ static int zval_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list
level = va_arg(args, int);
if (hash_key->nKeyLength == 0) { /* numeric key */
php_printf("%*c[%ld]=>\n", level + 1, ' ', hash_key->h);
php_printf("%*c[" ZEND_UINT_FMT "]=>\n", level + 1, ' ', hash_key->h);
} else { /* string key */
zend_unmangle_property_name(hash_key->arKey, hash_key->nKeyLength - 1, &class_name, &prop_name);
php_printf("%*c[", level + 1, ' ');
@ -303,7 +303,7 @@ head_done:
break;
case IS_RESOURCE: {
const char *type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC);
php_printf("%sresource(%ld) of type (%s) refcount(%u)\n", COMMON, Z_LVAL_PP(struc), type_name ? type_name : "Unknown", Z_REFCOUNT_PP(struc));
php_printf("%sresource(" ZEND_INT_FMT ") of type (%s) refcount(%u)\n", COMMON, Z_LVAL_PP(struc), type_name ? type_name : "Unknown", Z_REFCOUNT_PP(struc));
break;
}
default:

Loading…
Cancel
Save