Skip to content

Commit 6e008d4

Browse files
committed
It compiles. Sort-of. In a way. Yeah. But nothing works. Sigh
1 parent 66845fb commit 6e008d4

Some content is hidden

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

62 files changed

+1134
-1136
lines changed

Zend/zend.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,26 +234,26 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
234234
}
235235
switch (Z_TYPE_P(expr)) {
236236
case IS_NULL:
237-
Z_STRLEN_P(expr_copy) = 0;
237+
Z_STRSIZE_P(expr_copy) = 0;
238238
Z_STRVAL_P(expr_copy) = STR_EMPTY_ALLOC();
239239
break;
240240
case IS_BOOL:
241241
if (Z_LVAL_P(expr)) {
242-
Z_STRLEN_P(expr_copy) = 1;
242+
Z_STRSIZE_P(expr_copy) = 1;
243243
Z_STRVAL_P(expr_copy) = estrndup("1", 1);
244244
} else {
245-
Z_STRLEN_P(expr_copy) = 0;
245+
Z_STRSIZE_P(expr_copy) = 0;
246246
Z_STRVAL_P(expr_copy) = STR_EMPTY_ALLOC();
247247
}
248248
break;
249249
case IS_RESOURCE:
250250
Z_STRVAL_P(expr_copy) = (char *) emalloc(sizeof("Resource id #") - 1 + MAX_LENGTH_OF_LONG);
251-
Z_STRLEN_P(expr_copy) = snprintf(Z_STRVAL_P(expr_copy), sizeof("Resource id #") - 1 + MAX_LENGTH_OF_LONG, "Resource id #%ld", Z_LVAL_P(expr));
251+
Z_STRSIZE_P(expr_copy) = snprintf(Z_STRVAL_P(expr_copy), sizeof("Resource id #") - 1 + MAX_LENGTH_OF_LONG, "Resource id #%ld", Z_LVAL_P(expr));
252252
break;
253253
case IS_ARRAY:
254254
zend_error(E_NOTICE, "Array to string conversion");
255-
Z_STRLEN_P(expr_copy) = sizeof("Array") - 1;
256-
Z_STRVAL_P(expr_copy) = estrndup("Array", Z_STRLEN_P(expr_copy));
255+
Z_STRSIZE_P(expr_copy) = sizeof("Array") - 1;
256+
Z_STRVAL_P(expr_copy) = estrndup("Array", Z_STRSIZE_P(expr_copy));
257257
break;
258258
case IS_OBJECT:
259259
{
@@ -291,7 +291,7 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
291291
zval_ptr_dtor(&z);
292292
}
293293
zend_error(EG(exception) ? E_ERROR : E_RECOVERABLE_ERROR, "Object of class %s could not be converted to string", Z_OBJCE_P(expr)->name);
294-
Z_STRLEN_P(expr_copy) = 0;
294+
Z_STRSIZE_P(expr_copy) = 0;
295295
Z_STRVAL_P(expr_copy) = STR_EMPTY_ALLOC();
296296
}
297297
break;
@@ -326,17 +326,17 @@ ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int in
326326
if (use_copy) {
327327
expr = &expr_copy;
328328
}
329-
if (Z_STRLEN_P(expr) == 0) { /* optimize away empty strings */
329+
if (Z_STRSIZE_P(expr) == 0) { /* optimize away empty strings */
330330
if (use_copy) {
331331
zval_dtor(expr);
332332
}
333333
return 0;
334334
}
335-
write_func(Z_STRVAL_P(expr), Z_STRLEN_P(expr));
335+
write_func(Z_STRVAL_P(expr), Z_STRSIZE_P(expr));
336336
if (use_copy) {
337337
zval_dtor(expr);
338338
}
339-
return Z_STRLEN_P(expr);
339+
return Z_STRSIZE_P(expr);
340340
}
341341
/* }}} */
342342

