static void _build_trace_args(zval *arg, smart_str *str) /* {{{ */ { /* the trivial way would be to do * convert_to_string_ex(arg); * append it and kill the now tmp arg. * but that could cause some E_NOTICE and also damn long lines. */ ZVAL_DEREF(arg); switch (Z_TYPE_P(arg)) { case IS_NULL: smart_str_appends(str, "NULL, "); break; case IS_STRING: smart_str_appendc(str, '\''); smart_str_append_escaped(str, Z_STRVAL_P(arg), MIN(Z_STRLEN_P(arg), 15)); if (Z_STRLEN_P(arg) > 15) { smart_str_appends(str, "...', "); } else { smart_str_appends(str, "', "); } break; case IS_FALSE: smart_str_appends(str, "false, "); break; case IS_TRUE: smart_str_appends(str, "true, "); break; case IS_RESOURCE: smart_str_appends(str, "Resource id #"); smart_str_append_long(str, Z_RES_HANDLE_P(arg)); smart_str_appends(str, ", "); break; case IS_LONG: smart_str_append_long(str, Z_LVAL_P(arg)); smart_str_appends(str, ", "); break; case IS_DOUBLE: { double dval = Z_DVAL_P(arg); char *s_tmp = emalloc(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1); int l_tmp = zend_sprintf(s_tmp, "%.*G", (int) EG(precision), dval); /* SAFE */ smart_str_appendl(str, s_tmp, l_tmp); smart_str_appends(str, ", "); efree(s_tmp); break; } case IS_ARRAY: smart_str_appends(str, "Array, "); break; case IS_OBJECT: smart_str_appends(str, "Object("); smart_str_appends(str, ZSTR_VAL(Z_OBJCE_P(arg)->name)); smart_str_appends(str, "), "); break; } }
static void _build_trace_args(zval *arg, smart_str *str) /* {{{ */ { /* the trivial way would be to do * convert_to_string_ex(arg); * append it and kill the now tmp arg. * but that could cause some E_NOTICE and also damn long lines. */ ZVAL_DEREF(arg); switch (Z_TYPE_P(arg)) { case IS_NULL: smart_str_appends(str, "NULL, "); break; case IS_STRING: smart_str_appendc(str, '\''); smart_str_append_escaped(str, Z_STRVAL_P(arg), MIN(Z_STRLEN_P(arg), 15)); if (Z_STRLEN_P(arg) > 15) { smart_str_appends(str, "...', "); } else { smart_str_appends(str, "', "); } break; case IS_FALSE: smart_str_appends(str, "false, "); break; case IS_TRUE: smart_str_appends(str, "true, "); break; case IS_RESOURCE: smart_str_appends(str, "Resource id #"); smart_str_append_long(str, Z_RES_HANDLE_P(arg)); smart_str_appends(str, ", "); break; case IS_LONG: smart_str_append_long(str, Z_LVAL_P(arg)); smart_str_appends(str, ", "); break; case IS_DOUBLE: { smart_str_append_printf(str, "%.*G", (int) EG(precision), Z_DVAL_P(arg)); smart_str_appends(str, ", "); break; } case IS_ARRAY: smart_str_appends(str, "Array, "); break; case IS_OBJECT: { zend_string *class_name = Z_OBJ_HANDLER_P(arg, get_class_name)(Z_OBJ_P(arg)); smart_str_appends(str, "Object("); smart_str_appends(str, ZSTR_VAL(class_name)); smart_str_appends(str, "), "); zend_string_release_ex(class_name, 0); break; } } }