Skip to content

Commit 018e7f5

Browse files
ext/standard/html.c: clean up a bit (phpGH-16311)
- Instead of manually wrapping `assert()` statements with a `ZEND_DEBUG` condition, use `ZEND_ASSERT()`, so that for non-debug builds the compiler is told to assume that the assertion is correct. - Update some return types for methods that return `zend_result`.
1 parent c597f92 commit 018e7f5

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

ext/standard/html.c

+6-10
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ static inline unsigned char unimap_bsearch(const uni_to_enc *table, unsigned cod
451451
/* }}} */
452452

453453
/* {{{ map_from_unicode */
454-
static inline int map_from_unicode(unsigned code, enum entity_charset charset, unsigned *res)
454+
static inline zend_result map_from_unicode(unsigned code, enum entity_charset charset, unsigned *res)
455455
{
456456
unsigned char found;
457457
const uni_to_enc *table;
@@ -667,7 +667,7 @@ static inline int numeric_entity_is_allowed(unsigned uni_cp, int document_type)
667667
* On input, *buf should point to the first character after # and on output, it's the last
668668
* byte read, no matter if there was success or insuccess.
669669
*/
670-
static inline int process_numeric_entity(const char **buf, unsigned *code_point)
670+
static inline zend_result process_numeric_entity(const char **buf, unsigned *code_point)
671671
{
672672
zend_long code_l;
673673
int hexadecimal = (**buf == 'x' || **buf == 'X'); /* TODO: XML apparently disallows "X" */
@@ -703,7 +703,7 @@ static inline int process_numeric_entity(const char **buf, unsigned *code_point)
703703
/* }}} */
704704

705705
/* {{{ process_named_entity */
706-
static inline int process_named_entity_html(const char **buf, const char **start, size_t *length)
706+
static inline zend_result process_named_entity_html(const char **buf, const char **start, size_t *length)
707707
{
708708
*start = *buf;
709709

@@ -732,7 +732,7 @@ static inline int process_named_entity_html(const char **buf, const char **start
732732
/* }}} */
733733

734734
/* {{{ resolve_named_entity_html */
735-
static int resolve_named_entity_html(const char *start, size_t length, const entity_ht *ht, unsigned *uni_cp1, unsigned *uni_cp2)
735+
static zend_result resolve_named_entity_html(const char *start, size_t length, const entity_ht *ht, unsigned *uni_cp1, unsigned *uni_cp2)
736736
{
737737
const entity_cp_map *s;
738738
zend_ulong hash = zend_inline_hash_func(start, length);
@@ -780,9 +780,7 @@ static inline size_t write_octet_sequence(unsigned char *buf, enum entity_charse
780780
#if 0
781781
return php_mb2_int_to_char(buf, code);
782782
#else
783-
#if ZEND_DEBUG
784-
assert(code <= 0xFFU);
785-
#endif
783+
ZEND_ASSERT(code <= 0xFFU);
786784
*buf = code;
787785
return 1;
788786
#endif
@@ -791,9 +789,7 @@ static inline size_t write_octet_sequence(unsigned char *buf, enum entity_charse
791789
#if 0 /* idem */
792790
return php_mb2_int_to_char(buf, code);
793791
#else
794-
#if ZEND_DEBUG
795-
assert(code <= 0xFFU);
796-
#endif
792+
ZEND_ASSERT(code <= 0xFFU);
797793
*buf = code;
798794
return 1;
799795
#endif

0 commit comments

Comments
 (0)