OSDN Git Service

* fixinc/inclhack.def (endif_label): Add additional selector for
[pf3gnuchains/gcc-fork.git] / gcc / fixinc / inclhack.def
1 /* -*- Mode: C -*-  */
2
3 autogen definitions inclhack;
4
5 /*
6  *  Define all the fixes we know about for repairing damaged headers
7  */
8
9 /*
10  *  sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the definition
11  *  of struct rusage, so the prototype (added by fixproto) causes havoc.
12  */
13 fix = {
14     hackname = aix_syswait;
15     files    = sys/wait.h;
16     select = "bos325,";
17     sed    = "/^extern pid_t wait3();$/i\\\n"
18              "struct rusage;\n";
19 };
20
21
22 /*
23  *  sys/signal.h on some versions of AIX uses volatile in the typedef of
24  *  sig_atomic_t, which causes gcc to generate a warning about duplicate
25  *  volatile when a sig_atomic_t variable is declared volatile, as
26  *  required by ANSI C.
27  */
28 fix = {
29     hackname = aix_volatile;
30     files    = sys/signal.h;
31     select   = "typedef volatile int sig_atomic_t";
32     sed      = "s/typedef volatile int sig_atomic_t"
33                 "/typedef int sig_atomic_t/";
34 };
35
36
37 /*
38  *  Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
39  */
40 fix = {
41     hackname = alpha_getopt;
42     files  = "stdio.h";
43     files  = "stdlib.h";
44     select = 'getopt\(int, char \*\[';
45     sed    = 's/getopt(int, char \*\[\],[ ]*char \*)/'
46                'getopt(int, char *const[], const char *)/';
47 };
48
49
50 /* 
51  * Remove erroneous parentheses in sym.h on Alpha OSF/1.
52  */
53 fix = {
54     hackname = alpha_parens;
55     files    = sym.h;
56     select   = '#ifndef\(__mips64\)';
57     sed      = "s/#ifndef(__mips64)/#ifndef __mips64/";
58 };
59
60
61 /*
62  *  Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
63  */
64 fix = {
65     hackname = alpha_sbrk;
66     files    = unistd.h;
67     select   = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
68     sed  = "s/char\\([ \t]*\\*[\t ]*sbrk[ \t]*(\\)/void\\1/";
69 };
70
71
72 /*
73  *  Fix this ARM/RISCiX file where ___type is a Compiler
74  *  hint that is specific to the Norcroft compiler.
75  */
76 fix = {
77     hackname = arm_norcroft_hint;
78     select   = "___type p_type";
79     files    = "X11/Intrinsic.h";
80     sed      = "s/___type p_type/p_type/";
81 };
82
83
84 /*
85  *  Fix this ARM/RISCiX file to avoid interfering
86  *  with the use of __wchar_t in cc1plus.
87  */
88 fix = {
89     hackname = arm_wchar;
90     files  = stdlib.h;
91     select = "#[ \t]*define[ \t]*__wchar_t";
92     sed    = "s/\\(#[ \t]*ifndef[ \t]*\\)__wchar_t/\\1_GCC_WCHAR_T/";
93     sed    = "s/\\(#[ \t]*define[ \t]*\\)__wchar_t/\\1_GCC_WCHAR_T/";
94 };
95
96
97 /*
98  *  This file in A/UX 3.0.x/3.1.x contains an __asm directive for c89;
99  *  gcc doesn't understand it.
100  */
101 fix = {
102     hackname = aux_asm;
103     files    = sys/param.h;
104     select   = "#ifndef NOINLINE";
105     sed      = "s|#ifndef NOINLINE"
106                 "|#if !defined(NOINLINE) \\&\\& !defined(__GNUC__)|";
107 };
108
109
110 /*
111  *  For C++, avoid any typedef or macro definition of bool,
112  *  and use the built in type instead.
113  *  HP/UX 10.20 also has it in curses_colr/curses.h.
114  */
115 fix = {
116     hackname = avoid_bool;
117     files    = curses.h;
118     files    = curses_colr/curses.h;
119     files    = term.h;
120     files    = tinfo.h;
121
122     sed = "/^#[ \t]*define[ \t][ \t]*bool[ \t][ \t]*char[ \t]*$/i\\\n"
123                 "#ifndef __cplusplus\n";
124
125     sed = "/^#[ \t]*define[ \t][ \t]*bool[ \t][ \t]*char[ \t]*$/a\\\n"
126                 "#endif\n";
127
128     sed = "/^typedef[ \t][ \t]*char[ \t][ \t]*bool[ \t]*;/i\\\n"
129                 "#ifndef __cplusplus\n";
130
131     sed = "/^typedef[ \t][ \t]*char[ \t][ \t]*bool[ \t]*;/a\\\n"
132                 "#endif\n";
133
134     sed = "/^[ ]*typedef[ \t][ \t]*unsigned char[ \t][ \t]*bool[ \t]*;/i\\\n"
135                 "#ifndef __cplusplus\n";
136
137     sed = "/^[ ]*typedef[ \t][ \t]*unsigned char[ \t][ \t]*bool[ \t]*;/a\\\n"
138                 "#endif\n";
139
140     sed = "/^typedef[ \t][ \t]*int[ \t][ \t]*bool[ \t]*;/i\\\n"
141                 "#ifndef __cplusplus\n";
142
143     sed = "/^typedef[ \t][ \t]*int[ \t][ \t]*bool[ \t]*;/a\\\n"
144                 "#endif\n";
145
146     sed = "/^[ ]*typedef[ \t][ \t]*unsigned int[ \t][ \t]*bool[ \t]*;/i\\\n"
147                 "#ifndef __cplusplus\n";
148
149     sed = "/^[ ]*typedef[ \t][ \t]*unsigned int[ \t][ \t]*bool[ \t]*;/a\\\n"
150                 "#endif\n";
151 };
152
153
154 /*
155  *  Fix `typedef struct term;' on hppa1.1-hp-hpux9.
156  */
157 fix = {
158     hackname = bad_struct_term;
159     files  = curses.h;
160     select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
161     sed    = "s/^[ \t]*typedef[ \t][ \t]*"
162              "\\(struct[ \t][ \t]*term[ \t]*;[ \t]*\\)$/\\1/";
163 };
164
165
166 /*
167  *  Fix one other error in this file:
168  *  a mismatched quote not inside a C comment.
169  */
170 fix = {
171     hackname = badquote;
172     files    = sundev/vuid_event.h;
173     sed      = "s/doesn't/does not/";
174 };
175
176
177 /*
178  *  Fix #defines under Alpha OSF/1:
179  *  The following files contain '#pragma extern_prefix "_FOO"' followed by
180  *  a '#define something(x,y,z) _FOOsomething(x,y,z)'.  The intent of these
181  *  statements is to reduce namespace pollution.  While these macros work
182  *  properly in most cases, they don't allow you to take a pointer to the
183  *  "something" being modified.  To get around this limitation, change these
184  *  statements to be of the form '#define something _FOOsomething'.
185  */
186 fix = {
187     hackname = bad_lval;
188     files    = libgen.h;
189     files    = dirent.h;
190     files    = ftw.h;
191     files    = grp.h;
192     files    = ndbm.h;
193     files    = pthread.h;
194     files    = pwd.h;
195     files    = signal.h;
196     files    = standards.h;
197     files    = stdlib.h;
198     files    = string.h;
199     files    = stropts.h;
200     files    = time.h;
201     files    = unistd.h;
202     sed      =
203         "s/^[ \t]*#[ \t]*define[ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
204                "\\(_.\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
205 };
206
207
208 /*
209  *  check for broken assert.h that needs stdio.h
210  */
211 fix = {
212     hackname = broken_assert_stdio;
213     files    = assert.h;
214     select   = stderr;
215     bypass   = "include.*stdio.h";
216     sed      = "1i\\\n"
217                "#include <stdio.h>\n";
218 };
219
220
221 /*
222  *  check for broken assert.h that needs stdlib.h
223  */
224 fix = {
225     hackname = broken_assert_stdlib;
226     files    = assert.h;
227     select   = 'exit *\(|abort *\(';
228     bypass   = "include.*stdlib.h";
229     sed      = "1i\\\n"
230                "#ifdef __cplusplus\\\n"
231                "#include <stdlib.h>\\\n"
232                "#endif\n";
233 };
234
235
236 /*
237  *  Note that BSD43_* are used on recent MIPS systems.
238  */
239 fix = {
240     hackname = bsd43_io_macros;
241     select   = "BSD43__IO";
242     /*
243      *  Put single quotes aroung the character that appears after '('
244      *  and before ',', UNLESS it is a 'c' or 'g' or 'x'.
245      */
246     sed = "/[ \t]BSD43__IO[A-Z]*[ \t]*(/"       's/(\(.\),/(\'\1\',/';
247     sed = "/#[ \t]*define[ \t]*[ \t]BSD43__IO/" 's/\'\([cgx]\)\'/\1/g';
248 };
249
250
251 /*
252  *  Fix <c_asm.h> on Digital UNIX V4.0:
253  *  It contains a prototype for a DEC C internal asm() function,
254  *  clashing with gcc's asm keyword.  So protect this with __DECC.
255  */
256 fix = {
257     hackname = dec_intern_asm;
258     files    = c_asm.h;
259     sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
260     sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
261           "#endif\n";
262 };
263
264
265 #ifdef no_more
266 /*
267  *  And also with the HP-UX 10 and HP-UX 11 sys/pci.h file
268  */
269 fix = {
270     hackname = cxx_cmnt_hpux;
271     files    = sys/pci.h;
272     select   = "System Private Structures";
273     sed      = "s|//.*$||g";
274 };
275
276
277 /*
278  *  Turning // comments into normal comments trashes this IRIX 4.0.1
279  *  header file, which embeds // comments inside multi-line
280  *  comments.  If this looks like the IRIX header file, we refix it by
281  *  just throwing away the // comments.
282  */
283 fix = {
284     hackname = cxx_cmnt_irix;
285     files    = fam.h;
286     select   = indigo.esd;
287     sed      = "s|//.*$||g";
288 };
289
290
291 /*
292  *  Same problem with a file from SunOS 4.1.3 : a header file containing
293  *  the string "//" embedded in "/ * * /"
294  */
295 fix = {
296     hackname = cxx_cmnt_sunos;
297     files    = sbusdev/audiovar.h;
298     files    = sys/audiovar.h;
299     sed      = "s|//.*$||g";
300 };
301
302
303 /*
304  *  There is a similar problem with the VxWorks drv/netif/if_med.h file.
305  */
306 fix = {
307     hackname = cxx_cmnt_vxworks;
308     files    = drv/netif/if_med.h;
309     select   = "Wind River";
310     sed      = "s|//.*$||g";
311 };
312 #endif
313
314 /*
315  *  Remove the double-slash comments
316  *  They *must* be removed so it will not create nested comments!!
317  *  However, they will *not* be removed if the file name ends with
318  *  any of "++", ".hh" or ".H", or if the file name contains "cxx/".
319  *
320  *  There *used* to be a number of similar problems in various OSes:
321
322  *  Turning // comments into normal comments trashes this IRIX 4.0.1
323  *  header file, which embeds // comments inside multi-line
324  *  comments.  If this looks like the IRIX header file, we refix it by
325  *  just throwing away the // comments.
326
327  *  Same problem with a file from SunOS 4.1.3 : a header file containing
328  *  the string "//" embedded in "/ * * /"
329
330  *  There is a similar problem with the VxWorks drv/netif/if_med.h file.
331
332  *  And also with the HP-UX 10 and HP-UX 11 sys/pci.h file
333
334  *  Now that we delete the // comments instead of converting them to / * * /,
335  *  traditional hacks like irix_bogus_cxx_cmnt, no longer work (which
336  *  strangely enough was also used on alpha-dec-osf4.0d).  If we skip the
337  *  hack whenever we see ``"//"'', then the need for the secondary hack
338  *  disappears.  Note: it is painful to ensure that the first quote
339  *  exists, so we just check for the trailing quote directly abutting
340  *  the //.  Note: We should never touch a line that has // completely
341  *  within quotes but this is somewhat hard to check for.
342
343  *  Ultimately, this fix ought to go inside of C code where
344  *  we can do a better analysis on the need and method for fixing.
345  */
346 fix = {
347     hackname = no_double_slash;
348     /*
349      *  Test that the file-to-fix does not from a C++ directory
350      *  Also, only accept double slashes that are not part of URL's
351      *  and are not the end of a quoted string.
352      */
353     test   = ' -z "`echo ${file} | egrep \'(CC|cxx|\+\+)/\'`"';
354     select = '(^|[^:])//[^"*]';
355     sed    = 's,^//.*$,,';
356     sed    = 's,[^:]//[^"].*$,,';
357 };
358
359
360 /*
361  * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
362  */
363 fix = {
364     hackname = ecd_cursor;
365     files  = "sunwindow/win_lock.h";
366     files  = "sunwindow/win_cursor.h";
367     sed    = "s/ecd.cursor/ecd_cursor/";
368 };
369
370 /*
371  *  On SCO OpenServer 5.0.0 through (at least) 5.0.5 <sys/stat.h> contains
372  *  tiny static wrappers that aren't C++ safe.
373  */
374 fix = {
375     hackname = sco5_stat_wrappers;
376     mach     = "i*86-*-sco3.2v5*";
377     files    = "sys/stat.h";
378
379     sed = "/^static int[ \t]*[a-z]*stat(/i\\\n"
380         "#ifdef __cplusplus\\\n"
381         "extern \"C\"\\\n"
382         "{\\\n"
383         "#endif\\\n";
384
385     sed = "/^}$/a\\\n"
386         "#ifdef __cplusplus\\\n"
387         "}\\\n"
388         "#endif \/* __cplusplus *\/\\\n";
389 };
390
391
392
393 /*
394  *  Fix else directives that contain non-commentary text
395  *
396  * The fixinc_eol stuff is to work around a bug in the sed
397  */
398 fix = {
399     hackname = else_label;
400     select   = "^[ \t]*#[ \t]*else[ \t]+[!-.0-~]";
401     sed =      ":loop\n"
402                '/\\\\$/'                       "N\n"
403                's/\\\\$/\\\\+++fixinc_eol+++/' "\n"
404                '/\\\\$/'                       "b loop\n"
405                's/\\\\+++fixinc_eol+++/\\\\/g' "\n"
406
407                "s%^\\([ \t]*#[ \t]*else\\)[ \t]*/[^*].*%\\1%\n"
408                "s%^\\([ \t]*#[ \t]*else\\)[ \t]*[^/ \t].*%\\1%";
409 };
410
411
412 /*
413  *  Fix endif directives that contain non-commentary text
414  */
415 fix = {
416     hackname = endif_label;
417     /*
418      *  Select files that contain '#endif' directives with
419      *  some sort of following junk.  (Between the ascii '.'
420      *  and '0' lies the character '/'.  This will *NOT*
421      *  match '#endif / * foo * /', but it also wont match
422      *  '#endif / done' either.
423      *
424      *  We have a second regexp in the selector to detect
425      *  #endif followed by a / followed by anything other
426      *  than a *.  For example "#endif / * foo * /" or 
427      *  "#endif /% blah %/ which appear on OSF4.0A and AIX4.2
428      *  repsectively.
429      * 
430      *  We use the pattern [!-.0-z{|}~] instead of [^/ \t] to match a noncomment
431      *  following #else or #endif because some buggy egreps think [^/] matches
432      *  newline, and they thus think `#else ' matches
433      *  `#e[ndiflse]*[ \t]+[^/ \t]'.
434      *  [!-.0-~] does not work properly on AIX 4.1.
435      */
436     select   = "^[ \t]*#[ \t]*endif[ \t]+[!-.0-z\{\|\}\~]|^[ \t]*#[ \t]*endif[ \t]+/[^\*]";
437
438     /*
439      *  First, join the continued input lines.
440      *  IF the resulting line is an endif preprocessing directive,
441      *  then trim off the following patterns:
442      *  1.  sequences that start with '/' and is *NOT* followed by '*'
443      *  2.  Sequences that start with '*' and is *NOT* followed by '/'
444      *  3.  sequences that do not start with any of '/', '*', '\t' or ' '.
445      *
446      * The fixinc_eol stuff is to work around a bug in the sed
447      */
448     sed =      ":loop\n"
449                '/\\\\$/'                       "N\n"
450                's/\\\\$/\\\\+++fixinc_eol+++/' "\n"
451                '/\\\\$/'                       "b loop\n"
452                's/\\\\+++fixinc_eol+++/\\\\/g' "\n"
453
454                "s%^\\([ \t]*#[ \t]*endif\\)[ \t]*/[^*].*%\\1%\n"
455                "s%^\\([ \t]*#[ \t]*endif\\)[ \t]*\\*[^/].*%\\1%\n"
456                "s%^\\([ \t]*#[ \t]*endif\\)[ \t]*[^/* \t].*%\\1%";
457 };
458
459
460 /*
461  *  Fix HP's use of ../machine/inline.h to refer to
462  *    /usr/include/machine/inline.h
463  */
464 fix = {
465     hackname = hp_inline;
466     files  = sys/spinlock.h;
467     select = 'include.*"\.\./machine/';
468     sed    = "s,\"../machine/inline.h\",<machine/inline.h>,";
469     sed    = "s,\"../machine/psl.h\",<machine/psl.h>,";
470 };
471
472
473 /*
474  *  Check for (...) in C++ code in HP/UX sys/file.h.
475  */
476 fix = {
477     hackname = hp_sysfile;
478     files    = sys/file.h;
479     select   = "HPUX_SOURCE";
480     sed      = 's/(\.\.\.)/(struct file * ...)/';
481 };
482
483
484 /*
485  *  sys/mman.h on HP/UX is not C++ ready,
486  *  even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
487  *
488  *  rpc/types.h on OSF1/2.0 is not C++ ready, even though NO_IMPLICIT_EXTERN_C
489  *  is defined for the alpha.  The problem is the declaration of malloc.
490  */
491 fix = {
492     hackname = cxx_unready;
493     files    = sys/mman.h;
494     files    = rpc/types.h;
495     bypass = '"C"|__BEGIN_DECLS';
496
497     sed      = "1i\\\n"
498                "#ifdef __cplusplus\\\n"
499                "extern \"C\" {\\\n"
500                "#endif\\\n\n";
501     sed      = "$a\\\n"
502                "#ifdef __cplusplus\\\n"
503                "}\\\n"
504                "#endif\n";
505 };
506
507
508 /*
509  *  HPUX 10.x sys/param.h defines MAXINT which clashes with values.h
510  */
511 fix = {
512     hackname = hpux_maxint;
513     files    = sys/param.h;
514     sed      = "/^#[ \t]*define[ \t]*MAXINT[ \t]/i\\\n"
515                "#ifndef MAXINT\n";
516
517     sed      = "/^#[ \t]*define[ \t]*MAXINT[ \t]/a\\\n"
518                "#endif\n";
519 };
520
521
522 /*
523  *  Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
524  */
525 fix = {
526     hackname = hpux_systime;
527     files    = sys/time.h;
528     select   = "^extern struct sigevent;";
529     sed      = "s/^extern struct sigevent;/struct sigevent;/";
530 };
531
532
533 /*
534  *  Determine if we're on Interactive Unix 2.2 or later, in which case we
535  *  need to fix some additional files.  This is the same test for ISC that
536  *  Autoconf uses.  On Interactive 2.2, certain traditional Unix
537  *  definitions (notably getc and putc in stdio.h) are omitted if __STDC__
538  *  is defined, not just if _POSIX_SOURCE is defined.  This makes it
539  *  impossible to compile any nontrivial program except with -posix.
540  */
541 fix = {
542     hackname = interactv_add1;
543
544     test   = " -d /etc/conf/kconfig.d";
545     test   = ' -n "`grep _POSIX_VERSION /usr/include/sys/unistd.h`"';
546
547     files  = "stdio.h";
548     files  = "math.h";
549     files  = "ctype.h";
550     files  = "sys/limits.h";
551     files  = "sys/fcntl.h";
552     files  = "sys/dirent.h";
553
554     sed    = "s/!defined(__STDC__) && !defined(_POSIX_SOURCE)/"
555                "!defined(_POSIX_SOURCE)/";
556 };
557
558 fix = {
559     hackname = interactv_add2;
560
561     test   = " -d /etc/conf/kconfig.d";
562     test   = ' -n "`grep _POSIX_VERSION /usr/include/sys/unistd.h`"';
563
564     files  = math.h;
565     sed    = "s/fmod(double)/fmod(double, double)/";
566 };
567
568 fix = {
569     hackname = interactv_add3;
570
571     test   = " -d /etc/conf/kconfig.d";
572     test   = ' -n "`grep _POSIX_VERSION /usr/include/sys/unistd.h`"';
573
574     files  = sys/limits.h;
575
576     sed    = "/CHILD_MAX/s,/\\* Max, Max,";
577     sed    = "/OPEN_MAX/s,/\\* Max, Max,";
578 };
579
580
581 /*
582  *  Fix various _IO* defines, but do *not* quote the characters cgxtf.
583  */
584 fix = {
585     hackname = io_def_quotes;
586     select = "[ \t]*[ \t](_|DES)IO[A-Z]*[ \t]*\\( *[^,']";
587     sed = "s/\\([ \t]*[ \t]_IO[A-Z]*[ \t]*(\\)\\([^,']\\),/\\1'\\2',/";
588     sed = "s/\\([ \t]*[ \t]DESIO[A-Z]*[ \t]*(\\)\\([^,']\\),/\\1'\\2',/";
589     sed = "/#[ \t]*define[ \t]*[ \t]_IO/"       "s/'\\([cgxtf]\\)'/\\1/g";
590     sed = "/#[ \t]*define[ \t]*[ \t]DESIOC/"    's/\'\([cdgx]\)\'/\1/g';
591 };
592
593
594 /*
595  *  Fix CTRL macros
596  *
597  * Basically, what is supposed to be happening is that every
598  * _invocation_ of the "_CTRL()" or "CTRL()" macros is supposed to have
599  * its argument inserted into single quotes.  We _must_ do this because
600  * ANSI macro substitution rules prohibit looking inside quoted strings
601  * for the substitution names.  A side effect is that the quotes are
602  * inserted in the definitions of those macros as well.  So, the last
603  * three sed expressions are supposed to clean up the definitions, as
604  * long as those definitions are using "c", "g" or "x" as the macro
605  * argument :).  Yuck.
606  */
607 fix = {
608     hackname = ioctl_fix_ctrl;
609     select = "CTRL[ \t]*\\(";
610
611     sed = "/[^A-Z0-9_]CTRL[ \t]*(/"
612               "s/\\([^']\\))/'\\1')/";
613
614     sed = "/[^A-Z0-9]_CTRL[ \t]*(/"
615               "s/\\([^']\\))/'\\1')/";
616
617     sed = "/#[ \t]*define[ \t]*[ \t]CTRL/"
618               "s/'\\([cgx]\\)'/\\1/g";
619
620     sed = "/#[ \t]*define[ \t]*[ \t]_CTRL/"
621               "s/'\\([cgx]\\)'/\\1/g";
622
623     sed = "/#[ \t]*define[ \t]*[ \t]BSD43_CTRL/"
624               "s/'\\([cgx]\\)'/\\1/g";
625 };
626
627
628 /*
629  *  Check for missing ';' in struct
630  */
631 fix = {
632     hackname = ip_missing_semi;
633     files    = netinet/ip.h;
634     sed      = "/^struct/,/^};/s/}$/};/";
635 };
636
637
638 /*
639  *  IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
640  *  in prototype without previous definition.
641  */
642 fix = {
643     hackname = irix_multiline_cmnt;
644     files    = sys/types.h;
645
646     sed   = "s@type of the result@type of the result */@";
647     sed   = "s@of the sizeof@/* of the sizeof@";
648 };
649
650
651 /*
652  *  Some IRIX header files contain the string "//"
653  */
654 fix = {
655     hackname = irix_sockaddr;
656     files    = rpc/auth.h;
657     select   = "authdes_create.*struct sockaddr";
658     sed      = "/authdes_create.*struct sockaddr/i\\\n"
659                "struct sockaddr;\n";
660 };
661
662
663 /*
664  *  IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
665  *  in prototype without previous definition.
666  */
667 fix = {
668     hackname = irix_struct__file;
669     files = rpc/xdr.h;
670     sed   = "/xdrstdio_create.*struct __file_s/i\\\n"
671             "struct __file_s;\n";
672 };
673
674
675 /*
676  * Fixing ISC fmod declaration
677  */
678 fix = {
679     hackname = isc_fmod;
680     files    = math.h;
681     select   = 'fmod\(double\)';
682     sed      = "s/fmod(double)/fmod(double, double)/";
683 };
684
685   
686 /*
687  * Fix nested comments in Motorola's <limits.h> and <sys/limits.h>
688  */
689 fix = {
690     hackname = motorola_nested;
691     mach     = "m68k-motorola-sysv*";
692     files    = limits.h;
693     files    = sys/limits.h;
694     sed = "s@^\\(#undef[ \t][ \t]*PIPE_BUF[ \t]*"
695                    "/\\* max # bytes atomic in write to a\\)$@\\1 */@";
696     sed = "s@\\(/\\*#define\tHUGE_VAL\t3.40282346638528860e+38 \\)"
697           "\\(/\\*error value returned by Math lib\\*/\\)$@\\1*/ \\2@";
698 };
699
700   
701 /*
702  * Fixing nested comments in ISC <sys/limits.h>
703  */
704 fix = {
705     hackname = isc_sys_limits;
706     files  = sys/limits.h;
707     select = CHILD_MAX;
708     sed    = "/CHILD_MAX/s,/\\* Max, Max,";
709     sed    = "/OPEN_MAX/s,/\\* Max, Max,";
710 };
711
712
713 /*
714  * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
715  * use / * * / to concatenate tokens.
716  */
717 fix = {
718     hackname = kandr_concat;
719     files  = "sparc/asm_linkage.h";
720     files  = "sun3/asm_linkage.h";
721     files  = "sun3x/asm_linkage.h";
722     files  = "sun4/asm_linkage.h";
723     files  = "sun4c/asm_linkage.h";
724     files  = "sun4m/asm_linkage.h";
725     files  = "sun4c/debug/asm_linkage.h";
726     files  = "sun4m/debug/asm_linkage.h";
727     files  = "arm/as_support.h";
728     files  = "arm/mc_type.h";
729     files  = "arm/xcb.h";
730     files  = "dev/chardefmac.h";
731     files  = "dev/ps_irq.h";
732     files  = "dev/screen.h";
733     files  = "dev/scsi.h";
734     files  = "sys/tty.h";
735     files  = "Xm.acorn/XmP.h";
736     files  = bsd43/bsd43_.h;
737     select = '/\*\*/';
738     sed    = 's|/\*\*/|##|g';
739 };
740
741
742 /*
743  *  In limits.h, put #ifndefs around things that are supposed to be defined
744  *  in float.h to avoid redefinition errors if float.h is included first.
745  *  On HP/UX this patch does not work, because on HP/UX limits.h uses
746  *  multi line comments and the inserted #endif winds up inside the
747  *  comment.  Fortunately, HP/UX already uses #ifndefs in limits.h; if
748  *  we find a #ifndef FLT_MIN we assume that all the required #ifndefs
749  *  are there, and we do not add them ourselves.
750  *  Also fix a nested comment problem in sys/limits.h on Motorola sysV68 R3V7.1
751  */
752 fix = {
753     hackname = limits_ifndefs;
754     files  = "limits.h";
755     files  = "sys/limits.h";
756     bypass = "ifndef[ \t]+FLT_MIN";
757
758     sed  = "/[ \t]FLT_MIN[ \t]/i\\\n#ifndef FLT_MIN\n";
759     sed  = "/[ \t]FLT_MIN[ \t]/a\\\n#endif\n";
760     sed  = "/[ \t]FLT_MAX[ \t]/i\\\n#ifndef FLT_MAX\n";
761     sed  = "/[ \t]FLT_MAX[ \t]/a\\\n#endif\n";
762     sed  = "/[ \t]FLT_DIG[ \t]/i\\\n#ifndef FLT_DIG\n";
763     sed  = "/[ \t]FLT_DIG[ \t]/a\\\n#endif\n";
764     sed  = "/[ \t]DBL_MIN[ \t]/i\\\n#ifndef DBL_MIN\n";
765     sed  = "/[ \t]DBL_MIN[ \t]/a\\\n#endif\n";
766     sed  = "/[ \t]DBL_MAX[ \t]/i\\\n#ifndef DBL_MAX\n";
767     sed  = "/[ \t]DBL_MAX[ \t]/a\\\n#endif\n";
768     sed  = "/[ \t]DBL_DIG[ \t]/i\\\n#ifndef DBL_DIG\n";
769     sed  = "/[ \t]DBL_DIG[ \t]/a\\\n#endif\n";
770     sed  = "/^\\(\\/\\*#define\tHUGE_VAL\t3\\.[0-9e+]* *\\)\\/\\*/s//\\1/";
771 };
772
773
774 /*
775  *  Delete the '#define void int' line from curses.h on Lynx
776  */
777 fix = {
778     hackname = lynx_void_int;
779     files    = curses.h;
780     select   = "#[ \t]*define[ \t]+void[ \t]+int";
781     sed      = "/#[ \t]*define[ \t][ \t]*void[ \t]int/d";
782 };
783
784
785 /*
786  *  Fix fcntl prototype in fcntl.h on LynxOS.
787  */
788 fix = {
789     hackname = lynxos_fcntl_proto;
790     files    = fcntl.h;
791     select   = 'fcntl.*\(int, int, int\)';
792     sed      = 's/\(fcntl.*(int, int, \)int)/\1...)/';
793 };
794
795
796 /*
797  *  libm.a on m88k-motorola-sysv3 contains a stupid optimization for
798  *  function hypot(), which returns the second argument without even
799  *  looking at its value, if the other is 0.0.  Another drawback is
800  *  that fix-header doesn't fix fabs' prototype, and I have no idea why.
801  */
802 fix = {
803     hackname = m88k_bad_hypot_opt;
804     mach     = "m88k-motorola-sysv3*";
805     files    = "math.h";
806
807     sed = "s/extern double floor(), ceil(), fmod(), fabs();/"
808             "extern double floor(), ceil(), fmod(), fabs _PARAMS((double));/";
809
810     sed = "/^extern double hypot();$/a\\\n"
811           "\\/* Workaround a stupid Motorola optimization if one\\\n"
812           "   of x or y is 0.0 and the other is negative!  *\\/\\\n"
813           "#ifdef __STDC__\\\n"
814           "static __inline__ double fake_hypot (double x, double y)\\\n"
815           "#else\\\n"
816           "static __inline__ double fake_hypot (x, y)\\\n"
817           "\tdouble x, y;\\\n"
818           "#endif\\\n"
819           "{\\\n"
820           "\treturn fabs (hypot (x, y));\\\n"
821           "}\\\n"
822           "#define hypot\tfake_hypot\n";
823 };
824
825
826 /*
827  *  Fix incorrect S_IF* definitions on m88k-sysv3.
828  */
829 fix = {
830     hackname = m88k_bad_s_if;
831     mach     = "m88k-*-sysv3*";
832     files    = sys/stat.h;
833     select   = "#define[ \t]+S_IS[A-Z]*(m)[ \t]";
834
835     sed = "s/^\\(#define[ \t]*S_IS[A-Z]*(m)\\)[ \t]*"
836             "(m[ \t]*&[ \t]*\\(S_IF[A-Z][A-Z][A-Z][A-Z]*\\)[ \t]*)/"
837             "\\1 (((m)\\&S_IFMT)==\\2)/";
838
839     sed = "s/^\\(#define[ \t]*S_IS[A-Z]*(m)\\)[ \t]*"
840             "(m[ \t]*&[ \t]*\\(0[0-9]*\\)[ \t]*)/"
841             "\\1 (((m)\\&S_IFMT)==\\2)/";
842 };
843
844
845 /*
846  * Put cpp wrappers around these include files to avoid redeclaration
847  * errors during multiple inclusion on m88k-tektronix-sysv3.
848  */
849 fix = {
850     hackname = m88k_multi_incl;
851     mach     = "m88k-tektronix-sysv3*";
852     files    = "time.h";
853     bypass   = "#ifndef";
854     shell    =
855       "echo Fixing $file, to protect against multiple inclusion. >&2
856       cpp_wrapper=`echo $file | sed -e 's,\\.,_,g' -e 's,/,_,g'`
857       echo \"#ifndef __GCC_GOT_${cpp_wrapper}_\"
858       echo \"#define __GCC_GOT_${cpp_wrapper}_\"
859       cat
860       echo \"#endif /* ! __GCC_GOT_${cpp_wrapper}_ */\"";
861 };
862
863
864 /*
865  *  Fix non-ansi machine name defines
866  *  File selection is split into two parts:  the shell version as
867  *  a single patch, and the program version with each patch separate.
868  *  Each is substantially faster for the particular environment.
869  *  You have a dual maintenance problem here.
870  */
871 fix = {
872     hackname = machine_name;
873     /*
874      *  Select '#if.*' and '#elif" with possible non-ansi symbols
875      *  The only non-ansi symbols we know about start with one of:
876      *     MRS_bhimnprstuv
877      *  If any are added to the substitution list, then add it to
878      *  the selection list as well.  Hopefully we can avoid names
879      *  starting with "d" and "l", because this pattern would then
880      *  match "defined" and "lint" as well.  I suppose we could add
881      *  a "bypass = lint" if we had to though.
882      *
883      * The fixinc_eol stuff is to work around a bug in the sed
884      */
885     select = "^#[ \t]*(if|elif).*"
886              "[^a-zA-Z0-9_](_*[MSRrhim]|[Mbimnpstuv])[a-zA-Z0-9_]";
887     exesel = "^#[ \t]*(if|elif).*[^a-zA-Z0-9_]"
888              "("
889                   "M32"
890                  "|_*MIPSE[LB]"
891                  "|_*SYSTYPE_[A-Z0-9]"
892                  "|_*[Rr][34]000"
893                  "|_*host_mips"
894                  "|_*i386"
895                  "|_*mips"
896                  "|bsd4"
897                  "|is68k"
898                  "|m[68]8k"
899                  "|mc680"
900                  "|news"
901                  "|ns32000"
902                  "|pdp11"
903                  "|pyr"
904                  "|sel"
905                  "|sony_news"
906                  "|sparc"
907                  "|sun"
908                  "|tahoe"
909                  "|tower"
910                  "|u370"
911                  "|u3b"
912                  "|unix"
913                  "|vax"
914              ")";
915
916     sed =      ":loop\n"
917                '/\\\\$/'                       "N\n"
918                's/\\\\$/\\\\+++fixinc_eol+++/' "\n"
919                '/\\\\$/'                       "b loop\n"
920                's/\\\\+++fixinc_eol+++/\\\\/g' "\n"
921
922           "/#[\t ]*[el]*if/ {\n"
923                 "\ts/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g\n"
924
925                 "\ts/ M32 / __M32__ /g\n"
926                 "\ts/ _*MIPSE\\([LB]\\) / __MIPSE\\1__ /g\n"
927                 "\ts/ _*SYSTYPE_\\([A-Z0-9]*\\) / __SYSTYPE_\\1__ /g\n"
928                 "\ts/ _*\\([Rr][34]\\)000 / __\\1000__ /g\n"
929                 "\ts/ _*host_mips / __host_mips__ /g\n"
930                 "\ts/ _*i386 / __i386__ /g\n"
931                 "\ts/ _*mips / __mips__ /g\n"
932                 "\ts/ bsd4\\([0-9]\\) / __bsd4\\1__ /g\n"
933                 "\ts/ is68k / __is68k__ /g\n"
934                 "\ts/ m68k / __m68k__ /g\n"
935                 "\ts/ m88k / __m88k__ /g\n"
936                 "\ts/ mc680\\([0-9]\\)0 / __mc680\\10__ /g\n"
937                 "\ts/ news\\([0-9]*\\) / __news\\1__ /g\n"
938                 "\ts/ ns32000 / __ns32000__ /g\n"
939                 "\ts/ pdp11 / __pdp11__ /g\n"
940                 "\ts/ pyr / __pyr__ /g\n"
941                 "\ts/ sel / __sel__ /g\n"
942                 "\ts/ sony_news / __sony_news__ /g\n"
943                 "\ts/ sparc / __sparc__ /g\n"
944                 "\ts/ sun\\([a-z0-9]*\\) / __sun\\1__ /g\n"
945                 "\ts/ tahoe / __tahoe__ /g\n"
946                 "\ts/ tower\\([_0-9]*\\) / __tower\\1__ /g\n"
947                 "\ts/ u370 / __u370__ /g\n"
948                 "\ts/ u3b\\([0-9]*\\) / __u3b\\1__ /g\n"
949                 "\ts/ unix / __unix__ /g\n"
950                 "\ts/ vax / __vax__ /g\n"
951
952                 "\ts/ \\([a-zA-Z0-9_][a-zA-Z0-9_]*\\) /\\1/g\n\t}";
953 };
954
955
956 /*
957  *  Some math.h files define struct exception, which conflicts with
958  *  the class exception defined in the C++ file std/stdexcept.h.  We
959  *  redefine it to __math_exception.  This is not a great fix, but I
960  *  haven't been able to think of anything better.
961  */
962 fix = {
963     hackname = math_exception;
964     files    = math.h;
965     select   = "struct exception";
966     sed      = "/struct exception/i\\\n"
967                "#ifdef __cplusplus\\\n"
968                "#define exception __math_exception\\\n"
969                "#endif\n";
970     sed      = "/struct exception/a\\\n"
971                "#ifdef __cplusplus\\\n"
972                "#undef exception\\\n"
973                "#endif\n";
974
975     sed      = "/matherr/i\\\n"
976                "#ifdef __cplusplus\\\n"
977                "#define exception __math_exception\\\n"
978                "#endif\n";
979
980     sed      = "/matherr/a\\\n"
981                "#ifdef __cplusplus\\\n"
982                "#undef exception\\\n"
983                "#endif\n";
984
985 #ifdef MATH_EXCEPTION_FIXED
986
987 I think this patch needs some more thinking.
988 This is from SVR4.2 (With '#' replaced with '@').
989 Perhaps we could do without the "/matherr/a" entries?
990 Can we bypass the entire fix if someone was astute
991 enough to have '#ifdef __cplusplus' anywhere in the file?
992
993
994 *** /usr/include/math.h Fri Apr  3 18:54:59 1998
995 --- math.h      Sun May  9 07:28:58 1999
996 ***************
997 *** 25,31 ****
998 --- 25,37 ----
999   
1000   @ifndef __cplusplus
1001   
1002 + @ifdef __cplusplus
1003 + @define exception __math_exception
1004 + @endif
1005   struct exception
1006 + @ifdef __cplusplus
1007 + @undef exception
1008 + @endif
1009   {
1010         int     type;
1011         char    *name;
1012 ***************
1013 *** 34,40 ****
1014 --- 40,58 ----
1015         double  retval;
1016   };
1017   
1018 + @ifdef __cplusplus
1019 + @define exception __math_exception
1020 + @endif
1021 + @ifdef __cplusplus
1022 + @define exception __math_exception
1023 + @endif
1024   extern int    matherr(struct exception *);
1025 + @ifdef __cplusplus
1026 + @undef exception
1027 + @endif
1028 + @ifdef __cplusplus
1029 + @undef exception
1030 + @endif
1031   
1032   @endif /*__cplusplus*/
1033 #endif
1034 };
1035
1036
1037 /*
1038  * In math.h, put #ifndefs around things that might be defined
1039  * in a gcc specific math-*.h file.
1040  */
1041 fix = {
1042     hackname = math_gcc_ifndefs;
1043     files    = math.h;
1044
1045     shell    =
1046     /*
1047      *  First see if we have a definition for DBL_MAX in float.h
1048      *  If we do, we will replace the one in math.h with that one.
1049      */
1050
1051     /*
1052      *  IF we have such a define *and* HUGE_VAL is defined to be DBL_MAX
1053      *     *and* DBL_MAX is _not_ defined in the current file (math.h),
1054      *  THEN replace the defined value of HUGE_VAL
1055      *  ELSE just copy stdin to stdout so the main filter can process it
1056      */
1057
1058     /*
1059      *  Put conditional guards around the HUGE_VAL definition.
1060      */
1061
1062     "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
1063                 "2>/dev/null`\n\n"
1064
1065     "\tif ( test -n \"${dbl_max_def}\" \\\n"
1066     "\t\t-a -n \"`egrep '#define[ \t]*HUGE_VAL[ \t]+DBL_MAX' $file`\" \\\n"
1067     "\t\t-a -z \"`egrep '#define[ \t]+DBL_MAX[ \t]+' $file`\"\n"
1068              "\t   ) > /dev/null 2>&1\n"
1069     "\tthen sed -e '/define[ \t]HUGE_VAL[ \t]DBL_MAX/s/DBL_MAX/$dbl_max_def/'"
1070     "\n\telse cat ; fi |\n"
1071
1072     "\tsed -e '/define[ \t]HUGE_VAL[ \t]/i\\\n#ifndef HUGE_VAL\n' "
1073           "-e '/define[ \t]HUGE_VAL[ \t]/a\\\n#endif\n'";
1074 };
1075
1076
1077 /*
1078  *  nested comment
1079  */
1080 fix = {
1081     hackname = nested_comment;
1082     files    = rpc/rpc.h;
1083     sed      = 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@';
1084 };
1085
1086
1087 /*
1088  *  fix bogus recursive stdlib.h in NEWS-OS 4.0C
1089  */
1090 fix = {
1091     hackname = news_os_recursion;
1092     files    = stdlib.h;
1093     select   = "#include <stdlib.h>";
1094     sed      = "/^#include <stdlib.h>/i\\\n"
1095                     "#ifdef BOGUS_RECURSION\n";
1096     sed      = "/^#include <stdlib.h>/a\\\n"
1097                     "#endif\n";
1098 };
1099
1100
1101 /*
1102  *  NeXT 3.2 adds const prefix to some math functions.
1103  *  These conflict with the built-in functions.
1104  */
1105 fix = {
1106     hackname = next_math_prefix;
1107     files    = ansi/math.h;
1108     select   = "^extern.*double.*__const__.*";
1109
1110     sed = "/^extern.*double.*__const__.*sqrt(/s/__const__//";
1111     sed = "/^extern.*double.*__const__.*fabs(/s/__const__//";
1112     sed = "/^extern.*double.*__const__.*cos(/s/__const__//";
1113     sed = "/^extern.*double.*__const__.*hypot(/s/__const__//";
1114     sed = "/^extern.*double.*__const__.*sin(/s/__const__//";
1115 };
1116
1117
1118 /*
1119  *  NeXT 3.2 uses the word "template" as a parameter for some
1120  *  functions. GCC reports an invalid use of a reserved key word
1121  *  with the built-in functions. NeXT 3.2 includes the keyword
1122  *  volatile in the prototype for abort(). This conflicts with
1123  *  the built-in definition.
1124  */
1125 fix = {
1126     hackname = next_template;
1127     files    = bsd/libc.h;
1128     select   = template;
1129
1130     sed = '/\(.*template\)/s/template//';
1131     sed = "/extern.*volatile.*void.*abort/s/volatile//";
1132 };
1133
1134
1135 /*
1136  *  NeXT 3.2 includes the keyword volatile in the abort() and  exit()
1137  *  function prototypes. That conflicts with the  built-in functions.
1138  */
1139 fix = {
1140     hackname = next_volitile;
1141     files    = ansi/stdlib.h;
1142     select   = volatile;
1143
1144     sed    = "/extern.*volatile.*void.*exit/s/volatile//";
1145     sed    = "/extern.*volatile.*void.*abort/s/volatile//";
1146 };
1147
1148
1149 /*
1150  *  NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1151  *  Note that version 3 of the NeXT system has wait.h in a different directory,
1152  *  so that this code won't do anything.  But wait.h in version 3 has a
1153  *  conditional, so it doesn't need this fix.  So everything is okay.
1154  */
1155 fix = {
1156     hackname = next_wait_union;
1157     files    = sys/wait.h;
1158
1159     select = 'wait\(union wait';
1160
1161     sed = "s@wait(union wait@wait(void@";
1162 };
1163
1164
1165 /*
1166  *  a missing semi-colon at the end of the nodeent structure definition.
1167  */
1168 fix = {
1169     hackname = nodeent_syntax;
1170     files    = netdnet/dnetdb.h;
1171     sed      = "s/char.*na_addr *$/char *na_addr;/";
1172 };
1173
1174
1175 /*
1176  *  sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
1177  *  defining regex.h related types.  This causes libg++ build and usage
1178  *  failures.  Fixing this correctly requires checking and modifying 3 files.
1179  */
1180 fix = {
1181     hackname = osf_namespace_a;
1182     files    = reg_types.h;
1183     files    = sys/lc_core.h;
1184     test     = " -r reg_types.h";
1185     test     = " -r sys/lc_core.h";
1186     test     = " -n \"`grep '} regex_t;' reg_types.h`\"";
1187     test     = " -z \"`grep __regex_t regex.h`\"";
1188
1189     sed      = "s/regex_t/__regex_t/g";
1190     sed      = "s/regoff_t/__regoff_t/g";
1191     sed      = "s/regmatch_t/__regmatch_t/g";
1192 };
1193
1194 fix = {
1195     hackname = osf_namespace_b;
1196     files    = regex.h;
1197     test     = " -r reg_types.h";
1198     test     = " -r sys/lc_core.h";
1199     test     = " -n \"`grep '} regex_t;' reg_types.h`\"";
1200     test     = " -z \"`grep __regex_t regex.h`\"";
1201
1202     sed      = "/#include <reg_types.h>/a\\\n"
1203                "typedef __regex_t\tregex_t;\\\n"
1204                "typedef __regoff_t\tregoff_t;\\\n"
1205                "typedef __regmatch_t\tregmatch_t;\n";
1206 };
1207
1208
1209 /*
1210  *  Fix __page_size* declarations in pthread.h AIX 4.1.[34].
1211  *  The original ones fail if uninitialized externs are not common.
1212  *  This is the default for all ANSI standard C++ compilers.
1213  */
1214 fix = {
1215     hackname = pthread_page_size;
1216     files    = pthread.h;
1217     select   = "^int __page_size";
1218     sed      = "s/^int __page_size/extern int __page_size/";
1219 };
1220
1221
1222 /*
1223  *  Fix return type of fread and fwrite on sysV68
1224  */
1225 #ifdef LATER
1226 fix = {
1227     hackname = read_ret_type;
1228     files    = stdio.h;
1229     sed      = "s/^\\(extern int\tfclose(), fflush()\\), "
1230                  "\\(fread(), fwrite()\\)\\(.*\\)$"
1231                "/extern unsigned int\t\\2;\\\n\\1\\3/";
1232 };
1233 #endif
1234
1235
1236 /*
1237  *  function class(double x) conflicts with C++ keyword on rs/6000 
1238  */
1239 fix = {
1240     hackname = rs6000_double;
1241     files    = math.h;
1242     select   = '[^a-zA-Z_]class\(';
1243     
1244     sed   = "/class[(]/i\\\n#ifndef __cplusplus\n";
1245     sed   = "/class[(]/a\\\n#endif\n";
1246 };
1247
1248
1249 /*
1250  *  Wrong fchmod prototype on RS/6000.
1251  */
1252 fix = {
1253     hackname = rs6000_fchmod;
1254     files    = sys/stat.h;
1255     select   = 'fchmod\(char';
1256     sed      = 's/fchmod(char \*/fchmod(int/';
1257 };
1258
1259
1260 /*
1261  *  parameters conflict with C++ new on rs/6000 
1262  */
1263 fix = {
1264     hackname = rs6000_param;
1265     files  = "stdio.h";
1266     files  = "unistd.h";
1267
1268     sed = 's@rename(const char \*old, const char \*new)@'
1269             'rename(const char *_old, const char *_new)@';
1270 };
1271
1272
1273 /*
1274  *  Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1275  */
1276 #ifdef SONY
1277 fix = {
1278     hackname = sony_ctype;
1279     files    = ctype.h;
1280     test     = " -x /bin/sony";
1281     test     = " ! -z \"`if /bin/sony ; then echo true ; fi`\"";
1282     sed      = "s/__ctype/_ctype/g";
1283 };
1284 #endif
1285
1286 /*
1287  *  Incorrect #include in Sony News-OS 3.2.
1288  */
1289 fix = {
1290     hackname = sony_include;
1291     files    = machine/machparam.h;
1292     select   = '"\.\./machine/endian.h"';
1293     sed      = 's@"../machine/endian.h"@<machine/endian.h>@';
1294 };
1295
1296
1297 /*
1298  *  Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1299  */
1300 #ifdef SONY
1301 fix = {
1302     hackname = sony_stdio;
1303     files    = stdio.h;
1304     test     = " -x /bin/sony";
1305     test     = " ! -z \"`if /bin/sony ; then echo true ; fi`\"";
1306     sed      = "s/__filbuf/_filbuf/g\n"
1307                "s/__flsbuf/_flsbuf/g\n"
1308                "s/__iob/_iob/g";
1309 };
1310 #endif
1311
1312 /*
1313  *  Add a `static' declaration of `getrnge' into <regexp.h>.
1314  *
1315  *  Don't do this if there is already a `static void getrnge' declaration
1316  *  present, since this would cause a redeclaration error.  Solaris 2.x has
1317  *  such a declaration.
1318  */
1319 #ifdef SVR4
1320 fix = {
1321     hackname = static_getrnge;
1322     files    = regexp.h;
1323     bypass   = "static void getrnge";
1324     sed      = "/^static int[ \t]*size;/c\\\n"
1325                "static int      size ;\\\n\\\n"
1326                "static int getrnge ();";
1327 };
1328 #endif
1329
1330 /*
1331  *  a missing semi-colon at the end of the statsswtch structure definition.
1332  */
1333 fix = {
1334     hackname = statsswtch;
1335     files    = rpcsvc/rstat.h;
1336     select   = "boottime$";
1337     sed      = "s/boottime$/boottime;/";
1338 };
1339
1340
1341 /*
1342  *  Don't use or define the name va_list in stdio.h.
1343  *  This is for ANSI and also to interoperate properly with gcc's varargs.h.
1344  *  Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
1345  */
1346 fix = {
1347     hackname = stdio_va_list;
1348     files    = stdio.h;
1349
1350     /*
1351      * Use __gnuc_va_list in arg types in place of va_list.
1352      * On 386BSD use __gnuc_va_list instead of _VA_LIST_.  We're hoping the
1353      * trailing parentheses and semicolon save all other systems from this.
1354      * Define __va_list__ (something harmless and unused) instead of va_list.
1355      * Don't claim to have defined va_list.
1356      */
1357     shell =
1358  "if ( egrep \"__need___va_list\" $file ) > /dev/null 2>&1 ; then
1359     :
1360   else
1361     echo \"#define __need___va_list\"
1362     echo \"#include <stdarg.h>\"
1363   fi
1364
1365   sed -e 's@ va_list @ __gnuc_va_list @' \\
1366       -e 's@ va_list)@ __gnuc_va_list)@' \\
1367       -e 's@ _BSD_VA_LIST_));@ __gnuc_va_list));@' \\
1368       -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \\
1369       -e 's@ va_list@ __va_list__@' \\
1370       -e 's@\\*va_list@*__va_list__@' \\
1371       -e 's@ __va_list)@ __gnuc_va_list)@' \\
1372       -e 's@GNUC_VA_LIST@GNUC_Va_LIST@' \\
1373       -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \\
1374       -e 's@VA_LIST@DUMMY_VA_LIST@' \\
1375       -e 's@_Va_LIST@_VA_LIST@'";
1376 };
1377
1378
1379 /*
1380  *  Check for strict ansi compliance
1381  */
1382 #ifdef STRICT_ANSI
1383 fix = {
1384     hackname = strict_ansi;
1385     select   = "__STDC__[ \t]*[=!]=[ \t]*[01]";
1386     sed      = "s/__STDC__[ \t]*==[ \t]*0/!defined (__STRICT_ANSI__)/g";
1387     sed      = "s/__STDC__[ \t]*!=[ \t]*0/defined (__STRICT_ANSI__)/g";
1388     sed      = "s/__STDC__[ \t]*==[ \t]*1/defined (__STRICT_ANSI__)/g";
1389     sed      = "s/__STDC__[ \t]*!=[ \t]*1/!defined (__STRICT_ANSI__)/g";
1390 };
1391 #endif
1392
1393 /*
1394  *  Fix bogus #ifdef on SunOS 4.1.
1395  */
1396 fix = {
1397     hackname = sun_bogus_ifdef;
1398     files  = "hsfs/hsfs_spec.h";
1399     files  = "hsfs/iso_spec.h";
1400     select = '#ifdef __i386__ || __vax__';
1401     sed    = "s/\\#ifdef __i386__ || __vax__/\\#if __i386__ || __vax__/g";
1402 };
1403
1404
1405 /*
1406  *  Fix bogus #ifdef on SunOS 4.1.
1407  */
1408 fix = {
1409     hackname = sun_bogus_ifdef_sun4c;
1410     files  = "hsfs/hsnode.h";
1411     select = '#ifdef __i386__ || __sun4c__';
1412     sed    = "s/\\#ifdef __i386__ || __sun4c__/\\#if __i386__ || __sun4c__/g";
1413 };
1414
1415
1416 /*
1417  *  Fix the CAT macro in SunOS memvar.h.
1418  */
1419 fix = {
1420     hackname = sun_catmacro;
1421     files  = pixrect/memvar.h;
1422     select = "^#define[ \t]+CAT\\(a,b\\)";
1423     sed    = "/^#define[ \t]CAT(a,b)/ i\\\n"
1424                  "#ifdef __STDC__ \\\n"
1425                  "#define CAT(a,b) a##b\\\n"
1426                  "#else\n";
1427
1428     sed    = "/^#define[ \t]CAT(a,b)/ a\\\n"
1429                  "#endif\n";
1430 };
1431
1432
1433 /*
1434  *  Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
1435  *  Also fix return type of {m,re}alloc in <malloc.h> on sysV68
1436  */
1437 fix = {
1438     hackname = sun_malloc;
1439     files    = malloc.h;
1440
1441     sed   = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
1442     sed   = "s/int[ \t][ \t]*free/void\tfree/g";
1443     sed   = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
1444     sed   = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
1445 };
1446
1447
1448 /*
1449  *  Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
1450  *  declaration on Sun OS 4.x.  We must only fix this on Sun OS 4.x, because
1451  *  many other systems have similar text but correct versions of the file.
1452  *  To ensure only Sun's is fixed, we grep for a likely unique string.
1453  *  Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
1454  */
1455 fix = {
1456     hackname = sun_memcpy;
1457     files    = memory.h;
1458     select = "/\\*\t@\\(#\\)"
1459              "(head/memory.h\t50.1\t "
1460              "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
1461
1462     sed    = "1i\\\n/* This file was generated by fixincludes */\\\n"
1463              "#ifndef __memory_h__\\\n"
1464              "#define __memory_h__\\\n\\\n"
1465              "#ifdef __STDC__\\\n"
1466              "extern void *memccpy();\\\n"
1467              "extern void *memchr();\\\n"
1468              "extern void *memcpy();\\\n"
1469              "extern void *memset();\\\n"
1470              "#else\\\n"
1471              "extern char *memccpy();\\\n"
1472              "extern char *memchr();\\\n"
1473              "extern char *memcpy();\\\n"
1474              "extern char *memset();\\\n"
1475              "#endif /* __STDC__ */\\\n\\\n"
1476              "extern int memcmp();\\\n\\\n"
1477              "#endif /* __memory_h__ */\n";
1478
1479     sed    = "1,$d";
1480 };
1481
1482
1483 /*
1484  *  Check for yet more missing ';' in struct (in SunOS 4.0.x)
1485  */
1486 fix = {
1487     hackname = sun_rusers_semi;
1488     files    = rpcsvc/rusers.h;
1489     select   = "_cnt$";
1490     sed      = "/^struct/,/^};/s/_cnt$/_cnt;/";
1491 };
1492
1493
1494 /*
1495  *  signal.h on SunOS defines signal using (),
1496  *  which causes trouble when compiling with g++ -pedantic.
1497  */
1498 fix = {
1499     hackname = sun_signal;
1500     files    = sys/signal.h;
1501     files    = signal.h;
1502     select   = "^void\t" '\(\*signal\(\)\)\(\);';
1503
1504     sed = "/^void\t" '(\*signal())();$/i'  "\\\n"
1505           "#ifdef __cplusplus"             "\\\n"
1506           "void\t(*signal(...))(...);"     "\\\n"
1507           "#else"                          "\n";
1508
1509     sed = "/^void\t" '(\*signal())();$/a'  "\\\n"
1510           '#endif'                         "\n";
1511 };
1512
1513
1514 /*
1515  *  Apply fix this to all OSs since this problem seems to effect
1516  *  more than just SunOS.  In general, fixes which are triggered
1517  *  by a specific target are bad.
1518  */
1519 fix = {
1520     hackname = sun_auth_proto;
1521     files    = rpc/auth.h;
1522     files    = rpc/clnt.h;
1523     files    = rpc/svc.h;
1524     files    = rpc/xdr.h;
1525     /*
1526      *  Select those files containing '(*name)()'.
1527      */
1528     select   = '\(\*[a-z][a-z_]*\)\(\)';
1529     sed      = 's'
1530                 '/^\(.*(\*[a-z][a-z_]*)(\)'      '\();.*\)'
1531                 "/\\\n"
1532                     "#ifdef __cplusplus\\\n"
1533                     '\1...\2' "\\\n"
1534                     "#else\\\n"
1535                     '\1\2' "\\\n"
1536                     "#endif"
1537                 "/";
1538 };
1539
1540
1541 /*
1542  *  math.h on SunOS 4 puts the declaration of matherr before the definition
1543  *  of struct exception, so the prototype (added by fixproto) causes havoc.
1544  */
1545 fix = {
1546     hackname = sunos_matherr_decl;
1547     files    = math.h;
1548     /*
1549      *  Once a declaration for 'struct exception' is found,
1550      *  stop trying to insert a forward reference for it.
1551      */
1552     sed = "/^struct exception/,$b";
1553     sed = "/matherr/i\\\nstruct exception;\n";
1554 };
1555
1556
1557 /*
1558  *  Correct the return type for strlen in strings.h in SunOS 4.
1559  */
1560 fix = {
1561     hackname = sunos_strlen;
1562     files    = strings.h;
1563     sed = "s/int[ \t]*strlen();/__SIZE_TYPE__ strlen();/";
1564 };
1565
1566
1567 /*
1568  *  Solaris math.h and floatingpoint.h define __P without protection,
1569  *  which conflicts with the fixproto definition.  The fixproto
1570  *  definition and the Solaris definition are used the same way.
1571  */
1572 #ifdef SVR4
1573 fix = {
1574     hackname = svr4__p;
1575     files    = math.h;
1576     files    = floatingpoint.h;
1577     select   = "^#define[ \t]*__P";
1578     sed      = "/^#define[ \t]*__P/i\\\n#ifndef __P\n";
1579     sed      = "/^#define[ \t]*__P/a\\\n#endif\n";
1580 };
1581 #endif
1582
1583 /*
1584  *  Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
1585  *  that is visible to any ANSI compiler using this include.  Simply
1586  *  delete the lines that #define some string functions to internal forms.
1587  */
1588 #ifdef SVR4
1589 fix = {
1590     hackname = svr4_disable_opt;
1591     files    = string.h;
1592     select   = '#define.*__std_hdr_';
1593     sed      = '/#define.*__std_hdr_/d';
1594 };
1595 #endif
1596
1597 /*
1598  *  Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
1599  */
1600 #ifdef SVR4
1601 fix = {
1602     hackname = svr4_endian;
1603     files    = sys/endian.h;
1604     bypass   = '__GNUC__';
1605
1606     sed      = "/#\tifdef\t__STDC__/i\\\n"
1607                "#   if !defined (__GNUC__) && !defined (__GNUG__)\n";
1608
1609     sed      = "/#\t\tinclude\t<sys\\/byteorder.h>/s/\t\t/   /";
1610
1611     sed      = "/#   include\t<sys\\/byteorder.h>/i\\\n"
1612                "#   endif /* !defined (__GNUC__) && !defined (__GNUG__) */\n";
1613 };
1614 #endif
1615
1616 /*
1617  *  Remove useless extern keyword from struct forward declarations
1618  *  in <sys/stream.h> and <sys/strsubr.h>
1619  */
1620 #ifdef SVR4
1621 fix = {
1622     hackname = svr4_extern_struct;
1623     files    = sys/stream.h;
1624     files    = sys/strsubr.h;
1625     select   = 'extern struct [a-z_]*;';
1626     sed      = 's/extern struct \([a-z][a-z_]*\)/struct \1/';
1627 };
1628 #endif
1629
1630 /*
1631  *  Fix declarations of `ftw' and `nftw' in <ftw.h>.  On some/most SVR4
1632  *  systems the file <ftw.h> contains extern declarations of these
1633  *  functions followed by explicitly `static' definitions of these
1634  *  functions... and that's not allowed according to ANSI C.  (Note
1635  *  however that on Solaris, this header file glitch has been pre-fixed by
1636  *  Sun.  In the Solaris version of <ftw.h> there are no static
1637  *  definitions of any function so we don't need to do any of this stuff
1638  *  when on Solaris.
1639  */
1640 #ifdef SVR4
1641 #ifndef SOLARIS
1642 fix = {
1643     hackname = svr4_ftw;
1644     files    = ftw.h;
1645     select   = '^extern int ftw\(const';
1646
1647     sed = '/^extern int ftw(const/i' "\\\n"
1648             "#if !defined(_STYPES)\\\n"
1649             "static\\\n"
1650             "#else\\\n"
1651             "extern\\\n"
1652             "#endif";
1653     sed = 's/extern \(int ftw(const.*\)$/\1/';
1654     sed = "/^extern int nftw/i\\\n"
1655             "#if defined(_STYPES)\\\n"
1656             "static\\\n"
1657             "#else\\\n"
1658             "extern\\\n"
1659             "#endif";
1660     sed = 's/extern \(int nftw.*\)$/\1/';
1661     sed = "/^extern int ftw(),/c\\\n"
1662             "#if !defined(_STYPES)\\\n"
1663             "static\\\n"
1664             "#else\\\n"
1665             "extern\\\n"
1666             "#endif\\\n"
1667             "  int ftw();\\\n"
1668             "#if defined(_STYPES)\\\n"
1669             "static\\\n"
1670             "#else\\\n"
1671             "extern\\\n"
1672             "#endif\\\n"
1673             "  int nftw();";
1674 };
1675 #endif
1676 #endif
1677
1678
1679 /*
1680  *   Fix broken decl of getcwd present on some svr4 systems.
1681  */
1682 #ifdef SVR4
1683 fix = {
1684     hackname = svr4_getcwd;
1685     files    = stdlib.h;
1686     files    = unistd.h;
1687     select   = 'getcwd\(char \*, int\)';
1688
1689     sed = 's/getcwd(char \*, int)/getcwd(char *, size_t)/';
1690 };
1691 #endif
1692
1693 /*
1694  *  set ifdef _KERNEL
1695  */
1696 #ifdef SVR4
1697 fix = {
1698     hackname = svr4_kernel;
1699     files    = fs/rfs/rf_cache.h;
1700     files    = sys/erec.h;
1701     files    = sys/err.h;
1702     files    = sys/char.h;
1703     files    = sys/getpages.h;
1704     files    = sys/map.h;
1705     files    = sys/cmn_err.h;
1706     files    = sys/kdebugger.h;
1707     bypass   = '_KERNEL';
1708     sed      = "1i\\\n#ifdef _KERNEL";
1709     sed      = "$a\\\n#endif /* _KERNEL */";
1710 };
1711 #endif
1712
1713 /*
1714  *  Delete any #defines of `__i386' which may be present in <ieeefp.h>.  They
1715  *  tend to conflict with the compiler's own definition of this symbol.  (We
1716  *  will use the compiler's definition.)
1717  *  Likewise __sparc, for Solaris, and __i860, and a few others
1718  *  (guessing it is necessary for all of them).
1719  */
1720 #ifdef SVR4
1721 fix = {
1722     hackname = svr4_mach_defines;
1723     files    = ieeefp.h;
1724     select   = "#define[ \t]*__(i386|i860|mips|sparc|m88k|m68k)[ \t]";
1725     sed      = "/#define[ \t]*__\\(i386|i860|mips|sparc|m88k|m68k\\)[ \t]/d";
1726 };
1727 #endif
1728
1729 /*
1730  *  Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
1731  */
1732 #ifdef SVR4
1733 fix = {
1734     hackname = svr4_mkdev;
1735     files    = sys/mkdev.h;
1736
1737     sed      = "/^dev_t makedev(const/c\\\n"
1738                "static dev_t makedev(const major_t, const minor_t);";
1739
1740     sed      = "/^dev_t makedev()/c\\\n"
1741                "static dev_t makedev();";
1742
1743     sed      = "/^major_t major(const/c\\\n"
1744                "static major_t major(const dev_t);";
1745
1746     sed      = "/^major_t major()/c\\\n"
1747                "static major_t major();";
1748
1749     sed      = "/^minor_t minor(const/c\\\n"
1750                "static minor_t minor(const dev_t);";
1751
1752     sed      = "/^minor_t minor()/c\\\n"
1753                "static minor_t minor();";
1754 };
1755 #endif
1756
1757 /*
1758  *  Fix reference to NC_NPI_RAW in <sys/netcspace.h>.
1759  *  Also fix types of array initializers.
1760  */
1761 #ifdef SVR4
1762 fix = {
1763     hackname = svr4_netcspace;
1764     files    = sys/netcspace.h;
1765     select   = 'NC_NPI_RAW';
1766     sed      = 's/NC_NPI_RAW/NC_TPI_RAW/g';
1767     sed      = 's/NC_/(unsigned long) NC_/';
1768 };
1769 #endif
1770
1771 /*
1772  *  Fix reference to NMSZ in <sys/adv.h>.
1773  */
1774 #ifdef SVR4
1775 fix = {
1776     hackname = svr4_nmsz;
1777     files    = sys/adv.h;
1778     select   = '\[NMSZ\]';
1779     sed      = 's/\[NMSZ\]/\[RFS_NMSZ\]/g';
1780 };
1781 #endif
1782
1783 /*
1784  *  Completely replace <sys/varargs.h> with a file that includes gcc's
1785  *  stdarg.h or varargs.h files as appropriate.
1786  */
1787 #ifdef SVR4
1788 fix = {
1789     hackname = svr4_no_varargs;
1790     files    = sys/varargs.h;
1791     shell    = "cat > /dev/null\n"
1792                "cat << _EOF_\n"
1793                "/* This file was generated by fixincludes.  */\n"
1794                "#ifndef _SYS_VARARGS_H\n"
1795                "#define _SYS_VARARGS_H\n\n"
1796
1797                "#ifdef __STDC__\n"
1798                "#include <stdarg.h>\n"
1799                "#else\n"
1800                "#include <varargs.h>\n"
1801                "#endif\n\n"
1802
1803                "#endif  /* _SYS_VARARGS_H */\n"
1804                "_EOF_";
1805 };
1806 #endif
1807
1808 /*
1809  *   Fix broken decl of profil present on some svr4 systems.
1810  */
1811 #ifdef SVR4
1812 fix = {
1813     hackname = svr4_profil;
1814     files    = stdlib.h;
1815     files    = unistd.h;
1816
1817     sed = 's/profil(unsigned short \*, unsigned int, '
1818                          'unsigned int, unsigned int)'
1819            '/profil(unsigned short *, size_t, int, unsigned)/';
1820 };
1821 #endif
1822
1823 /*
1824  *  Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1825  */
1826 #ifdef SVR4
1827 fix = {
1828     hackname = svr4_proto_form;
1829     files    = sys/stat.h;
1830     select   = 'const extern';
1831
1832     sed      = "/^stat([ \t]*[^c]/ {\nN\nN\n"
1833                    "s/(.*)\\n/( /\n"
1834                    "s/;\\n/, /\n"
1835                    "s/;$/)/\n"  "}";
1836
1837     sed      = "/^lstat([ \t]*[^c]/ {\nN\nN\n"
1838                    "s/(.*)\\n/( /\n"
1839                    "s/;\\n/, /\n"
1840                    "s/;$/)/\n"  "}";
1841
1842     sed      = "/^fstat([ \t]*[^i]/ {\nN\nN\n"
1843                    "s/(.*)\\n/( /\n"
1844                    "s/;\\n/, /\n"
1845                    "s/;$/)/\n"  "}";
1846
1847     sed      = "/^mknod([ \t]*[^c]/{\nN\nN\nN\n"
1848                    "s/(.*)\\n/( /\n"
1849                    "s/;\\n/, /g\n"
1850                    "s/;$/)/\n"  "}";
1851
1852     sed      = "1,$s/\\([^A-Za-z]\\)path\\([^A-Za-z]\\)/\\1__path\\2/g";
1853     sed      = "1,$s/\\([^A-Za-z]\\)buf\\([^A-Za-z]\\)/\\1__buf\\2/g";
1854     sed      = "1,$s/\\([^A-Za-z]\\)fd\\([^A-Za-z]\\)/\\1__fd\\2/g";
1855     sed      = "1,$s/ret\\([^u]\\)/__ret\\1/g";
1856     sed      = "1,$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g";
1857     sed      = "1,$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g";
1858 };
1859 #endif
1860
1861 /*
1862  *  Add a prototyped declaration of mmap to <sys/mman.h>.
1863  */
1864 #ifdef SVR4
1865 fix = {
1866     hackname = svr4_proto_mmap;
1867     files    = sys/mman.h;
1868     select   = '^extern caddr_t mmap();$';
1869     sed = '/^extern caddr_t mmap();$/c' "\\\n"
1870           "#ifdef __STDC__\\\n"
1871           "extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\\\n"
1872           "#else /* !defined(__STDC__) */\\\n"
1873           "extern caddr_t mmap ();\\\n"
1874           "#endif /* !defined(__STDC__) */\\\n";
1875 };
1876 #endif
1877
1878 /*
1879  *  Add a #define of _SIGACTION_ into <sys/signal.h>.
1880  */
1881 #ifdef SVR4
1882 fix = {
1883     hackname = svr4_sigaction;
1884     files    = sys/signal.h;
1885     sed      = "/^struct sigaction {/i\\\n"
1886                "#define _SIGACTION_";
1887     sed      = 's/(void *(\*)())/(void (*)(int))/';
1888 };
1889 #endif
1890
1891 /*
1892  *  Put storage class at start of decl, to avoid warning.
1893  */
1894 #ifdef SVR4
1895 fix = {
1896     hackname = svr4_storage_class;
1897     files    = rpc/types.h;
1898     select   = 'const extern';
1899     sed      = 's/const extern/extern const/g';
1900 };
1901 #endif
1902
1903 /*
1904  *  Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
1905  *  in string.h on sysV68
1906  *  Correct the return type for strlen in string.h on Lynx.
1907  *  Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
1908  *  Add missing const for strdup on OSF/1 V3.0.
1909  *  On sysV88 layout is slightly different.
1910  */
1911 fix = {
1912     hackname = systypes;
1913     files  = "sys/types.h";
1914     files  = "stdlib.h";
1915     files  = "sys/stdtypes.h";
1916     files  = "stddef.h";
1917     files  = "memory.h";
1918     files  = "unistd.h";
1919     select = "typedef[ \t]+[a-z_][ \ta-z_]*[ \t]"
1920              "(size|ptrdiff|wchar)_t";
1921
1922       sed  = "/^[ \t]*\\*[ \t]*typedef unsigned int size_t;/N";
1923
1924       sed  = "s/^\\([ \t]*\\*[ \t]*typedef unsigned int size_t;\\n"
1925                "[ \t]*\\*\\/\\)/\\1\\\n"
1926              "#ifndef __SIZE_TYPE__\\\n"
1927              "#define __SIZE_TYPE__ long unsigned int\\\n"
1928              "#endif\\\n"
1929              "typedef __SIZE_TYPE__ size_t;\\\n/";
1930
1931       sed  = "/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]size_t/i\\\n"
1932                    "#ifndef __SIZE_TYPE__\\\n"
1933                    "#define __SIZE_TYPE__ long unsigned int\\\n"
1934                    "#endif\n";
1935
1936       sed  = "s/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]size_t/"
1937                "typedef __SIZE_TYPE__ size_t/";
1938
1939       sed  = "/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]ptrdiff_t/i\\\n"
1940                    "#ifndef __PTRDIFF_TYPE__\\\n"
1941                    "#define __PTRDIFF_TYPE__ long int\\\n"
1942                    "#endif\n";
1943
1944       sed  = "s/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]ptrdiff_t/"
1945                "typedef __PTRDIFF_TYPE__ ptrdiff_t/";
1946
1947       sed  = "/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]wchar_t/i\\\n"
1948                    "#ifndef __WCHAR_TYPE__\\\n"
1949                    "#define __WCHAR_TYPE__ int\\\n"
1950                    "#endif\\\n"
1951                    "#ifndef __cplusplus\n";
1952
1953       sed  = "/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]wchar_t/a\\\n"
1954                    "#endif\n";
1955
1956       sed  = "s/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]wchar_t/"
1957                "typedef __WCHAR_TYPE__ wchar_t/";
1958 };
1959
1960
1961 /*
1962  *  Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
1963  *  Also wrap protection around size_t for m88k-sysv3 systems.
1964  *  We use a funny name to ensure it follows 'systypes' fix.
1965  */
1966 fix = {
1967     hackname = systypes_for_aix;
1968     files    = sys/types.h;
1969     select   = "typedef[ \t][ \t]*[A-Za-z_][ \tA-Za-z_]*[ \t]size_t";
1970     bypass   = "_GCC_SIZE_T";
1971
1972     sed    = "/typedef[ \t][ \t]*[A-Za-z_][ \tA-Za-z_]*[ \t]size_t/i\\\n"
1973                  "#ifndef _GCC_SIZE_T\\\n"
1974                  "#define _GCC_SIZE_T\n";
1975
1976     sed    = "/typedef[ \t][ \t]*[A-Za-z_][ \tA-Za-z_]*[ \t]size_t/a\\\n"
1977                  "#endif\n";
1978 };
1979
1980
1981 /*
1982  *  if the #if says _cplusplus, not the double underscore __cplusplus
1983  *  that it should be
1984  */
1985 fix = {
1986     hackname = sysv68_string;
1987     files    = string.h;
1988
1989     sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
1990     sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
1991     sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
1992     sed = "/^extern char$/N";
1993     sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
1994     sed = "/^\tstrncmp(),$/N";
1995     sed = "s/^\\(\tstrncmp()\\),\\n\\(\tstrlen(),\\)$/\\1;\\\n"
1996           "extern unsigned int\\\n\\2/";
1997     sed = "/^extern int$/N";
1998     sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
1999 };
2000
2001
2002 /*
2003  *  Fix return type of exit and abort in <stdlib.h>
2004  *  Also wrap protection around size_t.
2005  */
2006 fix = {
2007     hackname = sysz_stdlib_for_sun;
2008     files    = stdlib.h;
2009
2010     sed   = "s/int\tabort/void\tabort/g";
2011     sed   = "s/int\tfree/void\tfree/g";
2012     sed   = "s/char[ \t]*\\*[ \t]*calloc/void \\*\tcalloc/g";
2013     sed   = "s/char[ \t]*\\*[ \t]*malloc/void \\*\tmalloc/g";
2014     sed   = "s/char[ \t]*\\*[ \t]*realloc/void \\*\trealloc/g";
2015     sed   = "s/int[ \t][ \t]*exit/void\texit/g";
2016
2017     sed   = "/typedef[ \ta-zA-Z_]*[ \t]size_t[ \t]*;/i\\\n"
2018                 "#ifndef _GCC_SIZE_T\\\n"
2019                 "#define _GCC_SIZE_T\n";
2020
2021     sed   = "/typedef[ \ta-zA-Z_]*[ \t]size_t[ \t]*;/a\\\n"
2022                 "#endif\n";
2023 };
2024
2025
2026 /*
2027  *  Fix this Sun file to avoid interfering with stddef.h.
2028  *  We use a funny name to ensure it follows 'systypes' fix.
2029  */
2030 fix = {
2031     hackname = sysz_stdtypes_for_sun;
2032     files = sys/stdtypes.h;
2033     sed   = "/[\t ]size_t.*;/i\\\n"
2034               "#ifndef _GCC_SIZE_T\\\n"
2035               "#define _GCC_SIZE_T\n";
2036
2037     sed   = "/[\t ]size_t.*;/a\\\n"
2038               "#endif\n";
2039
2040     sed   = "/[\t ]ptrdiff_t.*;/i\\\n"
2041               "#ifndef _GCC_PTRDIFF_T\\\n"
2042               "#define _GCC_PTRDIFF_T\n";
2043
2044     sed   = "/[\t ]ptrdiff_t.*;/a\\\n"
2045               "#endif\n";
2046
2047     sed   = "/[\t ]wchar_t.*;/i\\\n"
2048               "#ifndef _GCC_WCHAR_T\\\n"
2049               "#define _GCC_WCHAR_T\n";
2050
2051     sed   = "/[\t ]wchar_t.*;/a\\\n"
2052               "#endif\n";
2053 };
2054
2055
2056 /*
2057  *  Fix this file to avoid interfering with stddef.h,
2058  *  but don't mistakenly match ssize_t present in AIX for the ps/2,
2059  *  or typedefs which use (but do not set) size_t.
2060  */
2061 fix = {
2062     hackname = tinfo_cplusplus;
2063     files    = tinfo.h;
2064     sed      = "s/[ \t]_cplusplus/ __cplusplus/";
2065 };
2066
2067
2068 /*
2069  *  Cancel out ansi_compat.h on Ultrix.  Replace it with empty file.
2070  */
2071 fix = {
2072     hackname = ultrix_ansi_compat;
2073     files    = ansi_compat.h;
2074     select   = ULTRIX;
2075     sed      = "1i\\\n/* This file intentionally left blank. */\n";
2076     sed      = "1,$d";
2077 };
2078
2079
2080 /*
2081  * Ultrix V4.[35] puts the declaration of uname before the definition
2082  * of struct utsname, so the prototype (added by fixproto) causes havoc.
2083  */
2084 fix = {
2085     hackname = ultrix_fix_fixproto;
2086     files    = sys/utsname.h;
2087     select   = ULTRIX;
2088     sed      = "/^[ \t]*extern[ \t]*int[ \t]*uname();$/i\\\n"
2089                "struct utsname;\n";
2090 };
2091
2092
2093 /*
2094  *  parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
2095  *  also get rid of bogus inline definitions in HP-UX 8.0
2096  */
2097 fix = {
2098     hackname = ultrix_atof_param;
2099     files    = math.h;
2100
2101     sed = "s@atof(\\([ \t]*char[ \t]*\\*[^)]*\\))@atof(const \\1)@";
2102     sed = "s@inline int abs(int [a-z][a-z]*) {.*}@extern \"C\" int abs(int);@";
2103     sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2104     sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2105     sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2106 };
2107
2108
2109 /*
2110  *  parameters not const on DECstation Ultrix V4.0 and OSF/1.
2111  */
2112 fix = {
2113     hackname = ultrix_const;
2114     files    = stdio.h;
2115
2116     sed   = 's@perror( char \*__s );@perror( const char *__s );@';
2117     sed   = 's@fputs( char \*__s,@fputs( const char *__s,@';
2118     sed   = 's@fopen( char \*__filename, char \*__type );@'
2119               'fopen( const char *__filename, const char *__type );@';
2120     sed   = 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@';
2121     sed   = 's@fscanf( FILE \*__stream, char \*__format,@'
2122               'fscanf( FILE *__stream, const char *__format,@';
2123     sed   = 's@scanf( char \*__format,@scanf( const char *__format,@';
2124     sed   = 's@sscanf( char \*__s, char \*__format,@'
2125               'sscanf( const char *__s, const char *__format,@';
2126     sed   = 's@popen(char \*, char \*);@popen(const char *, const char *);@';
2127     sed   = 's@tempnam(char\*,char\*);@tempnam(const char*,const char*);@';
2128 };
2129
2130
2131 /*
2132  *  Check for bad #ifdef line (in Ultrix 4.1)
2133  */
2134 fix = {
2135     hackname = ultrix_ifdef;
2136     select   = "#ifdef KERNEL";
2137     files    = sys/file.h;
2138     sed      = "s/#ifdef KERNEL/#if defined(KERNEL)/";
2139 };
2140
2141
2142 /*
2143  *  Avoid nested comments on Ultrix 4.3.
2144  */
2145 fix = {
2146     hackname = ultrix_nested_cmnt;
2147     files    = rpc/svc.h;
2148     sed      = "s@^\\( \\*\tint protocol;  \\)/\\*@\\1*/ /*@";
2149 };
2150
2151
2152 /*
2153  *  Check for superfluous `static' (in Ultrix 4.2)
2154  *  On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
2155  */
2156 fix = {
2157     hackname = ultrix_static;
2158     files  = machine/cpu.h;
2159     select = '#include "r[34]_cpu';
2160     sed    = "s/^static struct tlb_pid_state/struct tlb_pid_state/";
2161     sed    = 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/';
2162     sed    = 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/';
2163 };
2164
2165
2166 /*
2167  *  Fix multiple defines for NULL
2168  */
2169 fix = {
2170     hackname = undefine_null;
2171     select = "^#[ \t]*define[ \t]*[ \t]NULL[ \t]";
2172     bypass = "#[ \t]*(ifn|un)def[ \t]*[ \t]NULL($|[ \t])";
2173     sed    = "/^#[ \t]*define[ \t][ \t]*NULL[ \t]/i\\\n"
2174                 "#undef NULL\n";
2175 };
2176
2177
2178 /*
2179  *  Fix definitions of macros used by va-i960.h in VxWorks header file.
2180  */
2181 fix = {
2182     hackname = va_i960_macro;
2183     files    = arch/i960/archI960.h;
2184     select   = "__(vsiz|vali|vpad|alignof__)";
2185     sed = "s/__vsiz/__vxvsiz/";
2186     sed = "s/__vali/__vxvali/";
2187     sed = "s/__vpad/__vxvpad/";
2188     sed = "s/__alignof__/__vxalignof__/";
2189 };
2190
2191
2192 /*
2193  *  AIX headers define NULL to be cast to a void pointer,
2194  *  which is illegal in ANSI C++.
2195  */
2196 fix = {
2197     hackname = void_null;
2198     files    = curses.h;
2199     files    = dbm.h;
2200     files    = locale.h;
2201     files    = stdio.h;
2202     files    = stdlib.h;
2203     files    = string.h;
2204     files    = time.h;
2205     files    = unistd.h;
2206     files    = sys/dir.h;
2207     files    = sys/param.h;
2208     files    = sys/types.h;
2209     select   = "#[ \t]*define[ \t][ \t]*NULL[ \t].*void";
2210     sed      = "s/^#[ \t]*define[ \t]*NULL[ \t]*((void[ \t]*\\*)0)"
2211                 "/#define NULL 0/";
2212 };
2213
2214
2215 /*
2216  *  Make VxWorks header which is almost gcc ready fully gcc ready.
2217  */
2218 fix = {
2219     hackname = vxworks_gcc_problem;
2220     files    = types/vxTypesBase.h;
2221     select   = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
2222
2223     sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
2224           "#if 1/";
2225
2226     sed = "/[ \t]size_t/i\\\n"
2227         "#ifndef _GCC_SIZE_T\\\n"
2228         "#define _GCC_SIZE_T\n";
2229
2230     sed = "/[ \t]size_t/a\\\n"
2231         "#endif\n";
2232
2233     sed = "/[ \t]ptrdiff_t/i\\\n"
2234         "#ifndef _GCC_PTRDIFF_T\\\n"
2235         "#define _GCC_PTRDIFF_T\n";
2236
2237     sed = "/[ \t]ptrdiff_t/a\\\n"
2238         "#endif\n";
2239
2240     sed = "/[ \t]wchar_t/i\\\n"
2241         "#ifndef _GCC_WCHAR_T\\\n"
2242         "#define _GCC_WCHAR_T\n";
2243
2244     sed = "/[ \t]wchar_t/a\\\n"
2245         "#endif\n";
2246 };
2247
2248
2249 /*
2250  *  Fix VxWorks <time.h> to not require including <vxTypes.h>.
2251  */
2252 fix = {
2253     hackname = vxworks_needs_vxtypes;
2254     files    = time.h;
2255     select   = "uint_t[ \t][ \t]*_clocks_per_sec";
2256     sed      = "s/uint_t/unsigned int/";
2257 };
2258
2259
2260 /*
2261  *  Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
2262  */
2263 fix = {
2264     hackname = vxworks_needs_vxworks;
2265     files    = sys/stat.h;
2266     test     = " -r types/vxTypesOld.h";
2267     test     = " -n \"`egrep '#include' $file`\"";
2268     test     = " -n \"`egrep ULONG $file`\"";
2269     select   = "#[ \t]define[ \t][ \t]*__INCstath";
2270
2271     sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
2272           "#include <types/vxTypesOld.h>\n";
2273 };
2274
2275
2276 /*
2277  *  Another bad dependency in VxWorks 5.2 <time.h>.
2278  */
2279 fix = {
2280     hackname = vxworks_time;
2281     files    = time.h;
2282     select   = "VOIDFUNCPTR";
2283     test     = " -r vxWorks.h";
2284     sed      = "/VOIDFUNCPTR/i\\\n"
2285                "#ifndef __gcc_VOIDFUNCPTR_defined\\\n"
2286                "#ifdef __cplusplus\\\n"
2287                "typedef void (*__gcc_VOIDFUNCPTR) (...);\\\n"
2288                "#else\\\n"
2289                "typedef void (*__gcc_VOIDFUNCPTR) ();\\\n"
2290                "#endif\\\n"
2291                "#define __gcc_VOIDFUNCPTR_defined\\\n"
2292                "#endif\n";
2293
2294     sed      = "s/VOIDFUNCPTR/__gcc_VOIDFUNCPTR/g";
2295 };
2296
2297
2298 /*
2299  *  There are several name conflicts with C++ reserved words in X11 header
2300  *  files.  These are fixed in some versions, so don't do the fixes if
2301  *  we find __cplusplus in the file.  These were found on the RS/6000.
2302  */
2303 fix = {
2304     hackname = x11_class;
2305     files    = X11/ShellP.h;
2306     bypass   = __cplusplus;
2307     sed      = "/char \\*class;/i\\\n"
2308                    "#ifdef __cplusplus\\\n"
2309                    "\tchar *c_class;\\\n"
2310                    "#else\n";
2311     sed      = "/char \\*class;/a\\\n"
2312                    "#endif\n";
2313 };
2314
2315
2316 /*
2317  *  class in Xm/BaseClassI.h
2318  */
2319 fix = {
2320     hackname = x11_class_usage;
2321     files    = Xm/BaseClassI.h;
2322     bypass   = "__cplusplus";
2323     sed      = "s/ class[)]/ c_class)/g";
2324 };
2325
2326
2327 /*
2328  *  new in Xm/Traversal.h
2329  */
2330 fix = {
2331     hackname = x11_new;
2332     files    = Xm/Traversal.h;
2333     bypass   = __cplusplus;
2334
2335     sed      = "/Widget\told, new;/i\\\n"
2336                    "#ifdef __cplusplus\\\n"
2337                    "\tWidget\told, c_new;\\\n"
2338                    "#else\n";
2339
2340     sed      = "/Widget\told, new;/a\\\n"
2341                    "#endif\n";
2342
2343     sed      = "s/Widget new,/Widget c_new,/g";
2344 };
2345
2346
2347 /*
2348  *  Incorrect sprintf declaration in X11/Xmu.h
2349  */
2350 fix = {
2351     hackname = x11_sprintf;
2352     files    = X11*/Xmu.h;
2353     sed      = "s,^extern char \\*\tsprintf();$,#ifndef __STDC__\\\n"
2354                "extern char *\tsprintf();\\\n"
2355                "#endif /* !defined __STDC__ */,";
2356 };
2357
2358
2359 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2360  *
2361  *  UNDO BROKEN FIXES
2362  *
2363  *  We sure do hope that broken fixes and needed fixes are never
2364  *  applied to the same file!!  :-}
2365  */
2366
2367 /*
2368  *  Purge some HP-UX 11 files that are only borken after they are "fixed".
2369  */
2370 fix = {
2371     hackname = zzz_ki_iface;
2372     files    = sys/ki_iface.h;
2373     select   = 'These definitions are for HP Internal developers';
2374     shell    =
2375          "echo \"Removing incorrect fix to <$file>\" >&2\n"
2376          "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n"
2377          "cat > /dev/null";
2378 };
2379
2380
2381 /*
2382  *  Purge some HP-UX 11 files that are only borken after they are "fixed".
2383  */
2384 fix = {
2385     hackname = zzz_ki;
2386     files    = sys/ki.h;
2387     select   = '11.00 HP-UX LP64';
2388     shell    =
2389          "echo \"Removing incorrect fix to <$file>\" >&2\n"
2390          "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n"
2391          "cat > /dev/null";
2392 };
2393
2394
2395 /*
2396  *  Purge some HP-UX 11 files that are only borken after they are "fixed".
2397  */
2398 fix = {
2399     hackname = zzz_ki_calls;
2400     files    = sys/ki_calls.h;
2401     select   = 'kthread_create_caller_t';
2402     shell    =
2403          "echo \"Removing incorrect fix to <$file>\" >&2\n"
2404          "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n"
2405          "cat > /dev/null";
2406 };
2407
2408
2409 /*
2410  *  Purge some HP-UX 11 files that are only borken after they are "fixed".
2411  */
2412 fix = {
2413     hackname = zzz_ki_defs;
2414     files    = sys/ki_defs.h;
2415     select   = 'Kernel Instrumentation Definitions';
2416     shell    =
2417          "echo \"Removing incorrect fix to <$file>\" >&2\n"
2418          "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n"
2419          "cat > /dev/null";
2420 };
2421
2422
2423 /*
2424  *  This file on SunOS 4 has a very large macro.  When the sed loop
2425  *  tries pull it in, it overflows the pattern space size of the SunOS
2426  *  sed (GNU sed does not have this problem).  Since the file does not
2427  *  require fixing, we remove it from the fixed directory.
2428  */
2429 fix = {
2430     hackname = zzz_bad_fixes;
2431     files    = sundev/ipi_error.h;
2432     /* shouldn't there be a select expression here??? */
2433     shell    =
2434          "echo \"Removing incorrect fix to <$file>\" >&2\n"
2435          "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n"
2436          "cat > /dev/null";
2437 };
2438
2439
2440 /*
2441  *  Purge some HP-UX 11 files that are only borken after they are "fixed".
2442  */
2443 fix = {
2444     hackname = zzz_time;
2445     files    = sys/time.h;
2446     select   = '11.0 and later representation of ki time';
2447     shell    =
2448          "echo \"Removing incorrect fix to <$file>\" >&2\n"
2449          "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n"
2450          "cat > /dev/null";
2451 };
2452
2453
2454 /*EOF*/