@@ -880,15 +880,15 @@ static zend_always_inline zend_string *zend_ffi_mangled_func_name(zend_string *n
880880 switch (type -> func .abi ) {
881881# ifdef HAVE_FFI_FASTCALL
882882 case FFI_FASTCALL :
883- return strpprintf (0 , "@%s @%zu" , ZSTR_VAL ( name ) , zend_ffi_arg_size (type ));
883+ return strpprintf (0 , "@%pS @%zu" , name , zend_ffi_arg_size (type ));
884884# endif
885885# ifdef HAVE_FFI_STDCALL
886886 case FFI_STDCALL :
887- return strpprintf (0 , "_%s @%zu" , ZSTR_VAL ( name ) , zend_ffi_arg_size (type ));
887+ return strpprintf (0 , "_%pS @%zu" , name , zend_ffi_arg_size (type ));
888888# endif
889889# ifdef HAVE_FFI_VECTORCALL_PARTIAL
890890 case FFI_VECTORCALL_PARTIAL :
891- return strpprintf (0 , "%s @@%zu" , ZSTR_VAL ( name ) , zend_ffi_arg_size (type ));
891+ return strpprintf (0 , "%pS @@%zu" , name , zend_ffi_arg_size (type ));
892892# endif
893893 default :
894894 /* other calling conventions don't apply name mangling */
@@ -1241,13 +1241,13 @@ static zval *zend_ffi_cdata_read_field(zend_object *obj, zend_string *field_name
12411241 type = ZEND_FFI_TYPE (type -> pointer .type );
12421242 }
12431243 if (UNEXPECTED (type -> kind != ZEND_FFI_TYPE_STRUCT )) {
1244- zend_throw_error (zend_ffi_exception_ce , "Attempt to read field '%s ' of non C struct/union" , ZSTR_VAL ( field_name ) );
1244+ zend_throw_error (zend_ffi_exception_ce , "Attempt to read field '%pS ' of non C struct/union" , field_name );
12451245 return & EG (uninitialized_zval );
12461246 }
12471247
12481248 field = zend_hash_find_ptr (& type -> record .fields , field_name );
12491249 if (UNEXPECTED (!field )) {
1250- zend_throw_error (zend_ffi_exception_ce , "Attempt to read undefined field '%s ' of C struct/union" , ZSTR_VAL ( field_name ) );
1250+ zend_throw_error (zend_ffi_exception_ce , "Attempt to read undefined field '%pS ' of C struct/union" , field_name );
12511251 return & EG (uninitialized_zval );
12521252 }
12531253
@@ -1310,20 +1310,20 @@ static zval *zend_ffi_cdata_write_field(zend_object *obj, zend_string *field_nam
13101310 field = * (cache_slot + 1 );
13111311 } else {
13121312 if (UNEXPECTED (type == NULL )) {
1313- zend_throw_error (zend_ffi_exception_ce , "Attempt to assign field '%s ' to uninitialized FFI\\CData object" , ZSTR_VAL ( field_name ) );
1313+ zend_throw_error (zend_ffi_exception_ce , "Attempt to assign field '%pS ' to uninitialized FFI\\CData object" , field_name );
13141314 return value ;
13151315 }
13161316 if (type -> kind == ZEND_FFI_TYPE_POINTER ) {
13171317 type = ZEND_FFI_TYPE (type -> pointer .type );
13181318 }
13191319 if (UNEXPECTED (type -> kind != ZEND_FFI_TYPE_STRUCT )) {
1320- zend_throw_error (zend_ffi_exception_ce , "Attempt to assign field '%s ' of non C struct/union" , ZSTR_VAL ( field_name ) );
1320+ zend_throw_error (zend_ffi_exception_ce , "Attempt to assign field '%pS ' of non C struct/union" , field_name );
13211321 return value ;
13221322 }
13231323
13241324 field = zend_hash_find_ptr (& type -> record .fields , field_name );
13251325 if (UNEXPECTED (!field )) {
1326- zend_throw_error (zend_ffi_exception_ce , "Attempt to assign undefined field '%s ' of C struct/union" , ZSTR_VAL ( field_name ) );
1326+ zend_throw_error (zend_ffi_exception_ce , "Attempt to assign undefined field '%pS ' of C struct/union" , field_name );
13271327 return value ;
13281328 }
13291329
@@ -1357,7 +1357,7 @@ static zval *zend_ffi_cdata_write_field(zend_object *obj, zend_string *field_nam
13571357 zend_throw_error (zend_ffi_exception_ce , "Attempt to assign read-only location" );
13581358 return value ;
13591359 } else if (UNEXPECTED (field -> is_const )) {
1360- zend_throw_error (zend_ffi_exception_ce , "Attempt to assign read-only field '%s '" , ZSTR_VAL ( field_name ) );
1360+ zend_throw_error (zend_ffi_exception_ce , "Attempt to assign read-only field '%pS '" , field_name );
13611361 return value ;
13621362 }
13631363
@@ -1684,7 +1684,7 @@ static ZEND_COLD void zend_ffi_pass_incompatible(const zval *arg, const zend_ffi
16841684
16851685 buf1 .start = buf1 .end = buf1 .buf + ((MAX_TYPE_NAME_LEN * 3 ) / 4 );
16861686 if (!zend_ffi_ctype_name (& buf1 , type )) {
1687- zend_throw_error (zend_ffi_exception_ce , "Passing incompatible argument %d of C function '%s '" , n + 1 , ZSTR_VAL ( EX (func )-> internal_function .function_name ) );
1687+ zend_throw_error (zend_ffi_exception_ce , "Passing incompatible argument %d of C function '%pS '" , n + 1 , EX (func )-> internal_function .function_name );
16881688 } else {
16891689 * buf1 .end = 0 ;
16901690 if (Z_TYPE_P (arg ) == IS_OBJECT && Z_OBJCE_P (arg ) == zend_ffi_cdata_ce ) {
@@ -1693,13 +1693,13 @@ static ZEND_COLD void zend_ffi_pass_incompatible(const zval *arg, const zend_ffi
16931693 type = ZEND_FFI_TYPE (cdata -> type );
16941694 buf2 .start = buf2 .end = buf2 .buf + ((MAX_TYPE_NAME_LEN * 3 ) / 4 );
16951695 if (!zend_ffi_ctype_name (& buf2 , type )) {
1696- zend_throw_error (zend_ffi_exception_ce , "Passing incompatible argument %d of C function '%s ', expecting '%s'" , n + 1 , ZSTR_VAL ( EX (func )-> internal_function .function_name ) , buf1 .start );
1696+ zend_throw_error (zend_ffi_exception_ce , "Passing incompatible argument %d of C function '%pS ', expecting '%s'" , n + 1 , EX (func )-> internal_function .function_name , buf1 .start );
16971697 } else {
16981698 * buf2 .end = 0 ;
1699- zend_throw_error (zend_ffi_exception_ce , "Passing incompatible argument %d of C function '%s ', expecting '%s', found '%s'" , n + 1 , ZSTR_VAL ( EX (func )-> internal_function .function_name ) , buf1 .start , buf2 .start );
1699+ zend_throw_error (zend_ffi_exception_ce , "Passing incompatible argument %d of C function '%pS ', expecting '%s', found '%s'" , n + 1 , EX (func )-> internal_function .function_name , buf1 .start , buf2 .start );
17001700 }
17011701 } else {
1702- zend_throw_error (zend_ffi_exception_ce , "Passing incompatible argument %d of C function '%s ', expecting '%s', found PHP '%s'" , n + 1 , ZSTR_VAL ( EX (func )-> internal_function .function_name ) , buf1 .start , zend_zval_value_name (arg ));
1702+ zend_throw_error (zend_ffi_exception_ce , "Passing incompatible argument %d of C function '%pS ', expecting '%s', found PHP '%s'" , n + 1 , EX (func )-> internal_function .function_name , buf1 .start , zend_zval_value_name (arg ));
17031703 }
17041704 }
17051705}
@@ -2493,7 +2493,7 @@ static zval *zend_ffi_read_var(zend_object *obj, zend_string *var_name, int read
24932493 }
24942494 }
24952495 if (!sym ) {
2496- zend_throw_error (zend_ffi_exception_ce , "Attempt to read undefined C variable '%s '" , ZSTR_VAL ( var_name ) );
2496+ zend_throw_error (zend_ffi_exception_ce , "Attempt to read undefined C variable '%pS '" , var_name );
24972497 return & EG (uninitialized_zval );
24982498 }
24992499
@@ -2537,12 +2537,12 @@ static zval *zend_ffi_write_var(zend_object *obj, zend_string *var_name, zval *v
25372537 }
25382538 }
25392539 if (!sym ) {
2540- zend_throw_error (zend_ffi_exception_ce , "Attempt to assign undefined C variable '%s '" , ZSTR_VAL ( var_name ) );
2540+ zend_throw_error (zend_ffi_exception_ce , "Attempt to assign undefined C variable '%pS '" , var_name );
25412541 return value ;
25422542 }
25432543
25442544 if (sym -> is_const ) {
2545- zend_throw_error (zend_ffi_exception_ce , "Attempt to assign read-only C variable '%s '" , ZSTR_VAL ( var_name ) );
2545+ zend_throw_error (zend_ffi_exception_ce , "Attempt to assign read-only C variable '%pS '" , var_name );
25462546 return value ;
25472547 }
25482548
@@ -2762,7 +2762,7 @@ static ZEND_FUNCTION(ffi_trampoline) /* {{{ */
27622762 arg_count = type -> func .args ? zend_hash_num_elements (type -> func .args ) : 0 ;
27632763 if (type -> attr & ZEND_FFI_ATTR_VARIADIC ) {
27642764 if (arg_count > EX_NUM_ARGS ()) {
2765- zend_throw_error (zend_ffi_exception_ce , "Incorrect number of arguments for C function '%s ', expecting at least %d parameter%s" , ZSTR_VAL ( EX (func )-> internal_function .function_name ) , arg_count , (arg_count != 1 ) ? "s" : "" );
2765+ zend_throw_error (zend_ffi_exception_ce , "Incorrect number of arguments for C function '%pS ', expecting at least %d parameter%s" , EX (func )-> internal_function .function_name , arg_count , (arg_count != 1 ) ? "s" : "" );
27662766 goto exit ;
27672767 }
27682768 if (EX_NUM_ARGS ()) {
@@ -2807,7 +2807,7 @@ static ZEND_FUNCTION(ffi_trampoline) /* {{{ */
28072807 }
28082808 } else {
28092809 if (arg_count != EX_NUM_ARGS ()) {
2810- zend_throw_error (zend_ffi_exception_ce , "Incorrect number of arguments for C function '%s ', expecting exactly %d parameter%s" , ZSTR_VAL ( EX (func )-> internal_function .function_name ) , arg_count , (arg_count != 1 ) ? "s" : "" );
2810+ zend_throw_error (zend_ffi_exception_ce , "Incorrect number of arguments for C function '%pS ', expecting exactly %d parameter%s" , EX (func )-> internal_function .function_name , arg_count , (arg_count != 1 ) ? "s" : "" );
28112811 goto exit ;
28122812 }
28132813 if (EX_NUM_ARGS ()) {
@@ -2935,7 +2935,7 @@ static zend_function *zend_ffi_get_func(zend_object **obj, zend_string *name, co
29352935 }
29362936 }
29372937 if (!sym ) {
2938- zend_throw_error (zend_ffi_exception_ce , "Attempt to call undefined C function '%s '" , ZSTR_VAL ( name ) );
2938+ zend_throw_error (zend_ffi_exception_ce , "Attempt to call undefined C function '%pS '" , name );
29392939 return NULL ;
29402940 }
29412941
@@ -3062,13 +3062,13 @@ ZEND_METHOD(FFI, cdef) /* {{{ */
30623062 char * err = GET_DL_ERROR ();
30633063#ifdef PHP_WIN32
30643064 if (err && err [0 ]) {
3065- zend_throw_error (zend_ffi_exception_ce , "Failed loading '%s ' (%s)" , ZSTR_VAL ( lib ) , err );
3065+ zend_throw_error (zend_ffi_exception_ce , "Failed loading '%pS ' (%s)" , lib , err );
30663066 php_win32_error_msg_free (err );
30673067 } else {
3068- zend_throw_error (zend_ffi_exception_ce , "Failed loading '%s ' (Unknown reason)" , ZSTR_VAL ( lib ) );
3068+ zend_throw_error (zend_ffi_exception_ce , "Failed loading '%pS ' (Unknown reason)" , lib );
30693069 }
30703070#else
3071- zend_throw_error (zend_ffi_exception_ce , "Failed loading '%s ' (%s)" , ZSTR_VAL ( lib ) , err );
3071+ zend_throw_error (zend_ffi_exception_ce , "Failed loading '%pS ' (%s)" , lib , err );
30723072 GET_DL_ERROR (); /* free the buffer storing the error */
30733073#endif
30743074 RETURN_THROWS ();
@@ -3101,7 +3101,7 @@ ZEND_METHOD(FFI, cdef) /* {{{ */
31013101 if (sym -> kind == ZEND_FFI_SYM_VAR ) {
31023102 addr = DL_FETCH_SYMBOL (handle , ZSTR_VAL (name ));
31033103 if (!addr ) {
3104- zend_throw_error (zend_ffi_exception_ce , "Failed resolving C variable '%s '" , ZSTR_VAL ( name ) );
3104+ zend_throw_error (zend_ffi_exception_ce , "Failed resolving C variable '%pS '" , name );
31053105 goto cleanup ;
31063106 }
31073107 sym -> addr = addr ;
@@ -3111,7 +3111,7 @@ ZEND_METHOD(FFI, cdef) /* {{{ */
31113111 addr = DL_FETCH_SYMBOL (handle , ZSTR_VAL (mangled_name ));
31123112 zend_string_release (mangled_name );
31133113 if (!addr ) {
3114- zend_throw_error (zend_ffi_exception_ce , "Failed resolving C function '%s '" , ZSTR_VAL ( name ) );
3114+ zend_throw_error (zend_ffi_exception_ce , "Failed resolving C function '%pS '" , name );
31153115 goto cleanup ;
31163116 }
31173117 sym -> addr = addr ;
@@ -3452,9 +3452,9 @@ static zend_ffi *zend_ffi_load(const char *filename, bool preload) /* {{{ */
34523452 addr = DL_FETCH_SYMBOL (handle , ZSTR_VAL (name ));
34533453 if (!addr ) {
34543454 if (preload ) {
3455- zend_error (E_WARNING , "FFI: failed pre-loading '%s', cannot resolve C variable '%s '" , filename , ZSTR_VAL ( name ) );
3455+ zend_error (E_WARNING , "FFI: failed pre-loading '%s', cannot resolve C variable '%pS '" , filename , name );
34563456 } else {
3457- zend_throw_error (zend_ffi_exception_ce , "Failed resolving C variable '%s '" , ZSTR_VAL ( name ) );
3457+ zend_throw_error (zend_ffi_exception_ce , "Failed resolving C variable '%pS '" , name );
34583458 }
34593459 if (lib ) {
34603460 DL_UNLOAD (handle );
@@ -3469,9 +3469,9 @@ static zend_ffi *zend_ffi_load(const char *filename, bool preload) /* {{{ */
34693469 zend_string_release (mangled_name );
34703470 if (!addr ) {
34713471 if (preload ) {
3472- zend_error (E_WARNING , "failed pre-loading '%s', cannot resolve C function '%s '" , filename , ZSTR_VAL ( name ) );
3472+ zend_error (E_WARNING , "failed pre-loading '%s', cannot resolve C function '%pS '" , filename , name );
34733473 } else {
3474- zend_throw_error (zend_ffi_exception_ce , "Failed resolving C function '%s '" , ZSTR_VAL ( name ) );
3474+ zend_throw_error (zend_ffi_exception_ce , "Failed resolving C function '%pS '" , name );
34753475 }
34763476 if (lib ) {
34773477 DL_UNLOAD (handle );
@@ -3492,7 +3492,7 @@ static zend_ffi *zend_ffi_load(const char *filename, bool preload) /* {{{ */
34923492 zend_ffi_type_dtor (type );
34933493 }
34943494 } else {
3495- zend_error (E_WARNING , "FFI: failed pre-loading '%s', redefinition of '%s '" , filename , ZSTR_VAL ( name ) );
3495+ zend_error (E_WARNING , "FFI: failed pre-loading '%s', redefinition of '%pS '" , filename , name );
34963496 if (lib ) {
34973497 DL_UNLOAD (handle );
34983498 }
@@ -3517,7 +3517,7 @@ static zend_ffi *zend_ffi_load(const char *filename, bool preload) /* {{{ */
35173517 zend_ffi_type_dtor (type );
35183518 }
35193519 } else {
3520- zend_error (E_WARNING , "FFI: failed pre-loading '%s', redefinition of '%s %s '" , filename , zend_ffi_tag_kind_name [tag -> kind ], ZSTR_VAL ( name ) );
3520+ zend_error (E_WARNING , "FFI: failed pre-loading '%s', redefinition of '%s %pS '" , filename , zend_ffi_tag_kind_name [tag -> kind ], name );
35213521 if (lib ) {
35223522 DL_UNLOAD (handle );
35233523 }
@@ -3649,7 +3649,7 @@ ZEND_METHOD(FFI, scope) /* {{{ */
36493649 }
36503650
36513651 if (!scope ) {
3652- zend_throw_error (zend_ffi_exception_ce , "Failed loading scope '%s '" , ZSTR_VAL ( scope_name ) );
3652+ zend_throw_error (zend_ffi_exception_ce , "Failed loading scope '%pS '" , scope_name );
36533653 RETURN_THROWS ();
36543654 }
36553655
@@ -3675,18 +3675,17 @@ void zend_ffi_cleanup_dcl(zend_ffi_dcl *dcl) /* {{{ */
36753675static void zend_ffi_throw_parser_error (const char * format , ...) /* {{{ */
36763676{
36773677 va_list va ;
3678- char * message = NULL ;
36793678
36803679 va_start (va , format );
3681- zend_vspprintf ( & message , 0 , format , va );
3680+ zend_string * message = zend_vstrpprintf ( 0 , format , va );
36823681
36833682 if (EG (current_execute_data )) {
3684- zend_throw_exception (zend_ffi_parser_exception_ce , message , 0 );
3683+ zend_throw_exception_ex (zend_ffi_parser_exception_ce , 0 , "%pS" , message );
36853684 } else {
3686- zend_error (E_WARNING , "FFI Parser: %s " , message );
3685+ zend_error (E_WARNING , "FFI Parser: %pS " , message );
36873686 }
36883687
3689- efree (message );
3688+ zend_string_release (message );
36903689 va_end (va );
36913690}
36923691/* }}} */
@@ -3711,11 +3710,11 @@ static zend_result zend_ffi_validate_incomplete_type(const zend_ffi_type *type,
37113710 ZEND_HASH_MAP_FOREACH_STR_KEY_PTR (FFI_G (tags ), key , tag ) {
37123711 if (ZEND_FFI_TYPE (tag -> type ) == type ) {
37133712 if (type -> kind == ZEND_FFI_TYPE_ENUM ) {
3714- zend_ffi_throw_parser_error ("Incomplete enum \"%s \" at line %d" , ZSTR_VAL ( key ) , FFI_G (line ));
3713+ zend_ffi_throw_parser_error ("Incomplete enum \"%pS \" at line %d" , key , FFI_G (line ));
37153714 } else if (type -> attr & ZEND_FFI_ATTR_UNION ) {
3716- zend_ffi_throw_parser_error ("Incomplete union \"%s \" at line %d" , ZSTR_VAL ( key ) , FFI_G (line ));
3715+ zend_ffi_throw_parser_error ("Incomplete union \"%pS \" at line %d" , key , FFI_G (line ));
37173716 } else {
3718- zend_ffi_throw_parser_error ("Incomplete struct \"%s \" at line %d" , ZSTR_VAL ( key ) , FFI_G (line ));
3717+ zend_ffi_throw_parser_error ("Incomplete struct \"%pS \" at line %d" , key , FFI_G (line ));
37193718 }
37203719 return FAILURE ;
37213720 }
@@ -3727,7 +3726,7 @@ static zend_result zend_ffi_validate_incomplete_type(const zend_ffi_type *type,
37273726
37283727 ZEND_HASH_MAP_FOREACH_STR_KEY_PTR (FFI_G (symbols ), key , sym ) {
37293728 if (type == ZEND_FFI_TYPE (sym -> type )) {
3730- zend_ffi_throw_parser_error ("Incomplete C type %s at line %d" , ZSTR_VAL ( key ) , FFI_G (line ));
3729+ zend_ffi_throw_parser_error ("Incomplete C type %pS at line %d" , key , FFI_G (line ));
37313730 return FAILURE ;
37323731 }
37333732 } ZEND_HASH_FOREACH_END ();
@@ -5114,14 +5113,14 @@ static char *zend_ffi_parse_directives(const char *filename, char *code_pos, cha
51145113
51155114static ZEND_COLD zend_function * zend_fake_get_constructor (zend_object * object ) /* {{{ */
51165115{
5117- zend_throw_error (NULL , "Instantiation of %s is not allowed" , ZSTR_VAL ( object -> ce -> name ) );
5116+ zend_throw_error (NULL , "Instantiation of %pS is not allowed" , object -> ce -> name );
51185117 return NULL ;
51195118}
51205119/* }}} */
51215120
51225121static ZEND_COLD zend_never_inline void zend_bad_array_access (zend_class_entry * ce ) /* {{{ */
51235122{
5124- zend_throw_error (NULL , "Cannot use object of type %s as array" , ZSTR_VAL ( ce -> name ) );
5123+ zend_throw_error (NULL , "Cannot use object of type %pS as array" , ce -> name );
51255124}
51265125/* }}} */
51275126
@@ -5153,7 +5152,7 @@ static ZEND_COLD void zend_fake_unset_dimension(zend_object *obj, zval *offset)
51535152
51545153static ZEND_COLD zend_never_inline void zend_bad_property_access (zend_class_entry * ce ) /* {{{ */
51555154{
5156- zend_throw_error (NULL , "Cannot access property of object of type %s " , ZSTR_VAL ( ce -> name ) );
5155+ zend_throw_error (NULL , "Cannot access property of object of type %pS " , ce -> name );
51575156}
51585157/* }}} */
51595158
@@ -5193,7 +5192,7 @@ static zval *zend_fake_get_property_ptr_ptr(zend_object *obj, zend_string *membe
51935192static ZEND_COLD zend_function * zend_fake_get_method (zend_object * * obj_ptr , zend_string * method_name , const zval * key ) /* {{{ */
51945193{
51955194 zend_class_entry * ce = (* obj_ptr )-> ce ;
5196- zend_throw_error (NULL , "Object of type %s does not support method calls" , ZSTR_VAL ( ce -> name ) );
5195+ zend_throw_error (NULL , "Object of type %pS does not support method calls" , ce -> name );
51975196 return NULL ;
51985197}
51995198/* }}} */
@@ -5753,18 +5752,17 @@ ZEND_GET_MODULE(ffi)
57535752void zend_ffi_parser_error (const char * format , ...) /* {{{ */
57545753{
57555754 va_list va ;
5756- char * message = NULL ;
57575755
57585756 va_start (va , format );
5759- zend_vspprintf ( & message , 0 , format , va );
5757+ zend_string * message = zend_vstrpprintf ( 0 , format , va );
57605758
57615759 if (EG (current_execute_data )) {
5762- zend_throw_exception (zend_ffi_parser_exception_ce , message , 0 );
5760+ zend_throw_exception_ex (zend_ffi_parser_exception_ce , 0 , "%pS" , message );
57635761 } else {
5764- zend_error (E_WARNING , "FFI Parser: %s " , message );
5762+ zend_error (E_WARNING , "FFI Parser: %pS " , message );
57655763 }
57665764
5767- efree (message );
5765+ zend_string_release (message );
57685766 va_end (va );
57695767
57705768 LONGJMP (FFI_G (bailout ), FAILURE );
@@ -6219,7 +6217,7 @@ void zend_ffi_add_anonymous_field(zend_ffi_dcl *struct_dcl, zend_ffi_dcl *field_
62196217 if (!zend_hash_add_ptr (& struct_type -> record .fields , key , new_field )) {
62206218 zend_ffi_type_dtor (new_field -> type );
62216219 pefree (new_field , FFI_G (persistent ));
6222- zend_ffi_parser_error ("Duplicate field name \"%s \" at line %d" , ZSTR_VAL ( key ) , FFI_G (line ));
6220+ zend_ffi_parser_error ("Duplicate field name \"%pS \" at line %d" , key , FFI_G (line ));
62236221 return ;
62246222 }
62256223 } else {
0 commit comments