Skip to content

Commit 5e4d727

Browse files
committed
Use standard bool type instead of boolean_e
1 parent 10f416f commit 5e4d727

File tree

3 files changed

+37
-42
lines changed

3 files changed

+37
-42
lines changed

main/snprintf.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ PHPAPI char * ap_php_conv_10(register wide_int num, register bool is_unsigned,
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 * is_negative, char *buf, size_t *len)
370+
bool 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;
@@ -570,7 +570,7 @@ typedef struct buf_area buffy;
570570
* Increase length
571571
* Set the has_prefix flag
572572
*/
573-
#define PREFIX( str, length, ch ) *--str = ch ; length++ ; has_prefix = YES
573+
#define PREFIX( str, length, ch ) *--str = ch ; length++ ; has_prefix = true
574574

575575

576576
/*
@@ -611,11 +611,11 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
611611
* Flag variables
612612
*/
613613
length_modifier_e modifier;
614-
boolean_e alternate_form;
615-
boolean_e print_sign;
616-
boolean_e print_blank;
617-
boolean_e adjust_precision;
618-
boolean_e adjust_width;
614+
bool alternate_form;
615+
bool print_sign;
616+
bool print_blank;
617+
bool adjust_precision;
618+
bool adjust_width;
619619
bool is_negative;
620620

621621
sp = odp->nextb;
@@ -630,7 +630,7 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
630630
*/
631631
zend_string *tmp_str = NULL;
632632
adjust = RIGHT;
633-
alternate_form = print_sign = print_blank = NO;
633+
alternate_form = print_sign = print_blank = false;
634634
pad_char = ' ';
635635
prefix_char = NUL;
636636

@@ -647,11 +647,11 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
647647
if (*fmt == '-')
648648
adjust = LEFT;
649649
else if (*fmt == '+')
650-
print_sign = YES;
650+
print_sign = true;
651651
else if (*fmt == '#')
652-
alternate_form = YES;
652+
alternate_form = true;
653653
else if (*fmt == ' ')
654-
print_blank = YES;
654+
print_blank = true;
655655
else if (*fmt == '0')
656656
pad_char = '0';
657657
else
@@ -663,23 +663,23 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
663663
*/
664664
if (isdigit((int)*fmt)) {
665665
STR_TO_DEC(fmt, min_width);
666-
adjust_width = YES;
666+
adjust_width = true;
667667
} else if (*fmt == '*') {
668668
min_width = va_arg(ap, int);
669669
fmt++;
670-
adjust_width = YES;
670+
adjust_width = true;
671671
if (min_width < 0) {
672672
adjust = LEFT;
673673
min_width = -min_width;
674674
}
675675
} else
676-
adjust_width = NO;
676+
adjust_width = false;
677677

678678
/*
679679
* Check if a precision was specified
680680
*/
681681
if (*fmt == '.') {
682-
adjust_precision = YES;
682+
adjust_precision = true;
683683
fmt++;
684684
if (isdigit((int)*fmt)) {
685685
STR_TO_DEC(fmt, precision);
@@ -695,9 +695,9 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
695695
precision = FORMAT_CONV_MAX_PRECISION;
696696
}
697697
} else
698-
adjust_precision = NO;
698+
adjust_precision = false;
699699
} else
700-
adjust_precision = adjust_width = NO;
700+
adjust_precision = adjust_width = false;
701701

