OSDN Git Service

Revert 137452.
[pf3gnuchains/gcc-fork.git] / fixincludes / fixincl.tpl
1 [= AutoGen5 Template -*- Mode: C -*-
2 x=fixincl.x =]
3 [= (dne " * " "/* ")=]
4  */
5 /* DO NOT SVN-MERGE THIS FILE, EITHER [=
6    (define re-ct 0) (define max-mach 0) (define ct 0)
7    (define HACK "") (define Hack "")    (define tmp "") 
8    (shell "date") =]
9  *
10  * You must regenerate it.  Use the ./genfixes script.
11  *
12  *
13  * This is part of the fixincl program used to install modified versions of
14  * certain ANSI-incompatible system header files which are fixed to work
15  * correctly with ANSI C and placed in a directory that GNU C will search.
16  *
17  * This file contains [=(count "fix")=] fixup descriptions.
18  *
19  * See README for more information.
20  *
21  *  inclhack copyright (c) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
22  *                         2006, 2007, 2008
23  *  The Free Software Foundation, Inc.
24  *
25  *  inclhack is free software: you can redistribute it and/or modify it
26  *  under the terms of the GNU General Public License as published by the
27  *  Free Software Foundation, either version 3 of the License, or
28  *  (at your option) any later version.
29  *  
30  *  inclhack is distributed in the hope that it will be useful, but
31  *  WITHOUT ANY WARRANTY; without even the implied warranty of
32  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
33  *  See the GNU General Public License for more details.
34  *  
35  *  You should have received a copy of the GNU General Public License along
36  *  with this program.  If not, see <http://www.gnu.org/licenses/>.
37  */
38 [=
39
40 FOR fix =]
41 /* * * * * * * * * * * * * * * * * * * * * * * * * *
42  *
43  *  Description of [=
44     (set! Hack (string-capitalize! (get "hackname")))
45     (set! HACK (string-upcase!     (get "hackname")))
46     (if (and (not (exist? "test_text")) (not (exist? "replace")))
47         (error (sprintf "include fix '%s' has no test text" Hack )) )
48     (. Hack)=] fix
49  */[=
50
51 # Note that this is not just for debugging purposes, but in case
52   some C fix wishes to refer to the regexps it is paired with.
53   See commentary at the top of fixfixes.c.
54 =]
55 tSCC z[=(. Hack)=]Name[] =
56      "[=hackname=]";
57
58 /*
59  *  File name selection pattern
60  */[=
61
62   IF (exist? "files")=]
63 tSCC z[=(. Hack)=]List[] =
64   "[=  (join "\\0" (stack "files")) =]\0";[=
65
66   ELSE =]
67 #define z[=(. Hack)=]List (char*)NULL[=
68   ENDIF (exist? "files") =]
69 /*
70  *  Machine/OS name selection pattern
71  */[=
72
73   IF (exist? "mach")=]
74 tSCC* apz[=(. Hack)=]Machs[] = {[=
75     (set! ct 0) =][=
76
77     FOR mach =]
78         [=
79       (set! tmp (get "mach"))
80       (set! ct (+ ct (string-length tmp) 5))
81       (kr-string tmp)=],[=
82     ENDFOR=]
83         (const char*)NULL };[=
84
85     (if (> ct max-mach) (set! max-mach ct)) =][=
86
87   ELSE =]
88 #define apz[=(. Hack)=]Machs (const char**)NULL[=
89   ENDIF (exist? "mach") =][=
90
91   IF (exist? "select")=]
92
93 /*
94  *  content selection pattern - do fix if pattern found
95  */[=
96     FOR select =]
97 tSCC z[=(. Hack)=]Select[=(for-index)=][] =
98        [=(kr-string (get "select"))=];[=
99     ENDFOR select =][=
100   ENDIF =][=
101
102   IF (exist? "bypass")=]
103
104 /*
105  *  content bypass pattern - skip fix if pattern found
106  */[=
107     FOR bypass =]
108 tSCC z[=(. Hack)=]Bypass[=(for-index)=][] =
109        [=(kr-string (get "bypass"))=];[=
110     ENDFOR bypass =][=
111   ENDIF =][=
112
113   IF (exist? "test")=]
114
115 /*
116  *  perform the 'test' shell command - do fix on success
117  */[=
118     FOR test =]
119 tSCC z[=(. Hack)=]Test[=(for-index)=][] =
120        [=(kr-string (get "test"))=];[=
121     ENDFOR  =][=
122   ENDIF     =][=
123
124   IF (exist? "c_test")=]
125
126 /*
127  *  perform the C function call test
128  */[=
129     FOR c_test =]
130 tSCC z[=(. Hack)=]FTst[=(for-index)=][] = "[=c_test=]";[=
131     ENDFOR c_test =][=
132   ENDIF =][=
133
134   IF (set! ct (+ (count "select") (count "bypass") 
135               (count "test") (count "c_test")))
136
137      (= ct 0)
138 =]
139 #define [=(. HACK)=]_TEST_CT  0
140 #define a[=(. Hack)=]Tests   (tTestDesc*)NULL[=
141   ELSE =]
142
143 #define    [=(. HACK)=]_TEST_CT  [=(. ct)=][=
144         (set! re-ct (+ re-ct (count "select") (count "bypass"))) =]
145 static tTestDesc a[=(. Hack)=]Tests[] = {[=
146
147     FOR test =]
148   { TT_TEST,     z[=(. Hack)=]Test[=(for-index)=],   0 /* unused */ },[=
149     ENDFOR test =][=
150
151     FOR c_test =]
152   { TT_FUNCTION, z[=(. Hack)=]FTst[=(for-index)=],   0 /* unused */ },[=
153     ENDFOR c_test =][=
154
155     FOR bypass =]
156   { TT_NEGREP,   z[=(. Hack)=]Bypass[=(for-index)=], (regex_t*)NULL },[=
157     ENDFOR bypass =][=
158
159     FOR select =]
160   { TT_EGREP,    z[=(. Hack)=]Select[=(for-index)=], (regex_t*)NULL },[=
161     ENDFOR select =] };[=
162   ENDIF =]
163
164 /*
165  *  Fix Command Arguments for [=(. Hack)=]
166  */
167 static const char* apz[=(. Hack)=]Patch[] = {[=
168     IF   (exist? "sed")=] "sed"[=
169       FOR sed=],
170     "-e", [=(kr-string (get "sed"))=][=
171       ENDFOR sed=],[=
172
173     ELIF (exist? "shell")=] "sh", "-c",
174     [=(kr-string (get "shell"))=],[=
175
176     ELIF (exist? "c_fix")=]
177     [=(kr-string (get "c_fix"))=],[=
178
179       FOR c_fix_arg =]
180     [=(kr-string (get "c_fix_arg"))=],[=
181       ENDFOR c_fix_arg =][=
182
183     ELIF (> (len "replace") 0) =]
184 [=(kr-string (get "replace"))=],[=
185
186     ENDIF=]
187     (char*)NULL };
188 [=ENDFOR fix=]
189
190 /* * * * * * * * * * * * * * * * * * * * * * * * * *
191  *
192  *  List of all fixes
193  */[=
194 #  as of this writing, 49 bytes are needed by the case statement format.
195    We also must allow for the size of the target machine machine name.
196    This allows for a 79 byte machine name.  Better be enough.
197 =]
198 #define REGEX_COUNT          [= (. re-ct) =]
199 #define MACH_LIST_SIZE_LIMIT [= (+ 128 max-mach) =]
200 #define FIX_COUNT            [= (count "fix") =]
201
202 /*
203  *  Enumerate the fixes[= # in a way that minimizes diffs :-) =]
204  */
205 typedef enum {[=
206
207 FOR fix "," =]
208     [=(string-upcase! (get "hackname"))=]_FIXIDX[=
209 ENDFOR
210
211 =]
212 } t_fixinc_idx;
213
214 tFixDesc fixDescList[ FIX_COUNT ] = {[=
215
216
217 FOR fix ",\n" =][=
218     (set! Hack (string-capitalize! (get "hackname")))
219     (set! HACK (string-upcase!     (get "hackname"))) =]
220   {  z[=(. Hack)=]Name,    z[=(. Hack)=]List,
221      apz[=(. Hack)=]Machs,
222      [=(. HACK)=]_TEST_CT, [=
223        IF (exist? "not_machine") =]FD_MACH_IFNOT[=
224        ELSE                      =]FD_MACH_ONLY[=
225        ENDIF =][=
226        IF    (exist? "shell")    =] | FD_SHELL_SCRIPT[=
227        ELIF  (exist? "c_fix")    =] | FD_SUBROUTINE[=
228        ELIF  (exist? "replace")  =] | FD_REPLACEMENT[=
229        ENDIF =],
230      a[=(. Hack)=]Tests,   apz[=(. Hack)=]Patch, 0 }[=
231
232 ENDFOR =]
233 };