diff --git a/Zend/zend_strtod.c b/Zend/zend_strtod.c index 1b66cada986..4b44a144292 100644 --- a/Zend/zend_strtod.c +++ b/Zend/zend_strtod.c @@ -3701,14 +3701,7 @@ zend_freedtoa(char *s) * calculation. */ -ZEND_API char * -zend_dtoa -#ifdef KR_headers - (dd, mode, ndigits, decpt, sign, rve) - double dd; int mode, ndigits, *decpt, *sign; char **rve; -#else - (double dd, int mode, int ndigits, int *decpt, int *sign, char **rve) -#endif +ZEND_API char *zend_dtoa(double dd, int mode, int ndigits, int *decpt, bool *sign, char **rve) { /* Arguments ndigits, decpt, sign are similar to those of ecvt and fcvt; trailing zeros are suppressed from diff --git a/Zend/zend_strtod.h b/Zend/zend_strtod.h index ea81827df28..232a4d71e42 100644 --- a/Zend/zend_strtod.h +++ b/Zend/zend_strtod.h @@ -24,7 +24,7 @@ BEGIN_EXTERN_C() ZEND_API void zend_freedtoa(char *s); -ZEND_API char * zend_dtoa(double _d, int mode, int ndigits, int *decpt, int *sign, char **rve); +ZEND_API char * zend_dtoa(double _d, int mode, int ndigits, int *decpt, bool *sign, char **rve); ZEND_API double zend_strtod(const char *s00, const char **se); ZEND_API double zend_hex_strtod(const char *str, const char **endptr); ZEND_API double zend_oct_strtod(const char *str, const char **endptr); diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index 0990b390d6b..71c1bbcbd93 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -83,7 +83,7 @@ php_sprintf_appendchars(zend_string **buffer, size_t *pos, char *add, size_t len inline static void php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add, size_t min_width, size_t max_width, char padding, - size_t alignment, size_t len, int neg, int expprec, int always_sign) + size_t alignment, size_t len, bool neg, int expprec, int always_sign) { size_t npad; size_t req_size; @@ -208,7 +208,7 @@ php_sprintf_appenduint(zend_string **buffer, size_t *pos, PRINTF_DEBUG(("sprintf: appending %d as \"%s\", i=%d\n", number, &numbuf[i], i)); php_sprintf_appendstring(buffer, pos, &numbuf[i], width, 0, - padding, alignment, (NUM_BUF_SIZE - 1) - i, 0, 0, 0); + padding, alignment, (NUM_BUF_SIZE - 1) - i, /* neg */ false, 0, 0); } /* }}} */ @@ -225,7 +225,7 @@ php_sprintf_appenddouble(zend_string **buffer, size_t *pos, char num_buf[NUM_BUF_SIZE]; char *s = NULL; size_t s_len = 0; - int is_negative = 0; + bool is_negative = false; #ifdef ZTS struct lconv lconv; #else @@ -346,7 +346,7 @@ php_sprintf_append2n(zend_string **buffer, size_t *pos, zend_long number, php_sprintf_appendstring(buffer, pos, &numbuf[i], width, 0, padding, alignment, (NUM_BUF_SIZE - 1) - i, - 0, expprec, 0); + /* neg */ false, expprec, 0); } /* }}} */ @@ -627,7 +627,7 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n width, precision, padding, alignment, ZSTR_LEN(str), - 0, expprec, 0); + /* neg */ false, expprec, 0); zend_tmp_string_release(t); break; } diff --git a/main/snprintf.c b/main/snprintf.c index 19619fe18d9..22779801d3f 100644 --- a/main/snprintf.c +++ b/main/snprintf.c @@ -57,7 +57,7 @@ * Materiel Command, USAF, under agreement number F39502-99-1-0512. */ -static char * __cvt(double value, int ndigit, int *decpt, int *sign, int fmode, int pad) /* {{{ */ +static char * __cvt(double value, int ndigit, int *decpt, bool *sign, int fmode, int pad) /* {{{ */ { register char *s = NULL; char *p, *rve, c; @@ -116,13 +116,13 @@ static char * __cvt(double value, int ndigit, int *decpt, int *sign, int fmode, } /* }}} */ -static inline char *php_ecvt(double value, int ndigit, int *decpt, int *sign) /* {{{ */ +static inline char *php_ecvt(double value, int ndigit, int *decpt, bool *sign) /* {{{ */ { return(__cvt(value, ndigit, decpt, sign, 0, 1)); } /* }}} */ -static inline char *php_fcvt(double value, int ndigit, int *decpt, int *sign) /* {{{ */ +static inline char *php_fcvt(double value, int ndigit, int *decpt, bool *sign) /* {{{ */ { return(__cvt(value, ndigit, decpt, sign, 1, 1)); } @@ -131,7 +131,8 @@ static inline char *php_fcvt(double value, int ndigit, int *decpt, int *sign) /* PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf) /* {{{ */ { char *digits, *dst, *src; - int i, decpt, sign; + int i, decpt; + bool sign; int mode = ndigit >= 0 ? 2 : 0; if (mode == 0) { @@ -182,7 +183,8 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c *dst = '\0'; } else { /* XXX - optimize */ - for (sign = decpt, i = 0; (sign /= 10) != 0; i++); + int n; + for (n = decpt, i = 0; (n /= 10) != 0; i++); dst[i + 1] = '\0'; while (decpt != 0) { dst[i--] = '0' + decpt % 10; @@ -283,8 +285,6 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c */ /* }}} */ -#define FALSE 0 -#define TRUE 1 #define NUL '\0' #define INT_NULL ((int *)0) @@ -300,23 +300,23 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c * Return value: * - a pointer to a string containing the number (no sign) * - len contains the length of the string - * - is_negative is set to TRUE or FALSE depending on the sign - * of the number (always set to FALSE if is_unsigned is TRUE) + * - is_negative is set to true or false depending on the sign + * of the number (always set to false if is_unsigned is true) * * The caller provides a buffer for the string: that is the buf_end argument * which is a pointer to the END of the buffer + 1 (i.e. if the buffer * is declared as buf[ 100 ], buf_end should be &buf[ 100 ]) */ /* char * ap_php_conv_10() {{{ */ -PHPAPI char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned, - register bool_int * is_negative, char *buf_end, register size_t *len) +PHPAPI char * ap_php_conv_10(register wide_int num, register bool is_unsigned, + register bool * is_negative, char *buf_end, register size_t *len) { register char *p = buf_end; register u_wide_int magnitude; if (is_unsigned) { magnitude = (u_wide_int) num; - *is_negative = FALSE; + *is_negative = false; } else { *is_negative = (num < 0); @@ -367,7 +367,7 @@ PHPAPI char * ap_php_conv_10(register wide_int num, register bool_int is_unsigne */ /* PHPAPI char * php_conv_fp() {{{ */ PHPAPI char * php_conv_fp(register char format, register double num, - boolean_e add_dp, int precision, char dec_point, bool_int * is_negative, char *buf, size_t *len) + boolean_e add_dp, int precision, char dec_point, bool * is_negative, char *buf, size_t *len) { register char *s = buf; register char *p, *p_orig; @@ -389,7 +389,7 @@ PHPAPI char * php_conv_fp(register char format, register double num, if (isalpha((int)*p)) { *len = strlen(p); memcpy(buf, p, *len + 1); - *is_negative = FALSE; + *is_negative = false; free(p_orig); return (buf); } @@ -436,12 +436,12 @@ PHPAPI char * php_conv_fp(register char format, register double num, if (format != 'F') { char temp[EXPONENT_LENGTH]; /* for exponent conversion */ size_t t_len; - bool_int exponent_is_negative; + bool exponent_is_negative; *s++ = format; /* either e or E */ decimal_point--; if (decimal_point != 0) { - p = ap_php_conv_10((wide_int) decimal_point, FALSE, &exponent_is_negative, &temp[EXPONENT_LENGTH], &t_len); + p = ap_php_conv_10((wide_int) decimal_point, false, &exponent_is_negative, &temp[EXPONENT_LENGTH], &t_len); *s++ = exponent_is_negative ? '-' : '+'; /* @@ -616,7 +616,7 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) / boolean_e print_blank; boolean_e adjust_precision; boolean_e adjust_width; - bool_int is_negative; + bool is_negative; sp = odp->nextb; bep = odp->buf_end; diff --git a/main/snprintf.h b/main/snprintf.h index b0d824a5ae9..dc476f66ed7 100644 --- a/main/snprintf.h +++ b/main/snprintf.h @@ -66,7 +66,7 @@ Example: #ifndef SNPRINTF_H #define SNPRINTF_H -typedef int bool_int; +#include typedef enum { NO = 0, YES = 1 @@ -83,7 +83,7 @@ PHPAPI int ap_php_asprintf(char **buf, const char *format, ...) ZEND_ATTRIBUTE_F PHPAPI char * php_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf); PHPAPI char * php_0cvt(double value, int ndigit, char dec_point, char exponent, char *buf); PHPAPI char * php_conv_fp(char format, double num, - boolean_e add_dp, int precision, char dec_point, bool_int * is_negative, char *buf, size_t *len); + boolean_e add_dp, int precision, char dec_point, bool * is_negative, char *buf, size_t *len); END_EXTERN_C() @@ -141,8 +141,8 @@ typedef enum { typedef WIDE_INT wide_int; typedef unsigned WIDE_INT u_wide_int; -PHPAPI char * ap_php_conv_10(wide_int num, bool_int is_unsigned, - bool_int * is_negative, char *buf_end, size_t *len); +PHPAPI char * ap_php_conv_10(wide_int num, bool is_unsigned, + bool * is_negative, char *buf_end, size_t *len); PHPAPI char * ap_php_conv_p2(u_wide_int num, int nbits, char format, char *buf_end, size_t *len); diff --git a/main/spprintf.c b/main/spprintf.c index ce760569f3a..df8ae5a3402 100644 --- a/main/spprintf.c +++ b/main/spprintf.c @@ -95,8 +95,6 @@ #include "snprintf.h" -#define FALSE 0 -#define TRUE 1 #define NUL '\0' #define INT_NULL ((int *)0) @@ -220,7 +218,7 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_ boolean_e print_blank; boolean_e adjust_precision; boolean_e adjust_width; - bool_int is_negative; + bool is_negative; while (*fmt) { if (*fmt != '%') {