@@ -525,14 +525,14 @@ PHP_FUNCTION(filter_has_var)
525
525
/* }}} */
526
526
527
527
static void php_filter_call (
528
- zval * filtered , zend_long filter , HashTable * filter_args_ht , zend_long filter_args_long , zend_bool filter_args_is_null ,
528
+ zval * filtered , zend_long filter , HashTable * filter_args_ht , zend_long filter_args_long ,
529
529
const int copy , zend_long filter_flags
530
530
) /* {{{ */ {
531
531
zval * options = NULL ;
532
532
zval * option ;
533
533
char * charset = NULL ;
534
534
535
- if (! filter_args_is_null && ! filter_args_ht ) {
535
+ if (filter_args_long ) {
536
536
zend_long lval = filter_args_long ;
537
537
538
538
if (filter != -1 ) { /* handler for array apply */
@@ -545,7 +545,7 @@ static void php_filter_call(
545
545
} else {
546
546
filter = lval ;
547
547
}
548
- } else if (! filter_args_is_null ) {
548
+ } else if (filter_args_ht ) {
549
549
if ((option = zend_hash_str_find (filter_args_ht , "filter" , sizeof ("filter" ) - 1 )) != NULL ) {
550
550
filter = zval_get_long (option );
551
551
}
@@ -603,18 +603,18 @@ static void php_filter_call(
603
603
}
604
604
/* }}} */
605
605
606
- static void php_filter_array_handler (zval * input , HashTable * op_ht , zend_long op_long , zend_bool op_is_null ,
606
+ static void php_filter_array_handler (zval * input , HashTable * op_ht , zend_long op_long ,
607
607
zval * return_value , zend_bool add_empty
608
608
) /* {{{ */ {
609
609
zend_string * arg_key ;
610
610
zval * tmp , * arg_elm ;
611
611
612
- if (op_is_null ) {
612
+ if (! op_long && ! op_ht ) {
613
613
ZVAL_DUP (return_value , input );
614
- php_filter_call (return_value , FILTER_DEFAULT , NULL , 0 , 1 , 0 , FILTER_REQUIRE_ARRAY );
615
- } else if (! op_ht ) {
614
+ php_filter_call (return_value , FILTER_DEFAULT , NULL , 0 , 0 , FILTER_REQUIRE_ARRAY );
615
+ } else if (op_long ) {
616
616
ZVAL_DUP (return_value , input );
617
- php_filter_call (return_value , op_long , NULL , 0 , 1 , 0 , FILTER_REQUIRE_ARRAY );
617
+ php_filter_call (return_value , op_long , NULL , 0 , 0 , FILTER_REQUIRE_ARRAY );
618
618
} else {
619
619
array_init (return_value );
620
620
@@ -638,7 +638,7 @@ static void php_filter_array_handler(zval *input, HashTable *op_ht, zend_long op
638
638
php_filter_call (& nval , -1 ,
639
639
Z_TYPE_P (arg_elm ) == IS_ARRAY ? Z_ARRVAL_P (arg_elm ) : NULL ,
640
640
Z_TYPE_P (arg_elm ) == IS_ARRAY ? 0 : zval_get_long (arg_elm ),
641
- Z_TYPE_P ( arg_elm ) == IS_NULL , 0 , FILTER_REQUIRE_SCALAR
641
+ 0 , FILTER_REQUIRE_SCALAR
642
642
);
643
643
zend_hash_update (Z_ARRVAL_P (return_value ), arg_key , & nval );
644
644
}
@@ -654,15 +654,14 @@ PHP_FUNCTION(filter_input)
654
654
zval * input = NULL , * tmp ;
655
655
zend_string * var ;
656
656
HashTable * filter_args_ht = NULL ;
657
- zend_long filter_args_long ;
658
- zend_bool filter_args_is_null = 1 ;
657
+ zend_long filter_args_long = 0 ;
659
658
660
659
ZEND_PARSE_PARAMETERS_START (2 , 4 )
661
660
Z_PARAM_LONG (fetch_from )
662
661
Z_PARAM_STR (var )
663
662
Z_PARAM_OPTIONAL
664
663
Z_PARAM_LONG (filter )
665
- Z_PARAM_ARRAY_HT_OR_LONG_OR_NULL (filter_args_ht , filter_args_long , filter_args_is_null )
664
+ Z_PARAM_ARRAY_HT_OR_LONG (filter_args_ht , filter_args_long )
666
665
ZEND_PARSE_PARAMETERS_END ();
667
666
668
667
if (!PHP_FILTER_ID_EXISTS (filter )) {
@@ -677,21 +676,19 @@ PHP_FUNCTION(filter_input)
677
676
if (!input || (tmp = zend_hash_find (Z_ARRVAL_P (input ), var )) == NULL ) {
678
677
zend_long filter_flags = 0 ;
679
678
zval * option , * opt , * def ;
680
- if (!filter_args_is_null ) {
681
- if (!filter_args_ht ) {
682
- filter_flags = filter_args_long ;
683
- } else {
684
- if ((option = zend_hash_str_find (filter_args_ht , "flags" , sizeof ("flags" ) - 1 )) != NULL ) {
685
- filter_flags = zval_get_long (option );
686
- }
679
+ if (filter_args_long ) {
680
+ filter_flags = filter_args_long ;
681
+ } else if (filter_args_ht ) {
682
+ if ((option = zend_hash_str_find (filter_args_ht , "flags" , sizeof ("flags" ) - 1 )) != NULL ) {
683
+ filter_flags = zval_get_long (option );
684
+ }
687
685
688
- if ((opt = zend_hash_str_find_deref (filter_args_ht , "options" , sizeof ("options" ) - 1 )) != NULL &&
689
- Z_TYPE_P (opt ) == IS_ARRAY &&
690
- (def = zend_hash_str_find_deref (Z_ARRVAL_P (opt ), "default" , sizeof ("default" ) - 1 )) != NULL
691
- ) {
692
- ZVAL_COPY (return_value , def );
693
- return ;
694
- }
686
+ if ((opt = zend_hash_str_find_deref (filter_args_ht , "options" , sizeof ("options" ) - 1 )) != NULL &&
687
+ Z_TYPE_P (opt ) == IS_ARRAY &&
688
+ (def = zend_hash_str_find_deref (Z_ARRVAL_P (opt ), "default" , sizeof ("default" ) - 1 )) != NULL
689
+ ) {
690
+ ZVAL_COPY (return_value , def );
691
+ return ;
695
692
}
696
693
}
697
694
@@ -709,7 +706,7 @@ PHP_FUNCTION(filter_input)
709
706
710
707
ZVAL_DUP (return_value , tmp );
711
708
712
- php_filter_call (return_value , filter , filter_args_ht , filter_args_long , filter_args_is_null , 1 , FILTER_REQUIRE_SCALAR );
709
+ php_filter_call (return_value , filter , filter_args_ht , filter_args_long , 1 , FILTER_REQUIRE_SCALAR );
713
710
}
714
711
/* }}} */
715
712
@@ -719,14 +716,13 @@ PHP_FUNCTION(filter_var)
719
716
zend_long filter = FILTER_DEFAULT ;
720
717
zval * data ;
721
718
HashTable * filter_args_ht = NULL ;
722
- zend_long filter_args_long ;
723
- zend_bool filter_args_is_null = 1 ;
719
+ zend_long filter_args_long = 0 ;
724
720
725
721
ZEND_PARSE_PARAMETERS_START (1 , 3 )
726
722
Z_PARAM_ZVAL (data )
727
723
Z_PARAM_OPTIONAL
728
724
Z_PARAM_LONG (filter )
729
- Z_PARAM_ARRAY_HT_OR_LONG_OR_NULL (filter_args_ht , filter_args_long , filter_args_is_null )
725
+ Z_PARAM_ARRAY_HT_OR_LONG (filter_args_ht , filter_args_long )
730
726
ZEND_PARSE_PARAMETERS_END ();
731
727
732
728
if (!PHP_FILTER_ID_EXISTS (filter )) {
@@ -735,7 +731,7 @@ PHP_FUNCTION(filter_var)
735
731
736
732
ZVAL_DUP (return_value , data );
737
733
738
- php_filter_call (return_value , filter , filter_args_ht , filter_args_long , filter_args_is_null , 1 , FILTER_REQUIRE_SCALAR );
734
+ php_filter_call (return_value , filter , filter_args_ht , filter_args_long , 1 , FILTER_REQUIRE_SCALAR );
739
735
}
740
736
/* }}} */
741
737
@@ -746,17 +742,16 @@ PHP_FUNCTION(filter_input_array)
746
742
zval * array_input = NULL ;
747
743
zend_bool add_empty = 1 ;
748
744
HashTable * op_ht = NULL ;
749
- zend_long op_long ;
750
- zend_bool op_is_null = 1 ;
745
+ zend_long op_long = 0 ;
751
746
752
747
ZEND_PARSE_PARAMETERS_START (1 , 3 )
753
748
Z_PARAM_LONG (fetch_from )
754
749
Z_PARAM_OPTIONAL
755
- Z_PARAM_ARRAY_HT_OR_LONG_OR_NULL (op_ht , op_long , op_is_null )
750
+ Z_PARAM_ARRAY_HT_OR_LONG (op_ht , op_long )
756
751
Z_PARAM_BOOL (add_empty )
757
752
ZEND_PARSE_PARAMETERS_END ();
758
753
759
- if (! op_is_null && ! op_ht && !PHP_FILTER_ID_EXISTS (op_long )) {
754
+ if (op_long && !PHP_FILTER_ID_EXISTS (op_long )) {
760
755
RETURN_FALSE ;
761
756
}
762
757
@@ -768,12 +763,10 @@ PHP_FUNCTION(filter_input_array)
768
763
if (!array_input ) {
769
764
zend_long filter_flags = 0 ;
770
765
zval * option ;
771
- if (!op_is_null ) {
772
- if (!op_ht ) {
773
- filter_flags = op_long ;
774
- } else if ((option = zend_hash_str_find (op_ht , "flags" , sizeof ("flags" ) - 1 )) != NULL ) {
775
- filter_flags = zval_get_long (option );
776
- }
766
+ if (op_long ) {
767
+ filter_flags = op_long ;
768
+ } else if (op_ht && (option = zend_hash_str_find (op_ht , "flags" , sizeof ("flags" ) - 1 )) != NULL ) {
769
+ filter_flags = zval_get_long (option );
777
770
}
778
771
779
772
/* The FILTER_NULL_ON_FAILURE flag inverts the usual return values of
@@ -788,7 +781,7 @@ PHP_FUNCTION(filter_input_array)
788
781
}
789
782
}
790
783
791
- php_filter_array_handler (array_input , op_ht , op_long , op_is_null , return_value , add_empty );
784
+ php_filter_array_handler (array_input , op_ht , op_long , return_value , add_empty );
792
785
}
793
786
/* }}} */
794
787
@@ -798,21 +791,20 @@ PHP_FUNCTION(filter_var_array)
798
791
zval * array_input = NULL ;
799
792
zend_bool add_empty = 1 ;
800
793
HashTable * op_ht = NULL ;
801
- zend_long op_long ;
802
- zend_bool op_is_null = 1 ;
794
+ zend_long op_long = 0 ;
803
795
804
796
ZEND_PARSE_PARAMETERS_START (1 , 3 )
805
797
Z_PARAM_ARRAY (array_input )
806
798
Z_PARAM_OPTIONAL
807
- Z_PARAM_ARRAY_HT_OR_LONG_OR_NULL (op_ht , op_long , op_is_null )
799
+ Z_PARAM_ARRAY_HT_OR_LONG (op_ht , op_long )
808
800
Z_PARAM_BOOL (add_empty )
809
801
ZEND_PARSE_PARAMETERS_END ();
810
802
811
- if (! op_is_null && ! op_ht && !PHP_FILTER_ID_EXISTS (op_long )) {
803
+ if (op_long && !PHP_FILTER_ID_EXISTS (op_long )) {
812
804
RETURN_FALSE ;
813
805
}
814
806
815
- php_filter_array_handler (array_input , op_ht , op_long , op_is_null , return_value , add_empty );
807
+ php_filter_array_handler (array_input , op_ht , op_long , return_value , add_empty );
816
808
}
817
809
/* }}} */
818
810
0 commit comments