@@ -743,21 +743,26 @@ check_for_redefinition (struct macro_source_file *source, int line,
743
743
return 0 ;
744
744
}
745
745
746
- /* A helper function to define a new object-like macro. */
746
+ /* A helper function to define a new object-like or function-like macro
747
+ according to KIND. When KIND is macro_object_like,
748
+ the macro_special_kind must be provided as ARGC, and ARGV must be NULL.
749
+ When KIND is macro_function_like, ARGC and ARGV are giving the function
750
+ arguments. */
747
751
748
752
static void
749
- macro_define_object_internal (struct macro_source_file * source , int line ,
750
- const char * name , const char * replacement ,
751
- enum macro_special_kind kind )
753
+ macro_define_internal (struct macro_source_file * source , int line ,
754
+ const char * name , enum macro_kind kind ,
755
+ int argc , const char * * argv ,
756
+ const char * replacement )
752
757
{
753
758
struct macro_table * t = source -> table ;
754
759
struct macro_key * k = NULL ;
755
760
struct macro_definition * d ;
756
761
757
762
if (! t -> redef_ok )
758
- k = check_for_redefinition (source , line ,
759
- name , macro_object_like ,
760
- 0 , 0 ,
763
+ k = check_for_redefinition (source , line ,
764
+ name , kind ,
765
+ argc , argv ,
761
766
replacement );
762
767
763
768
/* If we're redefining a symbol, and the existing key would be
@@ -774,10 +779,23 @@ macro_define_object_internal (struct macro_source_file *source, int line,
774
779
return ;
775
780
776
781
k = new_macro_key (t , name , source , line );
777
- d = new_macro_definition (t , macro_object_like , kind , 0 , replacement );
782
+ d = new_macro_definition (t , kind , argc , argv , replacement );
778
783
splay_tree_insert (t -> definitions , (splay_tree_key ) k , (splay_tree_value ) d );
779
784
}
780
785
786
+ /* A helper function to define a new object-like macro. */
787
+
788
+ static void
789
+ macro_define_object_internal (struct macro_source_file * source , int line ,
790
+ const char * name , const char * replacement ,
791
+ enum macro_special_kind special_kind )
792
+ {
793
+ macro_define_internal (source , line ,
794
+ name , macro_object_like ,
795
+ special_kind , NULL ,
796
+ replacement );
797
+ }
798
+
781
799
void
782
800
macro_define_object (struct macro_source_file * source , int line ,
783
801
const char * name , const char * replacement )
@@ -802,29 +820,12 @@ macro_define_function (struct macro_source_file *source, int line,
802
820
const char * name , int argc , const char * * argv ,
803
821
const char * replacement )
804
822
{
805
- struct macro_table * t = source -> table ;
806
- struct macro_key * k = NULL ;
807
- struct macro_definition * d ;
808
-
809
- if (! t -> redef_ok )
810
- k = check_for_redefinition (source , line ,
811
- name , macro_function_like ,
812
- argc , argv ,
813
- replacement );
814
-
815
- /* See comments about duplicate keys in macro_define_object. */
816
- if (k && ! key_compare (k , name , source , line ))
817
- return ;
818
-
819
- /* We should also check here that all the argument names in ARGV are
820
- distinct. */
821
-
822
- k = new_macro_key (t , name , source , line );
823
- d = new_macro_definition (t , macro_function_like , argc , argv , replacement );
824
- splay_tree_insert (t -> definitions , (splay_tree_key ) k , (splay_tree_value ) d );
823
+ macro_define_internal (source , line ,
824
+ name , macro_function_like ,
825
+ argc , argv ,
826
+ replacement );
825
827
}
826
828
827
-
828
829
void
829
830
macro_undef (struct macro_source_file * source , int line ,
830
831
const char * name )
0 commit comments