Skip to content

Commit dc03601

Browse files
committed
ext/libxml: Minor code nits
1 parent d1917c9 commit dc03601

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

ext/libxml/libxml.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char
409409
php_stream_statbuf ssbuf;
410410
char *resolved_path;
411411
const char *path_to_open = NULL;
412-
bool isescaped = false;
412+
bool is_escaped = false;
413413

414414
if (strstr(filename, "%00")) {
415415
php_error_docref(NULL, E_WARNING, "URI must not contain percent-encoded NUL bytes");
@@ -420,7 +420,7 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char
420420
if (uri && (uri->scheme == NULL ||
421421
(xmlStrncmp(BAD_CAST uri->scheme, BAD_CAST "file", 4) == 0))) {
422422
resolved_path = xmlURIUnescapeString(filename, 0, NULL);
423-
isescaped = 1;
423+
is_escaped = true;
424424
#if LIBXML_VERSION >= 20902 && LIBXML_VERSION < 21300 && defined(PHP_WIN32)
425425
/* Libxml 2.9.2 prefixes local paths with file:/ instead of file://,
426426
thus the php stream wrapper will fail on a valid case. For this
@@ -458,7 +458,7 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char
458458
php_stream_wrapper *wrapper = php_stream_locate_url_wrapper(resolved_path, &path_to_open, 0);
459459
if (wrapper && read_only && wrapper->wops->url_stat) {
460460
if (wrapper->wops->url_stat(wrapper, path_to_open, PHP_STREAM_URL_STAT_QUIET, &ssbuf, NULL) == -1) {
461-
if (isescaped) {
461+
if (is_escaped) {
462462
xmlFree(resolved_path);
463463
}
464464
return NULL;
@@ -472,7 +472,7 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char
472472
/* Prevent from closing this by fclose() */
473473
ret_val->flags |= PHP_STREAM_FLAG_NO_FCLOSE;
474474
}
475-
if (isescaped) {
475+
if (is_escaped) {
476476
xmlFree(resolved_path);
477477
}
478478
return ret_val;
@@ -513,13 +513,14 @@ php_libxml_input_buffer_create_filename(const char *URI, xmlCharEncoding enc)
513513
return NULL;
514514
}
515515

516-
if (URI == NULL)
517-
return(NULL);
516+
if (URI == NULL) {
517+
return NULL;
518+
}
518519

519520
context = php_libxml_streams_IO_open_read_wrapper(URI);
520521

521522
if (context == NULL) {
522-
return(NULL);
523+
return NULL;
523524
}
524525

525526
/* Check if there's been an external transport protocol with an encoding information */
@@ -544,7 +545,7 @@ php_libxml_input_buffer_create_filename(const char *URI, xmlCharEncoding enc)
544545
} else
545546
php_libxml_streams_IO_close(context);
546547

547-
return(ret);
548+
return ret;
548549
}
549550

550551
static xmlOutputBufferPtr
@@ -559,8 +560,9 @@ php_libxml_output_buffer_create_filename(const char *URI,
559560
void *context = NULL;
560561
char *unescaped = NULL;
561562

562-
if (URI == NULL)
563+
if (URI == NULL) {
563564
goto err;
565+
}
564566

565567
if (strstr(URI, "%00")) {
566568
php_error_docref(NULL, E_WARNING, "URI must not contain percent-encoded NUL bytes");
@@ -569,8 +571,9 @@ php_libxml_output_buffer_create_filename(const char *URI,
569571

570572
puri = xmlParseURI(URI);
571573
if (puri != NULL) {
572-
if (puri->scheme != NULL)
574+
if (puri->scheme != NULL) {
573575
unescaped = xmlURIUnescapeString(URI, 0, NULL);
576+
}
574577
xmlFreeURI(puri);
575578
}
576579

@@ -596,7 +599,7 @@ php_libxml_output_buffer_create_filename(const char *URI,
596599
ret->closecallback = php_libxml_streams_IO_close;
597600
}
598601

599-
return(ret);
602+
return ret;
600603

601604
err:
602605
/* Similarly to __xmlOutputBufferCreateFilename we should also close the encoder on failure. */
@@ -992,7 +995,7 @@ static PHP_RINIT_FUNCTION(libxml)
992995
* other threads/requests that might have disabled the loader
993996
* do not affect the current request.
994997
*/
995-
LIBXML(entity_loader_disabled) = 0;
998+
LIBXML(entity_loader_disabled) = false;
996999

9971000
return SUCCESS;
9981001
}
@@ -1094,7 +1097,7 @@ PHP_FUNCTION(libxml_use_internal_errors)
10941097
RETURN_BOOL(retval);
10951098
}
10961099

1097-
if (use_errors == 0) {
1100+
if (use_errors == false) {
10981101
xmlSetStructuredErrorFunc(NULL, NULL);
10991102
if (LIBXML(error_list)) {
11001103
zend_llist_destroy(LIBXML(error_list));
@@ -1196,7 +1199,7 @@ PHP_LIBXML_API bool php_libxml_disable_entity_loader(bool disable) /* {{{ */
11961199
/* {{{ Disable/Enable ability to load external entities */
11971200
PHP_FUNCTION(libxml_disable_entity_loader)
11981201
{
1199-
bool disable = 1;
1202+
bool disable = true;
12001203

12011204
ZEND_PARSE_PARAMETERS_START(0, 1)
12021205
Z_PARAM_OPTIONAL

0 commit comments

Comments
 (0)