Skip to content

Commit c5aa03c

Browse files
committed
ext/libxml: Use bool type instead of int type
1 parent 1f1cd5c commit c5aa03c

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

ext/libxml/libxml.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
#include "libxml_arginfo.h"
5050

5151
/* a true global for initialization */
52-
static int php_libxml_initialized = 0;
53-
static int php_libxml_per_request_initialization = 1;
52+
static bool php_libxml_initialized = false;
53+
static bool php_libxml_per_request_initialization = true;
5454
static xmlExternalEntityLoader php_libxml_default_entity_loader;
5555

5656
typedef struct php_libxml_func_handler {
@@ -404,7 +404,7 @@ PHP_LIBXML_API php_stream_context *php_libxml_get_stream_context(void)
404404
/* Channel libxml file io layer through the PHP streams subsystem.
405405
* This allows use of ftps:// and https:// urls */
406406

407-
static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char *mode, const int read_only)
407+
static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char *mode, const bool read_only)
408408
{
409409
php_stream_statbuf ssbuf;
410410
char *resolved_path;
@@ -480,12 +480,12 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char
480480

481481
static void *php_libxml_streams_IO_open_read_wrapper(const char *filename)
482482
{
483-
return php_libxml_streams_IO_open_wrapper(filename, "rb", 1);
483+
return php_libxml_streams_IO_open_wrapper(filename, "rb", true);
484484
}
485485

486486
static void *php_libxml_streams_IO_open_write_wrapper(const char *filename)
487487
{
488-
return php_libxml_streams_IO_open_wrapper(filename, "wb", 0);
488+
return php_libxml_streams_IO_open_wrapper(filename, "wb", false);
489489
}
490490

491491
static int php_libxml_streams_IO_read(void *context, char *buffer, int len)
@@ -916,7 +916,7 @@ PHP_LIBXML_API void php_libxml_initialize(void)
916916

917917
zend_hash_init(&php_libxml_exports, 0, NULL, php_libxml_exports_dtor, 1);
918918

919-
php_libxml_initialized = 1;
919+
php_libxml_initialized = true;
920920
}
921921
}
922922

@@ -930,7 +930,7 @@ PHP_LIBXML_API void php_libxml_shutdown(void)
930930
zend_hash_destroy(&php_libxml_exports);
931931

932932
xmlSetExternalEntityLoader(php_libxml_default_entity_loader);
933-
php_libxml_initialized = 0;
933+
php_libxml_initialized = false;
934934
}
935935
}
936936

@@ -962,7 +962,7 @@ static PHP_MINIT_FUNCTION(libxml)
962962

963963
for (sapi_name = supported_sapis; *sapi_name; sapi_name++) {
964964
if (strcmp(sapi_module.name, *sapi_name) == 0) {
965-
php_libxml_per_request_initialization = 0;
965+
php_libxml_per_request_initialization = false;
966966
break;
967967
}
968968
}
@@ -1242,7 +1242,7 @@ PHP_FUNCTION(libxml_get_external_entity_loader)
12421242
/* }}} */
12431243

12441244
/* {{{ Common functions shared by extensions */
1245-
int php_libxml_xmlCheckUTF8(const unsigned char *s)
1245+
bool php_libxml_xmlCheckUTF8(const unsigned char *s)
12461246
{
12471247
size_t i;
12481248
unsigned char c;
@@ -1251,21 +1251,21 @@ int php_libxml_xmlCheckUTF8(const unsigned char *s)
12511251
if ((c & 0x80) == 0) {
12521252
} else if ((c & 0xe0) == 0xc0) {
12531253
if ((s[i++] & 0xc0) != 0x80) {
1254-
return 0;
1254+
return false;
12551255
}
12561256
} else if ((c & 0xf0) == 0xe0) {
12571257
if ((s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80) {
1258-
return 0;
1258+
return false;
12591259
}
12601260
} else if ((c & 0xf8) == 0xf0) {
12611261
if ((s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80) {
1262-
return 0;
1262+
return false;
12631263
}
12641264
} else {
1265-
return 0;
1265+
return false;
12661266
}
12671267
}
1268-
return 1;
1268+
return true;
12691269
}
12701270

12711271
zval *php_libxml_register_export(const zend_class_entry *ce, php_libxml_export_node export_function)

ext/libxml/php_libxml.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ PHP_LIBXML_API void php_libxml_ctx_warning(void *ctx, const char *msg, ...);
207207
PHP_LIBXML_API void php_libxml_pretend_ctx_error_ex(const char *file, int line, int column, const char *msg,...);
208208
PHP_LIBXML_API void php_libxml_ctx_error(void *ctx, const char *msg, ...);
209209
PHP_LIBXML_API void php_libxml_error_handler_va(php_libxml_error_level error_type, void *ctx, const char *msg, va_list args);
210-
PHP_LIBXML_API int php_libxml_xmlCheckUTF8(const unsigned char *s);
210+
PHP_LIBXML_API bool php_libxml_xmlCheckUTF8(const unsigned char *s);
211211
PHP_LIBXML_API void php_libxml_switch_context(const zval *context, zval *oldcontext);
212212
PHP_LIBXML_API void php_libxml_issue_error(int level, const char *msg);
213213
PHP_LIBXML_API bool php_libxml_disable_entity_loader(bool disable);

0 commit comments

Comments
 (0)