Skip to content

Commit 10f416f

Browse files
committed
Use standard bool type instead of bool_int
1 parent 53aed48 commit 10f416f

File tree

6 files changed

+29
-38
lines changed

6 files changed

+29
-38
lines changed

Zend/zend_strtod.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3701,14 +3701,7 @@ zend_freedtoa(char *s)
37013701
* calculation.
37023702
*/
37033703

3704-
ZEND_API char *
3705-
zend_dtoa
3706-
#ifdef KR_headers
3707-
(dd, mode, ndigits, decpt, sign, rve)
3708-
double dd; int mode, ndigits, *decpt, *sign; char **rve;
3709-
#else
3710-
(double dd, int mode, int ndigits, int *decpt, int *sign, char **rve)
3711-
#endif
3704+
ZEND_API char *zend_dtoa(double dd, int mode, int ndigits, int *decpt, bool *sign, char **rve)
37123705
{
37133706
/* Arguments ndigits, decpt, sign are similar to those
37143707
of ecvt and fcvt; trailing zeros are suppressed from

Zend/zend_strtod.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
BEGIN_EXTERN_C()
2626
ZEND_API void zend_freedtoa(char *s);
27-
ZEND_API char * zend_dtoa(double _d, int mode, int ndigits, int *decpt, int *sign, char **rve);
27+
ZEND_API char * zend_dtoa(double _d, int mode, int ndigits, int *decpt, bool *sign, char **rve);
2828
ZEND_API double zend_strtod(const char *s00, const char **se);
2929
ZEND_API double zend_hex_strtod(const char *str, const char **endptr);
3030
ZEND_API double zend_oct_strtod(const char *str, const char **endptr);

ext/standard/formatted_print.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ php_sprintf_appendchars(zend_string **buffer, size_t *pos, char *add, size_t len
8383
inline static void
8484
php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add,
8585
size_t min_width, size_t max_width, char padding,
86-
size_t alignment, size_t len, int neg, int expprec, int always_sign)
86+
size_t alignment, size_t len, bool neg, int expprec, int always_sign)
8787
{
8888
size_t npad;
8989
size_t req_size;
@@ -208,7 +208,7 @@ php_sprintf_appenduint(zend_string **buffer, size_t *pos,
208208

209209
PRINTF_DEBUG(("sprintf: appending %d as \"%s\", i=%d\n", number, &numbuf[i], i));
210210
php_sprintf_appendstring(buffer, pos, &numbuf[i], width, 0,
211-
padding, alignment, (NUM_BUF_SIZE - 1) - i, 0, 0, 0);
211+
padding, alignment, (NUM_BUF_SIZE - 1) - i, /* neg */ false, 0, 0);
212212
}
213213
/* }}} */
214214

@@ -225,7 +225,7 @@ php_sprintf_appenddouble(zend_string **buffer, size_t *pos,
225225
char num_buf[NUM_BUF_SIZE];
226226
char *s = NULL;
227227
size_t s_len = 0;
228-
int is_negative = 0;
228+
bool is_negative = false;
229229
#ifdef ZTS
230230
struct lconv lconv;
231231
#else
@@ -346,7 +346,7 @@ php_sprintf_append2n(zend_string **buffer, size_t *pos, zend_long number,
346346

347347
php_sprintf_appendstring(buffer, pos, &numbuf[i], width, 0,
348348
padding, alignment, (NUM_BUF_SIZE - 1) - i,
349-
0, expprec, 0);
349+
/* neg */ false, expprec, 0);
350350
}
351351
/* }}} */
352352

@@ -627,7 +627,7 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n
627627
width, precision, padding,
628628
alignment,
629629
ZSTR_LEN(str),
630-
0, expprec, 0);
630+
/* neg */ false, expprec, 0);
631631
zend_tmp_string_release(t);
632632
break;
633633
}

main/snprintf.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
5858
*/
5959

