OSDN Git Service

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