mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Use standard bool type instead of bool_int
This commit is contained in:
parent
53aed48e5d
commit
10f416f5c2
6 changed files with 29 additions and 38 deletions
|
@ -3701,14 +3701,7 @@ zend_freedtoa(char *s)
|
||||||
* calculation.
|
* calculation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEND_API char *
|
ZEND_API char *zend_dtoa(double dd, int mode, int ndigits, int *decpt, bool *sign, char **rve)
|
||||||
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
|
|
||||||
{
|
{
|
||||||
/* Arguments ndigits, decpt, sign are similar to those
|
/* Arguments ndigits, decpt, sign are similar to those
|
||||||
of ecvt and fcvt; trailing zeros are suppressed from
|
of ecvt and fcvt; trailing zeros are suppressed from
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
BEGIN_EXTERN_C()
|
BEGIN_EXTERN_C()
|
||||||
ZEND_API void zend_freedtoa(char *s);
|
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_strtod(const char *s00, const char **se);
|
||||||
ZEND_API double zend_hex_strtod(const char *str, const char **endptr);
|
ZEND_API double zend_hex_strtod(const char *str, const char **endptr);
|
||||||
ZEND_API double zend_oct_strtod(const char *str, const char **endptr);
|
ZEND_API double zend_oct_strtod(const char *str, const char **endptr);
|
||||||
|
|
|
@ -83,7 +83,7 @@ php_sprintf_appendchars(zend_string **buffer, size_t *pos, char *add, size_t len
|
||||||
inline static void
|
inline static void
|
||||||
php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add,
|
php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add,
|
||||||
size_t min_width, size_t max_width, char padding,
|
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 npad;
|
||||||
size_t req_size;
|
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));
|
PRINTF_DEBUG(("sprintf: appending %d as \"%s\", i=%d\n", number, &numbuf[i], i));
|
||||||
php_sprintf_appendstring(buffer, pos, &numbuf[i], width, 0,
|
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 num_buf[NUM_BUF_SIZE];
|
||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
size_t s_len = 0;
|
size_t s_len = 0;
|
||||||
int is_negative = 0;
|
bool is_negative = false;
|
||||||
#ifdef ZTS
|
#ifdef ZTS
|
||||||
struct lconv lconv;
|
struct lconv lconv;
|
||||||
#else
|
#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,
|
php_sprintf_appendstring(buffer, pos, &numbuf[i], width, 0,
|
||||||
padding, alignment, (NUM_BUF_SIZE - 1) - i,
|
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,
|
width, precision, padding,
|
||||||
alignment,
|
alignment,
|
||||||
ZSTR_LEN(str),
|
ZSTR_LEN(str),
|
||||||
0, expprec, 0);
|
/* neg */ false, expprec, 0);
|
||||||
zend_tmp_string_release(t);
|
zend_tmp_string_release(t);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
|
* 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;
|
register char *s = NULL;
|
||||||
char *p, *rve, c;
|
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));
|
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));
|
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) /* {{{ */
|
PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf) /* {{{ */
|
||||||
{
|
{
|
||||||
char *digits, *dst, *src;
|
char *digits, *dst, *src;
|
||||||
int i, decpt, sign;
|
int i, decpt;
|
||||||
|
bool sign;
|
||||||
int mode = ndigit >= 0 ? 2 : 0;
|
int mode = ndigit >= 0 ? 2 : 0;
|
||||||
|
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
|
@ -182,7 +183,8 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c
|
||||||
*dst = '\0';
|
*dst = '\0';
|
||||||
} else {
|
} else {
|
||||||
/* XXX - optimize */
|
/* 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';
|
dst[i + 1] = '\0';
|
||||||
while (decpt != 0) {
|
while (decpt != 0) {
|
||||||
dst[i--] = '0' + decpt % 10;
|
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 NUL '\0'
|
||||||
#define INT_NULL ((int *)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:
|
* Return value:
|
||||||
* - a pointer to a string containing the number (no sign)
|
* - a pointer to a string containing the number (no sign)
|
||||||
* - len contains the length of the string
|
* - len contains the length of the string
|
||||||
* - is_negative is set to TRUE or FALSE depending on the sign
|
* - is_negative is set to true or false depending on the sign
|
||||||
* of the number (always set to FALSE if is_unsigned is TRUE)
|
* 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
|
* 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
|
* 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 ])
|
* is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
|
||||||
*/
|
*/
|
||||||
/* char * ap_php_conv_10() {{{ */
|
/* char * ap_php_conv_10() {{{ */
|
||||||
PHPAPI char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
|
PHPAPI char * ap_php_conv_10(register wide_int num, register bool is_unsigned,
|
||||||
register bool_int * is_negative, char *buf_end, register size_t *len)
|
register bool * is_negative, char *buf_end, register size_t *len)
|
||||||
{
|
{
|
||||||
register char *p = buf_end;
|
register char *p = buf_end;
|
||||||
register u_wide_int magnitude;
|
register u_wide_int magnitude;
|
||||||
|
|
||||||
if (is_unsigned) {
|
if (is_unsigned) {
|
||||||
magnitude = (u_wide_int) num;
|
magnitude = (u_wide_int) num;
|
||||||
*is_negative = FALSE;
|
*is_negative = false;
|
||||||
} else {
|
} else {
|
||||||
*is_negative = (num < 0);
|
*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() {{{ */
|
||||||
PHPAPI char * php_conv_fp(register char format, register double num,
|
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 *s = buf;
|
||||||
register char *p, *p_orig;
|
register char *p, *p_orig;
|
||||||
|
@ -389,7 +389,7 @@ PHPAPI char * php_conv_fp(register char format, register double num,
|
||||||
if (isalpha((int)*p)) {
|
if (isalpha((int)*p)) {
|
||||||
*len = strlen(p);
|
*len = strlen(p);
|
||||||
memcpy(buf, p, *len + 1);
|
memcpy(buf, p, *len + 1);
|
||||||
*is_negative = FALSE;
|
*is_negative = false;
|
||||||
free(p_orig);
|
free(p_orig);
|
||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
@ -436,12 +436,12 @@ PHPAPI char * php_conv_fp(register char format, register double num,
|
||||||
if (format != 'F') {
|
if (format != 'F') {
|
||||||
char temp[EXPONENT_LENGTH]; /* for exponent conversion */
|
char temp[EXPONENT_LENGTH]; /* for exponent conversion */
|
||||||
size_t t_len;
|
size_t t_len;
|
||||||
bool_int exponent_is_negative;
|
bool exponent_is_negative;
|
||||||
|
|
||||||
*s++ = format; /* either e or E */
|
*s++ = format; /* either e or E */
|
||||||
decimal_point--;
|
decimal_point--;
|
||||||
if (decimal_point != 0) {
|
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 ? '-' : '+';
|
*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 print_blank;
|
||||||
boolean_e adjust_precision;
|
boolean_e adjust_precision;
|
||||||
boolean_e adjust_width;
|
boolean_e adjust_width;
|
||||||
bool_int is_negative;
|
bool is_negative;
|
||||||
|
|
||||||
sp = odp->nextb;
|
sp = odp->nextb;
|
||||||
bep = odp->buf_end;
|
bep = odp->buf_end;
|
||||||
|
|
|
@ -66,7 +66,7 @@ Example:
|
||||||
#ifndef SNPRINTF_H
|
#ifndef SNPRINTF_H
|
||||||
#define SNPRINTF_H
|
#define SNPRINTF_H
|
||||||
|
|
||||||
typedef int bool_int;
|
#include <stdbool.h>
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NO = 0, YES = 1
|
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_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_0cvt(double value, int ndigit, char dec_point, char exponent, char *buf);
|
||||||
PHPAPI char * php_conv_fp(char format, double num,
|
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()
|
END_EXTERN_C()
|
||||||
|
|
||||||
|
@ -141,8 +141,8 @@ typedef enum {
|
||||||
typedef WIDE_INT wide_int;
|
typedef WIDE_INT wide_int;
|
||||||
typedef unsigned WIDE_INT u_wide_int;
|
typedef unsigned WIDE_INT u_wide_int;
|
||||||
|
|
||||||
PHPAPI char * ap_php_conv_10(wide_int num, bool_int is_unsigned,
|
PHPAPI char * ap_php_conv_10(wide_int num, bool is_unsigned,
|
||||||
bool_int * is_negative, char *buf_end, size_t *len);
|
bool * is_negative, char *buf_end, size_t *len);
|
||||||
|
|
||||||
PHPAPI char * ap_php_conv_p2(u_wide_int num, int nbits,
|
PHPAPI char * ap_php_conv_p2(u_wide_int num, int nbits,
|
||||||
char format, char *buf_end, size_t *len);
|
char format, char *buf_end, size_t *len);
|
||||||
|
|
|
@ -95,8 +95,6 @@
|
||||||
|
|
||||||
#include "snprintf.h"
|
#include "snprintf.h"
|
||||||
|
|
||||||
#define FALSE 0
|
|
||||||
#define TRUE 1
|
|
||||||
#define NUL '\0'
|
#define NUL '\0'
|
||||||
#define INT_NULL ((int *)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 print_blank;
|
||||||
boolean_e adjust_precision;
|
boolean_e adjust_precision;
|
||||||
boolean_e adjust_width;
|
boolean_e adjust_width;
|
||||||
bool_int is_negative;
|
bool is_negative;
|
||||||
|
|
||||||
while (*fmt) {
|
while (*fmt) {
|
||||||
if (*fmt != '%') {
|
if (*fmt != '%') {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue