OSDN Git Service

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