OSDN Git Service

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