00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include "fixlib.h"
00049
00050 #define _ENV_(v,m,n,t) extern tCC* v;
00051 ENV_TABLE
00052 #undef _ENV_
00053
00054 typedef apply_fix_p_t t_test_proc PARAMS(( tCC* file, tCC* text ));
00055
00056 typedef struct {
00057 tCC* test_name;
00058 t_test_proc* test_proc;
00059 } test_entry_t;
00060
00061 #define FIX_TEST_TABLE \
00062 _FT_( "machine_name", machine_name_test ) \
00063 _FT_( "stdc_0_in_system_headers", stdc_0_in_system_headers_test )
00064
00065 #define TEST_FOR_FIX_PROC_HEAD( test ) \
00066 static apply_fix_p_t test PARAMS(( tCC* file, tCC* text )); \
00067 static apply_fix_p_t test ( fname, text ) \
00068 tCC* fname; \
00069 tCC* text;
00070
00071
00072 TEST_FOR_FIX_PROC_HEAD( machine_name_test )
00073 {
00074 #ifndef MN_NAME_PAT
00075 return SKIP_FIX;
00076 #else
00077 regex_t *label_re, *name_re;
00078 regmatch_t match[2];
00079 tCC *base, *limit;
00080 IGNORE_ARG(fname);
00081
00082 mn_get_regexps(&label_re, &name_re, "machine_name_test");
00083
00084 for (base = text;
00085 regexec (label_re, base, 2, match, 0) == 0;
00086 base = limit)
00087 {
00088 base += match[0].rm_eo;
00089
00090
00091 limit = base;
00092 do
00093 {
00094 limit++;
00095 limit = strchr (limit, '\n');
00096 if (!limit)
00097 return SKIP_FIX;
00098 }
00099 while (limit[-1] == '\\');
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 if (regexec (name_re, base, 1, match, REG_NOTBOL))
00111 return SKIP_FIX;
00112
00113
00114 if (match[0].rm_eo <= limit - base)
00115 return APPLY_FIX;
00116
00117
00118 }
00119 return SKIP_FIX;
00120 #endif
00121 }
00122
00123
00124 TEST_FOR_FIX_PROC_HEAD( stdc_0_in_system_headers_test )
00125 {
00126 #ifdef STDC_0_IN_SYSTEM_HEADERS
00127 return (pz_machine == NULL) ? APPLY_FIX : SKIP_FIX;
00128 #else
00129 return APPLY_FIX;
00130 #endif
00131 }
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141 apply_fix_p_t
00142 run_test( tname, fname, text )
00143 tCC* tname;
00144 tCC* fname;
00145 tCC* text;
00146 {
00147 #define _FT_(n,p) { n, p },
00148 static test_entry_t test_table[] = { FIX_TEST_TABLE { NULL, NULL }};
00149 #undef _FT_
00150 #define TEST_TABLE_CT (ARRAY_SIZE (test_table)-1)
00151
00152 int ct = TEST_TABLE_CT;
00153 test_entry_t* pte = test_table;
00154
00155 do
00156 {
00157 if (strcmp( pte->test_name, tname ) == 0)
00158 return (*pte->test_proc)( fname, text );
00159 pte++;
00160 } while (--ct > 0);
00161 fprintf( stderr, "fixincludes error: the `%s' fix test is unknown\n",
00162 tname );
00163 exit( 3 );
00164 }