OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
-#include "php_psi_stdinc.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#else
+# include "php_config.h"
+#endif
#include "data.h"
#include "calc.h"
zend_internal_function_info *fi;
struct psi_impl_arg *iarg;
- aip = calloc(argc + 1 + !!impl->func->vararg, sizeof(*aip));
+ aip = pecalloc(argc + 1 + !!impl->func->vararg, sizeof(*aip), 1);
fi = (zend_internal_function_info *) &aip[0];
#ifdef ZEND_TYPE_ENCODE
struct psi_impl_arg *vararg = impl->func->vararg;
zend_internal_arg_info *ai = &aip[argc];
- ai->name = vararg->var->name;
+ ai->name = vararg->var->name->val;
#ifdef ZEND_TYPE_ENCODE
ai->type = ZEND_TYPE_ENCODE(psi_internal_type(vararg->type), 1);
#else
while (psi_plist_get(impl->func->args, i++, &iarg)) {
zend_internal_arg_info *ai = &aip[i];
- ai->name = iarg->var->name;
+ ai->name = iarg->var->name->val;
#ifdef ZEND_TYPE_ENCODE
ai->type = ZEND_TYPE_ENCODE(psi_internal_type(iarg->type), 1);
#else
return psi_val_boolval(tmp, real_type, boolval);
}
-static inline char *psi_u128_to_buf(char *buf, unsigned __int128 u128)
-{
- for (*buf = 0; u128 > 0; u128 /= 10) {
- *--buf = ((u128 % 10) + '0') & 0xff;
- }
- return buf;
-}
-
-static inline char *psi_i128_to_buf(char *buf, __int128 i128)
-{
- if (i128 < 0) {
- char *res = psi_u128_to_buf(buf, ~((unsigned __int128) i128) + 1);
-
- *--res = '-';
- return res;
- }
- return psi_u128_to_buf(buf, i128);
-}
-
-#if HAVE_INT128
-# define RETVAL_LONG_STR(V, s) do {\
- char buf[0x30] = {0}; \
- if (s && V >= ZEND_LONG_MIN && V <= ZEND_LONG_MAX) { \
- RETVAL_LONG(V); \
- } else if (!s && V <= ZEND_LONG_MAX) { \
- RETVAL_LONG(V); \
- } else if (!s && V <= ZEND_ULONG_MAX) { \
- RETVAL_STRING(zend_print_ulong_to_buf(&buf[sizeof(buf) - 1], V)); \
- } else if (s && V >= INT128_MIN && V <= INT128_MAX) { \
- RETVAL_STRING(psi_i128_to_buf(&buf[sizeof(buf) - 1], V)); \
- } else { \
- RETVAL_STRING(psi_u128_to_buf(&buf[sizeof(buf) - 1], V)); \
- } \
- } while (0)
-#else
-# define RETVAL_LONG_STR(V, s) do {\
- char buf[0x20] = {0}; \
- if (s && V >= ZEND_LONG_MIN && V <= ZEND_LONG_MAX) { \
- RETVAL_LONG(V); \
- } else if (!s && V <= ZEND_LONG_MAX) { \
- RETVAL_LONG(V); \
- } else { \
- RETVAL_STRING(zend_print_ulong_to_buf(&buf[sizeof(buf) - 1], V)); \
- } \
- } while (0)
-#endif
/*
* set $ivar = to_int(*dvar)
*/
case PSI_T_INT32: RETVAL_LONG(v->i32); break;
case PSI_T_UINT32: RETVAL_LONG(v->u32); break;
case PSI_T_INT64: RETVAL_LONG(v->i64); break;
- case PSI_T_UINT64: RETVAL_LONG_STR(v->u64, 0); break;
+ case PSI_T_UINT64: RETVAL_LONG_DOUBLE_STR(v->u64,); break;
#ifdef HAVE_INT128
- case PSI_T_INT128: RETVAL_LONG_STR(v->i128, 1); break;
- case PSI_T_UINT128: RETVAL_LONG_STR(v->u128, 0); break;
+ case PSI_T_INT128: RETVAL_LONG_DOUBLE_STR(v->i128, is_signed=true); break;
+ case PSI_T_UINT128: RETVAL_LONG_DOUBLE_STR(v->u128,); break;
#endif
case PSI_T_FLOAT:
RETVAL_DOUBLE((double) v->fval);
}
#if HAVE_INT128
-void psi_strto_i128(char *ptr, char *end, token_t real_type, impl_val *val) {
+static void psi_strto_i128(char *ptr, char *end, token_t real_type, impl_val *val) {
unsigned __int128 i = 0;
bool oct = false, hex = false, sign = false;
*/
impl_val *psi_let_intval(impl_val *tmp, struct psi_decl_arg *spec, token_t impl_type, impl_val *ival, zval *zvalue, void **to_free)
{
- zend_long intval;
- token_t real_type = spec ? psi_decl_type_get_real(spec->type)->type : PSI_T_LONG;
+ int64_t intval;
+ token_t real_type = spec ? psi_decl_type_get_real(spec->type)->type : PSI_T_INT64;
if (ival && impl_type == PSI_T_INT) {
impl_val *ptr = deref_impl_val(ret_val, var);
char *str;
- if (var->arg->var->array_size) {
+ if (var->arg->var->array_size && var->arg->var->pointer_level == 1) {
str = (char *) ptr;
} else {
str = ptr->ptr;
struct psi_set_exp *sub_exp;
psi_plist_get(set->inner, 0, &sub_exp);
- RETVAL_STRINGL(str, psi_long_num_exp(sub_exp->data.num, frame, NULL));
+ RETVAL_STRINGL(str, psi_num_exp_get_long(sub_exp->data.num, frame, NULL));
} else {
RETVAL_EMPTY_STRING();
}
}
psi_plist_get(set->inner, 0, &sub_exp);
- count = psi_long_num_exp(sub_exp->data.num, frame, NULL);
+ count = psi_num_exp_get_long(sub_exp->data.num, frame, NULL);
psi_plist_get(set->inner, 1, &sub_exp);
- for (ptr = (char *) ret_val; 0 < count--; ptr += size) {
size = psi_decl_var_get_size(psi_set_exp_get_decl_var(sub_exp));
+ for (ptr = (char *) ret_val; 0 < count--; ptr += size) {
zval ele;
ZVAL_NULL(&ele);
ZVAL_NULL(&ele);
psi_set_exp_exec_ex(sub_exp, &ele, sym->ptr, frame);
- add_assoc_zval(return_value, ivar->name + 1, &ele);
+ add_assoc_zval_ex(return_value, ivar->name->val + 1, ivar->name->len - 1, &ele);
}
}