60-
static char * __cvt(double value, int ndigit, int *decpt, int *sign, int fmode, int pad) /* {{{ */
60+
static char * __cvt(double value, int ndigit, int *decpt, bool *sign, int fmode, int pad) /* {{{ */
6161
{
6262
register char *s = NULL;
6363
char *p, *rve, c;
@@ -116,13 +116,13 @@ static char * __cvt(double value, int ndigit, int *decpt, int *sign, int fmode,
116116
}
117117
/* }}} */
118118

119-
static inline char *php_ecvt(double value, int ndigit, int *decpt, int *sign) /* {{{ */
119+
static inline char *php_ecvt(double value, int ndigit, int *decpt, bool *sign) /* {{{ */
120120
{
121121
return(__cvt(value, ndigit, decpt, sign, 0, 1));
122122
}
123123
/* }}} */
124124

125-
static inline char *php_fcvt(double value, int ndigit, int *decpt, int *sign) /* {{{ */
125+
static inline char *php_fcvt(double value, int ndigit, int *decpt, bool *sign) /* {{{ */
126126
{
127127
return(__cvt(value, ndigit, decpt, sign, 1, 1));
128128
}
@@ -131,7 +131,8 @@ static inline char *php_fcvt(double value, int ndigit, int *decpt, int *sign) /*
131131
PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf) /* {{{ */
132132
{
133133
char *digits, *dst, *src;
134-
int i, decpt, sign;
134+
int i, decpt;
135+
bool sign;
135136
int mode = ndigit >= 0 ? 2 : 0;
136137

137138
if (mode == 0) {
@@ -182,7 +183,8 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c
182183
*dst = '\0';
183184
} else {
184185
/* XXX - optimize */
185-
for (sign = decpt, i = 0; (sign /= 10) != 0; i++);
186+
int n;
187+
for (n = decpt, i = 0; (n /= 10) != 0; i++);
186188
dst[i + 1] = '\0';
187189
while (decpt != 0) {
188190
dst[i--] = '0' + decpt % 10;
@@ -283,8 +285,6 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c
283285
*/
284286
/* }}} */
285287

286-
#define FALSE 0
287-
#define TRUE 1
288288
#define NUL '\0'
289289
#define INT_NULL ((int *)0)
290290

@@ -300,23 +300,23 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c
300300
* Return value:
301301
* - a pointer to a string containing the number (no sign)
302302
* - len contains the length of the string
303-
* - is_negative is set to TRUE or FALSE depending on the sign
304-
* of the number (always set to FALSE if is_unsigned is TRUE)
303+
* - is_negative is set to true or false depending on the sign
304+
* of the number (always set to false if is_unsigned is true)
305305
*
306306
* The caller provides a buffer for the string: that is the buf_end argument
307307
* which is a pointer to the END of the buffer + 1 (i.e. if the buffer
308308
* is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
309309
*/
310310
/* char * ap_php_conv_10() {{{ */
311-
PHPAPI char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
312-
register bool_int * is_negative, char *buf_end, register size_t *len)
311+
PHPAPI char * ap_php_conv_10(register wide_int num, register bool is_unsigned,
312+
register bool * is_negative, char *buf_end, register size_t *len)
313313
{
314314
register char *p = buf_end;
315315
register u_wide_int magnitude;
316316

317317
if (is_unsigned) {
318318
magnitude = (u_wide_int) num;
319-
*is_negative = FALSE;
319+
*is_negative = false;
320320
} else {
321321
*is_negative = (num < 0);
322322

@@ -367,7 +367,7 @@ PHPAPI char * ap_php_conv_10(register wide_int num, register bool_int is_unsigne
367367
*/
368368
/* PHPAPI char * php_conv_fp() {{{ */
369369
PHPAPI char * php_conv_fp(register char format, register double num,
370-
boolean_e add_dp, int precision, char dec_point, bool_int * is_negative, char *buf, size_t *len)
370+
boolean_e add_dp, int precision, char dec_point, bool * is_negative, char *buf, size_t *len)
371371
{
372372
register char *s = buf;
373373
register char *p, *p_orig;
@@ -389,7 +389,7 @@ PHPAPI char * php_conv_fp(register char format, register double num,
389389
if (isalpha((int)*p)) {
390390
*len = strlen(p);
391391
memcpy(buf, p, *len + 1);
392-
*is_negative = FALSE;
392+
*is_negative = false;
393393
free(p_orig);
394394
return (buf);
395395
}
@@ -436,12 +436,12 @@ PHPAPI char * php_conv_fp(register char format, register double num,
436436
if (format != 'F') {
437437
char temp[EXPONENT_LENGTH]; /* for exponent conversion */
438438
size_t t_len;
439-
bool_int exponent_is_negative;
439+
bool exponent_is_negative;
440440

441441
*s++ = format; /* either e or E */
442442
decimal_point--;
443443
if (decimal_point != 0) {
444-
p = ap_php_conv_10((wide_int) decimal_point, FALSE, &exponent_is_negative, &temp[EXPONENT_LENGTH], &t_len);
444+
p = ap_php_conv_10((wide_int) decimal_point, false, &exponent_is_negative, &temp[EXPONENT_LENGTH], &t_len);
445445
*s++ = exponent_is_negative ? '-' : '+';
446446

447447
/*
@@ -616,7 +616,7 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
616616
boolean_e print_blank;
617617
boolean_e adjust_precision;
618618
boolean_e adjust_width;
619-
bool_int is_negative;
619+
bool is_negative;
620620

621621
sp = odp->nextb;
622622
bep = odp->buf_end;

main/snprintf.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ spprintf is the dynamical version of snprintf. It allocates the buffer in size
6666
#ifndef SNPRINTF_H
6767
#define SNPRINTF_H
6868

69-
typedef int bool_int;
69+
#include <stdbool.h>
7070

7171
typedef enum {
7272
NO = 0, YES = 1
@@ -83,7 +83,7 @@ PHPAPI int ap_php_asprintf(char **buf, const char *format, ...) ZEND_ATTRIBUTE_F
8383
PHPAPI char * php_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf);
8484
PHPAPI char * php_0cvt(double value, int ndigit, char dec_point, char exponent, char *buf);
8585
PHPAPI char * php_conv_fp(char format, double num,
86-
boolean_e add_dp, int precision, char dec_point, bool_int * is_negative, char *buf, size_t *len);
86+
boolean_e add_dp, int precision, char dec_point, bool * is_negative, char *buf, size_t *len);
8787

8888
END_EXTERN_C()
8989

@@ -141,8 +141,8 @@ typedef enum {
141141
typedef WIDE_INT wide_int;
142142
typedef unsigned WIDE_INT u_wide_int;
143143

144-
PHPAPI char * ap_php_conv_10(wide_int num, bool_int is_unsigned,
145-
bool_int * is_negative, char *buf_end, size_t *len);
144+
PHPAPI char * ap_php_conv_10(wide_int num, bool is_unsigned,
145+
bool * is_negative, char *buf_end, size_t *len);
146146

147147
PHPAPI char * ap_php_conv_p2(u_wide_int num, int nbits,
148148
char format, char *buf_end, size_t *len);

main/spprintf.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@
9595

9696
#include "snprintf.h"
9797

98-
#define FALSE 0
99-
#define TRUE 1
10098
#define NUL '\0'
10199
#define INT_NULL ((int *)0)
102100

@@ -220,7 +218,7 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
220218
boolean_e print_blank;
221219
boolean_e adjust_precision;
222220
boolean_e adjust_width;
223-
bool_int is_negative;
221+
bool is_negative;
224222

225223
while (*fmt) {
226224
if (*fmt != '%') {

0 commit comments

Comments
 (0)