OSDN Git Service

added several "test_text" attributes; changed several fixes to use `c_fix = format'
[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  */
785 fix = {
786     hackname = broken_cabs;
787     files  = "math.h";
788     select = '^extern double cabs';
789     sed    = '/^extern double cabs();/d';
790     sed    = '/^extern double cabs(struct dbl_hypot);/d';
791     test_text = "#ifdef __STDC__\n"
792                 "extern double cabs(struct dbl_hypot);\n"
793                 "#else\n"
794                 "extern double cabs();\n"
795                 "#endif";
796 };
797
798
799 /*
800  *  Fix various macros used to define ioctl numbers.
801  *  The traditional syntax was:
802  *
803  *    #define _CTRL(n, x) (('n'<<8)+x)
804  *    #define TCTRLCFOO _CTRL(T, 1)
805  *
806  *  but this does not work with the C standard, which disallows macro
807  *  expansion inside strings.  We have to rewrite it thus:
808  *
809  *    #define _CTRL(n, x) ((n<<8)+x)
810  *    #define TCTRLCFOO  _CTRL('T', 1)
811  *
812  *  The select expressions match too much, but the c_fix code is cautious.
813  *
814  *  CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
815  */
816 fix = {
817     hackname  = ctrl_quotes_def;
818     select    = "define[ \t]+[A-Z0-9_]+CTRL\\(([a-zA-Z]).*'\\1'";
819     c_fix     = char_macro_def;
820     c_fix_arg = "CTRL";
821     test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)";
822 };
823
824 fix = {
825     hackname  = ctrl_quotes_use;
826     select    = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
827     c_fix     = char_macro_use;
828     c_fix_arg = "CTRL";
829     test_text = "#define TIOCFOO BSD43_CTRL(T, 1)";
830 };
831
832
833 /*
834  *  sys/mman.h on HP/UX is not C++ ready,
835  *  even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
836  *
837  *  rpc/types.h on OSF1/2.0 is not C++ ready, even though NO_IMPLICIT_EXTERN_C
838  *  is defined for the alpha.  The problem is the declaration of malloc.
839  */
840 fix = {
841     hackname = cxx_unready;
842     files    = sys/mman.h;
843     files    = rpc/types.h;
844     select   = '[^#]+malloc.*;';  /* Catch any form of declaration
845                                      not within a macro.  */
846     bypass   = '"C"|__BEGIN_DECLS';
847
848     c_fix     = wrap;
849     c_fix_arg = "#ifdef __cplusplus\n"
850                 "extern \"C\" {\n"
851                 "#endif\n";
852     c_fix_arg = "#ifdef __cplusplus\n"
853                 "}\n"
854                 "#endif\n";
855     test_text = "extern void* malloc( size_t );";
856 };
857
858
859 /*
860  *  Fix <c_asm.h> on Digital UNIX V4.0:
861  *  It contains a prototype for a DEC C internal asm() function,
862  *  clashing with gcc's asm keyword.  So protect this with __DECC.
863  */
864 fix = {
865     hackname = dec_intern_asm;
866     files    = c_asm.h;
867     sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
868     sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
869           "#endif\n";
870     test_text =
871     "float fasm {\n"
872     "    ... asm stuff ...\n"
873     "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
874 };
875
876
877 /*
878  * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
879  */
880 fix = {
881     hackname = ecd_cursor;
882     files  = "sunwindow/win_lock.h";
883     files  = "sunwindow/win_cursor.h";
884     sed    = "s/ecd.cursor/ecd_cursor/";
885     test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
886 };
887
888
889 /*
890  *  fix-header doesn't fix fabs' prototype, and I have no idea why.
891  */
892 fix = {
893     hackname  = fix_header_breakage;
894     mach      = "m88k-motorola-sysv3*";
895     files     = "math.h";
896
897     select    = 'extern double floor\(\), ceil\(\), fmod\(\), fabs\(\);';
898     c_fix     = format;
899     c_fix_arg =
900     'extern double floor(), ceil(), fmod(), fabs _PARAMS((double));';
901     test_text = 'extern double floor(), ceil(), fmod(), fabs();';
902 };
903
904
905 /*
906  *  Fix HP's use of ../machine/inline.h to refer to
907  *    /usr/include/machine/inline.h
908  */
909 fix = {
910     hackname = hp_inline;
911     files  = sys/spinlock.h;
912     select = 'include.*"\.\./machine/';
913     sed    = "s,\"../machine/inline.h\",<machine/inline.h>,";
914     sed    = "s,\"../machine/psl.h\",<machine/psl.h>,";
915     test_text = '# include "../machine/inline.h"' "\n"
916                 '# include "../machine/dontfix.h"' "\n"
917                 '# include "../machine/psl.h"';
918 };
919
920
921 /*
922  *  Check for (...) in C++ code in HP/UX sys/file.h.
923  */
924 fix = {
925     hackname  = hp_sysfile;
926     files     = sys/file.h;
927     select    = "HPUX_SOURCE";
928     sed       = 's/(\.\.\.)/(struct file *, ...)/';
929     test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
930 };
931
932
933 /*
934  *  get rid of bogus inline definitions in HP-UX 8.0
935  */
936 fix = {
937     hackname = hpux8_bogus_inlines;
938     files    = math.h;
939     select   = inline;
940     sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
941            "@extern \"C\" int abs(int);@";
942     sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
943     sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
944     sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
945     test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
946                 "inline double sqr(double v) { return v**0.5; }";
947 };
948
949
950 /* 
951  * In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition 
952  * of UINT32_C has undefined behavior according to ISO/ANSI:
953  * the arguments to __CONCAT__ are not macro expanded before the
954  * concatination happens so the trailing ')' in the first argument
955  * is concatinated with the 'l' in the second argument creating an
956  * invalid pp token.  The behavior of invalid pp tokens is undefined.
957  * GCC does not handle these invalid tokens the way the HP compiler does.
958  * This problem will potentially occur anytime macros are used in the
959  * arguments to __CONCAT__.  A general solution to this problem would be to 
960  * insert another layer of macro between __CONCAT__ and its use
961  * in UINT32_C.  An example of this solution can be found in the C standard.
962  * A more specific solution, the one used here, is to change the UINT32_C
963  * macro to not used macros in the arguments to __CONCAT__.
964  */
965 fix = {
966     hackname = hpux11_uint32_c;
967     files    = inttypes.h;
968     select   = "^#define UINT32_C\\(__c\\)[ \t]*"
969                          "__CONCAT__\\(__CONCAT_U__\\(__c\\),l\\)";
970     c_fix    = format;
971     c_fix_arg = '#define UINT32_C(__c) __CONCAT__(__c,ul)';
972     test_text =
973     "#define CONCAT_U__(__c)\t__CONCAT__(__c,u)\n"
974     "#define UINT32_C(__c)\t__CONCAT__(__CONCAT_U__(__c),l)";
975 };
976
977 /*
978  *  On Interactive Unix 2.2, certain traditional Unix definitions
979  *  (notably getc and putc in stdio.h) are omitted if __STDC__ is
980  *  defined, not just if _POSIX_SOURCE is defined.  This makes it
981  *  impossible to compile any nontrivial program except with -posix.
982  */
983 fix = {
984     hackname = isc_omits_with_stdc;
985
986     files     = "stdio.h";
987     files     = "math.h";
988     files     = "ctype.h";
989     files     = "sys/limits.h";
990     files     = "sys/fcntl.h";
991     files     = "sys/dirent.h";
992
993     select    = '!defined\(__STDC__\) && !defined\(_POSIX_SOURCE\)';
994     c_fix     = format;
995     c_fix_arg = '!defined(_POSIX_SOURCE)';
996     test_text = "#if !defined(__STDC__) && !defined(_POSIX_SOURCE) /* ? ! */"
997                 "\nint foo;\n#endif";
998 };
999
1000 /*
1001  *  Fix various macros used to define ioctl numbers.
1002  *  The traditional syntax was:
1003  *
1004  *    #define _IO(n, x) (('n'<<8)+x)
1005  *    #define TIOCFOO _IO(T, 1)
1006  *
1007  *  but this does not work with the C standard, which disallows macro
1008  *  expansion inside strings.  We have to rewrite it thus:
1009  *
1010  *    #define _IO(n, x) ((n<<8)+x)
1011  *    #define TIOCFOO  _IO('T', 1)
1012  *
1013  *  The select expressions match too much, but the c_fix code is cautious.
1014  *
1015  *  _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
1016  */
1017 fix = {
1018     hackname  = io_quotes_def;
1019     select    = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\(([a-zA-Z]).*'\\1'";
1020     c_fix     = char_macro_def;
1021     c_fix_arg = "IO";
1022     test_text = "#define BSD43__IOWR(n, x) (('n'<<8)+x)";
1023 };
1024
1025 fix = {
1026     hackname  = io_quotes_use;
1027     select    = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
1028                 "\\( *[^,']";
1029     c_fix     = char_macro_use;
1030     c_fix_arg = "IO";
1031     test_text = "#define TIOCFOO BSD43__IOWR(T, 1)";
1032 };
1033
1034
1035 /*
1036  *  HPUX 10.x sys/param.h defines MAXINT which clashes with values.h
1037  */
1038 fix = {
1039     hackname  = hpux_maxint;
1040     files     = sys/param.h;
1041     select    = "^#[ \t]*define[ \t]*MAXINT[ \t]";
1042     sed      = "/^#[ \t]*define[ \t]*MAXINT[ \t]/i\\\n"
1043                "#ifndef MAXINT\n";
1044
1045     sed      = "/^#[ \t]*define[ \t]*MAXINT[ \t]/a\\\n"
1046                "#endif\n";
1047     test_text = '#define MAXINT 0x7FFFFFFF';
1048 };
1049
1050
1051 /*
1052  *  Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
1053  */
1054 fix = {
1055     hackname = hpux_systime;
1056     files    = sys/time.h;
1057     select   = "^extern struct sigevent;";
1058     sed      = "s/^extern struct sigevent;/struct sigevent;/";
1059     test_text = 'extern struct sigevent;';
1060 };
1061
1062
1063 /*
1064  *  Check for missing ';' in struct
1065  */
1066 fix = {
1067     hackname = ip_missing_semi;
1068     files    = netinet/ip.h;
1069     select   = "}$";
1070     sed      = "/^struct/,/^};/s/}$/};/";
1071     test_text=
1072     "struct mumble {\n"
1073     "  union {\n"
1074     "    int x;\n"
1075     "  }\n"
1076     "}; /* mumbled struct */\n";
1077 };
1078
1079
1080 /*
1081  *  IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction
1082  *  that causes the assembly preprocessor to complain about an
1083  *  unterminated character constant.
1084  */
1085 fix = {
1086     hackname  = irix_asm_apostrophe;
1087     files     = sys/asm.h;
1088
1089     select    = "^[ \t]*#.*[Ww]e're";
1090     c_fix     = format;
1091     c_fix_arg = "%1 are";
1092     c_fix_arg = "^([ \t]*#.*[Ww]e)'re";
1093     test_text = "\t# and we're on vacation";
1094 };
1095
1096
1097 /*
1098  *  Some IRIX header files contain the string "//"
1099  */
1100 fix = {
1101     hackname = irix_multiline_cmnt;
1102     files    = sys/types.h;
1103
1104     sed   = "s@type of the result@type of the result */@";
1105     sed   = "s@of the sizeof@/* of the sizeof@";
1106     test_text =
1107     "/* we check the type of the result\n"
1108     "// of the sizeof something.  This is a bad test :-( */";
1109 };
1110
1111
1112 /*
1113  * Fixing ISC fmod declaration
1114  */
1115 fix = {
1116     hackname  = isc_fmod;
1117     files     = math.h;
1118     select    = 'fmod\(double\)';
1119     c_fix     = format;
1120     c_fix_arg = "fmod(double, double)";
1121     test_text = "extern double  fmod(double);";
1122 };
1123
1124
1125 /*
1126  * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
1127  * use / * * / to concatenate tokens.
1128  */
1129 fix = {
1130     hackname = kandr_concat;
1131     files  = "sparc/asm_linkage.h";
1132     files  = "sun3/asm_linkage.h";
1133     files  = "sun3x/asm_linkage.h";
1134     files  = "sun4/asm_linkage.h";
1135     files  = "sun4c/asm_linkage.h";
1136     files  = "sun4m/asm_linkage.h";
1137     files  = "sun4c/debug/asm_linkage.h";
1138     files  = "sun4m/debug/asm_linkage.h";
1139     files  = "arm/as_support.h";
1140     files  = "arm/mc_type.h";
1141     files  = "arm/xcb.h";
1142     files  = "dev/chardefmac.h";
1143     files  = "dev/ps_irq.h";
1144     files  = "dev/screen.h";
1145     files  = "dev/scsi.h";
1146     files  = "sys/tty.h";
1147     files  = "Xm.acorn/XmP.h";
1148     files  = bsd43/bsd43_.h;
1149     select = '/\*\*/';
1150     c_fix     = format;
1151     c_fix_arg = '##';
1152     test_text = "#define __CONCAT__(a,b) a/**/b";
1153 };
1154
1155
1156 /*
1157  *  In limits.h, put #ifndefs around things that are supposed to be defined
1158  *  in float.h to avoid redefinition errors if float.h is included first.
1159  *  On HP/UX this patch does not work, because on HP/UX limits.h uses
1160  *  multi line comments and the inserted #endif winds up inside the
1161  *  comment.  Fortunately, HP/UX already uses #ifndefs in limits.h; if
1162  *  we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1163  *  are there, and we do not add them ourselves.
1164  */
1165 fix = {
1166     hackname = limits_ifndefs;
1167     files  = "limits.h";
1168     files  = "sys/limits.h";
1169     bypass = "ifndef[ \t]+FLT_MIN";
1170
1171     c_fix     = format;
1172     c_fix_arg = "#ifndef %1\n%0#endif\n";
1173     c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+"
1174                 "((FLT|DBL)_(MIN|MAX|DIG))"
1175                 "[ \t][^\n]*\n";
1176     test_text = " #\tdefine\tDBL_DIG \t 0  /* somthin' */";
1177 };
1178
1179
1180 /*
1181  *  Delete the '#define void int' line from curses.h on Lynx
1182  */
1183 fix = {
1184     hackname  = lynx_void_int;
1185     files     = curses.h;
1186     select    = "#[ \t]*define[ \t]+void[ \t]+int[ \t]*";
1187     c_fix     = format;
1188     c_fix_arg = "";
1189     test_text = "# define\tvoid\tint \t/* curses foiled again */";
1190 };
1191
1192
1193 /*
1194  *  Fix fcntl prototype in fcntl.h on LynxOS.
1195  */
1196 fix = {
1197     hackname  = lynxos_fcntl_proto;
1198     files     = fcntl.h;
1199     select    = "fcntl[ \t]*" '\(int, int, int\)';
1200     c_fix     = format;
1201     c_fix_arg = '%1...)';
1202     c_fix_arg = "(fcntl[ \t]*" '\(int, int, )int\)';
1203     test_text = "extern int fcntl(int, int, int);";
1204 };
1205
1206
1207 /*
1208  *  libm.a on m88k-motorola-sysv3 contains a stupid optimization for
1209  *  function hypot(), which returns the second argument without even
1210  *  looking at its value, if the other is 0.0.
1211  */
1212 fix = {
1213     hackname  = m88k_bad_hypot_opt;
1214     mach      = "m88k-motorola-sysv3*";
1215     files     = "math.h";
1216     select    = "^extern double hypot\\(\\);\n";
1217     c_fix     = format;
1218     c_fix_arg = "%0"
1219           "/* Workaround a stupid Motorola optimization if one\n"
1220           "   of x or y is 0.0 and the other is negative!  */\n"
1221           "#ifdef __STDC__\n"
1222           "static __inline__ double fake_hypot (double x, double y)\n"
1223           "#else\n"
1224           "static __inline__ double fake_hypot (x, y)\n"
1225           "\tdouble x, y;\n"
1226           "#endif\n"
1227           "{\n"
1228           "\treturn fabs (hypot (x, y));\n"
1229           "}\n"
1230           "#define hypot\tfake_hypot\n";
1231     test_text = "extern double hypot();";
1232 };
1233
1234
1235 /*
1236  *  Fix incorrect S_IF* definitions on m88k-sysv3.
1237  */
1238 fix = {
1239     hackname = m88k_bad_s_if;
1240     mach     = "m88k-*-sysv3*";
1241     files    = sys/stat.h;
1242     select   = "#define[ \t]+S_IS[A-Z]+\\(m\\)[ \t]+\\(m[ \t]*&";
1243
1244     c_fix     = format;
1245     c_fix_arg = '#define %1(m) (((m) & S_IFMT) == %2)';
1246     c_fix_arg = "#define[ \t]+(S_IS[A-Z]+)\\(m\\)[ \t]+"
1247                   "\\(m[ \t]*&[ \t]*"
1248                     "(S_IF[A-Z][A-Z][A-Z]+|0[0-9]+)"
1249                   "[ \t]*\\)";
1250     test_text = '#define S_ISREG(m) (m & S_IFREG) /* is regular? */';
1251 };
1252
1253
1254 /*
1255  * Put cpp wrappers around these include files to avoid redeclaration
1256  * errors during multiple inclusion on m88k-tektronix-sysv3.
1257  */
1258 fix = {
1259     hackname = m88k_multi_incl;
1260     mach     = "m88k-tektronix-sysv3*";
1261     files    = "time.h";
1262     bypass   = "#ifndef";
1263     shell    =
1264       "echo Fixing $file, to protect against multiple inclusion. >&2
1265       cpp_wrapper=`echo $file | sed -e 's,\\.,_,g' -e 's,/,_,g'`
1266       echo \"#ifndef __GCC_GOT_${cpp_wrapper}_\"
1267       echo \"#define __GCC_GOT_${cpp_wrapper}_\"
1268       cat
1269       echo \"#endif /* ! __GCC_GOT_${cpp_wrapper}_ */\"";
1270 };
1271
1272
1273 /*
1274  * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
1275  */
1276 fix = {
1277     hackname = machine_ansi_h_va_list;
1278     files    = machine/ansi.h;
1279     select   = '_BSD_VA_LIST_';
1280     bypass   = '__builtin_va_list';
1281
1282     sed      = "s/\\(_BSD_VA_LIST_[ \t][ \t]*\\).*$/\\1__builtin_va_list/";
1283 };
1284
1285
1286 /*
1287  *  Fix non-ansi machine name defines
1288  */
1289 fix = {
1290     hackname  = machine_name;
1291     c_test    = machine_name;
1292     c_fix     = machine_name;
1293     test_text = "#ifdef i386 /* no uniform machine_name test, so\n"
1294                 "               this only works on i?86 machines */";
1295 };
1296
1297
1298 /*
1299  *  Some math.h files define struct exception, which conflicts with
1300  *  the class exception defined in the C++ file std/stdexcept.h.  We
1301  *  redefine it to __math_exception.  This is not a great fix, but I
1302  *  haven't been able to think of anything better.
1303  *  Note that we have to put the #ifdef/#endif blocks at beginning
1304  *  and end of file, because fixproto runs after us and may insert
1305  *  additional references to struct exception.
1306  */
1307 fix = {
1308     hackname  = math_exception;
1309     files     = math.h;
1310     select    = "struct exception";
1311     bypass    = "We have a problem when using C\\+\\+";
1312     c_fix     = wrap;
1313
1314     c_fix_arg = "#ifdef __cplusplus\n"
1315                 "#define exception __math_exception\n"
1316                 "#endif\n";
1317
1318     c_fix_arg = "#ifdef __cplusplus\n"
1319                 "#undef exception\n"
1320                 "#endif\n";
1321
1322     test_text = "typedef struct exception t_math_exception;";
1323 };
1324
1325 fix = {
1326     hackname = math_huge_val_from_dbl_max;
1327     files    = math.h;
1328     /*
1329      * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
1330      * in math.h, this fix applies.
1331      */
1332     select   = "define[ \t]*HUGE_VAL[ \t]*DBL_MAX";
1333     bypass   = "define[ \t]*DBL_MAX";
1334
1335     shell    =
1336     /*
1337      *  See if we have a definition for DBL_MAX in float.h.
1338      *  If we do, we will replace the one in math.h with that one.
1339      */
1340
1341     "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
1342                 "2>/dev/null`\n\n"
1343
1344     "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
1345     "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
1346                         "s/DBL_MAX/'\"$dbl_max_def/\"\n"
1347     "\telse cat\n"
1348     "\tfi";
1349 };
1350
1351 /*
1352  * In any case, put #ifndef .. #endif around #define HUGE_VAL in math.h.
1353  */
1354 fix = {
1355     hackname = math_huge_val_ifndef;
1356     files    = math/math.h;
1357     select   = "define[ \t]*HUGE_VAL";
1358
1359     sed      = "/define[ \t]HUGE_VAL[ \t]/i\\\n#ifndef HUGE_VAL\n";
1360     sed      = "/define[ \t]HUGE_VAL[ \t]/a\\\n#endif\n";
1361 };
1362
1363
1364 /*
1365  * Fix nested comments in Motorola's <limits.h> and <sys/limits.h>
1366  */
1367 fix = {
1368     hackname = nested_motorola;
1369     mach     = "m68k-motorola-sysv*";
1370     files    = limits.h;
1371     files    = sys/limits.h;
1372     sed = "s@^\\(#undef[ \t][ \t]*PIPE_BUF[ \t]*"
1373                    "/\\* max # bytes atomic in write to a\\)$@\\1 */@";
1374     sed = "s@\\(/\\*#define\tHUGE_VAL\t3.[0-9e+]* \\)"
1375           "\\(/\\*error value returned by Math lib\\*/\\)$@\\1*/ \\2@";
1376 };
1377
1378
1379 /*
1380  * Fixing nested comments in ISC <sys/limits.h>
1381  */
1382 fix = {
1383     hackname = nested_sys_limits;
1384     files  = sys/limits.h;
1385     select = CHILD_MAX;
1386     sed    = "/CHILD_MAX/s,/\\* Max, Max,";
1387     sed    = "/OPEN_MAX/s,/\\* Max, Max,";
1388     test_text = "/*\n#define CHILD_MAX 20 /* Max, Max, ... */ /*\n"
1389                 "#define OPEN_MAX  20 /* Max, Max, ... */\n";
1390 };
1391
1392 /*
1393  *  nested comment
1394  */
1395 fix = {
1396     hackname  = nested_auth_des;
1397     files     = rpc/rpc.h;
1398     select    = '(/\*.*rpc/auth_des\.h>.*)/\*';
1399     c_fix     = format;
1400     c_fix_arg = "%1*/ /*";
1401     test_text = "/*#include <rpc/auth_des.h> /* skip this */";
1402 };
1403
1404
1405 /*
1406  *  Avoid nested comments on Ultrix 4.3.
1407  */
1408 fix = {
1409     hackname = nested_ultrix;
1410     files    = rpc/svc.h;
1411     sed      = "s@^\\( \\*\tint protocol;  \\)/\\*@\\1*/ /*@";
1412 };
1413
1414
1415 /*
1416  *  fix bogus recursive stdlib.h in NEWS-OS 4.0C
1417  */
1418 fix = {
1419     hackname = news_os_recursion;
1420     files    = stdlib.h;
1421     select   = "#include <stdlib.h>";
1422     sed      = "/^#include <stdlib.h>/i\\\n"
1423                     "#ifdef BOGUS_RECURSION\n";
1424     sed      = "/^#include <stdlib.h>/a\\\n"
1425                     "#endif\n";
1426 };
1427
1428
1429 /*
1430  *  NeXT 3.2 adds const prefix to some math functions.
1431  *  These conflict with the built-in functions.
1432  */
1433 fix = {
1434     hackname = next_math_prefix;
1435     files    = ansi/math.h;
1436     select   = "^extern.*double.*__const__.*";
1437
1438     sed = "/^extern.*double.*__const__.*sqrt(/s/__const__//";
1439     sed = "/^extern.*double.*__const__.*fabs(/s/__const__//";
1440     sed = "/^extern.*double.*__const__.*cos(/s/__const__//";
1441     sed = "/^extern.*double.*__const__.*hypot(/s/__const__//";
1442     sed = "/^extern.*double.*__const__.*sin(/s/__const__//";
1443 };
1444
1445
1446 /*
1447  *  NeXT 3.2 uses the word "template" as a parameter for some
1448  *  functions. GCC reports an invalid use of a reserved key word
1449  *  with the built-in functions. NeXT 3.2 includes the keyword
1450  *  volatile in the prototype for abort(). This conflicts with
1451  *  the built-in definition.
1452  */
1453 fix = {
1454     hackname = next_template;
1455     files    = bsd/libc.h;
1456     select   = template;
1457
1458     sed = '/\(.*template\)/s/template//';
1459     sed = "/extern.*volatile.*void.*abort/s/volatile//";
1460 };
1461
1462
1463 /*
1464  *  NeXT 3.2 includes the keyword volatile in the abort() and  exit()
1465  *  function prototypes. That conflicts with the  built-in functions.
1466  */
1467 fix = {
1468     hackname = next_volitile;
1469     files    = ansi/stdlib.h;
1470     select   = volatile;
1471
1472     sed    = "/extern.*volatile.*void.*exit/s/volatile//";
1473     sed    = "/extern.*volatile.*void.*abort/s/volatile//";
1474 };
1475
1476
1477 /*
1478  *  NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1479  *  Note that version 3 of the NeXT system has wait.h in a different directory,
1480  *  so that this code won't do anything.  But wait.h in version 3 has a
1481  *  conditional, so it doesn't need this fix.  So everything is okay.
1482  */
1483 fix = {
1484     hackname = next_wait_union;
1485     files    = sys/wait.h;
1486
1487     select = 'wait\(union wait';
1488
1489     sed = "s@wait(union wait@wait(void@";
1490 };
1491
1492
1493 /*
1494  *  a missing semi-colon at the end of the nodeent structure definition.
1495  */
1496 fix = {
1497     hackname = nodeent_syntax;
1498     files    = netdnet/dnetdb.h;
1499     sed      = "s/char.*na_addr *$/char *na_addr;/";
1500 };
1501
1502
1503 /*
1504  *  sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
1505  *  defining regex.h related types.  This causes libg++ build and usage
1506  *  failures.  Fixing this correctly requires checking and modifying 3 files.
1507  */
1508 fix = {
1509     hackname = osf_namespace_a;
1510     files    = reg_types.h;
1511     files    = sys/lc_core.h;
1512     test     = " -r reg_types.h";
1513     test     = " -r sys/lc_core.h";
1514     test     = " -n \"`grep '} regex_t;' reg_types.h`\"";
1515     test     = " -z \"`grep __regex_t regex.h`\"";
1516
1517     sed      = "s/regex_t/__regex_t/g";
1518     sed      = "s/regoff_t/__regoff_t/g";
1519     sed      = "s/regmatch_t/__regmatch_t/g";
1520 };
1521
1522 fix = {
1523     hackname = osf_namespace_b;
1524     files    = regex.h;
1525     test     = " -r reg_types.h";
1526     test     = " -r sys/lc_core.h";
1527     test     = " -n \"`grep '} regex_t;' reg_types.h`\"";
1528     test     = " -z \"`grep __regex_t regex.h`\"";
1529
1530     sed      = "/#include <reg_types.h>/a\\\n"
1531                "typedef __regex_t\tregex_t;\\\n"
1532                "typedef __regoff_t\tregoff_t;\\\n"
1533                "typedef __regmatch_t\tregmatch_t;\n";
1534 };
1535
1536
1537 /*
1538  *  Fix __page_size* declarations in pthread.h AIX 4.1.[34].
1539  *  The original ones fail if uninitialized externs are not common.
1540  *  This is the default for all ANSI standard C++ compilers.
1541  */
1542 fix = {
1543     hackname = pthread_page_size;
1544     files    = pthread.h;
1545     select   = "^int __page_size";
1546     sed      = "s/^int __page_size/extern int __page_size/";
1547 };
1548
1549
1550 /*
1551  *  Fix return type of fread and fwrite on sysV68
1552  */
1553 fix = {
1554     hackname = read_ret_type;
1555     files    = stdio.h;
1556     select   = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
1557     sed      = "s/^\\(extern int\tfclose(), fflush()\\), "
1558                  "\\(fread(), fwrite()\\)\\(.*\\)$"
1559                "/extern unsigned int\t\\2;\\\n\\1\\3/";
1560 };
1561
1562
1563 /*
1564  *  function class(double x) conflicts with C++ keyword on rs/6000 
1565  */
1566 fix = {
1567     hackname = rs6000_double;
1568     files    = math.h;
1569     select   = '[^a-zA-Z_]class\(';
1570     
1571     sed   = "/class[(]/i\\\n#ifndef __cplusplus\n";
1572     sed   = "/class[(]/a\\\n#endif\n";
1573 };
1574
1575
1576 /*
1577  *  Wrong fchmod prototype on RS/6000.
1578  */
1579 fix = {
1580     hackname = rs6000_fchmod;
1581     files    = sys/stat.h;
1582     select   = 'fchmod\(char';
1583     sed      = 's/fchmod(char \*/fchmod(int/';
1584 };
1585
1586
1587 /*
1588  *  parameters conflict with C++ new on rs/6000 
1589  */
1590 fix = {
1591     hackname = rs6000_param;
1592     files  = "stdio.h";
1593     files  = "unistd.h";
1594     select = 'const char new';
1595
1596     sed = 's@rename(const char \*old, const char \*new)@'
1597             'rename(const char *_old, const char *_new)@';
1598 };
1599
1600
1601 /*
1602  *  The static functions lstat() and fchmod() in <sys/stat.h> 
1603  *  cause G++ grief since they're not wrapped in "if __cplusplus".
1604  *
1605  *  On SCO OpenServer 5.0.0 through (at least) 5.0.5 <sys/stat.h> contains
1606  *  tiny static wrappers that aren't C++ safe.
1607  */
1608 fix = {
1609     hackname = sco_static_func;
1610     files    = sys/stat.h;
1611     mach     = "i?86-*-sco3.2*";
1612     select   = "^static int";
1613
1614     sed      = "/^static int/i\\\n"
1615                "#if __cplusplus\\\n"
1616                "extern \"C\" {\\\n"
1617                "#endif /* __cplusplus */";
1618
1619     sed      = "/^}$/a\\\n"
1620                "#if __cplusplus\\\n"
1621                " }\\\n"
1622                "#endif /* __cplusplus */";
1623 };
1624
1625
1626 /*
1627  *  "!__STDC__" is "!defined( __STRICT_ANSI__ )"
1628  */
1629 fix = {
1630     hackname = sco_strict_ansi;
1631     mach     = "i?86-*-sco3.2*";
1632     select   = "^[ \t]*#[ \t]*if.*!__STDC__";
1633     sed      = 's/!__STDC__/!defined(__STRICT_ANSI__)/g';
1634 };
1635
1636
1637 /*
1638  *  Fix prototype declaration of utime in sys/times.h.
1639  *  In 3.2v4.0 the const is missing.
1640  */
1641 fix = {
1642     hackname = sco_utime;
1643     files    = sys/times.h;
1644     mach     = "i?86-*-sco3.2v4*";
1645     select   = "\(const char \*, struct utimbuf \*\);";
1646     sed      = 's/(const char \*, struct utimbuf \*);/'
1647                  '(const char *, const struct utimbuf *);/';
1648 };
1649
1650
1651 /*
1652  *  Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1653  */
1654 #ifdef SONY
1655 fix = {
1656     hackname = sony_ctype;
1657     files    = ctype.h;
1658     test     = " -x /bin/sony";
1659     test     = " ! -z \"`if /bin/sony ; then echo true ; fi`\"";
1660     sed      = "s/__ctype/_ctype/g";
1661 };
1662 #endif
1663
1664 /*
1665  *  Incorrect #include in Sony News-OS 3.2.
1666  */
1667 fix = {
1668     hackname = sony_include;
1669     files    = machine/machparam.h;
1670     select   = '"\.\./machine/endian.h"';
1671     sed      = 's@"../machine/endian.h"@<machine/endian.h>@';
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_stdio;
1681     files    = stdio.h;
1682     test     = " -x /bin/sony";
1683     test     = " ! -z \"`if /bin/sony ; then echo true ; fi`\"";
1684     sed      = "s/__filbuf/_filbuf/g\n"
1685                "s/__flsbuf/_flsbuf/g\n"
1686                "s/__iob/_iob/g";
1687 };
1688 #endif
1689
1690 /*
1691  *  Add a `static' declaration of `getrnge' into <regexp.h>.
1692  *
1693  *  Don't do this if there is already a `static void getrnge' declaration
1694  *  present, since this would cause a redeclaration error.  Solaris 2.x has
1695  *  such a declaration.
1696  */
1697 #ifdef SVR4
1698 fix = {
1699     hackname = static_getrnge;
1700     files    = regexp.h;
1701     bypass   = "static void getrnge";
1702     sed      = "/^static int[ \t]*size;/c\\\n"
1703                "static int      size ;\\\n\\\n"
1704                "static int getrnge ();";
1705 };
1706 #endif
1707
1708
1709 /*
1710  *  a missing semi-colon at the end of the statsswtch structure definition.
1711  */
1712 fix = {
1713     hackname = statsswtch;
1714     files    = rpcsvc/rstat.h;
1715     select   = "boottime$";
1716     sed      = "s/boottime$/boottime;/";
1717 };
1718
1719
1720 /*
1721  *  Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
1722  *  On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
1723  *  OK too.
1724  */
1725 fix = {
1726     hackname = stdio_stdarg_h;
1727     files    = stdio.h;
1728     bypass   = "include.*(stdarg\.h|machine/ansi\.h)";
1729
1730     c_fix     = wrap;
1731
1732     c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
1733
1734     test_text = "";
1735 };
1736
1737
1738 /*
1739  *  Don't use or define the name va_list in stdio.h.
1740  *  This is for ANSI and also to interoperate properly with gcc's varargs.h.
1741  *  Note _BSD_VA_LIST_ is dealt with elsewhere.
1742  */
1743 fix = {
1744     hackname = stdio_va_list;
1745     files    = stdio.h;
1746     bypass   = '__gnuc_va_list|_BSD_VA_LIST_';
1747
1748     /*
1749      * Use __gnuc_va_list in arg types in place of va_list.
1750      * On 386BSD use __gnuc_va_list instead of _VA_LIST_.  We're hoping the
1751      * trailing parentheses and semicolon save all other systems from this.
1752      * Define __not_va_list__ (something harmless and unused)
1753      * instead of va_list.
1754      * Don't claim to have defined va_list.
1755      */
1756     sed = "s@ va_list @ __gnuc_va_list @\n"
1757           "s@ va_list)@ __gnuc_va_list)@\n"
1758           "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
1759           "s@ va_list@ __not_va_list__@\n"
1760           "s@\\*va_list@*__not_va_list__@\n"
1761           "s@ __va_list)@ __gnuc_va_list)@\n"
1762           "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
1763            "@typedef \\1 __not_va_list__;@\n"
1764           "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
1765           "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
1766           "s@VA_LIST@DUMMY_VA_LIST@\n"
1767           "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 /*
1787  *  IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
1788  *  in prototype without previous definition.
1789  */
1790 fix = {
1791     hackname  = struct_file;
1792     files     = rpc/xdr.h;
1793     select    = '^.*xdrstdio_create.*struct __file_s';
1794     c_fix     = format;
1795     c_fix_arg = "struct __file_s;\n%0";
1796     test_text = "extern void xdrstdio_create( struct __file_s* );";
1797 };
1798
1799
1800 /*
1801  *  IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
1802  *  in prototype without previous definition.
1803  */
1804 fix = {
1805     hackname  = struct_sockaddr;
1806     files     = rpc/auth.h;
1807     select    = "^.*authdes_create.*struct sockaddr";
1808     bypass    = "<sys/socket\.h>";
1809     c_fix     = format;
1810     c_fix_arg = "struct sockaddr;\n%0";
1811     test_text = "extern AUTH* authdes_create( struct sockaddr* );";
1812 };
1813
1814
1815 /*
1816  *  Apply fix this to all OSs since this problem seems to effect
1817  *  more than just SunOS.
1818  */
1819 fix = {
1820     hackname = sun_auth_proto;
1821     files    = rpc/auth.h;
1822     files    = rpc/clnt.h;
1823     files    = rpc/svc.h;
1824     files    = rpc/xdr.h;
1825     /*
1826      *  Select those files containing '(*name)()'.
1827      */
1828     select   = '\(\*[a-z][a-z_]*\)\(\)';
1829     sed      = 's'
1830                 '/^\(.*(\*[a-z][a-z_]*)(\)'      '\();.*\)'
1831                 "/\\\n"
1832                     "#ifdef __cplusplus\\\n"
1833                     '\1...\2' "\\\n"
1834                     "#else\\\n"
1835                     '\1\2' "\\\n"
1836                     "#endif"
1837                 "/";
1838 };
1839
1840
1841 /*
1842  *  Fix bogus #ifdef on SunOS 4.1.
1843  */
1844 fix = {
1845     hackname = sun_bogus_ifdef;
1846     files  = "hsfs/hsfs_spec.h";
1847     files  = "hsfs/iso_spec.h";
1848     select = '#ifdef __i386__ || __vax__';
1849     sed    = "s/\\#ifdef __i386__ || __vax__/\\#if __i386__ || __vax__/g";
1850 };
1851
1852
1853 /*
1854  *  Fix bogus #ifdef on SunOS 4.1.
1855  */
1856 fix = {
1857     hackname = sun_bogus_ifdef_sun4c;
1858     files  = "hsfs/hsnode.h";
1859     select = '#ifdef __i386__ || __sun4c__';
1860     sed    = "s/\\#ifdef __i386__ || __sun4c__/\\#if __i386__ || __sun4c__/g";
1861 };
1862
1863
1864 /*
1865  *  Fix the CAT macro in SunOS memvar.h.
1866  */
1867 fix = {
1868     hackname = sun_catmacro;
1869     files  = pixrect/memvar.h;
1870     select = "^#define[ \t]+CAT\\(a,b\\)";
1871     sed    = "/^#define[ \t]CAT(a,b)/ i\\\n"
1872                  "#ifdef __STDC__ \\\n"
1873                  "#define CAT(a,b) a##b\\\n"
1874                  "#else\n";
1875
1876     sed    = "/^#define[ \t]CAT(a,b)/ a\\\n"
1877                  "#endif\n";
1878 };
1879
1880
1881 /*
1882  *  Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
1883  *  Also fix return type of {m,re}alloc in <malloc.h> on sysV68
1884  */
1885 fix = {
1886     hackname = sun_malloc;
1887     files    = malloc.h;
1888
1889     sed   = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
1890     sed   = "s/int[ \t][ \t]*free/void\tfree/g";
1891     sed   = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
1892     sed   = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
1893 };
1894
1895
1896 /*
1897  *  Check for yet more missing ';' in struct (in SunOS 4.0.x)
1898  */
1899 fix = {
1900     hackname = sun_rusers_semi;
1901     files    = rpcsvc/rusers.h;
1902     select   = "_cnt$";
1903     sed      = "/^struct/,/^};/s/_cnt$/_cnt;/";
1904 };
1905
1906
1907 /*
1908  *  signal.h on SunOS defines signal using (),
1909  *  which causes trouble when compiling with g++ -pedantic.
1910  */
1911 fix = {
1912     hackname = sun_signal;
1913     files    = sys/signal.h;
1914     files    = signal.h;
1915     select   = "^void\t" '\(\*signal\(\)\)\(\);';
1916
1917     sed = "/^void\t" '(\*signal())();$/i'  "\\\n"
1918           "#ifdef __cplusplus"             "\\\n"
1919           "void\t(*signal(...))(...);"     "\\\n"
1920           "#else"                          "\n";
1921
1922     sed = "/^void\t" '(\*signal())();$/a'  "\\\n"
1923           '#endif'                         "\n";
1924 };
1925
1926
1927 /*
1928  *  math.h on SunOS 4 puts the declaration of matherr before the definition
1929  *  of struct exception, so the prototype (added by fixproto) causes havoc.
1930  */
1931 fix = {
1932     hackname = sunos_matherr_decl;
1933     files    = math.h;
1934     /*  If matherr has a prototype already, the header needs no fix.  */
1935     bypass   = 'matherr.*struct exception';
1936     /*
1937      *  Once a declaration for 'struct exception' is found,
1938      *  stop trying to insert a forward reference for it.
1939      */
1940     sed = "/^struct exception/,$b";
1941     sed = "/matherr/i\\\nstruct exception;\n";
1942 };
1943
1944
1945 /*
1946  *  Correct the return type for strlen in strings.h in SunOS 4.
1947  */
1948 fix = {
1949     hackname = sunos_strlen;
1950     files    = strings.h;
1951     select   = "int[ \t]*strlen";
1952     sed = "s/int[ \t]*strlen();/__SIZE_TYPE__ strlen();/";
1953 };
1954
1955
1956 /*
1957  *  Solaris math.h and floatingpoint.h define __P without protection,
1958  *  which conflicts with the fixproto definition.  The fixproto
1959  *  definition and the Solaris definition are used the same way.
1960  */
1961 #ifdef SVR4
1962 fix = {
1963     hackname = svr4__p;
1964     files    = math.h;
1965     files    = floatingpoint.h;
1966     select   = "^#define[ \t]*__P";
1967     sed      = "/^#define[ \t]*__P/i\\\n#ifndef __P\n";
1968     sed      = "/^#define[ \t]*__P/a\\\n#endif\n";
1969 };
1970 #endif
1971
1972 /*
1973  *  Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
1974  *  that is visible to any ANSI compiler using this include.  Simply
1975  *  delete the lines that #define some string functions to internal forms.
1976  */
1977 #ifdef SVR4
1978 fix = {
1979     hackname = svr4_disable_opt;
1980     files    = string.h;
1981     select   = '#define.*__std_hdr_';
1982     sed      = '/#define.*__std_hdr_/d';
1983 };
1984 #endif
1985
1986
1987 /*
1988  *  Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
1989  *  On some systems (UnixWare 2, UnixWare 7), the file is byteorder.h
1990  *  but we still "hijack" it and redirect it to the GNU byteorder.h..
1991  *
1992  *
1993  */
1994 #ifdef SVR5
1995 fix = {
1996     hackname = svr4_endian;
1997     files    = sys/endian.h;
1998 #ifdef LATER
1999     /*
2000      * since we emit our own sys/byteorder.h,
2001      * this fix can never be applied to that file.
2002      */
2003     files    = sys/byteorder.h;
2004 #endif
2005     bypass   = '__GNUC__';
2006
2007     sed      = "/#\tifdef\t__STDC__/i\\\n"
2008                "#   if !defined (__GNUC__) && !defined (__GNUG__)\n";
2009
2010     sed      = "/#\t\tinclude\t<sys\\/byteorder.h>/s/\t\t/   /";
2011
2012     sed      = "/#   include\t<sys\\/byteorder.h>/i\\\n"
2013                "#   endif /* !defined (__GNUC__) && !defined (__GNUG__) */\n";
2014 };
2015 #endif /* SVR5 */
2016
2017
2018 /*
2019  *  Remove useless extern keyword from struct forward declarations
2020  *  in <sys/stream.h> and <sys/strsubr.h>
2021  */
2022 #ifdef SVR4
2023 fix = {
2024     hackname = svr4_extern_struct;
2025     files    = sys/stream.h;
2026     files    = sys/strsubr.h;
2027     select   = 'extern struct [a-z_]*;';
2028     sed      = 's/extern struct \([a-z][a-z_]*\)/struct \1/';
2029 };
2030 #endif
2031
2032 /*
2033  *  Fix declarations of `ftw' and `nftw' in <ftw.h>.  On some/most SVR4
2034  *  systems the file <ftw.h> contains extern declarations of these
2035  *  functions followed by explicitly `static' definitions of these
2036  *  functions... and that's not allowed according to ANSI C.  (Note
2037  *  however that on Solaris, this header file glitch has been pre-fixed by
2038  *  Sun.  In the Solaris version of <ftw.h> there are no static
2039  *  definitions of any function so we don't need to do any of this stuff
2040  *  when on Solaris.
2041  */
2042 #ifdef SVR4
2043 #ifndef SOLARIS
2044 fix = {
2045     hackname = svr4_ftw;
2046     files    = ftw.h;
2047     select   = '^extern int ftw\(const';
2048
2049     sed = '/^extern int ftw(const/i' "\\\n"
2050             "#if !defined(_STYPES)\\\n"
2051             "static\\\n"
2052             "#else\\\n"
2053             "extern\\\n"
2054             "#endif";
2055     sed = 's/extern \(int ftw(const.*\)$/\1/';
2056     sed = "/^extern int nftw/i\\\n"
2057             "#if defined(_STYPES)\\\n"
2058             "static\\\n"
2059             "#else\\\n"
2060             "extern\\\n"
2061             "#endif";
2062     sed = 's/extern \(int nftw.*\)$/\1/';
2063     sed = "/^extern int ftw(),/c\\\n"
2064             "#if !defined(_STYPES)\\\n"
2065             "static\\\n"
2066             "#else\\\n"
2067             "extern\\\n"
2068             "#endif\\\n"
2069             "  int ftw();\\\n"
2070             "#if defined(_STYPES)\\\n"
2071             "static\\\n"
2072             "#else\\\n"
2073             "extern\\\n"
2074             "#endif\\\n"
2075             "  int nftw();";
2076 };
2077 #endif
2078 #endif
2079
2080
2081 /*
2082  *   Fix broken decl of getcwd present on some svr4 systems.
2083  */
2084 fix = {
2085     hackname = svr4_getcwd;
2086     files    = stdlib.h;
2087     files    = unistd.h;
2088     files    = prototypes.h;
2089     select   = 'getcwd\(char \*, int\)';
2090
2091     sed = 's/getcwd(char \*, int)/getcwd(char *, size_t)/';
2092 };
2093
2094
2095 /*
2096  *  set ifdef _KERNEL
2097  */
2098 #ifdef SVR4
2099 fix = {
2100     hackname = svr4_kernel;
2101     files    = fs/rfs/rf_cache.h;
2102     files    = sys/erec.h;
2103     files    = sys/err.h;
2104     files    = sys/char.h;
2105     files    = sys/getpages.h;
2106     files    = sys/map.h;
2107     files    = sys/cmn_err.h;
2108     files    = sys/kdebugger.h;
2109     bypass   = '_KERNEL';
2110     c_fix     = wrap;
2111
2112     c_fix_arg = "#ifdef _KERNEL\n";
2113     c_fix_arg = "#endif /* _KERNEL */\n";
2114     test_text = "";
2115 };
2116 #endif
2117
2118 /*
2119  *  Delete any #defines of `__i386' which may be present in <ieeefp.h>.  They
2120  *  tend to conflict with the compiler's own definition of this symbol.  (We
2121  *  will use the compiler's definition.)
2122  *  Likewise __sparc, for Solaris, and __i860, and a few others
2123  *  (guessing it is necessary for all of them).
2124  */
2125 #ifdef SVR4
2126 fix = {
2127     hackname = svr4_mach_defines;
2128     files    = ieeefp.h;
2129     select   = "#define[ \t]*__(i386|i860|mips|sparc|m88k|m68k)[ \t]";
2130     sed      = "/#define[ \t]*__\\(i386|i860|mips|sparc|m88k|m68k\\)[ \t]/d";
2131 };
2132 #endif
2133
2134
2135 /*
2136  *  Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
2137  *  They are declared as non-static then immediately redeclared as static.
2138  */
2139 #ifdef SVR5
2140 fix = {
2141     hackname = svr4_mkdev;
2142     files    = sys/mkdev.h;
2143     select   = '^static';
2144
2145     sed      = "/^dev_t makedev(/s/^/static /";
2146     sed      = "/^major_t major(/s/^/static /";
2147     sed      = "/^minor_t minor(/s/^/static /";
2148 };
2149 #endif /* SVR5 */
2150
2151
2152 /*
2153  *  Fix reference to NC_NPI_RAW in <sys/netcspace.h>.
2154  *  Also fix types of array initializers.
2155  */
2156 #ifdef SVR4
2157 fix = {
2158     hackname = svr4_netcspace;
2159     files    = sys/netcspace.h;
2160     select   = 'NC_NPI_RAW';
2161     sed      = 's/NC_NPI_RAW/NC_TPI_RAW/g';
2162     sed      = 's/NC_/(unsigned long) NC_/';
2163 };
2164 #endif
2165
2166 /*
2167  *  Fix reference to NMSZ in <sys/adv.h>.
2168  */
2169 #ifdef SVR4
2170 fix = {
2171     hackname = svr4_nmsz;
2172     files    = sys/adv.h;
2173     select   = '\[NMSZ\]';
2174     sed      = 's/\[NMSZ\]/\[RFS_NMSZ\]/g';
2175 };
2176 #endif
2177
2178
2179 /*
2180  *   Fix broken decl of profil present on some svr4 systems.
2181  */
2182 fix = {
2183     hackname = svr4_profil;
2184     files    = stdlib.h;
2185     files    = unistd.h;
2186
2187     sed = 's/profil(unsigned short \*, unsigned int, '
2188                          'unsigned int, unsigned int)'
2189            '/profil(unsigned short *, size_t, int, unsigned)/';
2190 };
2191
2192
2193 /*
2194  *  Convert functions to prototype form, and fix arg names in <sys/stat.h>.
2195  */
2196 #ifdef SVR4
2197 fix = {
2198     hackname = svr4_proto_form;
2199     files    = sys/stat.h;
2200     select   = 'const extern';
2201
2202     sed      = "/^stat([ \t]*[^c]/ {\nN\nN\n"
2203                    "s/(.*)\\n/( /\n"
2204                    "s/;\\n/, /\n"
2205                    "s/;$/)/\n"  "}";
2206
2207     sed      = "/^lstat([ \t]*[^c]/ {\nN\nN\n"
2208                    "s/(.*)\\n/( /\n"
2209                    "s/;\\n/, /\n"
2210                    "s/;$/)/\n"  "}";
2211
2212     sed      = "/^fstat([ \t]*[^i]/ {\nN\nN\n"
2213                    "s/(.*)\\n/( /\n"
2214                    "s/;\\n/, /\n"
2215                    "s/;$/)/\n"  "}";
2216
2217     sed      = "/^mknod([ \t]*[^c]/{\nN\nN\nN\n"
2218                    "s/(.*)\\n/( /\n"
2219                    "s/;\\n/, /g\n"
2220                    "s/;$/)/\n"  "}";
2221
2222     sed      = "1,$s/\\([^A-Za-z]\\)path\\([^A-Za-z]\\)/\\1__path\\2/g";
2223     sed      = "1,$s/\\([^A-Za-z]\\)buf\\([^A-Za-z]\\)/\\1__buf\\2/g";
2224     sed      = "1,$s/\\([^A-Za-z]\\)fd\\([^A-Za-z]\\)/\\1__fd\\2/g";
2225     sed      = "1,$s/ret\\([^u]\\)/__ret\\1/g";
2226     sed      = "1,$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g";
2227     sed      = "1,$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g";
2228 };
2229 #endif
2230
2231 /*
2232  *  Add a prototyped declaration of mmap to <sys/mman.h>.
2233  */
2234 #ifdef SVR4
2235 fix = {
2236     hackname = svr4_proto_mmap;
2237     files    = sys/mman.h;
2238     select   = '^extern caddr_t mmap();$';
2239     sed = '/^extern caddr_t mmap();$/c' "\\\n"
2240           "#ifdef __STDC__\\\n"
2241           "extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\\\n"
2242           "#else /* !defined(__STDC__) */\\\n"
2243           "extern caddr_t mmap ();\\\n"
2244           "#endif /* !defined(__STDC__) */\\\n";
2245 };
2246 #endif
2247
2248 /*
2249  *  Add a #define of _SIGACTION_ into <sys/signal.h>.
2250  */
2251 #ifdef SVR4
2252 fix = {
2253     hackname = svr4_sigaction;
2254     files    = sys/signal.h;
2255     sed      = "/^struct sigaction {/i\\\n"
2256                "#define _SIGACTION_";
2257     sed      = 's/(void *(\*)())/(void (*)(int))/';
2258 };
2259 #endif
2260
2261 /*
2262  *  Put storage class at start of decl, to avoid warning.
2263  */
2264 #ifdef SVR4
2265 fix = {
2266     hackname = svr4_storage_class;
2267     files    = rpc/types.h;
2268     select   = 'const extern';
2269     sed      = 's/const extern/extern const/g';
2270 };
2271 #endif
2272
2273
2274 /* 
2275  *  Like svr4_mach_defines, but with newfangled syntax.
2276  *  Source lines are of #define __i386 #machine(i386).   Delete them.
2277  */
2278 #ifdef SVR5
2279 fix = {
2280     hackname = svr5_mach_defines;
2281     files    = ieeefp.h;
2282     select   = "#define[ \t]*__i386.*\(i386\)";
2283     sed      = "/#define[ \t]*__i386.*/d";
2284 };
2285 #endif /*  SVR5 */
2286
2287
2288 /*
2289  * Fix these files to use the same types that we think they should.
2290  * XXX - extremely dubious changes here.
2291  */
2292 fix = {
2293     hackname = systypes;
2294     files  = "sys/types.h";
2295     files  = "stdlib.h";
2296     files  = "sys/stdtypes.h";
2297     files  = "stddef.h";
2298     files  = "memory.h";
2299     files  = "unistd.h";
2300     select = "typedef[ \t]+[a-z_][ \ta-z_]*[ \t]"
2301              "(size|ptrdiff|wchar)_t";
2302
2303       sed  = "/^[ \t]*\\*[ \t]*typedef unsigned int size_t;/N";
2304
2305       sed  = "s/^\\([ \t]*\\*[ \t]*typedef unsigned int size_t;\\n"
2306                "[ \t]*\\*\\/\\)/\\1\\\n"
2307              "#ifndef __SIZE_TYPE__\\\n"
2308              "#define __SIZE_TYPE__ long unsigned int\\\n"
2309              "#endif\\\n"
2310              "typedef __SIZE_TYPE__ size_t;\\\n/";
2311
2312       sed  = "/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]size_t/i\\\n"
2313                    "#ifndef __SIZE_TYPE__\\\n"
2314                    "#define __SIZE_TYPE__ long unsigned int\\\n"
2315                    "#endif\n";
2316
2317       sed  = "s/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]size_t/"
2318                "typedef __SIZE_TYPE__ size_t/";
2319
2320       sed  = "/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]ptrdiff_t/i\\\n"
2321                    "#ifndef __PTRDIFF_TYPE__\\\n"
2322                    "#define __PTRDIFF_TYPE__ long int\\\n"
2323                    "#endif\n";
2324
2325       sed  = "s/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]ptrdiff_t/"
2326                "typedef __PTRDIFF_TYPE__ ptrdiff_t/";
2327
2328       sed  = "/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]wchar_t/i\\\n"
2329                    "#ifndef __WCHAR_TYPE__\\\n"
2330                    "#define __WCHAR_TYPE__ int\\\n"
2331                    "#endif\\\n"
2332                    "#ifndef __cplusplus\n";
2333
2334       sed  = "/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]wchar_t/a\\\n"
2335                    "#endif\n";
2336
2337       sed  = "s/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]wchar_t/"
2338                "typedef __WCHAR_TYPE__ wchar_t/";
2339 };
2340
2341
2342 /*
2343  * Fix files that may contain a stray definition of size_t.  Take care
2344  * not to match ssize_t or mere uses of size_t.
2345  */
2346 fix = {
2347     hackname = systypes_stdlib_size_t;
2348     files    = sys/types.h;
2349     files    = stdlib.h;
2350     select   = "typedef[ \t][ \t]*[A-Za-z_][ \tA-Za-z_]*[ \t]size_t";
2351     bypass   = "_(GCC|BSD)_SIZE_T";
2352
2353     sed    = "/typedef[ \t][ \t]*[A-Za-z_][ \tA-Za-z_]*[ \t]size_t/i\\\n"
2354                  "#ifndef _GCC_SIZE_T\\\n"
2355                  "#define _GCC_SIZE_T\n";
2356
2357     sed    = "/typedef[ \t][ \t]*[A-Za-z_][ \tA-Za-z_]*[ \t]size_t/a\\\n"
2358                  "#endif\n";
2359 };
2360
2361
2362 /*
2363  *  Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
2364  *  in string.h on sysV68
2365  *  Correct the return type for strlen in string.h on Lynx.
2366  *  Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
2367  *  Add missing const for strdup on OSF/1 V3.0.
2368  *  On sysV88 layout is slightly different.
2369  */
2370 fix = {
2371     hackname = sysv68_string;
2372     files    = string.h;
2373
2374     sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
2375     sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
2376     sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
2377     sed = "/^extern char$/N";
2378     sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
2379     sed = "/^\tstrncmp(),$/N";
2380     sed = "s/^\\(\tstrncmp()\\),\\n\\(\tstrlen(),\\)$/\\1;\\\n"
2381           "extern unsigned int\\\n\\2/";
2382     sed = "/^extern int$/N";
2383     sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
2384 };
2385
2386
2387 /*
2388  *  Fix return type of exit and abort in <stdlib.h>
2389  */
2390 fix = {
2391     hackname = sysz_stdlib_for_sun;
2392     files    = stdlib.h;
2393
2394     sed   = "s/int\tabort/void\tabort/g";
2395     sed   = "s/int\tfree/void\tfree/g";
2396     sed   = "s/char[ \t]*\\*[ \t]*calloc/void \\*\tcalloc/g";
2397     sed   = "s/char[ \t]*\\*[ \t]*malloc/void \\*\tmalloc/g";
2398     sed   = "s/char[ \t]*\\*[ \t]*realloc/void \\*\trealloc/g";
2399     sed   = "s/char[ \t]*\\*[ \t]*bsearch/void \\*\tbsearch/g";
2400     sed   = "s/int[ \t][ \t]*exit/void\texit/g";
2401 };
2402
2403
2404 /*
2405  *  Fix this Sun file to avoid interfering with stddef.h.
2406  *  We use a funny name to ensure it follows 'systypes' fix.
2407  */
2408 fix = {
2409     hackname = sysz_stdtypes_for_sun;
2410     files = sys/stdtypes.h;
2411     sed   = "/[\t ]size_t.*;/i\\\n"
2412               "#ifndef _GCC_SIZE_T\\\n"
2413               "#define _GCC_SIZE_T\n";
2414
2415     sed   = "/[\t ]size_t.*;/a\\\n"
2416               "#endif\n";
2417
2418     sed   = "/[\t ]ptrdiff_t.*;/i\\\n"
2419               "#ifndef _GCC_PTRDIFF_T\\\n"
2420               "#define _GCC_PTRDIFF_T\n";
2421
2422     sed   = "/[\t ]ptrdiff_t.*;/a\\\n"
2423               "#endif\n";
2424
2425     sed   = "/[\t ]wchar_t.*;/i\\\n"
2426               "#ifndef _GCC_WCHAR_T\\\n"
2427               "#define _GCC_WCHAR_T\n";
2428
2429     sed   = "/[\t ]wchar_t.*;/a\\\n"
2430               "#endif\n";
2431 };
2432
2433
2434 /*
2435  *  if the #if says _cplusplus, not the double underscore __cplusplus
2436  *  that it should be
2437  */
2438 fix = {
2439     hackname = tinfo_cplusplus;
2440     files    = tinfo.h;
2441     select   = "[ \t]_cplusplus";
2442     sed      = "s/[ \t]_cplusplus/ __cplusplus/";
2443 };
2444
2445
2446 /*
2447  *  parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
2448  */
2449 fix = {
2450     hackname = ultrix_atof_param;
2451     files    = math.h;
2452     select   = "atof\\([ \t]*char";
2453
2454     sed = "s@atof(\\([ \t]*char[ \t]*\\*[^)]*\\))@atof(const \\1)@";
2455 };
2456
2457
2458 /*
2459  *  parameters not const on DECstation Ultrix V4.0 and OSF/1.
2460  */
2461 fix = {
2462     hackname = ultrix_const;
2463     files    = stdio.h;
2464
2465     sed   = 's@perror( char \*__s );@perror( const char *__s );@';
2466     sed   = 's@fputs( char \*__s,@fputs( const char *__s,@';
2467     sed   = 's@fopen( char \*__filename, char \*__type );@'
2468               'fopen( const char *__filename, const char *__type );@';
2469     sed   = 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@';
2470     sed   = 's@fscanf( FILE \*__stream, char \*__format,@'
2471               'fscanf( FILE *__stream, const char *__format,@';
2472     sed   = 's@scanf( char \*__format,@scanf( const char *__format,@';
2473     sed   = 's@sscanf( char \*__s, char \*__format,@'
2474               'sscanf( const char *__s, const char *__format,@';
2475     sed   = 's@popen(char \*, char \*);@popen(const char *, const char *);@';
2476     sed   = 's@tempnam(char\*,char\*);@tempnam(const char*,const char*);@';
2477 };
2478
2479
2480 /*
2481  * Ultrix V4.[35] puts the declaration of uname before the definition
2482  * of struct utsname, so the prototype (added by fixproto) causes havoc.
2483  */
2484 fix = {
2485     hackname = ultrix_fix_fixproto;
2486     files    = sys/utsname.h;
2487     select   = ULTRIX;
2488     sed      = "/^[ \t]*extern[ \t]*int[ \t]*uname();$/i\\\n"
2489                "struct utsname;\n";
2490 };
2491
2492
2493 /*
2494  *  Check for bad #ifdef line (in Ultrix 4.1)
2495  */
2496 fix = {
2497     hackname = ultrix_ifdef;
2498     select   = "#ifdef KERNEL[ \t]*[^ \t]";
2499     files    = sys/file.h;
2500     sed      = "s/#ifdef KERNEL/#if defined(KERNEL)/";
2501 };
2502
2503
2504 /*
2505  *  Check for superfluous `static' (in Ultrix 4.2)
2506  *  On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
2507  */
2508 fix = {
2509     hackname = ultrix_static;
2510     files  = machine/cpu.h;
2511     select = '#include "r[34]_cpu';
2512     sed    = "s/^static struct tlb_pid_state/struct tlb_pid_state/";
2513     sed    = 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/';
2514     sed    = 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/';
2515 };
2516
2517
2518 /*
2519  *  Fix multiple defines for NULL.  Sometimes, we stumble into \r\n
2520  *  terminated lines, so accommodate these.  Test both ways.
2521  */
2522 fix = {
2523     hackname  = undefine_null;
2524     select    = "^#[ \t]*define[ \t]+NULL[ \t]";
2525     bypass    = "#[ \t]*(ifn|un)def[ \t]+NULL($|[ \t\r])";
2526
2527     c_fix     = format;
2528     c_fix_arg = "#ifndef NULL%2\n#define NULL%1%2\n#endif%2\n";
2529     c_fix_arg = "^#[ \t]*define[ \t]*[ \t]NULL([^\r\n]+)([\r]*)\n";
2530
2531     test_text = "#define NULL 0UL\r\n#define NULL\t((void*)0)\n";
2532 };
2533
2534
2535 /*
2536  * If arpa/inet.h prototypes are incompatible with the ones we just
2537  * installed in <sys/byteorder.h>, just remove the protos.
2538  * Because of this close association, this patch must be applied only
2539  * on those systems where the replacement byteorder header is installed.
2540  */
2541 fix = {
2542     hackname = unixware7_byteorder_fix;
2543     files    = arpa/inet.h;
2544     select   = "in_port_t";
2545 #ifndef SVR5
2546         mach = "*-*-sysv4*";
2547         mach = "i[34567]86-*-sysv5*";
2548         mach = "i[34567]86-*-udk*";
2549         mach = "i[34567]86-*-solaris2.[0-4]";
2550         mach = "powerpcle-*-solaris2.[0-4]";
2551         mach = "sparc-*-solaris2.[0-4]";
2552 #endif /* SVR5 */
2553     sed      =  '/^extern.*htons.*(in_port_t)/d';
2554     sed      =  '/^extern.*ntohs.*(in_port_t)/d';
2555 };
2556
2557
2558 /*
2559  *  Fix definitions of macros used by va-i960.h in VxWorks header file.
2560  */
2561 fix = {
2562     hackname = va_i960_macro;
2563     files    = arch/i960/archI960.h;
2564     select   = "__(vsiz|vali|vpad|alignof__)";
2565     sed = "s/__vsiz/__vxvsiz/";
2566     sed = "s/__vali/__vxvali/";
2567     sed = "s/__vpad/__vxvpad/";
2568     sed = "s/__alignof__/__vxalignof__/";
2569 };
2570
2571
2572 /*
2573  *  AIX headers define NULL to be cast to a void pointer,
2574  *  which is illegal in ANSI C++.
2575  */
2576 fix = {
2577     hackname = void_null;
2578     files    = curses.h;
2579     files    = dbm.h;
2580     files    = locale.h;
2581     files    = stdio.h;
2582     files    = stdlib.h;
2583     files    = string.h;
2584     files    = time.h;
2585     files    = unistd.h;
2586     files    = sys/dir.h;
2587     files    = sys/param.h;
2588     files    = sys/types.h;
2589     select   = "#[ \t]*define[ \t][ \t]*NULL[ \t].*void";
2590     sed      = "s/^#[ \t]*define[ \t]*NULL[ \t]*((void[ \t]*\\*)0)"
2591                 "/#define NULL 0/";
2592 };
2593
2594
2595 /*
2596  *  Make VxWorks header which is almost gcc ready fully gcc ready.
2597  */
2598 fix = {
2599     hackname = vxworks_gcc_problem;
2600     files    = types/vxTypesBase.h;
2601     select   = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
2602
2603     sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
2604           "#if 1/";
2605
2606     sed = "/[ \t]size_t/i\\\n"
2607         "#ifndef _GCC_SIZE_T\\\n"
2608         "#define _GCC_SIZE_T\n";
2609
2610     sed = "/[ \t]size_t/a\\\n"
2611         "#endif\n";
2612
2613     sed = "/[ \t]ptrdiff_t/i\\\n"
2614         "#ifndef _GCC_PTRDIFF_T\\\n"
2615         "#define _GCC_PTRDIFF_T\n";
2616
2617     sed = "/[ \t]ptrdiff_t/a\\\n"
2618         "#endif\n";
2619
2620     sed = "/[ \t]wchar_t/i\\\n"
2621         "#ifndef _GCC_WCHAR_T\\\n"
2622         "#define _GCC_WCHAR_T\n";
2623
2624     sed = "/[ \t]wchar_t/a\\\n"
2625         "#endif\n";
2626 };
2627
2628
2629 /*
2630  *  Fix VxWorks <time.h> to not require including <vxTypes.h>.
2631  */
2632 fix = {
2633     hackname = vxworks_needs_vxtypes;
2634     files    = time.h;
2635     select   = "uint_t[ \t][ \t]*_clocks_per_sec";
2636     sed      = "s/uint_t/unsigned int/";
2637     test_text = "uint_t\t_clocks_per_sec;";
2638 };
2639
2640
2641 /*
2642  *  Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
2643  */
2644 fix = {
2645     hackname = vxworks_needs_vxworks;
2646     files    = sys/stat.h;
2647     test     = " -r types/vxTypesOld.h";
2648     test     = " -n \"`egrep '#include' $file`\"";
2649     test     = " -n \"`egrep ULONG $file`\"";
2650     select   = "#[ \t]define[ \t][ \t]*__INCstath";
2651
2652     sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
2653           "#include <types/vxTypesOld.h>\n";
2654 };
2655
2656
2657 /*
2658  *  Another bad dependency in VxWorks 5.2 <time.h>.
2659  */
2660 fix = {
2661     hackname = vxworks_time;
2662     files    = time.h;
2663     select   = "VOIDFUNCPTR";
2664     test     = " -r vxWorks.h";
2665     sed      = "/VOIDFUNCPTR/i\\\n"
2666                "#ifndef __gcc_VOIDFUNCPTR_defined\\\n"
2667                "#ifdef __cplusplus\\\n"
2668                "typedef void (*__gcc_VOIDFUNCPTR) (...);\\\n"
2669                "#else\\\n"
2670                "typedef void (*__gcc_VOIDFUNCPTR) ();\\\n"
2671                "#endif\\\n"
2672                "#define __gcc_VOIDFUNCPTR_defined\\\n"
2673                "#endif\n";
2674
2675     sed      = "s/VOIDFUNCPTR/__gcc_VOIDFUNCPTR/g";
2676 };
2677
2678
2679 /*
2680  *  There are several name conflicts with C++ reserved words in X11 header
2681  *  files.  These are fixed in some versions, so don't do the fixes if
2682  *  we find __cplusplus in the file.  These were found on the RS/6000.
2683  */
2684 fix = {
2685     hackname = x11_class;
2686     files    = X11/ShellP.h;
2687     bypass   = __cplusplus;
2688     sed      = "/char \\*class;/i\\\n"
2689                    "#ifdef __cplusplus\\\n"
2690                    "\tchar *c_class;\\\n"
2691                    "#else\n";
2692     sed      = "/char \\*class;/a\\\n"
2693                    "#endif\n";
2694     test_text =
2695     "struct {\n"
2696     "   char *class;\n"
2697     "} mumble;\n";
2698 };
2699
2700
2701 /*
2702  *  class in Xm/BaseClassI.h
2703  */
2704 fix = {
2705     hackname = x11_class_usage;
2706     files    = Xm/BaseClassI.h;
2707     bypass   = "__cplusplus";
2708     sed      = "s/ class[)]/ c_class)/g";
2709     test_text = "extern mumble (int  class);\n";
2710 };
2711
2712
2713 /*
2714  *  new in Xm/Traversal.h
2715  */
2716 fix = {
2717     hackname = x11_new;
2718     files    = Xm/Traversal.h;
2719     bypass   = __cplusplus;
2720
2721     sed      = "/Widget\told, new;/i\\\n"
2722                    "#ifdef __cplusplus\\\n"
2723                    "\tWidget\told, c_new;\\\n"
2724                    "#else\n";
2725
2726     sed      = "/Widget\told, new;/a\\\n"
2727                    "#endif\n";
2728
2729     sed      = "s/Widget new,/Widget c_new,/g";
2730     test_text =
2731     "struct wedge {\n"
2732     "   Widget\told, new; /* fix the new */\n"
2733     "};\nextern Wedged( Widget new, Widget old );";
2734 };
2735
2736
2737 /*
2738  *  Incorrect sprintf declaration in X11/Xmu.h
2739  */
2740 fix = {
2741     hackname = x11_sprintf;
2742     files    = X11/Xmu.h;
2743     files    = X11/Xmu/Xmu.h;
2744     select   = 'sprintf\(\)';
2745
2746     sed      = "s,^extern char \\*\tsprintf();$,#ifndef __STDC__\\\n"
2747                "extern char *\tsprintf();\\\n"
2748                "#endif /* !defined __STDC__ */,";
2749     test_text = "extern char *\tsprintf();";
2750 };
2751
2752 /*EOF*/