Skip to content

Commit 815d573

Browse files
committed
Use standard boolean type as zend_bool typedef
1 parent baa2858 commit 815d573

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

Zend/zend_globals.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,14 @@ struct _zend_compiler_globals {
8181

8282
HashTable *auto_globals;
8383

84-
zend_bool parse_error;
84+
/* From zend_language_parser.y:
85+
* CG(parse_error) states:
86+
* 0 => yyres = NULL, yystr is the unexpected token
87+
* 1 => yyres = NULL, yystr is one of the expected tokens
88+
* 2 => yyres != NULL, yystr is the unexpected token
89+
* 3 => yyres != NULL, yystr is one of the expected tokens
90+
*/
91+
unsigned int parse_error;
8592
zend_bool in_compilation;
8693
zend_bool short_tags;
8794

Zend/zend_types.h

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

2525
#include "zend_portability.h"
2626
#include "zend_long.h"
27+
#include <stdbool.h>
2728

2829
#ifdef __SSE2__
2930
# include <mmintrin.h>
@@ -46,7 +47,7 @@
4647
# define ZEND_ENDIAN_LOHI_C_4(a, b, c, d) a, b, c, d
4748
#endif
4849

49-
typedef unsigned char zend_bool;
50+
typedef bool zend_bool;
5051
typedef unsigned char zend_uchar;
5152

5253
typedef enum {

main/main.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,9 @@ static PHP_INI_MH(OnUpdateTimeout)
447447

448448
/* {{{ php_get_display_errors_mode() helper function
449449
*/
450-
static int php_get_display_errors_mode(char *value, size_t value_length)
450+
static unsigned int php_get_display_errors_mode(char *value, size_t value_length)
451451
{
452-
int mode;
452+
unsigned int mode;
453453

454454
if (!value) {
455455
return PHP_DISPLAY_ERRORS_STDOUT;
@@ -480,7 +480,12 @@ static int php_get_display_errors_mode(char *value, size_t value_length)
480480
*/
481481
static PHP_INI_MH(OnUpdateDisplayErrors)
482482
{
483-
PG(display_errors) = (zend_bool) php_get_display_errors_mode(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
483+
PG(errors_output_stream) = php_get_display_errors_mode(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
484+
if (PG(errors_output_stream) > 0) {
485+
PG(display_errors) = true;
486+
} else {
487+
PG(display_errors) = false;
488+
}
484489

485490
return SUCCESS;
486491
}
@@ -490,7 +495,8 @@ static PHP_INI_MH(OnUpdateDisplayErrors)
490495
*/
491496
static PHP_INI_DISP(display_errors_mode)
492497
{
493-
int mode, cgi_or_cli;
498+
unsigned int mode;
499+
bool cgi_or_cli;
494500
size_t tmp_value_length;
495501
char *tmp_value;
496502

@@ -1344,7 +1350,7 @@ static ZEND_COLD void php_error_cb(int orig_type, const char *error_filename, co
13441350
} else {
13451351
/* Write CLI/CGI errors to stderr if display_errors = "stderr" */
13461352
if ((!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "cgi") || !strcmp(sapi_module.name, "phpdbg")) &&
1347-
PG(display_errors) == PHP_DISPLAY_ERRORS_STDERR
1353+
PG(errors_output_stream) == PHP_DISPLAY_ERRORS_STDERR
13481354
) {
13491355
fprintf(stderr, "%s: %s in %s on line %" PRIu32 "\n", error_type_str, buffer, error_filename, error_lineno);
13501356
#ifdef PHP_WIN32

main/php_globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct _php_core_globals {
6565
zend_long memory_limit;
6666
zend_long max_input_time;
6767

68+
unsigned int errors_output_stream;
6869
zend_bool display_errors;
6970
zend_bool display_startup_errors;
7071
zend_bool log_errors;

0 commit comments

Comments
 (0)