Skip to content

Commit c799ce7

Browse files
committed
Merge pull request php#7 from weltling/string_size_refactor_take_2
String size refactor take 2 next wave
2 parents ef960ef + 3266be8 commit c799ce7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+562
-516
lines changed

Zend/zend_dtrace.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,8 @@ ZEND_API void dtrace_execute_ex(zend_execute_data *execute_data TSRMLS_DC)
5858
}
5959

6060
if (DTRACE_FUNCTION_ENTRY_ENABLED() || DTRACE_FUNCTION_RETURN_ENABLED()) {
61-
filename = dtrace_get_executed_filename(TSRMLS_C);
6261
classname = get_active_class_name(&scope TSRMLS_CC);
6362
funcname = get_active_function_name(TSRMLS_C);
64-
lineno = zend_get_executed_lineno(TSRMLS_C);
6563
}
6664

6765
if (DTRACE_EXECUTE_ENTRY_ENABLED()) {

Zend/zend_execute.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ static zend_always_inline void zend_vm_stack_clear_multiple(int nested TSRMLS_DC
293293
void **end = p - (int)(zend_uintptr_t)*p;
294294

295295
while (p != end) {
296-
zval *q = *(zval **)(--p);
296+
zval *q = (zval *) *(--p);
297297
*p = NULL;
298298
i_zval_ptr_dtor(q ZEND_FILE_LINE_CC);
299299
}

Zend/zend_vm_execute.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020

2121
#ifdef ZEND_WIN32
2222
# pragma warning(once : 4101)
23+
# pragma warning(once : 6235)
24+
# pragma warning(once : 6237)
25+
# pragma warning(once : 6239)
26+
# pragma warning(once : 6240)
27+
# pragma warning(once : 6285)
28+
# pragma warning(once : 6286)
29+
# pragma warning(once : 6326)
2330
#endif
2431
static user_opcode_handler_t zend_user_opcode_handlers[256] = {
2532
(user_opcode_handler_t)NULL,

Zend/zend_vm_gen.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1216,8 +1216,26 @@ function gen_vm($def, $skel) {
12161216
// Insert header
12171217
out($f, $GLOBALS['header_text']);
12181218

1219+
out($f, "#ifdef ZEND_WIN32\n");
12191220
// Suppress free_op1 warnings on Windows
1220-
out($f, "#ifdef ZEND_WIN32\n# pragma warning(once : 4101)\n#endif\n");
1221+
out($f, "# pragma warning(once : 4101)\n");
1222+
if (ZEND_VM_SPEC) {
1223+
// Suppress (<non-zero constant> || <expression>) warnings on windows
1224+
out($f, "# pragma warning(once : 6235)\n");
1225+
// Suppress (<zero> && <expression>) warnings on windows
1226+
out($f, "# pragma warning(once : 6237)\n");
1227+
// Suppress (<non-zero constant> && <expression>) warnings on windows
1228+
out($f, "# pragma warning(once : 6239)\n");
1229+
// Suppress (<expression> && <non-zero constant>) warnings on windows
1230+
out($f, "# pragma warning(once : 6240)\n");
1231+
// Suppress (<non-zero constant> || <non-zero constant>) warnings on windows
1232+
out($f, "# pragma warning(once : 6285)\n");
1233+
// Suppress (<non-zero constant> || <expression>) warnings on windows
1234+
out($f, "# pragma warning(once : 6286)\n");
1235+
// Suppress constant with constant comparsion warnings on windows
1236+
out($f, "# pragma warning(once : 6326)\n");
1237+
}
1238+
out($f, "#endif\n");
12211239

12221240
// Support for ZEND_USER_OPCODE
12231241
out($f, "static user_opcode_handler_t zend_user_opcode_handlers[256] = {\n");

ext/date/tests/bug65184.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
66
die("skip Test is valid for Windows");
77
}
88
?>
9+
--INI--
10+
date.timezone = UTC
911
--FILE--
1012
<?php
1113
setlocale(LC_ALL, 'Japanese_Japan.932');

ext/ereg/ereg.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ static void php_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
291291
zval **regex, /* Regular expression */
292292
**array = NULL; /* Optional register array */
293293
char *findin; /* String to apply expression to */
294-
int findin_len;
294+
zend_str_size_int findin_len;
295295
regex_t re;
296296
regmatch_t *subs;
297297
int err, match_len, string_len;
@@ -302,7 +302,7 @@ static void php_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
302302
char *string = NULL;
303303
int argc = ZEND_NUM_ARGS();
304304

305-
if (zend_parse_parameters(argc TSRMLS_CC, "Zs|Z", &regex, &findin, &findin_len, &array) == FAILURE) {
305+
if (zend_parse_parameters(argc TSRMLS_CC, "ZS|Z", &regex, &findin, &findin_len, &array) == FAILURE) {
306306
return;
307307
}
308308

@@ -555,9 +555,9 @@ static void php_do_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
555555
char *string;
556556
char *replace;
557557
char *ret;
558-
int arg_string_len;
558+
zend_str_size_int arg_string_len;
559559

560-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZs", &arg_pattern, &arg_replace, &arg_string, &arg_string_len) == FAILURE) {
560+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZS", &arg_pattern, &arg_replace, &arg_string, &arg_string_len) == FAILURE) {
561561
return;
562562
}
563563

@@ -632,10 +632,10 @@ static void php_split(INTERNAL_FUNCTION_PARAMETERS, int icase)
632632
regex_t re;
633633
regmatch_t subs[1];
634634
char *spliton, *str, *strp, *endp;
635-
int spliton_len, str_len;
635+
zend_str_size_int spliton_len, str_len;
636636
int err, size, copts = 0;
637637

638-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &spliton, &spliton_len, &str, &str_len, &count) == FAILURE) {
638+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|l", &spliton, &spliton_len, &str, &str_len, &count) == FAILURE) {
639639
return;
640640
}
641641

@@ -731,11 +731,11 @@ PHP_FUNCTION(spliti)
731731
PHP_EREG_API PHP_FUNCTION(sql_regcase)
732732
{
733733
char *string, *tmp;
734-
int string_len;
734+
zend_str_size_int string_len;
735735
unsigned char c;
736736
register int i, j;
737737

738-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) {
738+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &string, &string_len) == FAILURE) {
739739
return;
740740
}
741741

