OSDN Git Service

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