OSDN Git Service

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