ext/iconv/iconv.c

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn
11601160
size_t ini_in_left;
11611161
const char *ini_in_p;
11621162
size_t out_reserved = 4;
1163-
int dummy;
1163+
zend_str_size_int dummy;
11641164

11651165
smart_str_appendc(pretval, 'B');
11661166
char_cnt--;
@@ -1723,7 +1723,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
17231723
case '\r': case '\n': case ' ': case '\t': {
17241724
char *decoded_text;
17251725
size_t decoded_text_len;
1726-
int dummy;
1726+
zend_str_size_int dummy;
17271727

17281728
switch (enc_scheme) {
17291729
case PHP_ICONV_ENC_SCHEME_BASE64:
@@ -1958,15 +1958,15 @@ static void _php_iconv_show_error(php_iconv_err_t err, const char *out_charset,
19581958
PHP_FUNCTION(iconv_strlen)
19591959
{
19601960
char *charset = ICONVG(internal_encoding);
1961-
int charset_len = 0;
1961+
zend_str_size_int charset_len = 0;
19621962
char *str;
1963-
int str_len;
1963+
zend_str_size_int str_len;
19641964

19651965
php_iconv_err_t err;
19661966

19671967
unsigned int retval;
19681968

1969-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s",
1969+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|S",
19701970
&str, &str_len, &charset, &charset_len) == FAILURE) {
19711971
RETURN_FALSE;
19721972
}
@@ -1991,16 +1991,16 @@ PHP_FUNCTION(iconv_strlen)
19911991
PHP_FUNCTION(iconv_substr)
19921992
{
19931993
char *charset = ICONVG(internal_encoding);
1994-
int charset_len = 0;
1994+
zend_str_size_int charset_len = 0;
19951995
char *str;
1996-
int str_len;
1996+
zend_str_size_int str_len;
19971997
long offset, length = 0;
19981998

19991999
php_iconv_err_t err;
20002000

20012001
smart_str retval = {0};
20022002

2003-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|ls",
2003+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sl|lS",
20042004
&str, &str_len, &offset, &length,
20052005
&charset, &charset_len) == FAILURE) {
20062006
RETURN_FALSE;
@@ -2031,18 +2031,18 @@ PHP_FUNCTION(iconv_substr)
20312031
PHP_FUNCTION(iconv_strpos)
20322032
{
20332033
char *charset = ICONVG(internal_encoding);
2034-
int charset_len = 0;
2034+
zend_str_size_int charset_len = 0;
20352035
char *haystk;
2036-
int haystk_len;
2036+
zend_str_size_int haystk_len;
20372037
char *ndl;
2038-
int ndl_len;
2038+
zend_str_size_int ndl_len;
20392039
long offset = 0;
20402040

20412041
php_iconv_err_t err;
20422042

20432043
unsigned int retval;
20442044

2045-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|ls",
2045+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|lS",
20462046
&haystk, &haystk_len, &ndl, &ndl_len,
20472047
&offset, &charset, &charset_len) == FAILURE) {
20482048
RETURN_FALSE;
@@ -2079,17 +2079,17 @@ PHP_FUNCTION(iconv_strpos)
20792079
PHP_FUNCTION(iconv_strrpos)
20802080
{
20812081
char *charset = ICONVG(internal_encoding);
2082-
int charset_len = 0;
2082+
zend_str_size_int charset_len = 0;
20832083
char *haystk;
2084-
int haystk_len;
2084+
zend_str_size_int haystk_len;
20852085
char *ndl;
2086-
int ndl_len;
2086+
zend_str_size_int ndl_len;
20872087

20882088
php_iconv_err_t err;
20892089

20902090
unsigned int retval;
20912091

2092-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|s",
2092+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|S",
20932093
&haystk, &haystk_len, &ndl, &ndl_len,
20942094
&charset, &charset_len) == FAILURE) {
20952095
RETURN_FALSE;
@@ -2121,9 +2121,9 @@ PHP_FUNCTION(iconv_strrpos)
21212121
PHP_FUNCTION(iconv_mime_encode)
21222122
{
21232123
const char *field_name = NULL;
2124-
int field_name_len;
2124+
zend_str_size_int field_name_len;
21252125
const char *field_value = NULL;
2126-
int field_value_len;
2126+
zend_str_size_int field_value_len;
21272127
zval *pref = NULL;
21282128
zval tmp_zv, *tmp_zv_p = NULL;
21292129
smart_str retval = {0};
@@ -2135,7 +2135,7 @@ PHP_FUNCTION(iconv_mime_encode)
21352135
const char *lfchars = "\r\n";
21362136
php_iconv_enc_scheme_t scheme_id = PHP_ICONV_ENC_SCHEME_BASE64;
21372137

2138-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|a",
2138+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|a",
21392139
&field_name, &field_name_len, &field_value, &field_value_len,
21402140
&pref) == FAILURE) {
21412141

@@ -2146,7 +2146,7 @@ PHP_FUNCTION(iconv_mime_encode)
21462146
zval **ppval;
21472147

21482148
if (zend_hash_find(Z_ARRVAL_P(pref), "scheme", sizeof("scheme"), (void **)&ppval) == SUCCESS) {
2149-
if (Z_TYPE_PP(ppval) == IS_STRING && Z_STRLEN_PP(ppval) > 0) {
2149+
if (Z_TYPE_PP(ppval) == IS_STRING && Z_STRSIZE_PP(ppval) > 0) {
21502150
switch (Z_STRVAL_PP(ppval)[0]) {
21512151
case 'B': case 'b':
21522152
scheme_id = PHP_ICONV_ENC_SCHEME_BASE64;
@@ -2160,24 +2160,24 @@ PHP_FUNCTION(iconv_mime_encode)
21602160
}
21612161

21622162
if (zend_hash_find(Z_ARRVAL_P(pref), "input-charset", sizeof("input-charset"), (void **)&ppval) == SUCCESS) {
2163-
if (Z_STRLEN_PP(ppval) >= ICONV_CSNMAXLEN) {
2163+
if (Z_STRSIZE_PP(ppval) >= ICONV_CSNMAXLEN) {
21642164
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
21652165
RETURN_FALSE;
21662166
}
21672167

2168-
if (Z_TYPE_PP(ppval) == IS_STRING && Z_STRLEN_PP(ppval) > 0) {
2168+
if (Z_TYPE_PP(ppval) == IS_STRING && Z_STRSIZE_PP(ppval) > 0) {
21692169
in_charset = Z_STRVAL_PP(ppval);
21702170
}
21712171
}
21722172

21732173

21742174
if (zend_hash_find(Z_ARRVAL_P(pref), "output-charset", sizeof("output-charset"), (void **)&ppval) == SUCCESS) {
2175-
if (Z_STRLEN_PP(ppval) >= ICONV_CSNMAXLEN) {
2175+
if (Z_STRSIZE_PP(ppval) >= ICONV_CSNMAXLEN) {
21762176
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
21772177
RETURN_FALSE;
21782178
}
21792179

2180-
if (Z_TYPE_PP(ppval) == IS_STRING && Z_STRLEN_PP(ppval) > 0) {
2180+
if (Z_TYPE_PP(ppval) == IS_STRING && Z_STRSIZE_PP(ppval) > 0) {
21812181
out_charset = Z_STRVAL_PP(ppval);
21822182
}
21832183
}
@@ -2241,16 +2241,16 @@ PHP_FUNCTION(iconv_mime_encode)
22412241
PHP_FUNCTION(iconv_mime_decode)
22422242
{
22432243
char *encoded_str;
2244-
int encoded_str_len;
2244+
zend_str_size_int encoded_str_len;
22452245
char *charset = ICONVG(internal_encoding);
2246-
int charset_len = 0;
2246+
zend_str_size_int charset_len = 0;
22472247
long mode = 0;
22482248

22492249
smart_str retval = {0};
22502250

22512251
php_iconv_err_t err;
22522252

2253-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls",
2253+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|lS",
22542254
&encoded_str, &encoded_str_len, &mode, &charset, &charset_len) == FAILURE) {
22552255

22562256
RETURN_FALSE;
@@ -2282,14 +2282,14 @@ PHP_FUNCTION(iconv_mime_decode)
22822282
PHP_FUNCTION(iconv_mime_decode_headers)
22832283
{
22842284
const char *encoded_str;
2285-
int encoded_str_len;
2285+
zend_str_size_int encoded_str_len;
22862286
char *charset = ICONVG(internal_encoding);
2287-
int charset_len = 0;
2287+
zend_str_size_int charset_len = 0;
22882288
long mode = 0;
22892289

22902290
php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS;
22912291

2292-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls",
2292+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|lS",
22932293
&encoded_str, &encoded_str_len, &mode, &charset, &charset_len) == FAILURE) {
22942294

22952295
RETURN_FALSE;
@@ -2380,10 +2380,10 @@ PHP_NAMED_FUNCTION(php_if_iconv)
23802380
{
23812381
char *in_charset, *out_charset, *in_buffer, *out_buffer;
23822382
size_t out_len;
2383-
int in_charset_len = 0, out_charset_len = 0, in_buffer_len;
2383+
zend_str_size_int in_charset_len = 0, out_charset_len = 0, in_buffer_len;
23842384
php_iconv_err_t err;
23852385

2386-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss",
2386+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSS",
23872387
&in_charset, &in_charset_len, &out_charset, &out_charset_len, &in_buffer, &in_buffer_len) == FAILURE)
23882388
return;
23892389

@@ -2411,9 +2411,10 @@ PHP_NAMED_FUNCTION(php_if_iconv)
24112411
PHP_FUNCTION(iconv_set_encoding)
24122412
{
24132413
char *type, *charset;
2414-
int type_len, charset_len =0, retval;
2414+
zend_str_size_int type_len, charset_len =0;
2415+
int retval;
24152416

2416-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &type, &type_len, &charset, &charset_len) == FAILURE)
2417+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &type, &type_len, &charset, &charset_len) == FAILURE)
24172418
return;
24182419

24192420
if (charset_len >= ICONV_CSNMAXLEN) {
@@ -2444,9 +2445,9 @@ PHP_FUNCTION(iconv_set_encoding)
24442445
PHP_FUNCTION(iconv_get_encoding)
24452446
{
24462447
char *type = "all";
2447-
int type_len = sizeof("all")-1;
2448+
zend_str_size_int type_len = sizeof("all")-1;
24482449

2449-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &type, &type_len) == FAILURE)
2450+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &type, &type_len) == FAILURE)
24502451
return;
24512452

24522453
if (!strcasecmp("all", type)) {

ext/intl/breakiterator/breakiterator_iterators.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static void _breakiterator_parts_move_forward(zend_object_iterator *iter TSRMLS_
173173
* No need to do anything, the engine increments ->index */
174174

175175
const char *s = Z_STRVAL_P(bio->text);
176-
int32_t slen = Z_STRLEN_P(bio->text),
176+
int32_t slen = Z_STRSIZE_P(bio->text),
177177
len;
178178
char *res;
179179

@@ -251,7 +251,7 @@ U_CFUNC zend_object_value IntlPartsIterator_object_create(zend_class_entry *ce T
251251
}
252252

253253
U_CFUNC zend_function *IntlPartsIterator_get_method(zval **object_ptr,
254-
char *method, int method_len, const zend_literal *key TSRMLS_DC)
254+
char *method, zend_str_size_int method_len, const zend_literal *key TSRMLS_DC)
255255
{
256256
zend_literal local_literal = {0};
257257
zend_function *ret;

0 commit comments

Comments
 (0)