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 ( 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 ( tCC* fname ATTRIBUTE_UNUSED, \
00067 tCC* text ATTRIBUTE_UNUSED )
00068
00069 TEST_FOR_FIX_PROC_HEAD( machine_name_test )
00070 {
00071 regex_t *label_re, *name_re;
00072 regmatch_t match[2];
00073 tCC *base, *limit;
00074 IGNORE_ARG(fname);
00075
00076 if (!mn_get_regexps (&label_re, &name_re, "machine_name_test"))
00077 return SKIP_FIX;
00078
00079 for (base = text;
00080 xregexec (label_re, base, 2, match, 0) == 0;
00081 base = limit)
00082 {
00083 base += match[0].rm_eo;
00084
00085
00086 limit = base;
00087 do
00088 {
00089 limit++;
00090 limit = strchr (limit, '\n');
00091 if (!limit)
00092 return SKIP_FIX;
00093 }
00094 while (limit[-1] == '\\');
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 if (xregexec (name_re, base, 1, match, REG_NOTBOL))
00106 return SKIP_FIX;
00107
00108
00109 if (match[0].rm_eo <= limit - base)
00110 return APPLY_FIX;
00111
00112
00113 }
00114 return SKIP_FIX;
00115 }
00116
00117
00118 TEST_FOR_FIX_PROC_HEAD( stdc_0_in_system_headers_test )
00119 {
00120 #ifdef STDC_0_IN_SYSTEM_HEADERS
00121 return (pz_machine == NULL) ? APPLY_FIX : SKIP_FIX;
00122 #else
00123 return APPLY_FIX;
00124 #endif
00125 }
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 apply_fix_p_t
00136 run_test( tCC* tname, tCC* fname, tCC* text )
00137 {
00138 #define _FT_(n,p) { n, p },
00139 static test_entry_t test_table[] = { FIX_TEST_TABLE { NULL, NULL }};
00140 #undef _FT_
00141 #define TEST_TABLE_CT (ARRAY_SIZE (test_table)-1)
00142
00143 int ct = TEST_TABLE_CT;
00144 test_entry_t* pte = test_table;
00145
00146 do
00147 {
00148 if (strcmp( pte->test_name, tname ) == 0)
00149 return (*pte->test_proc)( fname, text );
00150 pte++;
00151 } while (--ct > 0);
00152 fprintf( stderr, "fixincludes error: the `%s' fix test is unknown\n",
00153 tname );
00154 exit( 3 );
00155 }