@@ -1138,7 +1138,7 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
11381138
# endif
11391139
#endif
11401140
va_copy(usr_copy, args);
1141-
Z_STRLEN_P(z_error_message) = zend_vspprintf(&Z_STRVAL_P(z_error_message), 0, format, usr_copy);
1141+
Z_STRSIZE_P(z_error_message) = zend_vspprintf(&Z_STRVAL_P(z_error_message), 0, format, usr_copy);
11421142
#ifdef va_copy
11431143
va_end(usr_copy);
11441144
#endif

Zend/zend_API.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ static int parse_arg_object_to_string(zval **arg, char **p, zend_str_size_int *p
266266
if (Z_OBJ_HANDLER_P(*arg, cast_object)(*arg, obj, type TSRMLS_CC) == SUCCESS) {
267267
zval_ptr_dtor(arg);
268268
*arg = obj;
269-
*pl = Z_STRLEN_PP(arg);
269+
*pl = Z_STRSIZE_PP(arg);
270270
*p = Z_STRVAL_PP(arg);
271271
return SUCCESS;
272272
}
@@ -276,7 +276,7 @@ static int parse_arg_object_to_string(zval **arg, char **p, zend_str_size_int *p
276276
if (Z_OBJ_HT_PP(arg) == &std_object_handlers || !Z_OBJ_HANDLER_PP(arg, cast_object)) {
277277
SEPARATE_ZVAL_IF_NOT_REF(arg);
278278
if (zend_std_cast_object_tostring(*arg, *arg, type TSRMLS_CC) == SUCCESS) {
279-
*pl = Z_STRLEN_PP(arg);
279+
*pl = Z_STRSIZE_PP(arg);
280280
*p = Z_STRVAL_PP(arg);
281281
return SUCCESS;
282282
}
@@ -292,7 +292,7 @@ static int parse_arg_object_to_string(zval **arg, char **p, zend_str_size_int *p
292292
if (!use_copy) {
293293
ZVAL_ZVAL(*arg, z, 1, 1);
294294
}
295-
*pl = Z_STRLEN_PP(arg);
295+
*pl = Z_STRSIZE_PP(arg);
296296
*p = Z_STRVAL_PP(arg);
297297
return SUCCESS;
298298
}
@@ -337,7 +337,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con
337337
double d;
338338
int type;
339339

340-
if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), p, &d, -1)) == 0) {
340+
if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRSIZE_PP(arg), p, &d, -1)) == 0) {
341341
return "long";
342342
} else if (type == IS_DOUBLE) {
343343
if (c == 'L') {
@@ -396,7 +396,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con
396396
long l;
397397
int type;
398398

399-
if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &l, p, -1)) == 0) {
399+
if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRSIZE_PP(arg), &l, p, -1)) == 0) {
400400
return "double";
401401
} else if (type == IS_LONG) {
402402
*p = (double) l;
@@ -458,7 +458,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con
458458
SEPARATE_ZVAL(arg);
459459
}
460460
*p = Z_STRVAL_PP(arg);
461-
pl = Z_STRLEN_PP(arg);
461+
pl = Z_STRSIZE_PP(arg);
462462
if ((c == 'p' || c == 'P') && CHECK_ZVAL_NULL_PATH(*arg)) {
463463
return "a valid path";
464464
}
@@ -610,7 +610,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con
610610
break;
611611
}
612612
convert_to_string_ex(arg);
613-
if (zend_lookup_class(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &lookup TSRMLS_CC) == FAILURE) {
613+
if (zend_lookup_class(Z_STRVAL_PP(arg), Z_STRSIZE_PP(arg), &lookup TSRMLS_CC) == FAILURE) {
614614
*pce = NULL;
615615
} else {
616616
*pce = *lookup;
@@ -1560,7 +1560,7 @@ ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value) /* {{{ */
15601560

15611561
switch (Z_TYPE_P(key)) {
15621562
case IS_STRING:
1563-
result = zend_symtable_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &value, sizeof(zval *), NULL);
1563+
result = zend_symtable_update(ht, Z_STRVAL_P(key), Z_STRSIZE_P(key) + 1, &value, sizeof(zval *), NULL);
15641564
break;
15651565
case IS_NULL:
15661566
result = zend_symtable_update(ht, "", 1, &value, sizeof(zval *), NULL);
@@ -2773,10 +2773,10 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
27732773
if (!ce_org) {
27742774
/* Skip leading \ */
27752775
if (Z_STRVAL_P(callable)[0] == '\\') {
2776-
mlen = Z_STRLEN_P(callable) - 1;
2776+
mlen = Z_STRSIZE_P(callable) - 1;
27772777
lmname = zend_str_tolower_dup(Z_STRVAL_P(callable) + 1, mlen);
27782778
} else {
2779-
mlen = Z_STRLEN_P(callable);
2779+
mlen = Z_STRSIZE_P(callable);
27802780
lmname = zend_str_tolower_dup(Z_STRVAL_P(callable), mlen);
27812781
}
27822782
/* Check if function with given name exists.
@@ -2789,13 +2789,13 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
27892789
}
27902790

27912791
/* Split name into class/namespace and method/function names */
2792-
if ((colon = zend_memrchr(Z_STRVAL_P(callable), ':', Z_STRLEN_P(callable))) != NULL &&
2792+
if ((colon = zend_memrchr(Z_STRVAL_P(callable), ':', Z_STRSIZE_P(callable))) != NULL &&
27932793
colon > Z_STRVAL_P(callable) &&
27942794
*(colon-1) == ':'
27952795
) {
27962796
colon--;
27972797
clen = colon - Z_STRVAL_P(callable);
2798-
mlen = Z_STRLEN_P(callable) - clen - 2;
2798+
mlen = Z_STRSIZE_P(callable) - clen - 2;
27992799

28002800
if (colon == Z_STRVAL_P(callable)) {
28012801
if (error) zend_spprintf(error, 0, "invalid function name");
@@ -2823,7 +2823,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
28232823
mname = Z_STRVAL_P(callable) + clen + 2;
28242824
} else if (ce_org) {
28252825
/* Try to fetch find static method of given class. */
2826-
mlen = Z_STRLEN_P(callable);
2826+
mlen = Z_STRSIZE_P(callable);
28272827
mname = Z_STRVAL_P(callable);
28282828
ftable = &ce_org->function_table;
28292829
fcc->calling_scope = ce_org;
@@ -3056,17 +3056,17 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch
30563056
if (callable_name) {
30573057
char *ptr;
30583058

3059-
*callable_name_len = fcc->calling_scope->name_length + Z_STRLEN_P(callable) + sizeof("::") - 1;
3059+
*callable_name_len = fcc->calling_scope->name_length + Z_STRSIZE_P(callable) + sizeof("::") - 1;
30603060
ptr = *callable_name = emalloc(*callable_name_len + 1);
30613061
memcpy(ptr, fcc->calling_scope->name, fcc->calling_scope->name_length);
30623062
ptr += fcc->calling_scope->name_length;
30633063
memcpy(ptr, "::", sizeof("::") - 1);
30643064
ptr += sizeof("::") - 1;
3065-
memcpy(ptr, Z_STRVAL_P(callable), Z_STRLEN_P(callable) + 1);
3065+
memcpy(ptr, Z_STRVAL_P(callable), Z_STRSIZE_P(callable) + 1);
30663066
}
30673067
} else if (callable_name) {
3068-
*callable_name = estrndup(Z_STRVAL_P(callable), Z_STRLEN_P(callable));
3069-
*callable_name_len = Z_STRLEN_P(callable);
3068+
*callable_name = estrndup(Z_STRVAL_P(callable), Z_STRSIZE_P(callable));
3069+
*callable_name_len = Z_STRSIZE_P(callable);
30703070
}
30713071
if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) {
30723072
fcc->called_scope = fcc->calling_scope;
@@ -3106,20 +3106,20 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch
31063106
if (callable_name) {
31073107
char *ptr;
31083108

3109-
*callable_name_len = Z_STRLEN_PP(obj) + Z_STRLEN_PP(method) + sizeof("::") - 1;
3109+
*callable_name_len = Z_STRSIZE_PP(obj) + Z_STRSIZE_PP(method) + sizeof("::") - 1;
31103110
ptr = *callable_name = emalloc(*callable_name_len + 1);
3111-
memcpy(ptr, Z_STRVAL_PP(obj), Z_STRLEN_PP(obj));
3112-
ptr += Z_STRLEN_PP(obj);
3111+
memcpy(ptr, Z_STRVAL_PP(obj), Z_STRSIZE_PP(obj));
3112+
ptr += Z_STRSIZE_PP(obj);
31133113
memcpy(ptr, "::", sizeof("::") - 1);
31143114
ptr += sizeof("::") - 1;
3115-
memcpy(ptr, Z_STRVAL_PP(method), Z_STRLEN_PP(method) + 1);
3115+
memcpy(ptr, Z_STRVAL_PP(method), Z_STRSIZE_PP(method) + 1);
31163116
}
31173117

31183118
if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) {
31193119
return 1;
31203120
}
31213121

3122-
if (!zend_is_callable_check_class(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj), fcc, &strict_class, error TSRMLS_CC)) {
3122+
if (!zend_is_callable_check_class(Z_STRVAL_PP(obj), Z_STRSIZE_PP(obj), fcc, &strict_class, error TSRMLS_CC)) {
31233123
return 0;
31243124
}
31253125

@@ -3136,13 +3136,13 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch
31363136
if (callable_name) {
31373137
char *ptr;
31383138

3139-
*callable_name_len = fcc->calling_scope->name_length + Z_STRLEN_PP(method) + sizeof("::") - 1;
3139+
*callable_name_len = fcc->calling_scope->name_length + Z_STRSIZE_PP(method) + sizeof("::") - 1;
31403140
ptr = *callable_name = emalloc(*callable_name_len + 1);
31413141
memcpy(ptr, fcc->calling_scope->name, fcc->calling_scope->name_length);
31423142
ptr += fcc->calling_scope->name_length;
31433143
memcpy(ptr, "::", sizeof("::") - 1);
31443144
ptr += sizeof("::") - 1;
3145-
memcpy(ptr, Z_STRVAL_PP(method), Z_STRLEN_PP(method) + 1);
3145+
memcpy(ptr, Z_STRVAL_PP(method), Z_STRSIZE_PP(method) + 1);
31463146
}
31473147

31483148
if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) {
@@ -3204,8 +3204,8 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch
32043204
int use_copy;
32053205

32063206
zend_make_printable_zval(callable, &expr_copy, &use_copy);
3207-
*callable_name = estrndup(Z_STRVAL(expr_copy), Z_STRLEN(expr_copy));
3208-
*callable_name_len = Z_STRLEN(expr_copy);
3207+
*callable_name = estrndup(Z_STRVAL(expr_copy), Z_STRSIZE(expr_copy));
3208+
*callable_name_len = Z_STRSIZE(expr_copy);
32093209
zval_dtor(&expr_copy);
32103210
}
32113211
if (error) zend_spprintf(error, 0, "no array or string given");

Zend/zend_builtin_functions.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -626,10 +626,10 @@ ZEND_FUNCTION(each)
626626
ZEND_FUNCTION(error_reporting)
627627
{
628628
char *err;
629-
int err_len;
629+
zend_str_size err_len;
630630
int old_error_reporting;
631631

632-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &err, &err_len) == FAILURE) {
632+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &err, &err_len) == FAILURE) {
633633
return;
634634
}
635635

