@@ -88,7 +88,7 @@ static inline bool is_placeholder(char c) {
8888}
8989
9090/* Length of prefix not containing any wildcards */ 
91- static  uint8_t  browscap_compute_prefix_len (zend_string  * pattern ) {
91+ static  uint8_t  browscap_compute_prefix_len (const   zend_string  * pattern ) {
9292	size_t  i ;
9393	for  (i  =  0 ; i  <  ZSTR_LEN (pattern ); i ++ ) {
9494		if  (is_placeholder (ZSTR_VAL (pattern )[i ])) {
@@ -126,7 +126,7 @@ static size_t browscap_compute_contains(
126126}
127127
128128/* Length of regex, including escapes, anchors, etc. */ 
129- static  size_t  browscap_compute_regex_len (zend_string  * pattern ) {
129+ static  size_t  browscap_compute_regex_len (const   zend_string  * pattern ) {
130130	size_t  i , len  =  ZSTR_LEN (pattern );
131131	for  (i  =  0 ; i  <  ZSTR_LEN (pattern ); i ++ ) {
132132		switch  (ZSTR_VAL (pattern )[i ]) {
@@ -145,7 +145,7 @@ static size_t browscap_compute_regex_len(zend_string *pattern) {
145145	return  len  +  sizeof ("~^$~" )- 1 ;
146146}
147147
148- static  zend_string  * browscap_convert_pattern (zend_string  * pattern , int  persistent ) /* {{{ */ 
148+ static  zend_string  * browscap_convert_pattern (const   zend_string  * pattern , bool  persistent ) /* {{{ */ 
149149{
150150	size_t  i , j = 0 ;
151151	char  * t ;
@@ -306,7 +306,7 @@ static void php_browscap_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callb
306306{
307307	browscap_parser_ctx  * ctx  =  arg ;
308308	browser_data  * bdata  =  ctx -> bdata ;
309- 	int  persistent  =  GC_FLAGS (bdata -> htab ) &  IS_ARRAY_PERSISTENT ;
309+ 	bool  persistent  =  GC_FLAGS (bdata -> htab ) &  IS_ARRAY_PERSISTENT ;
310310
311311	if  (!arg1 ) {
312312		return ;
@@ -315,7 +315,7 @@ static void php_browscap_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callb
315315	switch  (callback_type ) {
316316		case  ZEND_INI_PARSER_ENTRY :
317317			if  (ctx -> current_entry  !=  NULL  &&  arg2 ) {
318- 				zend_string  * new_key ,  * new_value ;
318+ 				zend_string  * new_value ;
319319
320320				/* Set proper value for true/false settings */ 
321321				if  (zend_string_equals_literal_ci (Z_STR_P (arg2 ), "on" )
@@ -350,7 +350,7 @@ static void php_browscap_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callb
350350
351351					ctx -> current_entry -> parent  =  new_value ;
352352				} else  {
353- 					new_key  =  browscap_intern_str_ci (ctx , Z_STR_P (arg1 ), persistent );
353+ 					zend_string   * new_key  =  browscap_intern_str_ci (ctx , Z_STR_P (arg1 ), persistent );
354354					browscap_add_kv (bdata , new_key , new_value , persistent );
355355					ctx -> current_entry -> kv_end  =  bdata -> kv_used ;
356356				}
@@ -402,7 +402,7 @@ static void php_browscap_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callb
402402}
403403/* }}} */ 
404404
405- static  int  browscap_read_file (char  * filename , browser_data  * browdata , int  persistent ) /* {{{ */ 
405+ static  zend_result  browscap_read_file (char  * filename , browser_data  * browdata , bool  persistent ) /* {{{ */ 
406406{
407407	zend_file_handle  fh ;
408408	browscap_parser_ctx  ctx  =  {0 };
@@ -459,7 +459,7 @@ static void browscap_globals_ctor(zend_browscap_globals *browscap_globals) /* {{
459459/* }}} */ 
460460#endif 
461461
462- static  void  browscap_bdata_dtor (browser_data  * bdata , int  persistent ) /* {{{ */ 
462+ static  void  browscap_bdata_dtor (browser_data  * bdata , bool  persistent ) /* {{{ */ 
463463{
464464	if  (bdata -> htab  !=  NULL ) {
465465		uint32_t  i ;
@@ -510,7 +510,7 @@ PHP_MINIT_FUNCTION(browscap) /* {{{ */
510510	/* ctor call not really needed for non-ZTS */ 
511511
512512	if  (browscap  &&  browscap [0 ]) {
513- 		if  (browscap_read_file (browscap , & global_bdata , 1 ) ==  FAILURE ) {
513+ 		if  (browscap_read_file (browscap , & global_bdata , true ) ==  FAILURE ) {
514514			return  FAILURE ;
515515		}
516516	}
@@ -538,7 +538,7 @@ PHP_MSHUTDOWN_FUNCTION(browscap) /* {{{ */
538538}
539539/* }}} */ 
540540
541- static  inline  size_t  browscap_get_minimum_length (browscap_entry  * entry ) {
541+ static  inline  size_t  browscap_get_minimum_length (const   browscap_entry  * entry ) {
542542	size_t  len  =  entry -> prefix_len ;
543543	int  i ;
544544	for  (i  =  0 ; i  <  BROWSCAP_NUM_CONTAINS ; i ++ ) {
@@ -622,21 +622,20 @@ static bool browscap_match_string_wildcard(const char *s, const char *s_end, con
622622	return  pattern_current  ==  pattern_end ;
623623}
624624
625- static  int  browser_reg_compare (browscap_entry  * entry , zend_string  * agent_name , browscap_entry  * * found_entry_ptr , size_t  * cached_prev_len ) /* {{{ */ 
625+ static  int  browser_reg_compare (browscap_entry  * entry , const   zend_string  * agent_name , browscap_entry  * * found_entry_ptr , size_t  * cached_prev_len ) /* {{{ */ 
626626{
627627	browscap_entry  * found_entry  =  * found_entry_ptr ;
628628	ALLOCA_FLAG (use_heap )
629629	zend_string  * pattern_lc ;
630630	const  char  * cur ;
631- 	int  i ;
632631
633632	/* Lowercase the pattern, the agent name is already lowercase */ 
634633	ZSTR_ALLOCA_ALLOC (pattern_lc , ZSTR_LEN (entry -> pattern ), use_heap );
635634	zend_str_tolower_copy (ZSTR_VAL (pattern_lc ), ZSTR_VAL (entry -> pattern ), ZSTR_LEN (entry -> pattern ));
636635
637636	/* Check if the agent contains the "contains" portions */ 
638637	cur  =  ZSTR_VAL (agent_name ) +  entry -> prefix_len ;
639- 	for  (i  =  0 ; i  <  BROWSCAP_NUM_CONTAINS ; i ++ ) {
638+ 	for  (int   i  =  0 ; i  <  BROWSCAP_NUM_CONTAINS ; i ++ ) {
640639		if  (entry -> contains_len [i ] !=  0 ) {
641640			cur  =  zend_memnstr (cur ,
642641				ZSTR_VAL (pattern_lc ) +  entry -> contains_start [i ],
@@ -668,7 +667,7 @@ static int browser_reg_compare(browscap_entry *entry, zend_string *agent_name, b
668667		   number of characters changed in the user agent being checked versus 
669668		   the previous match found and the current match. */ 
670669		size_t  curr_len  =  entry -> prefix_len ; /* Start from the prefix because the prefix is free of wildcards */ 
671- 		zend_string  * current_match  =  entry -> pattern ;
670+ 		const   zend_string  * current_match  =  entry -> pattern ;
672671		for  (size_t  i  =  curr_len ; i  <  ZSTR_LEN (current_match ); i ++ ) {
673672			switch  (ZSTR_VAL (current_match )[i ]) {
674673				case  '?' :
@@ -717,7 +716,7 @@ PHP_FUNCTION(get_browser)
717716	if  (BROWSCAP_G (activation_bdata ).filename [0 ] !=  '\0 ') {
718717		bdata  =  & BROWSCAP_G (activation_bdata );
719718		if  (bdata -> htab  ==  NULL ) { /* not initialized yet */ 
720- 			if  (browscap_read_file (bdata -> filename , bdata , 0 ) ==  FAILURE ) {
719+ 			if  (browscap_read_file (bdata -> filename , bdata , false ) ==  FAILURE ) {
721720				RETURN_FALSE ;
722721			}
723722		}
0 commit comments