summaryrefslogtreecommitdiff
path: root/ext/standard/formatted_print.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/formatted_print.c')
-rw-r--r--ext/standard/formatted_print.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c
index 1c381cdb00..e8bce6fa3f 100644
--- a/ext/standard/formatted_print.c
+++ b/ext/standard/formatted_print.c
@@ -59,12 +59,12 @@ static char HEXCHARS[] = "0123456789ABCDEF";
inline static void
php_sprintf_appendchar(zend_string **buffer, size_t *pos, char add)
{
- if (!*buffer || (*pos + 1) >= (*buffer)->len) {
- PRINTF_DEBUG(("%s(): ereallocing buffer to %d bytes\n", get_active_function_name(), (*buffer)->len));
- *buffer = zend_string_extend(*buffer, (*buffer)->len << 1, 0);
+ if (!*buffer || (*pos + 1) >= ZSTR_LEN(*buffer)) {
+ PRINTF_DEBUG(("%s(): ereallocing buffer to %d bytes\n", get_active_function_name(), ZSTR_LEN(*buffer)));
+ *buffer = zend_string_extend(*buffer, ZSTR_LEN(*buffer) << 1, 0);
}
PRINTF_DEBUG(("sprintf: appending '%c', pos=\n", add, *pos));
- (*buffer)->val[(*pos)++] = add;
+ ZSTR_VAL(*buffer)[(*pos)++] = add;
}
/* }}} */
@@ -83,7 +83,7 @@ php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add,
npad = (min_width < copy_len) ? 0 : min_width - copy_len;
PRINTF_DEBUG(("sprintf: appendstring(%x, %d, %d, \"%s\", %d, '%c', %d)\n",
- *buffer, *pos, (*buffer)->len, add, min_width, padding, alignment));
+ *buffer, *pos, ZSTR_LEN(*buffer), add, min_width, padding, alignment));
m_width = MAX(min_width, copy_len);
if(m_width > INT_MAX - *pos - 1) {
@@ -92,8 +92,8 @@ php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add,
req_size = *pos + m_width + 1;
- if (!*buffer || req_size > (*buffer)->len) {
- size_t size = (*buffer)->len;
+ if (!*buffer || req_size > ZSTR_LEN(*buffer)) {
+ size_t size = ZSTR_LEN(*buffer);
while (req_size > size) {
if (size > ZEND_SIZE_MAX/2) {
zend_error_noreturn(E_ERROR, "Field width %zd is too long", req_size);
@@ -105,21 +105,21 @@ php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add,
}
if (alignment == ALIGN_RIGHT) {
if ((neg || always_sign) && padding=='0') {
- (*buffer)->val[(*pos)++] = (neg) ? '-' : '+';
+ ZSTR_VAL(*buffer)[(*pos)++] = (neg) ? '-' : '+';
add++;
len--;
copy_len--;
}
while (npad-- > 0) {
- (*buffer)->val[(*pos)++] = padding;
+ ZSTR_VAL(*buffer)[(*pos)++] = padding;
}
}
PRINTF_DEBUG(("sprintf: appending \"%s\"\n", add));
- memcpy(&(*buffer)->val[*pos], add, copy_len + 1);
+ memcpy(&ZSTR_VAL(*buffer)[*pos], add, copy_len + 1);
*pos += copy_len;
if (alignment == ALIGN_LEFT) {
while (npad--) {
- (*buffer)->val[(*pos)++] = padding;
+ ZSTR_VAL(*buffer)[(*pos)++] = padding;
}
}
}
@@ -136,7 +136,7 @@ php_sprintf_appendint(zend_string **buffer, size_t *pos, zend_long number,
register unsigned int i = NUM_BUF_SIZE - 1, neg = 0;
PRINTF_DEBUG(("sprintf: appendint(%x, %x, %x, %d, %d, '%c', %d)\n",
- *buffer, pos, &(*buffer)->len, number, width, padding, alignment));
+ *buffer, pos, &ZSTR_LEN(*buffer), number, width, padding, alignment));
if (number < 0) {
neg = 1;
magn = ((zend_ulong) -(number + 1)) + 1;
@@ -180,7 +180,7 @@ php_sprintf_appenduint(zend_string **buffer, size_t *pos,
register unsigned int i = NUM_BUF_SIZE - 1;
PRINTF_DEBUG(("sprintf: appenduint(%x, %x, %x, %d, %d, '%c', %d)\n",
- *buffer, pos, &(*buffer)->len, number, width, padding, alignment));
+ *buffer, pos, &ZSTR_LEN(*buffer), number, width, padding, alignment));
magn = (zend_ulong) number;
/* Can't right-pad 0's on integers */
@@ -224,7 +224,7 @@ php_sprintf_appenddouble(zend_string **buffer, size_t *pos,
#endif
PRINTF_DEBUG(("sprintf: appenddouble(%x, %x, %x, %f, %d, '%c', %d, %c)\n",
- *buffer, pos, &(*buffer)->len, number, width, padding, alignment, fmt));
+ *buffer, pos, &ZSTR_LEN(*buffer), number, width, padding, alignment, fmt));
if ((adjust & ADJ_PRECISION) == 0) {
precision = FLOAT_PRECISION;
} else if (precision > MAX_FLOAT_PRECISION) {
@@ -317,7 +317,7 @@ php_sprintf_append2n(zend_string **buffer, size_t *pos, zend_long number,
register int andbits = (1 << n) - 1;
PRINTF_DEBUG(("sprintf: append2n(%x, %x, %x, %d, %d, '%c', %d, %d, %x)\n",
- *buffer, pos, &(*buffer)->len, number, width, padding, alignment, n,
+ *buffer, pos, &ZSTR_LEN(*buffer), number, width, padding, alignment, n,
chartable));
PRINTF_DEBUG(("sprintf: append2n 2^%d andbits=%x\n", n, andbits));
@@ -579,10 +579,10 @@ php_formatted_print(zend_execute_data *execute_data, int use_array, int format_o
case 's': {
zend_string *str = zval_get_string(tmp);
php_sprintf_appendstring(&result, &outpos,
- str->val,
+ ZSTR_VAL(str),
width, precision, padding,
alignment,
- str->len,
+ ZSTR_LEN(str),
0, expprec, 0);
zend_string_release(str);
break;
@@ -664,8 +664,8 @@ php_formatted_print(zend_execute_data *execute_data, int use_array, int format_o
}
/* possibly, we have to make sure we have room for the terminating null? */
- result->val[outpos]=0;
- result->len = outpos;
+ ZSTR_VAL(result)[outpos]=0;
+ ZSTR_LEN(result) = outpos;
return result;
}
/* }}} */
@@ -706,7 +706,7 @@ PHP_FUNCTION(user_printf)
if ((result=php_formatted_print(execute_data, 0, 0))==NULL) {
RETURN_FALSE;
}
- rlen = PHPWRITE(result->val, result->len);
+ rlen = PHPWRITE(ZSTR_VAL(result), ZSTR_LEN(result));
zend_string_free(result);
RETURN_LONG(rlen);
}
@@ -722,7 +722,7 @@ PHP_FUNCTION(vprintf)
if ((result=php_formatted_print(execute_data, 1, 0))==NULL) {
RETURN_FALSE;
}
- rlen = PHPWRITE(result->val, result->len);
+ rlen = PHPWRITE(ZSTR_VAL(result), ZSTR_LEN(result));
zend_string_free(result);
RETURN_LONG(rlen);
}
@@ -750,9 +750,9 @@ PHP_FUNCTION(fprintf)
RETURN_FALSE;
}
- php_stream_write(stream, result->val, result->len);
+ php_stream_write(stream, ZSTR_VAL(result), ZSTR_LEN(result));
- RETVAL_LONG(result->len);
+ RETVAL_LONG(ZSTR_LEN(result));
zend_string_free(result);
}
/* }}} */
@@ -779,9 +779,9 @@ PHP_FUNCTION(vfprintf)
RETURN_FALSE;
}
- php_stream_write(stream, result->val, result->len);
+ php_stream_write(stream, ZSTR_VAL(result), ZSTR_LEN(result));
- RETVAL_LONG(result->len);
+ RETVAL_LONG(ZSTR_LEN(result));
zend_string_free(result);
}
/* }}} */