@@ -822,7 +822,7 @@ ZEND_FUNCTION(get_parent_class)
822822
} else if (Z_TYPE_P(arg) == IS_STRING) {
823823
zend_class_entry **pce;
824824

825-
if (zend_lookup_class(Z_STRVAL_P(arg), Z_STRLEN_P(arg), &pce TSRMLS_CC) == SUCCESS) {
825+
if (zend_lookup_class(Z_STRVAL_P(arg), Z_STRSIZE_P(arg), &pce TSRMLS_CC) == SUCCESS) {
826826
ce = *pce;
827827
}
828828
}
@@ -858,7 +858,7 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass)
858858

859859
if (allow_string && Z_TYPE_P(obj) == IS_STRING) {
860860
zend_class_entry **the_ce;
861-
if (zend_lookup_class(Z_STRVAL_P(obj), Z_STRLEN_P(obj), &the_ce TSRMLS_CC) == FAILURE) {
861+
if (zend_lookup_class(Z_STRVAL_P(obj), Z_STRSIZE_P(obj), &the_ce TSRMLS_CC) == FAILURE) {
862862
RETURN_FALSE;
863863
}
864864
instance_ce = *the_ce;
@@ -1054,7 +1054,7 @@ ZEND_FUNCTION(get_class_methods)
10541054
}
10551055
ce = Z_OBJCE_P(klass);
10561056
} else if (Z_TYPE_P(klass) == IS_STRING) {
1057-
if (zend_lookup_class(Z_STRVAL_P(klass), Z_STRLEN_P(klass), &pce TSRMLS_CC) == SUCCESS) {
1057+
if (zend_lookup_class(Z_STRVAL_P(klass), Z_STRSIZE_P(klass), &pce TSRMLS_CC) == SUCCESS) {
10581058
ce = *pce;
10591059
}
10601060
}
@@ -1123,7 +1123,7 @@ ZEND_FUNCTION(method_exists)
11231123
if (Z_TYPE_P(klass) == IS_OBJECT) {
11241124
ce = Z_OBJCE_P(klass);
11251125
} else if (Z_TYPE_P(klass) == IS_STRING) {
1126-
if (zend_lookup_class(Z_STRVAL_P(klass), Z_STRLEN_P(klass), &pce TSRMLS_CC) == FAILURE) {
1126+
if (zend_lookup_class(Z_STRVAL_P(klass), Z_STRSIZE_P(klass), &pce TSRMLS_CC) == FAILURE) {
11271127
RETURN_FALSE;
11281128
}
11291129
ce = *pce;
@@ -1185,7 +1185,7 @@ ZEND_FUNCTION(property_exists)
11851185
}
11861186

11871187
if (Z_TYPE_P(object) == IS_STRING) {
1188-
if (zend_lookup_class(Z_STRVAL_P(object), Z_STRLEN_P(object), &pce TSRMLS_CC) == FAILURE) {
1188+
if (zend_lookup_class(Z_STRVAL_P(object), Z_STRSIZE_P(object), &pce TSRMLS_CC) == FAILURE) {
11891189
RETURN_FALSE;
11901190
}
11911191
ce = *pce;
@@ -1349,12 +1349,12 @@ ZEND_FUNCTION(trait_exists)
13491349
ZEND_FUNCTION(function_exists)
13501350
{
13511351
char *name;
1352-
int name_len;
1352+
zend_str_size name_len;
13531353
zend_function *func;
13541354
char *lcname;
13551355
zend_bool retval;
13561356

1357-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
1357+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &name, &name_len) == FAILURE) {
13581358
return;
13591359
}
13601360

Zend/zend_closures.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ ZEND_METHOD(Closure, bind)
107107

108108
if (Z_TYPE_P(scope_arg) == IS_STRING) {
109109
class_name = Z_STRVAL_P(scope_arg);
110-
class_name_len = Z_STRLEN_P(scope_arg);
110+
class_name_len = Z_STRSIZE_P(scope_arg);
111111
} else {
112112
tmp_zval = *scope_arg;
113113
zval_copy_ctor(&tmp_zval);
114114
convert_to_string(&tmp_zval);
115115
class_name = Z_STRVAL(tmp_zval);
116-
class_name_len = Z_STRLEN(tmp_zval);
116+
class_name_len = Z_STRSIZE(tmp_zval);
117117
}
118118

119119
if ((class_name_len == sizeof("static") - 1) &&

0 commit comments

Comments
 (0)