OSDN Git Service

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