702702
/*
703703
* Modifier check
@@ -993,7 +993,7 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
993993
}
994994
#endif
995995
s = php_conv_fp((*fmt == 'f')?'F':*fmt, fp_num, alternate_form,
996-
(adjust_precision == NO) ? FLOAT_DIGITS : precision,
996+
(adjust_precision == false) ? FLOAT_DIGITS : precision,
997997
(*fmt == 'f')?LCONV_DECIMAL_POINT:'.',
998998
&is_negative, &num_buf[1], &s_len);
999999
if (is_negative)
@@ -1036,7 +1036,7 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
10361036
break;
10371037
}
10381038

1039-
if (adjust_precision == NO) {
1039+
if (adjust_precision == false) {
10401040
precision = FLOAT_DIGITS;
10411041
} else if (precision == 0) {
10421042
precision = 1;

main/snprintf.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ spprintf is the dynamical version of snprintf. It allocates the buffer in size
6868

6969
#include <stdbool.h>
7070

71-
typedef enum {
72-
NO = 0, YES = 1
73-
} boolean_e;
74-
75-
7671
BEGIN_EXTERN_C()
7772
PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4);
7873
PHPAPI int ap_php_vslprintf(char *buf, size_t len, const char *format, va_list ap);
@@ -83,7 +78,7 @@ PHPAPI int ap_php_asprintf(char **buf, const char *format, ...) ZEND_ATTRIBUTE_F
8378
PHPAPI char * php_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf);
8479
PHPAPI char * php_0cvt(double value, int ndigit, char dec_point, char exponent, char *buf);
8580
PHPAPI char * php_conv_fp(char format, double num,
86-
boolean_e add_dp, int precision, char dec_point, bool * is_negative, char *buf, size_t *len);
81+
bool add_dp, int precision, char dec_point, bool * is_negative, char *buf, size_t *len);
8782

8883
END_EXTERN_C()
8984

main/spprintf.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,11 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
213213
* Flag variables
214214
*/
215215
length_modifier_e modifier;
216-
boolean_e alternate_form;
217-
boolean_e print_sign;
218-
boolean_e print_blank;
219-
boolean_e adjust_precision;
220-
boolean_e adjust_width;
216+
bool alternate_form;
217+
bool print_sign;
218+
bool print_blank;
219+
bool adjust_precision;
220+
bool adjust_width;
221221
bool is_negative;
222222

223223
while (*fmt) {
@@ -229,7 +229,7 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
229229
*/
230230
zend_string *tmp_str = NULL;
231231
adjust = RIGHT;
232-
alternate_form = print_sign = print_blank = NO;
232+
alternate_form = print_sign = print_blank = false;
233233
pad_char = ' ';
234234
prefix_char = NUL;
235235

@@ -246,11 +246,11 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
246246
if (*fmt == '-')
247247
adjust = LEFT;
248248
else if (*fmt == '+')
249-
print_sign = YES;
249+
print_sign = true;
250250
else if (*fmt == '#')
251-
alternate_form = YES;
251+
alternate_form = true;
252252
else if (*fmt == ' ')
253-
print_blank = YES;
253+
print_blank = true;
254254
else if (*fmt == '0')
255255
pad_char = '0';
256256
else
@@ -262,23 +262,23 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
262262
*/
263263
if (isdigit((int)*fmt)) {
264264
STR_TO_DEC(fmt, min_width);
265-
adjust_width = YES;
265+
adjust_width = true;
266266
} else if (*fmt == '*') {
267267
min_width = va_arg(ap, int);
268268
fmt++;
269-
adjust_width = YES;
269+
adjust_width = true;
270270
if (min_width < 0) {
271271
adjust = LEFT;
272272
min_width = -min_width;
273273
}
274274
} else
275-
adjust_width = NO;
275+
adjust_width = false;
276276

277277
/*
278278
* Check if a precision was specified
279279
*/
280280
if (*fmt == '.') {
281-
adjust_precision = YES;
281+
adjust_precision = true;
282282
fmt++;
283283
if (isdigit((int)*fmt)) {
284284
STR_TO_DEC(fmt, precision);
@@ -294,9 +294,9 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
294294
precision = FORMAT_CONV_MAX_PRECISION;
295295
}
296296
} else
297-
adjust_precision = NO;
297+
adjust_precision = false;
298298
} else
299-
adjust_precision = adjust_width = NO;
299+
adjust_precision = adjust_width = false;
300300

301301
/*
302302
* Modifier check
@@ -594,7 +594,7 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
594594
}
595595
#endif
596596
s = php_conv_fp((*fmt == 'f')?'F':*fmt, fp_num, alternate_form,
597-
(adjust_precision == NO) ? FLOAT_DIGITS : precision,
597+
(adjust_precision == false) ? FLOAT_DIGITS : precision,
598598
(*fmt == 'f')?LCONV_DECIMAL_POINT:'.',
599599
&is_negative, &num_buf[1], &s_len);
600600
if (is_negative)
@@ -637,7 +637,7 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
637637
break;
638638
}
639639

640-
if (adjust_precision == NO)
640+
if (adjust_precision == false)
641641
precision = FLOAT_DIGITS;
642642
else if (precision == 0)
643643
precision = 1;

0 commit comments

Comments
 (0)