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