comparison main.c @ 141:63414cddf09c

Accept and ignore -m32. I thought this had been handled a long time back, but apparently not. :-?
author David A. Holland
date Wed, 10 Jul 2013 13:48:07 -0400
parents 904f7a9827e3
children 26ee741196d1
comparison
equal deleted inserted replaced
140:904f7a9827e3 141:63414cddf09c
81 .nestcomment = false, 81 .nestcomment = false,
82 .undef = false, 82 .undef = false,
83 .unused = false, 83 .unused = false,
84 }; 84 };
85 85
86 /* this is always true, but can be set explicitly with -traditional */
87 static bool traditional = true;
88
89 //////////////////////////////////////////////////////////// 86 ////////////////////////////////////////////////////////////
90 // commandline macros 87 // commandline macros
91 88
92 struct commandline_macro { 89 struct commandline_macro {
93 struct place where; 90 struct place where;
733 } 730 }
734 731
735 //////////////////////////////////////////////////////////// 732 ////////////////////////////////////////////////////////////
736 // options 733 // options
737 734
735 struct ignore_option {
736 const char *string;
737 };
738
738 struct flag_option { 739 struct flag_option {
739 const char *string; 740 const char *string;
740 bool *flag; 741 bool *flag;
741 bool setto; 742 bool setto;
742 }; 743 };
753 754
754 struct arg_option { 755 struct arg_option {
755 const char *string; 756 const char *string;
756 void (*func)(const struct place *, char *); 757 void (*func)(const struct place *, char *);
757 }; 758 };
759
760 static const struct ignore_option ignore_options[] = {
761 { "m32" },
762 { "traditional" },
763 };
764 static const unsigned num_ignore_options = HOWMANY(ignore_options);
758 765
759 static const struct flag_option flag_options[] = { 766 static const struct flag_option flag_options[] = {
760 { "C", &mode.output_retain_comments, true }, 767 { "C", &mode.output_retain_comments, true },
761 { "CC", &mode.output_retain_comments, true }, 768 { "CC", &mode.output_retain_comments, true },
762 { "MG", &mode.depend_assume_generated, true }, 769 { "MG", &mode.depend_assume_generated, true },
773 { "Wundef", &warns.undef, true }, 780 { "Wundef", &warns.undef, true },
774 { "Wunused-macros", &warns.unused, true }, 781 { "Wunused-macros", &warns.unused, true },
775 { "fdollars-in-identifiers", &mode.input_allow_dollars, true }, 782 { "fdollars-in-identifiers", &mode.input_allow_dollars, true },
776 { "fno-dollars-in-identifiers", &mode.input_allow_dollars, false }, 783 { "fno-dollars-in-identifiers", &mode.input_allow_dollars, false },
777 { "nostdinc", &mode.do_stdinc, false }, 784 { "nostdinc", &mode.do_stdinc, false },
778 { "traditional", &traditional, true },
779 { "undef", &mode.do_stddef, false }, 785 { "undef", &mode.do_stddef, false },
780 }; 786 };
781 static const unsigned num_flag_options = HOWMANY(flag_options); 787 static const unsigned num_flag_options = HOWMANY(flag_options);
782 788
783 static const struct act_option act_options[] = { 789 static const struct act_option act_options[] = {
820 { "iwithprefix", commandline_addincpath_late_withprefix }, 826 { "iwithprefix", commandline_addincpath_late_withprefix },
821 { "iwithprefixbefore", commandline_addincpath_user_withprefix }, 827 { "iwithprefixbefore", commandline_addincpath_user_withprefix },
822 { "x", commandline_setlang }, 828 { "x", commandline_setlang },
823 }; 829 };
824 static const unsigned num_arg_options = HOWMANY(arg_options); 830 static const unsigned num_arg_options = HOWMANY(arg_options);
831
832 static
833 bool
834 check_ignore_option(const char *opt)
835 {
836 unsigned i;
837 int r;
838
839 for (i=0; i<num_ignore_options; i++) {
840 r = strcmp(opt, ignore_options[i].string);
841 if (r == 0) {
842 return true;
843 }
844 if (r < 0) {
845 break;
846 }
847 }
848 return false;
849 }
825 850
826 static 851 static
827 bool 852 bool
828 check_flag_option(const char *opt) 853 check_flag_option(const char *opt)
829 { 854 {
1015 for (i=1; i<argc; i++) { 1040 for (i=1; i<argc; i++) {
1016 if (argv[i][0] != '-') { 1041 if (argv[i][0] != '-') {
1017 break; 1042 break;
1018 } 1043 }
1019 place_setcommandline(&cmdplace, i, 1); 1044 place_setcommandline(&cmdplace, i, 1);
1045 if (check_ignore_option(argv[i]+1)) {
1046 continue;
1047 }
1020 if (check_flag_option(argv[i]+1)) { 1048 if (check_flag_option(argv[i]+1)) {
1021 continue; 1049 continue;
1022 } 1050 }
1023 if (check_act_option(argv[i]+1)) { 1051 if (check_act_option(argv[i]+1)) {
1024 continue; 1052 continue;