OSDN Git Service

7de99b6660f1a6a52c3e80636c8030d76ec0eef6
[pf3gnuchains/gcc-fork.git] / gcc / fixinc / inclhack.sh
1 #!/bin/sh
2 #
3 #  DO NOT EDIT THIS FILE - it has been generated
4 #
5 # Install modified versions of certain ANSI-incompatible system header
6 # files which are fixed to work correctly with ANSI C and placed in a
7 # directory that GNU C will search.
8 #
9 # This script contains 113 fixup scripts.
10 #
11 # See README-fixinc for more information.
12 #
13 #  fixincludes copyright (c) 2000 The Free Software Foundation, Inc.
14 #
15 # fixincludes is free software.
16
17 # You may redistribute it and/or modify it under the terms of the
18 # GNU General Public License, as published by the Free Software
19 # Foundation; either version 2, or (at your option) any later version.
20
21 # fixincludes is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24 # See the GNU General Public License for more details.
25
26 # You should have received a copy of the GNU General Public License
27 # along with fixincludes.  See the file "COPYING".  If not,
28 # write to:  The Free Software Foundation, Inc.,
29 #            59 Temple Place - Suite 330,
30 #            Boston,  MA  02111-1307, USA.
31 #
32 # # # # # # # # # # # # # # # # # # # # #
33 #
34 # Directory in which to store the results.
35 # Fail if no arg to specify a directory for the output.
36 if [ "x$1" = "x" ]
37 then
38   echo fixincludes: no output directory specified
39   exit 1
40 fi
41
42 LIB=${1}
43 shift
44
45 # Make sure it exists.
46 if [ ! -d $LIB ]; then
47   mkdir $LIB || {
48     echo fixincludes:  output dir '`'$LIB"' cannot be created"
49     exit 1
50   }
51 else
52   ( cd $LIB && touch DONE && rm DONE ) || {
53     echo fixincludes:  output dir '`'$LIB"' is an invalid directory"
54     exit 1
55   }
56 fi
57
58 FIXTESTS=$PWD/fixinc/fixtests
59 FIXFIXES=$PWD/fixinc/fixfixes
60
61 if test -z "$VERBOSE"
62 then
63   VERBOSE=2
64   export VERBOSE
65 else
66   case "$VERBOSE" in
67   [0-9] ) : ;;
68   * )  VERBOSE=3 ;;
69   esac
70 fi
71
72 # Define what target system we're fixing.
73 #
74 if test -r ./Makefile; then
75   target_canonical="`sed -n -e 's,^target[      ]*=[    ]*\(.*\)$,\1,p' < Makefile`"
76 fi
77
78 # If not from the Makefile, then try config.guess
79 #
80 if test -z "${target_canonical}" ; then
81   if test -x ./config.guess ; then
82     target_canonical="`config.guess`" ; fi
83   test -z "${target_canonical}" && target_canonical=unknown
84 fi
85 export target_canonical
86
87 # # # # # # # # # # # # # # # # # # # # #
88 #
89 # Define PWDCMD as a command to use to get the working dir
90 # in the form that we want.
91 PWDCMD=pwd
92
93 case "`$PWDCMD`" in
94 //*)
95     # On an Apollo, discard everything before `/usr'.
96     PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
97     ;;
98 esac
99
100 # Original directory.
101 ORIGDIR=`${PWDCMD}`
102
103 # Make LIB absolute only if needed to avoid problems with the amd.
104 case $LIB in
105 /*)
106     ;;
107 *)
108     cd $LIB; LIB=`${PWDCMD}`
109     ;;
110 esac
111
112 if test $VERBOSE -gt 0
113 then echo Fixing headers into ${LIB} for ${target_canonical} target ; fi
114
115 # Determine whether this system has symbolic links.
116 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
117   rm -f $LIB/ShouldNotExist
118   LINKS=true
119 elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
120   rm -f /tmp/ShouldNotExist
121   LINKS=true
122 else
123   LINKS=false
124 fi
125
126 # # # # # # # # # # # # # # # # # # # # #
127 #
128 #  Search each input directory for broken header files.
129 #  This loop ends near the end of the file.
130 #
131 if test $# -eq 0
132 then
133     INPUTLIST="/usr/include"
134 else
135     INPUTLIST="$@"
136 fi
137
138 for INPUT in ${INPUTLIST} ; do
139
140 cd ${ORIGDIR}
141
142 cd ${INPUT} || continue
143 INPUT=`${PWDCMD}`
144
145 #
146 # # # # # # # # # # # # # # # # # # # # #
147 #
148 if test $VERBOSE -gt 1
149 then echo Finding directories and links to directories ; fi
150
151 # Find all directories and all symlinks that point to directories.
152 # Put the list in $all_dirs.
153 # Each time we find a symlink, add it to newdirs
154 # so that we do another find within the dir the link points to.
155 # Note that $all_dirs may have duplicates in it;
156 # later parts of this file are supposed to ignore them.
157 dirs="."
158 levels=2
159 all_dirs=""
160 search_dirs=""
161
162 while [ -n "$dirs" ] && [ $levels -gt 0 ]
163 do
164   levels=`expr $levels - 1`
165   newdirs=
166   for d in $dirs
167   do
168     if test $VERBOSE -gt 1
169     then echo " Searching $INPUT/$d" ; fi
170
171     # Find all directories under $d, relative to $d, excluding $d itself.
172     # (The /. is needed after $d in case $d is a symlink.)
173     all_dirs="$all_dirs `find $d/. -type d -print | \
174                sed -e '/\/\.$/d' -e 's@/./@/@g'`"
175     # Find all links to directories.
176     # Using `-exec test -d' in find fails on some systems,
177     # and trying to run test via sh fails on others,
178     # so this is the simplest alternative left.
179     # First find all the links, then test each one.
180     theselinks=
181     $LINKS && \
182       theselinks=`find $d/. -type l -print | sed -e 's@/./@/@g'`
183     for d1 in $theselinks --dummy--
184     do
185       # If the link points to a directory,
186       # add that dir to $newdirs
187       if [ -d $d1 ]
188       then
189         all_dirs="$all_dirs $d1"
190         if [ "`ls -ld $d1 | sed -n 's/.*-> //p'`" != "." ]
191         then
192           newdirs="$newdirs $d1"
193           search_dirs="$search_dirs $d1"
194         fi
195       fi
196     done
197   done
198
199   dirs="$newdirs"
200 done
201
202 # # # # # # # # # # # # # # # # # # # # #
203 #
204 dirs=
205 if test $VERBOSE -gt 2
206 then echo "All directories (including links to directories):"
207      echo $all_dirs
208 fi
209
210 for file in $all_dirs; do
211   rm -rf $LIB/$file
212   if [ ! -d $LIB/$file ]
213   then mkdir $LIB/$file
214   fi
215 done
216 mkdir $LIB/root
217
218 # # # # # # # # # # # # # # # # # # # # #
219 #
220 # treetops gets an alternating list
221 # of old directories to copy
222 # and the new directories to copy to.
223 treetops=". ${LIB}"
224
225 if $LINKS; then
226   if test $VERBOSE -gt 1
227   then echo 'Making symbolic directory links' ; fi
228   cwd=`${PWDCMD}`
229
230   for sym_link in $search_dirs; do
231     cd ${INPUT}
232     dest=`ls -ld ${sym_link} | sed -n 's/.*-> //p'`
233
234     # In case $dest is relative, get to ${sym_link}'s dir first.
235     #
236     cd ./`echo ${sym_link} | sed 's;/[^/]*$;;'`
237
238     # Check that the target directory exists.
239     # Redirections changed to avoid bug in sh on Ultrix.
240     #
241     (cd $dest) > /dev/null 2>&1
242     if [ $? = 0 ]; then
243       cd $dest
244
245       # full_dest_dir gets the dir that the link actually leads to.
246       #
247       full_dest_dir=`${PWDCMD}`
248
249       # Canonicalize ${INPUT} now to minimize the time an
250       # automounter has to change the result of ${PWDCMD}.
251       #
252       cinput=`cd ${INPUT}; ${PWDCMD}`
253
254       # If a link points to ., make a similar link to .
255       #
256       if [ ${full_dest_dir} = ${cinput} ]; then
257         if test $VERBOSE -gt 2
258         then echo ${sym_link} '->' . ': Making self link' ; fi
259         rm -fr ${LIB}/${sym_link} > /dev/null 2>&1
260         ln -s . ${LIB}/${sym_link} > /dev/null 2>&1
261
262       # If link leads back into ${INPUT},
263       # make a similar link here.
264       #
265       elif expr ${full_dest_dir} : "${cinput}/.*" > /dev/null; then
266         # Y gets the actual target dir name, relative to ${INPUT}.
267         y=`echo ${full_dest_dir} | sed -n "s&${cinput}/&&p"`
268         # DOTS is the relative path from ${LIB}/${sym_link} back to ${LIB}.
269         dots=`echo "${sym_link}" |
270           sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
271         if test $VERBOSE -gt 2
272         then echo ${sym_link} '->' $dots$y ': Making local link' ; fi
273         rm -fr ${LIB}/${sym_link} > /dev/null 2>&1
274         ln -s $dots$y ${LIB}/${sym_link} > /dev/null 2>&1
275
276       else
277         # If the link is to a dir $target outside ${INPUT},
278         # repoint the link at ${INPUT}/root$target
279         # and process $target into ${INPUT}/root$target
280         # treat this directory as if it actually contained the files.
281         #
282         if test $VERBOSE -gt 2
283         then echo ${sym_link} '->' root${full_dest_dir} ': Making rooted link'
284         fi
285         if [ -d $LIB/root${full_dest_dir} ]
286         then true
287         else
288           dirname=root${full_dest_dir}/
289           dirmade=.
290           cd $LIB
291           while [ x$dirname != x ]; do
292             component=`echo $dirname | sed -e 's|/.*$||'`
293             mkdir $component >/dev/null 2>&1
294             cd $component
295             dirmade=$dirmade/$component
296             dirname=`echo $dirname | sed -e 's|[^/]*/||'`
297           done
298         fi
299
300         # Duplicate directory structure created in ${LIB}/${sym_link} in new
301         # root area.
302         #
303         for file2 in $all_dirs; do
304           case $file2 in
305             ${sym_link}/*)
306               dupdir=${LIB}/root${full_dest_dir}/`echo $file2 |
307                       sed -n "s|^${sym_link}/||p"`
308               if test $VERBOSE -gt 2
309               then echo "Duplicating ${sym_link}'s ${dupdir}" ; fi
310               if [ -d ${dupdir} ]
311               then true
312               else
313                 mkdir ${dupdir}
314               fi
315               ;;
316             *)
317               ;;
318           esac
319         done
320
321         # Get the path from ${LIB} to ${sym_link}, accounting for symlinks.
322         #
323         parent=`echo "${sym_link}" | sed -e 's@/[^/]*$@@'`
324         libabs=`cd ${LIB}; ${PWDCMD}`
325         file2=`cd ${LIB}; cd $parent; ${PWDCMD} | sed -e "s@^${libabs}@@"`
326
327         # DOTS is the relative path from ${LIB}/${sym_link} back to ${LIB}.
328         #
329         dots=`echo "$file2" | sed -e 's@/[^/]*@../@g'`
330         rm -fr ${LIB}/${sym_link} > /dev/null 2>&1
331         ln -s ${dots}root${full_dest_dir} ${LIB}/${sym_link} > /dev/null 2>&1
332         treetops="$treetops ${sym_link} ${LIB}/root${full_dest_dir}"
333       fi
334     fi
335   done
336 fi
337
338 # # # # # # # # # # # # # # # # # # # # #
339 #
340 required=
341 set x $treetops
342 shift
343 while [ $# != 0 ]; do
344   # $1 is an old directory to copy, and $2 is the new directory to copy to.
345   #
346   SRCDIR=`cd ${INPUT} ; cd $1 ; ${PWDCMD}`
347   export SRCDIR
348
349   FIND_BASE=$1
350   export FIND_BASE
351   shift
352
353   DESTDIR=`cd $1;${PWDCMD}`
354   export DESTDIR
355   shift
356
357   # The same dir can appear more than once in treetops.
358   # There's no need to scan it more than once.
359   #
360   if [ -f ${DESTDIR}/DONE ]
361   then continue ; fi
362
363   touch ${DESTDIR}/DONE
364   if test $VERBOSE -gt 1
365   then echo Fixing directory ${SRCDIR} into ${DESTDIR} ; fi
366
367   # Check files which are symlinks as well as those which are files.
368   #
369   cd ${INPUT}
370   files=`if $LINKS; then
371     find ${FIND_BASE}/. -name '*.h' \( -type f -o -type l \) -print
372   else
373     find ${FIND_BASE}/. -name '*.h' -type f -print
374   fi | \
375     sed -e 's;/\./;/;g' -e 's;//*;/;g' `
376
377   echo Checking header files
378   for file in $files; do
379
380     # Skip unreadable files, symlinks to directories and glibc files
381     if test ! -r "${file}" || test -d "${file}/." ; then
382       continue
383     fi
384
385     fixlist=""
386     DESTFILE=${DESTDIR}/`echo ${file} | sed "s;${FIND_BASE}/;;" `
387
388     #
389     # Fix Aaa_Ki_Iface
390     #
391     case "${file}" in ./sys/ki_iface.h )
392     if ( test -n "`egrep 'These definitions are for HP Internal developers' ${file}`"
393        ) > /dev/null 2>&1 ; then
394     echo "AAA_ki_iface bypassing file ${file}"
395     continue
396
397     fi # end of select 'if'
398     ;; # case end for file name test
399     esac
400
401
402     #
403     # Fix Aaa_Ki
404     #
405     case "${file}" in ./sys/ki.h )
406     if ( test -n "`egrep '11.00 HP-UX LP64' ${file}`"
407        ) > /dev/null 2>&1 ; then
408     echo "AAA_ki bypassing file ${file}"
409     continue
410
411     fi # end of select 'if'
412     ;; # case end for file name test
413     esac
414
415
416     #
417     # Fix Aaa_Ki_Calls
418     #
419     case "${file}" in ./sys/ki_calls.h )
420     if ( test -n "`egrep 'kthread_create_caller_t' ${file}`"
421        ) > /dev/null 2>&1 ; then
422     echo "AAA_ki_calls bypassing file ${file}"
423     continue
424
425     fi # end of select 'if'
426     ;; # case end for file name test
427     esac
428
429
430     #
431     # Fix Aaa_Ki_Defs
432     #
433     case "${file}" in ./sys/ki_defs.h )
434     if ( test -n "`egrep 'Kernel Instrumentation Definitions' ${file}`"
435        ) > /dev/null 2>&1 ; then
436     echo "AAA_ki_defs bypassing file ${file}"
437     continue
438
439     fi # end of select 'if'
440     ;; # case end for file name test
441     esac
442
443
444     #
445     # Fix Aaa_Bad_Fixes
446     #
447     case "${file}" in ./sundev/ipi_error.h )
448     echo "AAA_bad_fixes bypassing file ${file}"
449     continue
450
451     ;; # case end for file name test
452     esac
453
454
455     #
456     # Fix Aaa_Time
457     #
458     case "${file}" in ./sys/time.h )
459     if ( test -n "`egrep '11.0 and later representation of ki time' ${file}`"
460        ) > /dev/null 2>&1 ; then
461     echo "AAA_time bypassing file ${file}"
462     continue
463
464     fi # end of select 'if'
465     ;; # case end for file name test
466     esac
467
468
469     #
470     # Fix Aab_Dgux_Int_Varargs
471     #
472     case "${file}" in ./_int_varargs.h )
473     echo "AAB_dgux_int_varargs replacing file ${file}" >&2
474     cat > ${DESTFILE} << '_EOF_'
475 #ifndef __INT_VARARGS_H
476 #define __INT_VARARGS_H
477
478 /************************************************************************/
479 /* _INT_VARARGS.H - Define the common stuff for varargs/stdarg/stdio.   */
480 /************************************************************************/
481
482 /*
483 ** This file is a DG internal header.  Never include this
484 ** file directly.
485 */
486
487 #ifndef ___int_features_h
488 #include &lt;sys/_int_features.h&gt;
489 #endif
490
491 #if !(defined(_VA_LIST) || defined(_VA_LIST_))
492 #define _VA_LIST
493 #define _VA_LIST_
494
495 #ifdef __LINT__
496
497 #ifdef __STDC__
498 typedef void * va_list;
499 #else
500 typedef char * va_list;
501 #endif
502
503 #else
504 #if _M88K_ANY
505
506 #if defined(__DCC__)
507
508 typedef struct {
509       int     next_arg;
510       int     *mem_ptr;
511       int     *reg_ptr;
512 } va_list;
513
514 #else  /* ! defined(__DCC__) */
515
516 typedef struct {
517       int  __va_arg;       /* argument number */
518       int *__va_stk;       /* start of args passed on stack */
519       int *__va_reg;       /* start of args passed in regs */
520 } va_list;
521
522 #endif  /* ! defined(__DCC__) */
523
524 #elif _IX86_ANY
525
526 #if defined(__GNUC__) || defined(__STDC__)
527 typedef void * va_list;
528 #else
529 typedef char * va_list;
530 #endif
531
532 #endif  /*  _IX86_ANY */
533
534 #endif /* __LINT__ */
535 #endif /*  !(defined(_VA_LIST) || defined(_VA_LIST_)) */
536 #endif /*  #ifndef __INT_VARARGS_H  */
537
538 _EOF_
539     continue
540
541     ;; # case end for file name test
542     esac
543
544
545     #
546     # Fix Aab_Fd_Zero_Asm_Posix_Types_H
547     #
548     case "${file}" in ./asm/posix_types.h )
549     case "$target_canonical" in i[34567]86-*-linux-gnu* )
550     if ( test -z "`egrep '} while' ${file}`"
551        ) > /dev/null 2>&1 ; then
552     echo "AAB_fd_zero_asm_posix_types_h replacing file ${file}" >&2
553     cat > ${DESTFILE} << '_EOF_'
554 /* This file fixes a bug in the __FD_ZERO macro
555    for older versions of the Linux kernel. */
556 #ifndef _POSIX_TYPES_H_WRAPPER
557 #include <features.h>
558 #include_next <asm/posix_types.h>
559
560 #if defined(__FD_ZERO) && !defined(__GLIBC__)
561 #undef __FD_ZERO
562 #define __FD_ZERO(fdsetp) \
563   do { \
564     int __d0, __d1; \
565                 __asm__ __volatile__("cld ; rep ; stosl" \
566                         : "=&c" (__d0), "=&D" (__d1) \
567                         : "a" (0), "0" (__FDSET_LONGS), \
568                           "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
569   } while (0)
570 #endif
571
572 #define _POSIX_TYPES_H_WRAPPER
573 #endif /* _POSIX_TYPES_H_WRAPPER */
574
575 _EOF_
576     continue
577
578     fi # end of bypass 'if'
579     ;; # case end for machine type test
580     esac
581     ;; # case end for file name test
582     esac
583
584
585     #
586     # Fix Aab_Fd_Zero_Gnu_Types_H
587     #
588     case "${file}" in ./gnu/types.h )
589     case "$target_canonical" in i[34567]86-*-linux-gnu* )
590     echo "AAB_fd_zero_gnu_types_h replacing file ${file}" >&2
591     cat > ${DESTFILE} << '_EOF_'
592 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
593 #ifndef _TYPES_H_WRAPPER
594 #include <features.h>
595 #include_next <gnu/types.h>
596
597 #if defined(__FD_ZERO) && !defined(__GLIBC__)
598 #undef __FD_ZERO
599 # define __FD_ZERO(fdsetp) \
600   do { \
601     int __d0, __d1; \
602         __asm__ __volatile__("cld ; rep ; stosl" \
603                 : "=&c" (__d0), "=&D" (__d1) \
604                 : "a" (0), "0" (__FDSET_LONGS), \
605                   "1" ((__fd_set *) (fdsetp)) :"memory"); \
606   } while (0)
607 #endif
608
609 #define _TYPES_H_WRAPPER
610 #endif /* _TYPES_H_WRAPPER */
611
612 _EOF_
613     continue
614
615     ;; # case end for machine type test
616     esac
617     ;; # case end for file name test
618     esac
619
620
621     #
622     # Fix Aab_Fd_Zero_Selectbits_H
623     #
624     case "${file}" in ./selectbits.h )
625     case "$target_canonical" in i[34567]86-*-linux-gnu* )
626     echo "AAB_fd_zero_selectbits_h replacing file ${file}" >&2
627     cat > ${DESTFILE} << '_EOF_'
628 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
629 #ifndef _SELECTBITS_H_WRAPPER
630 #include <features.h>
631 #include_next <selectbits.h>
632
633 #if defined(__FD_ZERO) && defined(__GLIBC__) \
634         && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \
635         && __GLIBC_MINOR__ == 0
636 #undef __FD_ZERO
637 #define __FD_ZERO(fdsetp) \
638   do { \
639     int __d0, __d1; \
640   __asm__ __volatile__ ("cld; rep; stosl" \
641                         : "=&c" (__d0), "=&D" (__d1) \
642                         : "a" (0), "0" (sizeof (__fd_set) \
643                                         / sizeof (__fd_mask)), \
644                           "1" ((__fd_mask *) (fdsetp)) \
645                         : "memory"); \
646   } while (0)
647 #endif
648
649 #define _SELECTBITS_H_WRAPPER
650 #endif /* _SELECTBITS_H_WRAPPER */
651
652 _EOF_
653     continue
654
655     ;; # case end for machine type test
656     esac
657     ;; # case end for file name test
658     esac
659
660
661     #
662     # Fix Aab_Sun_Memcpy
663     #
664     case "${file}" in ./memory.h )
665     if ( test -n "`egrep '/\\*  @\\(#\\)(head/memory.h  50.1     |memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2    )\\*/' ${file}`"
666        ) > /dev/null 2>&1 ; then
667     echo "AAB_sun_memcpy replacing file ${file}" >&2
668     cat > ${DESTFILE} << '_EOF_'
669 /* This file was generated by fixincludes */
670 #ifndef __memory_h__
671 #define __memory_h__
672
673 #ifdef __STDC__
674 extern void *memccpy();
675 extern void *memchr();
676 extern void *memcpy();
677 extern void *memset();
678 #else
679 extern char *memccpy();
680 extern char *memchr();
681 extern char *memcpy();
682 extern char *memset();
683 #endif /* __STDC__ */
684
685 extern int memcmp();
686
687 #endif /* __memory_h__ */
688
689 _EOF_
690     continue
691
692     fi # end of select 'if'
693     ;; # case end for file name test
694     esac
695
696
697     #
698     # Fix Aab_Svr4_Replace_Byteorder
699     #
700     case "${file}" in ./sys/byteorder.h )
701     case "$target_canonical" in *-*-sysv4* | \
702         i[34567]86-*-sysv5* | \
703         i[34567]86-*-udk* | \
704         i[34567]86-*-solaris2.[0-4] | \
705         powerpcle-*-solaris2.[0-4] | \
706         sparc-*-solaris2.[0-4] )
707     echo "AAB_svr4_replace_byteorder replacing file ${file}" >&2
708     cat > ${DESTFILE} << '_EOF_'
709 #ifndef _SYS_BYTEORDER_H
710 #define _SYS_BYTEORDER_H
711
712 /* Functions to convert `short' and `long' quantities from host byte order
713    to (internet) network byte order (i.e. big-endian).
714
715    Written by Ron Guilmette (rfg@ncd.com).
716
717    This isn't actually used by GCC.  It is installed by fixinc.svr4.
718
719    For big-endian machines these functions are essentially no-ops.
720
721    For little-endian machines, we define the functions using specialized
722    asm sequences in cases where doing so yields better code (e.g. i386).  */
723
724 #if !defined (__GNUC__) && !defined (__GNUG__)
725 #error You lose!  This file is only useful with GNU compilers.
726 #endif
727
728 #ifndef __BYTE_ORDER__
729 /* Byte order defines.  These are as defined on UnixWare 1.1, but with
730    double underscores added at the front and back.  */
731 #define __LITTLE_ENDIAN__   1234
732 #define __BIG_ENDIAN__      4321
733 #define __PDP_ENDIAN__      3412
734 #endif
735
736 #ifdef __STDC__
737 static __inline__ unsigned long htonl (unsigned long);
738 static __inline__ unsigned short htons (unsigned int);
739 static __inline__ unsigned long ntohl (unsigned long);
740 static __inline__ unsigned short ntohs (unsigned int);
741 #endif /* defined (__STDC__) */
742
743 #if defined (__i386__)
744
745 #ifndef __BYTE_ORDER__
746 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
747 #endif
748
749 /* Convert a host long to a network long.  */
750
751 /* We must use a new-style function definition, so that this will also
752    be valid for C++.  */
753 static __inline__ unsigned long
754 htonl (unsigned long __arg)
755 {
756   register unsigned long __result;
757
758   __asm__ ("xchg%B0 %b0,%h0
759         ror%L0 $16,%0
760         xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
761   return __result;
762 }
763
764 /* Convert a host short to a network short.  */
765
766 static __inline__ unsigned short
767 htons (unsigned int __arg)
768 {
769   register unsigned short __result;
770
771   __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
772   return __result;
773 }
774
775 #elif ((defined (__i860__) && !defined (__i860_big_endian__))   \
776        || defined (__ns32k__) || defined (__vax__)              \
777        || defined (__spur__) || defined (__arm__))
778
779 #ifndef __BYTE_ORDER__
780 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
781 #endif
782
783 /* For other little-endian machines, using C code is just as efficient as
784    using assembly code.  */
785
786 /* Convert a host long to a network long.  */
787
788 static __inline__ unsigned long
789 htonl (unsigned long __arg)
790 {
791   register unsigned long __result;
792
793   __result = (__arg >> 24) & 0x000000ff;
794   __result |= (__arg >> 8) & 0x0000ff00;
795   __result |= (__arg << 8) & 0x00ff0000;
796   __result |= (__arg << 24) & 0xff000000;
797   return __result;
798 }
799
800 /* Convert a host short to a network short.  */
801
802 static __inline__ unsigned short
803 htons (unsigned int __arg)
804 {
805   register unsigned short __result;
806
807   __result = (__arg << 8) & 0xff00;
808   __result |= (__arg >> 8) & 0x00ff;
809   return __result;
810 }
811
812 #else /* must be a big-endian machine */
813
814 #ifndef __BYTE_ORDER__
815 #define __BYTE_ORDER__ __BIG_ENDIAN__
816 #endif
817
818 /* Convert a host long to a network long.  */
819
820 static __inline__ unsigned long
821 htonl (unsigned long __arg)
822 {
823   return __arg;
824 }
825
826 /* Convert a host short to a network short.  */
827
828 static __inline__ unsigned short
829 htons (unsigned int __arg)
830 {
831   return __arg;
832 }
833
834 #endif /* big-endian */
835
836 /* Convert a network long to a host long.  */
837
838 static __inline__ unsigned long
839 ntohl (unsigned long __arg)
840 {
841   return htonl (__arg);
842 }
843
844 /* Convert a network short to a host short.  */
845
846 static __inline__ unsigned short
847 ntohs (unsigned int __arg)
848 {
849   return htons (__arg);
850 }
851 #endif
852
853 _EOF_
854     continue
855
856     ;; # case end for machine type test
857     esac
858     ;; # case end for file name test
859     esac
860
861
862     #
863     # Fix Aab_Ultrix_Ansi_Compat
864     #
865     case "${file}" in ./ansi_compat.h )
866     if ( test -n "`egrep 'ULTRIX' ${file}`"
867        ) > /dev/null 2>&1 ; then
868     echo "AAB_ultrix_ansi_compat replacing file ${file}" >&2
869     cat > ${DESTFILE} << '_EOF_'
870 /* This file intentionally left blank.  */
871
872 _EOF_
873     continue
874
875     fi # end of select 'if'
876     ;; # case end for file name test
877     esac
878
879
880     #
881     # Fix Aix_Syswait
882     #
883     case "${file}" in ./sys/wait.h )
884     if ( test -n "`egrep 'bos325,' ${file}`"
885        ) > /dev/null 2>&1 ; then
886     fixlist="${fixlist}
887       aix_syswait"
888     if [ ! -r ${DESTFILE} ]
889     then infile=${file}
890     else infile=${DESTFILE} ; fi 
891
892     sed -e '/^extern pid_t wait3();$/i\
893 struct rusage;
894 ' \
895           < $infile > ${DESTDIR}/fixinc.tmp
896     rm -f ${DESTFILE}
897     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
898     fi # end of select 'if'
899     ;; # case end for file name test
900     esac
901
902
903     #
904     # Fix Aix_Volatile
905     #
906     case "${file}" in ./sys/signal.h )
907     if ( test -n "`egrep 'typedef volatile int sig_atomic_t' ${file}`"
908        ) > /dev/null 2>&1 ; then
909     fixlist="${fixlist}
910       aix_volatile"
911     if [ ! -r ${DESTFILE} ]
912     then infile=${file}
913     else infile=${DESTFILE} ; fi 
914
915     sed -e 's/typedef volatile int sig_atomic_t/typedef int sig_atomic_t/' \
916           < $infile > ${DESTDIR}/fixinc.tmp
917     rm -f ${DESTFILE}
918     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
919     fi # end of select 'if'
920     ;; # case end for file name test
921     esac
922
923
924     #
925     # Fix Alpha_Getopt
926     #
927     case "${file}" in ./stdio.h | \
928         ./stdlib.h )
929     if ( test -n "`egrep 'getopt\\(int, char \\*\\[' ${file}`"
930        ) > /dev/null 2>&1 ; then
931     fixlist="${fixlist}
932       alpha_getopt"
933     if [ ! -r ${DESTFILE} ]
934     then infile=${file}
935     else infile=${DESTFILE} ; fi 
936
937     sed -e 's/getopt(int, char \*\[\],[ ]*char \*)/getopt(int, char *const[], const char *)/' \
938           < $infile > ${DESTDIR}/fixinc.tmp
939     rm -f ${DESTFILE}
940     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
941     fi # end of select 'if'
942     ;; # case end for file name test
943     esac
944
945
946     #
947     # Fix Alpha_Parens
948     #
949     case "${file}" in ./sym.h )
950     if ( test -n "`egrep '#ifndef\\(__mips64\\)' ${file}`"
951        ) > /dev/null 2>&1 ; then
952     fixlist="${fixlist}
953       alpha_parens"
954     if [ ! -r ${DESTFILE} ]
955     then infile=${file}
956     else infile=${DESTFILE} ; fi 
957
958     sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
959           < $infile > ${DESTDIR}/fixinc.tmp
960     rm -f ${DESTFILE}
961     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
962     fi # end of select 'if'
963     ;; # case end for file name test
964     esac
965
966
967     #
968     # Fix Alpha_Sbrk
969     #
970     case "${file}" in ./unistd.h )
971     if ( test -n "`egrep 'char[         ]*\\*[   ]*sbrk[        ]*\\(' ${file}`"
972        ) > /dev/null 2>&1 ; then
973     fixlist="${fixlist}
974       alpha_sbrk"
975     if [ ! -r ${DESTFILE} ]
976     then infile=${file}
977     else infile=${DESTFILE} ; fi 
978
979     sed -e 's/char\([   ]*\*[    ]*sbrk[        ]*(\)/void\1/' \
980           < $infile > ${DESTDIR}/fixinc.tmp
981     rm -f ${DESTFILE}
982     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
983     fi # end of select 'if'
984     ;; # case end for file name test
985     esac
986
987
988     #
989     # Fix Arm_Norcroft_Hint
990     #
991     case "${file}" in ./X11/Intrinsic.h )
992     if ( test -n "`egrep '___type p_type' ${file}`"
993        ) > /dev/null 2>&1 ; then
994     fixlist="${fixlist}
995       arm_norcroft_hint"
996     if [ ! -r ${DESTFILE} ]
997     then infile=${file}
998     else infile=${DESTFILE} ; fi 
999
1000     sed -e 's/___type p_type/p_type/' \
1001           < $infile > ${DESTDIR}/fixinc.tmp
1002     rm -f ${DESTFILE}
1003     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1004     fi # end of select 'if'
1005     ;; # case end for file name test
1006     esac
1007
1008
1009     #
1010     # Fix Arm_Wchar
1011     #
1012     case "${file}" in ./stdlib.h )
1013     if ( test -n "`egrep '#[    ]*define[       ]*__wchar_t' ${file}`"
1014        ) > /dev/null 2>&1 ; then
1015     fixlist="${fixlist}
1016       arm_wchar"
1017     if [ ! -r ${DESTFILE} ]
1018     then infile=${file}
1019     else infile=${DESTFILE} ; fi 
1020
1021     sed -e 's/\(#[      ]*ifndef[       ]*\)__wchar_t/\1_GCC_WCHAR_T/' \
1022         -e 's/\(#[      ]*define[       ]*\)__wchar_t/\1_GCC_WCHAR_T/' \
1023           < $infile > ${DESTDIR}/fixinc.tmp
1024     rm -f ${DESTFILE}
1025     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1026     fi # end of select 'if'
1027     ;; # case end for file name test
1028     esac
1029
1030
1031     #
1032     # Fix Aux_Asm
1033     #
1034     case "${file}" in ./sys/param.h )
1035     if ( test -n "`egrep '#ifndef NOINLINE' ${file}`"
1036        ) > /dev/null 2>&1 ; then
1037     fixlist="${fixlist}
1038       aux_asm"
1039     if [ ! -r ${DESTFILE} ]
1040     then infile=${file}
1041     else infile=${DESTFILE} ; fi 
1042
1043     sed -e 's|#ifndef NOINLINE|#if !defined(NOINLINE) \&\& !defined(__GNUC__)|' \
1044           < $infile > ${DESTDIR}/fixinc.tmp
1045     rm -f ${DESTFILE}
1046     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1047     fi # end of select 'if'
1048     ;; # case end for file name test
1049     esac
1050
1051
1052     #
1053     # Fix Avoid_Bool
1054     #
1055     case "${file}" in ./curses.h | \
1056         ./curses_colr/curses.h | \
1057         ./term.h | \
1058         ./tinfo.h )
1059     if ( test -n "`egrep 'char[         ]+bool|bool[    ]+char' ${file}`"
1060        ) > /dev/null 2>&1 ; then
1061     if ( test -z "`egrep 'we must use the C\\+\\+ compiler'\\''s type' ${file}`"
1062        ) > /dev/null 2>&1 ; then
1063     fixlist="${fixlist}
1064       avoid_bool"
1065     if [ ! -r ${DESTFILE} ]
1066     then infile=${file}
1067     else infile=${DESTFILE} ; fi 
1068
1069     sed -e '/^#[        ]*define[       ][      ]*bool[         ][      ]*char[         ]*$/i\
1070 #ifndef __cplusplus
1071 ' \
1072         -e '/^#[        ]*define[       ][      ]*bool[         ][      ]*char[         ]*$/a\
1073 #endif
1074 ' \
1075         -e '/^typedef[  ][      ]*char[         ][      ]*bool[         ]*;/i\
1076 #ifndef __cplusplus
1077 ' \
1078         -e '/^typedef[  ][      ]*char[         ][      ]*bool[         ]*;/a\
1079 #endif
1080 ' \
1081         -e '/^[ ]*typedef[      ][      ]*unsigned char[        ][      ]*bool[         ]*;/i\
1082 #ifndef __cplusplus
1083 ' \
1084         -e '/^[ ]*typedef[      ][      ]*unsigned char[        ][      ]*bool[         ]*;/a\
1085 #endif
1086 ' \
1087         -e '/^typedef[  ][      ]*int[  ][      ]*bool[         ]*;/i\
1088 #ifndef __cplusplus
1089 ' \
1090         -e '/^typedef[  ][      ]*int[  ][      ]*bool[         ]*;/a\
1091 #endif
1092 ' \
1093         -e '/^[ ]*typedef[      ][      ]*unsigned int[         ][      ]*bool[         ]*;/i\
1094 #ifndef __cplusplus
1095 ' \
1096         -e '/^[ ]*typedef[      ][      ]*unsigned int[         ][      ]*bool[         ]*;/a\
1097 #endif
1098 ' \
1099           < $infile > ${DESTDIR}/fixinc.tmp
1100     rm -f ${DESTFILE}
1101     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1102     fi # end of bypass 'if'
1103     fi # end of select 'if'
1104     ;; # case end for file name test
1105     esac
1106
1107
1108     #
1109     # Fix Bad_Struct_Term
1110     #
1111     case "${file}" in ./curses.h )
1112     if ( test -n "`egrep '^[    ]*typedef[      ]+struct[       ]+term[         ]*;' ${file}`"
1113        ) > /dev/null 2>&1 ; then
1114     fixlist="${fixlist}
1115       bad_struct_term"
1116     if [ ! -r ${DESTFILE} ]
1117     then infile=${file}
1118     else infile=${DESTFILE} ; fi 
1119
1120     sed -e 's/^[        ]*typedef[      ][      ]*\(struct[     ][      ]*term[         ]*;[    ]*\)$/\1/' \
1121           < $infile > ${DESTDIR}/fixinc.tmp
1122     rm -f ${DESTFILE}
1123     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1124     fi # end of select 'if'
1125     ;; # case end for file name test
1126     esac
1127
1128
1129     #
1130     # Fix Badquote
1131     #
1132     case "${file}" in ./sundev/vuid_event.h )
1133     fixlist="${fixlist}
1134       badquote"
1135     if [ ! -r ${DESTFILE} ]
1136     then infile=${file}
1137     else infile=${DESTFILE} ; fi 
1138
1139     sed -e 's/doesn'\''t/does not/' \
1140           < $infile > ${DESTDIR}/fixinc.tmp
1141     rm -f ${DESTFILE}
1142     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1143     ;; # case end for file name test
1144     esac
1145
1146
1147     #
1148     # Fix Bad_Lval
1149     #
1150     case "${file}" in ./libgen.h | \
1151         ./dirent.h | \
1152         ./ftw.h | \
1153         ./grp.h | \
1154         ./ndbm.h | \
1155         ./pthread.h | \
1156         ./pwd.h | \
1157         ./signal.h | \
1158         ./standards.h | \
1159         ./stdlib.h | \
1160         ./string.h | \
1161         ./stropts.h | \
1162         ./time.h | \
1163         ./unistd.h )
1164     if ( test -n "`egrep '^[    ]*#[    ]*pragma[       ][      ]*extern_prefix' ${file}`"
1165        ) > /dev/null 2>&1 ; then
1166     fixlist="${fixlist}
1167       bad_lval"
1168     if [ ! -r ${DESTFILE} ]
1169     then infile=${file}
1170     else infile=${DESTFILE} ; fi 
1171
1172     sed -e 's/^[        ]*#[    ]*define[       ]*\([^(]*\)\(([^)]*)\)[         ]*\(_.\)\1\2[   ]*$/#define \1 \3\1/' \
1173           < $infile > ${DESTDIR}/fixinc.tmp
1174     rm -f ${DESTFILE}
1175     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1176     fi # end of select 'if'
1177     ;; # case end for file name test
1178     esac
1179
1180
1181     #
1182     # Fix Broken_Assert_Stdio
1183     #
1184     case "${file}" in ./assert.h )
1185     if ( test -n "`egrep 'stderr' ${file}`"
1186        ) > /dev/null 2>&1 ; then
1187     if ( test -z "`egrep 'include.*stdio.h' ${file}`"
1188        ) > /dev/null 2>&1 ; then
1189     fixlist="${fixlist}
1190       broken_assert_stdio"
1191     if [ ! -r ${DESTFILE} ]
1192     then infile=${file}
1193     else infile=${DESTFILE} ; fi 
1194
1195     sed -e '1i\
1196 #include <stdio.h>
1197 ' \
1198           < $infile > ${DESTDIR}/fixinc.tmp
1199     rm -f ${DESTFILE}
1200     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1201     fi # end of bypass 'if'
1202     fi # end of select 'if'
1203     ;; # case end for file name test
1204     esac
1205
1206
1207     #
1208     # Fix Broken_Assert_Stdlib
1209     #
1210     case "${file}" in ./assert.h )
1211     if ( test -n "`egrep 'exit *\\(|abort *\\(' ${file}`"
1212        ) > /dev/null 2>&1 ; then
1213     if ( test -z "`egrep 'include.*stdlib.h' ${file}`"
1214        ) > /dev/null 2>&1 ; then
1215     fixlist="${fixlist}
1216       broken_assert_stdlib"
1217     if [ ! -r ${DESTFILE} ]
1218     then infile=${file}
1219     else infile=${DESTFILE} ; fi 
1220
1221     sed -e '1i\
1222 #ifdef __cplusplus\
1223 #include <stdlib.h>\
1224 #endif
1225 ' \
1226           < $infile > ${DESTDIR}/fixinc.tmp
1227     rm -f ${DESTFILE}
1228     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1229     fi # end of bypass 'if'
1230     fi # end of select 'if'
1231     ;; # case end for file name test
1232     esac
1233
1234
1235     #
1236     # Fix Dec_Intern_Asm
1237     #
1238     case "${file}" in ./c_asm.h )
1239     fixlist="${fixlist}
1240       dec_intern_asm"
1241     if [ ! -r ${DESTFILE} ]
1242     then infile=${file}
1243     else infile=${DESTFILE} ; fi 
1244
1245     sed -e '/^[         ]*float[        ]*fasm/i\
1246 #ifdef __DECC
1247 ' \
1248         -e '/^[         ]*#[    ]*pragma[       ]*intrinsic([   ]*dasm/a\
1249 #endif
1250 ' \
1251           < $infile > ${DESTDIR}/fixinc.tmp
1252     rm -f ${DESTFILE}
1253     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1254     ;; # case end for file name test
1255     esac
1256
1257
1258     #
1259     # Fix No_Double_Slash
1260     #
1261     if ${FIXTESTS} ${file} double_slash
1262     then
1263     fixlist="${fixlist}
1264       no_double_slash"
1265     if [ ! -r ${DESTFILE} ]
1266     then infile=${file}
1267     else infile=${DESTFILE} ; fi 
1268     ${FIXFIXES} ${file} no_double_slash < $infile > ${DESTDIR}/fixinc.tmp
1269     rm -f ${DESTFILE}
1270     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1271     fi # end of c_test 'if'
1272
1273
1274     #
1275     # Fix Ecd_Cursor
1276     #
1277     case "${file}" in ./sunwindow/win_lock.h | \
1278         ./sunwindow/win_cursor.h )
1279     fixlist="${fixlist}
1280       ecd_cursor"
1281     if [ ! -r ${DESTFILE} ]
1282     then infile=${file}
1283     else infile=${DESTFILE} ; fi 
1284
1285     sed -e 's/ecd.cursor/ecd_cursor/' \
1286           < $infile > ${DESTDIR}/fixinc.tmp
1287     rm -f ${DESTFILE}
1288     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1289     ;; # case end for file name test
1290     esac
1291
1292
1293     #
1294     # Fix Sco5_Stat_Wrappers
1295     #
1296     case "${file}" in ./sys/stat.h )
1297     case "$target_canonical" in i*86-*-sco3.2v5* )
1298     fixlist="${fixlist}
1299       sco5_stat_wrappers"
1300     if [ ! -r ${DESTFILE} ]
1301     then infile=${file}
1302     else infile=${DESTFILE} ; fi 
1303
1304     sed -e '/^static int[       ]*[a-z]*stat(/i\
1305 #ifdef __cplusplus\
1306 extern "C"\
1307 {\
1308 #endif\
1309 ' \
1310         -e '/^}$/a\
1311 #ifdef __cplusplus\
1312 }\
1313 #endif /* __cplusplus */\
1314 ' \
1315           < $infile > ${DESTDIR}/fixinc.tmp
1316     rm -f ${DESTFILE}
1317     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1318     ;; # case end for machine type test
1319     esac
1320     ;; # case end for file name test
1321     esac
1322
1323
1324     #
1325     # Fix End_Else_Label
1326     #
1327     if ${FIXTESTS} ${file} else_endif_label
1328     then
1329     fixlist="${fixlist}
1330       end_else_label"
1331     if [ ! -r ${DESTFILE} ]
1332     then infile=${file}
1333     else infile=${DESTFILE} ; fi 
1334     ${FIXFIXES} ${file} else_endif_label < $infile > ${DESTDIR}/fixinc.tmp
1335     rm -f ${DESTFILE}
1336     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1337     fi # end of c_test 'if'
1338
1339
1340     #
1341     # Fix Hp_Inline
1342     #
1343     case "${file}" in ./sys/spinlock.h )
1344     if ( test -n "`egrep 'include.*\"\\.\\./machine/' ${file}`"
1345        ) > /dev/null 2>&1 ; then
1346     fixlist="${fixlist}
1347       hp_inline"
1348     if [ ! -r ${DESTFILE} ]
1349     then infile=${file}
1350     else infile=${DESTFILE} ; fi 
1351
1352     sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
1353         -e 's,"../machine/psl.h",<machine/psl.h>,' \
1354           < $infile > ${DESTDIR}/fixinc.tmp
1355     rm -f ${DESTFILE}
1356     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1357     fi # end of select 'if'
1358     ;; # case end for file name test
1359     esac
1360
1361
1362     #
1363     # Fix Hp_Sysfile
1364     #
1365     case "${file}" in ./sys/file.h )
1366     if ( test -n "`egrep 'HPUX_SOURCE' ${file}`"
1367        ) > /dev/null 2>&1 ; then
1368     fixlist="${fixlist}
1369       hp_sysfile"
1370     if [ ! -r ${DESTFILE} ]
1371     then infile=${file}
1372     else infile=${DESTFILE} ; fi 
1373
1374     sed -e 's/(\.\.\.)/(struct file * ...)/' \
1375           < $infile > ${DESTDIR}/fixinc.tmp
1376     rm -f ${DESTFILE}
1377     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1378     fi # end of select 'if'
1379     ;; # case end for file name test
1380     esac
1381
1382
1383     #
1384     # Fix Cxx_Unready
1385     #
1386     case "${file}" in ./sys/mman.h | \
1387         ./rpc/types.h )
1388     if ( test -z "`egrep '\"C\"|__BEGIN_DECLS' ${file}`"
1389        ) > /dev/null 2>&1 ; then
1390     fixlist="${fixlist}
1391       cxx_unready"
1392     if [ ! -r ${DESTFILE} ]
1393     then infile=${file}
1394     else infile=${DESTFILE} ; fi 
1395
1396     sed -e '1i\
1397 #ifdef __cplusplus\
1398 extern "C" {\
1399 #endif\
1400
1401 ' \
1402         -e '$a\
1403 #ifdef __cplusplus\
1404 }\
1405 #endif
1406 ' \
1407           < $infile > ${DESTDIR}/fixinc.tmp
1408     rm -f ${DESTFILE}
1409     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1410     fi # end of bypass 'if'
1411     ;; # case end for file name test
1412     esac
1413
1414
1415     #
1416     # Fix Hpux_Maxint
1417     #
1418     case "${file}" in ./sys/param.h )
1419     fixlist="${fixlist}
1420       hpux_maxint"
1421     if [ ! -r ${DESTFILE} ]
1422     then infile=${file}
1423     else infile=${DESTFILE} ; fi 
1424
1425     sed -e '/^#[        ]*define[       ]*MAXINT[       ]/i\
1426 #ifndef MAXINT
1427 ' \
1428         -e '/^#[        ]*define[       ]*MAXINT[       ]/a\
1429 #endif
1430 ' \
1431           < $infile > ${DESTDIR}/fixinc.tmp
1432     rm -f ${DESTFILE}
1433     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1434     ;; # case end for file name test
1435     esac
1436
1437
1438     #
1439     # Fix Hpux_Systime
1440     #
1441     case "${file}" in ./sys/time.h )
1442     if ( test -n "`egrep '^extern struct sigevent;' ${file}`"
1443        ) > /dev/null 2>&1 ; then
1444     fixlist="${fixlist}
1445       hpux_systime"
1446     if [ ! -r ${DESTFILE} ]
1447     then infile=${file}
1448     else infile=${DESTFILE} ; fi 
1449
1450     sed -e 's/^extern struct sigevent;/struct sigevent;/' \
1451           < $infile > ${DESTDIR}/fixinc.tmp
1452     rm -f ${DESTFILE}
1453     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1454     fi # end of select 'if'
1455     ;; # case end for file name test
1456     esac
1457
1458
1459     #
1460     # Fix Hpux8_Bogus_Inlines
1461     #
1462     case "${file}" in ./math.h )
1463     if ( test -n "`egrep 'inline' ${file}`"
1464        ) > /dev/null 2>&1 ; then
1465     fixlist="${fixlist}
1466       hpux8_bogus_inlines"
1467     if [ ! -r ${DESTFILE} ]
1468     then infile=${file}
1469     else infile=${DESTFILE} ; fi 
1470
1471     sed -e 's@inline int abs(int [a-z][a-z]*) {.*}@extern "C" int abs(int);@' \
1472         -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
1473         -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
1474         -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
1475           < $infile > ${DESTDIR}/fixinc.tmp
1476     rm -f ${DESTFILE}
1477     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1478     fi # end of select 'if'
1479     ;; # case end for file name test
1480     esac
1481
1482
1483     #
1484     # Fix Hpux11_Uint32_C
1485     #
1486     case "${file}" in ./inttypes.h )
1487     if ( test -n "`egrep '^#define UINT32_C\\(__c\\)[   ]*__CONCAT__\\(__CONCAT_U__\\(__c\\),l\\)' ${file}`"
1488        ) > /dev/null 2>&1 ; then
1489     fixlist="${fixlist}
1490       hpux11_uint32_c"
1491     if [ ! -r ${DESTFILE} ]
1492     then infile=${file}
1493     else infile=${DESTFILE} ; fi 
1494
1495     sed -e 's/^#define UINT32_C(__c)\([         ]*\)__CONCAT__(__CONCAT_U__(__c),l)/#define UINT32_C(__c)\1__CONCAT__(__c,ul)/' \
1496           < $infile > ${DESTDIR}/fixinc.tmp
1497     rm -f ${DESTFILE}
1498     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1499     fi # end of select 'if'
1500     ;; # case end for file name test
1501     esac
1502
1503
1504     #
1505     # Fix Isc_Omits_With_Stdc
1506     #
1507     case "${file}" in ./stdio.h | \
1508         ./math.h | \
1509         ./ctype.h | \
1510         ./sys/limits.h | \
1511         ./sys/fcntl.h | \
1512         ./sys/dirent.h )
1513     if ( test -n "`egrep 'defined(__STDC__) && !defined(_POSIX_SOURCE)' ${file}`"
1514        ) > /dev/null 2>&1 ; then
1515     fixlist="${fixlist}
1516       isc_omits_with_stdc"
1517     if [ ! -r ${DESTFILE} ]
1518     then infile=${file}
1519     else infile=${DESTFILE} ; fi 
1520
1521     sed -e 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
1522           < $infile > ${DESTDIR}/fixinc.tmp
1523     rm -f ${DESTFILE}
1524     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1525     fi # end of select 'if'
1526     ;; # case end for file name test
1527     esac
1528
1529
1530     #
1531     # Fix Io_Use_Quotes
1532     #
1533     if ( test -n "`egrep 'define[       ]+[A-Z0-9_]+[   ]+[A-Z0-9_]+IO[A-Z]*[   ]*\\( *[^,'\\'']' ${file}`"
1534        ) > /dev/null 2>&1 ; then
1535     fixlist="${fixlist}
1536       io_use_quotes"
1537     if [ ! -r ${DESTFILE} ]
1538     then infile=${file}
1539     else infile=${DESTFILE} ; fi 
1540     ${FIXFIXES} ${file} IO_use < $infile > ${DESTDIR}/fixinc.tmp
1541     rm -f ${DESTFILE}
1542     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1543     fi # end of select 'if'
1544
1545
1546     #
1547     # Fix Io_Def_Quotes
1548     #
1549     if ( test -n "`egrep 'define[       ]+[A-Z0-9_]+IO[A-Z]*\\(([a-zA-Z]).*'\\''\\1'\\''' ${file}`"
1550        ) > /dev/null 2>&1 ; then
1551     fixlist="${fixlist}
1552       io_def_quotes"
1553     if [ ! -r ${DESTFILE} ]
1554     then infile=${file}
1555     else infile=${DESTFILE} ; fi 
1556     ${FIXFIXES} ${file} IO_defn < $infile > ${DESTDIR}/fixinc.tmp
1557     rm -f ${DESTFILE}
1558     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1559     fi # end of select 'if'
1560
1561
1562     #
1563     # Fix Ctrl_Use_Quotes
1564     #
1565     if ( test -n "`egrep 'define[       ]+[A-Z0-9_]+[   ]+[A-Z0-9_]+CTRL[       ]*\\( *[^,'\\'']' ${file}`"
1566        ) > /dev/null 2>&1 ; then
1567     fixlist="${fixlist}
1568       ctrl_use_quotes"
1569     if [ ! -r ${DESTFILE} ]
1570     then infile=${file}
1571     else infile=${DESTFILE} ; fi 
1572     ${FIXFIXES} ${file} CTRL_use < $infile > ${DESTDIR}/fixinc.tmp
1573     rm -f ${DESTFILE}
1574     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1575     fi # end of select 'if'
1576
1577
1578     #
1579     # Fix Ctrl_Def_Quotes
1580     #
1581     if ( test -n "`egrep 'define[       ]+[A-Z0-9_]+CTRL\\(([a-zA-Z]).*'\\''\\1'\\''' ${file}`"
1582        ) > /dev/null 2>&1 ; then
1583     fixlist="${fixlist}
1584       ctrl_def_quotes"
1585     if [ ! -r ${DESTFILE} ]
1586     then infile=${file}
1587     else infile=${DESTFILE} ; fi 
1588     ${FIXFIXES} ${file} CTRL_defn < $infile > ${DESTDIR}/fixinc.tmp
1589     rm -f ${DESTFILE}
1590     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1591     fi # end of select 'if'
1592
1593
1594     #
1595     # Fix Ip_Missing_Semi
1596     #
1597     case "${file}" in ./netinet/ip.h )
1598     if ( test -n "`egrep '}$' ${file}`"
1599        ) > /dev/null 2>&1 ; then
1600     fixlist="${fixlist}
1601       ip_missing_semi"
1602     if [ ! -r ${DESTFILE} ]
1603     then infile=${file}
1604     else infile=${DESTFILE} ; fi 
1605
1606     sed -e '/^struct/,/^};/s/}$/};/' \
1607           < $infile > ${DESTDIR}/fixinc.tmp
1608     rm -f ${DESTFILE}
1609     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1610     fi # end of select 'if'
1611     ;; # case end for file name test
1612     esac
1613
1614
1615     #
1616     # Fix Irix_Multiline_Cmnt
1617     #
1618     case "${file}" in ./sys/types.h )
1619     fixlist="${fixlist}
1620       irix_multiline_cmnt"
1621     if [ ! -r ${DESTFILE} ]
1622     then infile=${file}
1623     else infile=${DESTFILE} ; fi 
1624
1625     sed -e 's@type of the result@type of the result */@' \
1626         -e 's@of the sizeof@/* of the sizeof@' \
1627           < $infile > ${DESTDIR}/fixinc.tmp
1628     rm -f ${DESTFILE}
1629     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1630     ;; # case end for file name test
1631     esac
1632
1633
1634     #
1635     # Fix Irix_Sockaddr
1636     #
1637     case "${file}" in ./rpc/auth.h )
1638     if ( test -n "`egrep 'authdes_create.*struct sockaddr' ${file}`"
1639        ) > /dev/null 2>&1 ; then
1640     fixlist="${fixlist}
1641       irix_sockaddr"
1642     if [ ! -r ${DESTFILE} ]
1643     then infile=${file}
1644     else infile=${DESTFILE} ; fi 
1645
1646     sed -e '/authdes_create.*struct sockaddr/i\
1647 struct sockaddr;
1648 ' \
1649           < $infile > ${DESTDIR}/fixinc.tmp
1650     rm -f ${DESTFILE}
1651     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1652     fi # end of select 'if'
1653     ;; # case end for file name test
1654     esac
1655
1656
1657     #
1658     # Fix Irix_Struct__File
1659     #
1660     case "${file}" in ./rpc/xdr.h )
1661     fixlist="${fixlist}
1662       irix_struct__file"
1663     if [ ! -r ${DESTFILE} ]
1664     then infile=${file}
1665     else infile=${DESTFILE} ; fi 
1666
1667     sed -e '/xdrstdio_create.*struct __file_s/i\
1668 struct __file_s;
1669 ' \
1670           < $infile > ${DESTDIR}/fixinc.tmp
1671     rm -f ${DESTFILE}
1672     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1673     ;; # case end for file name test
1674     esac
1675
1676
1677     #
1678     # Fix Irix_Asm_Apostrophe
1679     #
1680     case "${file}" in ./sys/asm.h )
1681     if ( test -n "`egrep '^[    ]*#.*[Ww]e'\\''re' ${file}`"
1682        ) > /dev/null 2>&1 ; then
1683     fixlist="${fixlist}
1684       irix_asm_apostrophe"
1685     if [ ! -r ${DESTFILE} ]
1686     then infile=${file}
1687     else infile=${DESTFILE} ; fi 
1688
1689     sed -e '/^[         ]*#/s/\([Ww]e\)'\''re/\1 are/' \
1690           < $infile > ${DESTDIR}/fixinc.tmp
1691     rm -f ${DESTFILE}
1692     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1693     fi # end of select 'if'
1694     ;; # case end for file name test
1695     esac
1696
1697
1698     #
1699     # Fix Isc_Fmod
1700     #
1701     case "${file}" in ./math.h )
1702     if ( test -n "`egrep 'fmod\\(double\\)' ${file}`"
1703        ) > /dev/null 2>&1 ; then
1704     fixlist="${fixlist}
1705       isc_fmod"
1706     if [ ! -r ${DESTFILE} ]
1707     then infile=${file}
1708     else infile=${DESTFILE} ; fi 
1709
1710     sed -e 's/fmod(double)/fmod(double, double)/' \
1711           < $infile > ${DESTDIR}/fixinc.tmp
1712     rm -f ${DESTFILE}
1713     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1714     fi # end of select 'if'
1715     ;; # case end for file name test
1716     esac
1717
1718
1719     #
1720     # Fix Motorola_Nested
1721     #
1722     case "${file}" in ./limits.h | \
1723         ./sys/limits.h )
1724     case "$target_canonical" in m68k-motorola-sysv* )
1725     fixlist="${fixlist}
1726       motorola_nested"
1727     if [ ! -r ${DESTFILE} ]
1728     then infile=${file}
1729     else infile=${DESTFILE} ; fi 
1730
1731     sed -e 's@^\(#undef[        ][      ]*PIPE_BUF[     ]*/\* max # bytes atomic in write to a\)$@\1 */@' \
1732         -e 's@\(/\*#define      HUGE_VAL        3.40282346638528860e+38 \)\(/\*error value returned by Math lib\*/\)$@\1*/ \2@' \
1733           < $infile > ${DESTDIR}/fixinc.tmp
1734     rm -f ${DESTFILE}
1735     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1736     ;; # case end for machine type test
1737     esac
1738     ;; # case end for file name test
1739     esac
1740
1741
1742     #
1743     # Fix Isc_Sys_Limits
1744     #
1745     case "${file}" in ./sys/limits.h )
1746     if ( test -n "`egrep 'CHILD_MAX' ${file}`"
1747        ) > /dev/null 2>&1 ; then
1748     fixlist="${fixlist}
1749       isc_sys_limits"
1750     if [ ! -r ${DESTFILE} ]
1751     then infile=${file}
1752     else infile=${DESTFILE} ; fi 
1753
1754     sed -e '/CHILD_MAX/s,/\* Max, Max,' \
1755         -e '/OPEN_MAX/s,/\* Max, Max,' \
1756           < $infile > ${DESTDIR}/fixinc.tmp
1757     rm -f ${DESTFILE}
1758     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1759     fi # end of select 'if'
1760     ;; # case end for file name test
1761     esac
1762
1763
1764     #
1765     # Fix Kandr_Concat
1766     #
1767     case "${file}" in ./sparc/asm_linkage.h | \
1768         ./sun3/asm_linkage.h | \
1769         ./sun3x/asm_linkage.h | \
1770         ./sun4/asm_linkage.h | \
1771         ./sun4c/asm_linkage.h | \
1772         ./sun4m/asm_linkage.h | \
1773         ./sun4c/debug/asm_linkage.h | \
1774         ./sun4m/debug/asm_linkage.h | \
1775         ./arm/as_support.h | \
1776         ./arm/mc_type.h | \
1777         ./arm/xcb.h | \
1778         ./dev/chardefmac.h | \
1779         ./dev/ps_irq.h | \
1780         ./dev/screen.h | \
1781         ./dev/scsi.h | \
1782         ./sys/tty.h | \
1783         ./Xm.acorn/XmP.h | \
1784         ./bsd43/bsd43_.h )
1785     if ( test -n "`egrep '/\\*\\*/' ${file}`"
1786        ) > /dev/null 2>&1 ; then
1787     fixlist="${fixlist}
1788       kandr_concat"
1789     if [ ! -r ${DESTFILE} ]
1790     then infile=${file}
1791     else infile=${DESTFILE} ; fi 
1792
1793     sed -e 's|/\*\*/|##|g' \
1794           < $infile > ${DESTDIR}/fixinc.tmp
1795     rm -f ${DESTFILE}
1796     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1797     fi # end of select 'if'
1798     ;; # case end for file name test
1799     esac
1800
1801
1802     #
1803     # Fix Limits_Ifndefs
1804     #
1805     case "${file}" in ./limits.h | \
1806         ./sys/limits.h )
1807     if ( test -z "`egrep 'ifndef[       ]+FLT_MIN' ${file}`"
1808        ) > /dev/null 2>&1 ; then
1809     fixlist="${fixlist}
1810       limits_ifndefs"
1811     if [ ! -r ${DESTFILE} ]
1812     then infile=${file}
1813     else infile=${DESTFILE} ; fi 
1814
1815     sed -e '/[  ]FLT_MIN[       ]/i\
1816 #ifndef FLT_MIN
1817 ' \
1818         -e '/[  ]FLT_MIN[       ]/a\
1819 #endif
1820 ' \
1821         -e '/[  ]FLT_MAX[       ]/i\
1822 #ifndef FLT_MAX
1823 ' \
1824         -e '/[  ]FLT_MAX[       ]/a\
1825 #endif
1826 ' \
1827         -e '/[  ]FLT_DIG[       ]/i\
1828 #ifndef FLT_DIG
1829 ' \
1830         -e '/[  ]FLT_DIG[       ]/a\
1831 #endif
1832 ' \
1833         -e '/[  ]DBL_MIN[       ]/i\
1834 #ifndef DBL_MIN
1835 ' \
1836         -e '/[  ]DBL_MIN[       ]/a\
1837 #endif
1838 ' \
1839         -e '/[  ]DBL_MAX[       ]/i\
1840 #ifndef DBL_MAX
1841 ' \
1842         -e '/[  ]DBL_MAX[       ]/a\
1843 #endif
1844 ' \
1845         -e '/[  ]DBL_DIG[       ]/i\
1846 #ifndef DBL_DIG
1847 ' \
1848         -e '/[  ]DBL_DIG[       ]/a\
1849 #endif
1850 ' \
1851         -e '/^\(\/\*#define     HUGE_VAL        3\.[0-9e+]* *\)\/\*/s//\1/' \
1852           < $infile > ${DESTDIR}/fixinc.tmp
1853     rm -f ${DESTFILE}
1854     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1855     fi # end of bypass 'if'
1856     ;; # case end for file name test
1857     esac
1858
1859
1860     #
1861     # Fix Lynx_Void_Int
1862     #
1863     case "${file}" in ./curses.h )
1864     if ( test -n "`egrep '#[    ]*define[       ]+void[         ]+int' ${file}`"
1865        ) > /dev/null 2>&1 ; then
1866     fixlist="${fixlist}
1867       lynx_void_int"
1868     if [ ! -r ${DESTFILE} ]
1869     then infile=${file}
1870     else infile=${DESTFILE} ; fi 
1871
1872     sed -e '/#[         ]*define[       ][      ]*void[         ]int/d' \
1873           < $infile > ${DESTDIR}/fixinc.tmp
1874     rm -f ${DESTFILE}
1875     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1876     fi # end of select 'if'
1877     ;; # case end for file name test
1878     esac
1879
1880
1881     #
1882     # Fix Lynxos_Fcntl_Proto
1883     #
1884     case "${file}" in ./fcntl.h )
1885     if ( test -n "`egrep 'fcntl.*\\(int, int, int\\)' ${file}`"
1886        ) > /dev/null 2>&1 ; then
1887     fixlist="${fixlist}
1888       lynxos_fcntl_proto"
1889     if [ ! -r ${DESTFILE} ]
1890     then infile=${file}
1891     else infile=${DESTFILE} ; fi 
1892
1893     sed -e 's/\(fcntl.*(int, int, \)int)/\1...)/' \
1894           < $infile > ${DESTDIR}/fixinc.tmp
1895     rm -f ${DESTFILE}
1896     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1897     fi # end of select 'if'
1898     ;; # case end for file name test
1899     esac
1900
1901
1902     #
1903     # Fix M88k_Bad_Hypot_Opt
1904     #
1905     case "${file}" in ./math.h )
1906     case "$target_canonical" in m88k-motorola-sysv3* )
1907     fixlist="${fixlist}
1908       m88k_bad_hypot_opt"
1909     if [ ! -r ${DESTFILE} ]
1910     then infile=${file}
1911     else infile=${DESTFILE} ; fi 
1912
1913     sed -e 's/extern double floor(), ceil(), fmod(), fabs();/extern double floor(), ceil(), fmod(), fabs _PARAMS((double));/' \
1914         -e '/^extern double hypot();$/a\
1915 \/* Workaround a stupid Motorola optimization if one\
1916    of x or y is 0.0 and the other is negative!  *\/\
1917 #ifdef __STDC__\
1918 static __inline__ double fake_hypot (double x, double y)\
1919 #else\
1920 static __inline__ double fake_hypot (x, y)\
1921         double x, y;\
1922 #endif\
1923 {\
1924         return fabs (hypot (x, y));\
1925 }\
1926 #define hypot   fake_hypot
1927 ' \
1928           < $infile > ${DESTDIR}/fixinc.tmp
1929     rm -f ${DESTFILE}
1930     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1931     ;; # case end for machine type test
1932     esac
1933     ;; # case end for file name test
1934     esac
1935
1936
1937     #
1938     # Fix M88k_Bad_S_If
1939     #
1940     case "${file}" in ./sys/stat.h )
1941     case "$target_canonical" in m88k-*-sysv3* )
1942     if ( test -n "`egrep '#define[      ]+S_IS[A-Z]*(m)[        ]' ${file}`"
1943        ) > /dev/null 2>&1 ; then
1944     fixlist="${fixlist}
1945       m88k_bad_s_if"
1946     if [ ! -r ${DESTFILE} ]
1947     then infile=${file}
1948     else infile=${DESTFILE} ; fi 
1949
1950     sed -e 's/^\(#define[       ]*S_IS[A-Z]*(m)\)[      ]*(m[   ]*&[    ]*\(S_IF[A-Z][A-Z][A-Z][A-Z]*\)[        ]*)/\1 (((m)\&S_IFMT)==\2)/' \
1951         -e 's/^\(#define[       ]*S_IS[A-Z]*(m)\)[      ]*(m[   ]*&[    ]*\(0[0-9]*\)[  ]*)/\1 (((m)\&S_IFMT)==\2)/' \
1952           < $infile > ${DESTDIR}/fixinc.tmp
1953     rm -f ${DESTFILE}
1954     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1955     fi # end of select 'if'
1956     ;; # case end for machine type test
1957     esac
1958     ;; # case end for file name test
1959     esac
1960
1961
1962     #
1963     # Fix M88k_Multi_Incl
1964     #
1965     case "${file}" in ./time.h )
1966     case "$target_canonical" in m88k-tektronix-sysv3* )
1967     if ( test -z "`egrep '#ifndef' ${file}`"
1968        ) > /dev/null 2>&1 ; then
1969     fixlist="${fixlist}
1970       m88k_multi_incl"
1971     if [ ! -r ${DESTFILE} ]
1972     then infile=${file}
1973     else infile=${DESTFILE} ; fi 
1974     ( echo Fixing $file, to protect against multiple inclusion. >&2
1975       cpp_wrapper=`echo $file | sed -e 's,\.,_,g' -e 's,/,_,g'`
1976       echo "#ifndef __GCC_GOT_${cpp_wrapper}_"
1977       echo "#define __GCC_GOT_${cpp_wrapper}_"
1978       cat
1979       echo "#endif /* ! __GCC_GOT_${cpp_wrapper}_ */" ) < $infile > ${DESTDIR}/fixinc.tmp
1980
1981     #  Shell scripts have the potential of removing the output
1982     #  We interpret that to mean the file is not to be altered
1983     #
1984     if test ! -f ${DESTDIR}/fixinc.tmp
1985     then continue ; fi 
1986     rm -f ${DESTFILE}
1987     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
1988     fi # end of bypass 'if'
1989     ;; # case end for machine type test
1990     esac
1991     ;; # case end for file name test
1992     esac
1993
1994
1995     #
1996     # Fix Machine_Name
1997     #
1998     if ${FIXTESTS} ${file} machine_name
1999     then
2000     fixlist="${fixlist}
2001       machine_name"
2002     if [ ! -r ${DESTFILE} ]
2003     then infile=${file}
2004     else infile=${DESTFILE} ; fi 
2005     ${FIXFIXES} ${file} machine_name < $infile > ${DESTDIR}/fixinc.tmp
2006     rm -f ${DESTFILE}
2007     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2008     fi # end of c_test 'if'
2009
2010
2011     #
2012     # Fix Math_Exception
2013     #
2014     case "${file}" in ./math.h )
2015     if ( test -n "`egrep 'struct exception' ${file}`"
2016        ) > /dev/null 2>&1 ; then
2017     if ( test -z "`egrep 'We have a problem when using C\\+\\+' ${file}`"
2018        ) > /dev/null 2>&1 ; then
2019     fixlist="${fixlist}
2020       math_exception"
2021     if [ ! -r ${DESTFILE} ]
2022     then infile=${file}
2023     else infile=${DESTFILE} ; fi 
2024
2025     sed -e '/struct exception/i\
2026 #ifdef __cplusplus\
2027 #define exception __math_exception\
2028 #endif
2029 ' \
2030         -e '/struct exception/a\
2031 #ifdef __cplusplus\
2032 #undef exception\
2033 #endif
2034 ' \
2035           < $infile > ${DESTDIR}/fixinc.tmp
2036     rm -f ${DESTFILE}
2037     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2038     fi # end of bypass 'if'
2039     fi # end of select 'if'
2040     ;; # case end for file name test
2041     esac
2042
2043
2044     #
2045     # Fix Math_Huge_Val_From_Dbl_Max
2046     #
2047     case "${file}" in ./math.h )
2048     if ( test -n "`egrep 'define[       ]*HUGE_VAL[     ]*DBL_MAX' ${file}`"
2049        ) > /dev/null 2>&1 ; then
2050     if ( test -z "`egrep 'define[       ]*DBL_MAX' ${file}`"
2051        ) > /dev/null 2>&1 ; then
2052     fixlist="${fixlist}
2053       math_huge_val_from_dbl_max"
2054     if [ ! -r ${DESTFILE} ]
2055     then infile=${file}
2056     else infile=${DESTFILE} ; fi 
2057     (   dbl_max_def=`egrep 'define[     ]+DBL_MAX[      ]+.*' float.h 2>/dev/null`
2058
2059         if ( test -n "${dbl_max_def}" ) > /dev/null 2>&1
2060         then sed -e '/define[   ]*HUGE_VAL[     ]*DBL_MAX/s/DBL_MAX/'"$dbl_max_def/"
2061         else cat
2062         fi ) < $infile > ${DESTDIR}/fixinc.tmp
2063
2064     #  Shell scripts have the potential of removing the output
2065     #  We interpret that to mean the file is not to be altered
2066     #
2067     if test ! -f ${DESTDIR}/fixinc.tmp
2068     then continue ; fi 
2069     rm -f ${DESTFILE}
2070     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2071     fi # end of bypass 'if'
2072     fi # end of select 'if'
2073     ;; # case end for file name test
2074     esac
2075
2076
2077     #
2078     # Fix Math_Huge_Val_Ifndef
2079     #
2080     case "${file}" in ./math/math.h )
2081     if ( test -n "`egrep 'define[       ]*HUGE_VAL' ${file}`"
2082        ) > /dev/null 2>&1 ; then
2083     fixlist="${fixlist}
2084       math_huge_val_ifndef"
2085     if [ ! -r ${DESTFILE} ]
2086     then infile=${file}
2087     else infile=${DESTFILE} ; fi 
2088
2089     sed -e '/define[    ]HUGE_VAL[      ]/i\
2090 #ifndef HUGE_VAL
2091 ' \
2092         -e '/define[    ]HUGE_VAL[      ]/a\
2093 #endif
2094 ' \
2095           < $infile > ${DESTDIR}/fixinc.tmp
2096     rm -f ${DESTFILE}
2097     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2098     fi # end of select 'if'
2099     ;; # case end for file name test
2100     esac
2101
2102
2103     #
2104     # Fix Nested_Comment
2105     #
2106     case "${file}" in ./rpc/rpc.h )
2107     fixlist="${fixlist}
2108       nested_comment"
2109     if [ ! -r ${DESTFILE} ]
2110     then infile=${file}
2111     else infile=${DESTFILE} ; fi 
2112
2113     sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \
2114           < $infile > ${DESTDIR}/fixinc.tmp
2115     rm -f ${DESTFILE}
2116     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2117     ;; # case end for file name test
2118     esac
2119
2120
2121     #
2122     # Fix News_Os_Recursion
2123     #
2124     case "${file}" in ./stdlib.h )
2125     if ( test -n "`egrep '#include <stdlib.h>' ${file}`"
2126        ) > /dev/null 2>&1 ; then
2127     fixlist="${fixlist}
2128       news_os_recursion"
2129     if [ ! -r ${DESTFILE} ]
2130     then infile=${file}
2131     else infile=${DESTFILE} ; fi 
2132
2133     sed -e '/^#include <stdlib.h>/i\
2134 #ifdef BOGUS_RECURSION
2135 ' \
2136         -e '/^#include <stdlib.h>/a\
2137 #endif
2138 ' \
2139           < $infile > ${DESTDIR}/fixinc.tmp
2140     rm -f ${DESTFILE}
2141     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2142     fi # end of select 'if'
2143     ;; # case end for file name test
2144     esac
2145
2146
2147     #
2148     # Fix Next_Math_Prefix
2149     #
2150     case "${file}" in ./ansi/math.h )
2151     if ( test -n "`egrep '^extern.*double.*__const__.*' ${file}`"
2152        ) > /dev/null 2>&1 ; then
2153     fixlist="${fixlist}
2154       next_math_prefix"
2155     if [ ! -r ${DESTFILE} ]
2156     then infile=${file}
2157     else infile=${DESTFILE} ; fi 
2158
2159     sed -e '/^extern.*double.*__const__.*sqrt(/s/__const__//' \
2160         -e '/^extern.*double.*__const__.*fabs(/s/__const__//' \
2161         -e '/^extern.*double.*__const__.*cos(/s/__const__//' \
2162         -e '/^extern.*double.*__const__.*hypot(/s/__const__//' \
2163         -e '/^extern.*double.*__const__.*sin(/s/__const__//' \
2164           < $infile > ${DESTDIR}/fixinc.tmp
2165     rm -f ${DESTFILE}
2166     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2167     fi # end of select 'if'
2168     ;; # case end for file name test
2169     esac
2170
2171
2172     #
2173     # Fix Next_Template
2174     #
2175     case "${file}" in ./bsd/libc.h )
2176     if ( test -n "`egrep 'template' ${file}`"
2177        ) > /dev/null 2>&1 ; then
2178     fixlist="${fixlist}
2179       next_template"
2180     if [ ! -r ${DESTFILE} ]
2181     then infile=${file}
2182     else infile=${DESTFILE} ; fi 
2183
2184     sed -e '/\(.*template\)/s/template//' \
2185         -e '/extern.*volatile.*void.*abort/s/volatile//' \
2186           < $infile > ${DESTDIR}/fixinc.tmp
2187     rm -f ${DESTFILE}
2188     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2189     fi # end of select 'if'
2190     ;; # case end for file name test
2191     esac
2192
2193
2194     #
2195     # Fix Next_Volitile
2196     #
2197     case "${file}" in ./ansi/stdlib.h )
2198     if ( test -n "`egrep 'volatile' ${file}`"
2199        ) > /dev/null 2>&1 ; then
2200     fixlist="${fixlist}
2201       next_volitile"
2202     if [ ! -r ${DESTFILE} ]
2203     then infile=${file}
2204     else infile=${DESTFILE} ; fi 
2205
2206     sed -e '/extern.*volatile.*void.*exit/s/volatile//' \
2207         -e '/extern.*volatile.*void.*abort/s/volatile//' \
2208           < $infile > ${DESTDIR}/fixinc.tmp
2209     rm -f ${DESTFILE}
2210     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2211     fi # end of select 'if'
2212     ;; # case end for file name test
2213     esac
2214
2215
2216     #
2217     # Fix Next_Wait_Union
2218     #
2219     case "${file}" in ./sys/wait.h )
2220     if ( test -n "`egrep 'wait\\(union wait' ${file}`"
2221        ) > /dev/null 2>&1 ; then
2222     fixlist="${fixlist}
2223       next_wait_union"
2224     if [ ! -r ${DESTFILE} ]
2225     then infile=${file}
2226     else infile=${DESTFILE} ; fi 
2227
2228     sed -e 's@wait(union wait@wait(void@' \
2229           < $infile > ${DESTDIR}/fixinc.tmp
2230     rm -f ${DESTFILE}
2231     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2232     fi # end of select 'if'
2233     ;; # case end for file name test
2234     esac
2235
2236
2237     #
2238     # Fix Nodeent_Syntax
2239     #
2240     case "${file}" in ./netdnet/dnetdb.h )
2241     fixlist="${fixlist}
2242       nodeent_syntax"
2243     if [ ! -r ${DESTFILE} ]
2244     then infile=${file}
2245     else infile=${DESTFILE} ; fi 
2246
2247     sed -e 's/char.*na_addr *$/char *na_addr;/' \
2248           < $infile > ${DESTDIR}/fixinc.tmp
2249     rm -f ${DESTFILE}
2250     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2251     ;; # case end for file name test
2252     esac
2253
2254
2255     #
2256     # Fix Osf_Namespace_A
2257     #
2258     case "${file}" in ./reg_types.h | \
2259         ./sys/lc_core.h )
2260     if ( test '('  -r reg_types.h ')' -a \
2261               '('  -r sys/lc_core.h ')' -a \
2262               '('  -n "`grep '} regex_t;' reg_types.h`" ')' -a \
2263               '('  -z "`grep __regex_t regex.h`" ')'
2264        ) > /dev/null 2>&1 ; then
2265     fixlist="${fixlist}
2266       osf_namespace_a"
2267     if [ ! -r ${DESTFILE} ]
2268     then infile=${file}
2269     else infile=${DESTFILE} ; fi 
2270
2271     sed -e 's/regex_t/__regex_t/g' \
2272         -e 's/regoff_t/__regoff_t/g' \
2273         -e 's/regmatch_t/__regmatch_t/g' \
2274           < $infile > ${DESTDIR}/fixinc.tmp
2275     rm -f ${DESTFILE}
2276     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2277     fi # end of test expression 'if'
2278     ;; # case end for file name test
2279     esac
2280
2281
2282     #
2283     # Fix Osf_Namespace_B
2284     #
2285     case "${file}" in ./regex.h )
2286     if ( test '('  -r reg_types.h ')' -a \
2287               '('  -r sys/lc_core.h ')' -a \
2288               '('  -n "`grep '} regex_t;' reg_types.h`" ')' -a \
2289               '('  -z "`grep __regex_t regex.h`" ')'
2290        ) > /dev/null 2>&1 ; then
2291     fixlist="${fixlist}
2292       osf_namespace_b"
2293     if [ ! -r ${DESTFILE} ]
2294     then infile=${file}
2295     else infile=${DESTFILE} ; fi 
2296
2297     sed -e '/#include <reg_types.h>/a\
2298 typedef __regex_t       regex_t;\
2299 typedef __regoff_t      regoff_t;\
2300 typedef __regmatch_t    regmatch_t;
2301 ' \
2302           < $infile > ${DESTDIR}/fixinc.tmp
2303     rm -f ${DESTFILE}
2304     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2305     fi # end of test expression 'if'
2306     ;; # case end for file name test
2307     esac
2308
2309
2310     #
2311     # Fix Pthread_Page_Size
2312     #
2313     case "${file}" in ./pthread.h )
2314     if ( test -n "`egrep '^int __page_size' ${file}`"
2315        ) > /dev/null 2>&1 ; then
2316     fixlist="${fixlist}
2317       pthread_page_size"
2318     if [ ! -r ${DESTFILE} ]
2319     then infile=${file}
2320     else infile=${DESTFILE} ; fi 
2321
2322     sed -e 's/^int __page_size/extern int __page_size/' \
2323           < $infile > ${DESTDIR}/fixinc.tmp
2324     rm -f ${DESTFILE}
2325     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2326     fi # end of select 'if'
2327     ;; # case end for file name test
2328     esac
2329
2330
2331     #
2332     # Fix Read_Ret_Type
2333     #
2334     case "${file}" in ./stdio.h )
2335     if ( test -n "`egrep 'extern int    .*, fread\\(\\), fwrite\\(\\)' ${file}`"
2336        ) > /dev/null 2>&1 ; then
2337     fixlist="${fixlist}
2338       read_ret_type"
2339     if [ ! -r ${DESTFILE} ]
2340     then infile=${file}
2341     else infile=${DESTFILE} ; fi 
2342
2343     sed -e 's/^\(extern int     fclose(), fflush()\), \(fread(), fwrite()\)\(.*\)$/extern unsigned int  \2;\
2344 \1\3/' \
2345           < $infile > ${DESTDIR}/fixinc.tmp
2346     rm -f ${DESTFILE}
2347     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2348     fi # end of select 'if'
2349     ;; # case end for file name test
2350     esac
2351
2352
2353     #
2354     # Fix Rs6000_Double
2355     #
2356     case "${file}" in ./math.h )
2357     if ( test -n "`egrep '[^a-zA-Z_]class\\(' ${file}`"
2358        ) > /dev/null 2>&1 ; then
2359     fixlist="${fixlist}
2360       rs6000_double"
2361     if [ ! -r ${DESTFILE} ]
2362     then infile=${file}
2363     else infile=${DESTFILE} ; fi 
2364
2365     sed -e '/class[(]/i\
2366 #ifndef __cplusplus
2367 ' \
2368         -e '/class[(]/a\
2369 #endif
2370 ' \
2371           < $infile > ${DESTDIR}/fixinc.tmp
2372     rm -f ${DESTFILE}
2373     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2374     fi # end of select 'if'
2375     ;; # case end for file name test
2376     esac
2377
2378
2379     #
2380     # Fix Rs6000_Fchmod
2381     #
2382     case "${file}" in ./sys/stat.h )
2383     if ( test -n "`egrep 'fchmod\\(char' ${file}`"
2384        ) > /dev/null 2>&1 ; then
2385     fixlist="${fixlist}
2386       rs6000_fchmod"
2387     if [ ! -r ${DESTFILE} ]
2388     then infile=${file}
2389     else infile=${DESTFILE} ; fi 
2390
2391     sed -e 's/fchmod(char \*/fchmod(int/' \
2392           < $infile > ${DESTDIR}/fixinc.tmp
2393     rm -f ${DESTFILE}
2394     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2395     fi # end of select 'if'
2396     ;; # case end for file name test
2397     esac
2398
2399
2400     #
2401     # Fix Rs6000_Param
2402     #
2403     case "${file}" in ./stdio.h | \
2404         ./unistd.h )
2405     if ( test -n "`egrep 'const char new' ${file}`"
2406        ) > /dev/null 2>&1 ; then
2407     fixlist="${fixlist}
2408       rs6000_param"
2409     if [ ! -r ${DESTFILE} ]
2410     then infile=${file}
2411     else infile=${DESTFILE} ; fi 
2412
2413     sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
2414           < $infile > ${DESTDIR}/fixinc.tmp
2415     rm -f ${DESTFILE}
2416     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2417     fi # end of select 'if'
2418     ;; # case end for file name test
2419     esac
2420
2421
2422     #
2423     # Fix Sony_Include
2424     #
2425     case "${file}" in ./machine/machparam.h )
2426     if ( test -n "`egrep '\"\\.\\./machine/endian.h\"' ${file}`"
2427        ) > /dev/null 2>&1 ; then
2428     fixlist="${fixlist}
2429       sony_include"
2430     if [ ! -r ${DESTFILE} ]
2431     then infile=${file}
2432     else infile=${DESTFILE} ; fi 
2433
2434     sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
2435           < $infile > ${DESTDIR}/fixinc.tmp
2436     rm -f ${DESTFILE}
2437     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2438     fi # end of select 'if'
2439     ;; # case end for file name test
2440     esac
2441
2442
2443     #
2444     # Fix Statsswtch
2445     #
2446     case "${file}" in ./rpcsvc/rstat.h )
2447     if ( test -n "`egrep 'boottime$' ${file}`"
2448        ) > /dev/null 2>&1 ; then
2449     fixlist="${fixlist}
2450       statsswtch"
2451     if [ ! -r ${DESTFILE} ]
2452     then infile=${file}
2453     else infile=${DESTFILE} ; fi 
2454
2455     sed -e 's/boottime$/boottime;/' \
2456           < $infile > ${DESTDIR}/fixinc.tmp
2457     rm -f ${DESTFILE}
2458     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2459     fi # end of select 'if'
2460     ;; # case end for file name test
2461     esac
2462
2463
2464     #
2465     # Fix Stdio_Va_List
2466     #
2467     case "${file}" in ./stdio.h )
2468     if ( test -z "`egrep '__gnuc_va_list' ${file}`"
2469        ) > /dev/null 2>&1 ; then
2470     fixlist="${fixlist}
2471       stdio_va_list"
2472     if [ ! -r ${DESTFILE} ]
2473     then infile=${file}
2474     else infile=${DESTFILE} ; fi 
2475     ( if ( egrep "__need___va_list" $file ) > /dev/null 2>&1 ; then
2476     :
2477   else
2478     echo "#define __need___va_list"
2479     echo "#include <stdarg.h>"
2480   fi
2481
2482   sed -e 's@ va_list @ __gnuc_va_list @' \
2483       -e 's@ va_list)@ __gnuc_va_list)@' \
2484       -e 's@ _BSD_VA_LIST_))@ __gnuc_va_list))@' \
2485       -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
2486       -e 's@ va_list@ __not_va_list__@' \
2487       -e 's@\*va_list@*__not_va_list__@' \
2488       -e 's@ __va_list)@ __gnuc_va_list)@' \
2489       -e 's@GNUC_VA_LIST@GNUC_Va_LIST@' \
2490       -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
2491       -e 's@VA_LIST@DUMMY_VA_LIST@' \
2492       -e 's@_Va_LIST@_VA_LIST@' ) < $infile > ${DESTDIR}/fixinc.tmp
2493
2494     #  Shell scripts have the potential of removing the output
2495     #  We interpret that to mean the file is not to be altered
2496     #
2497     if test ! -f ${DESTDIR}/fixinc.tmp
2498     then continue ; fi 
2499     rm -f ${DESTFILE}
2500     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2501     fi # end of bypass 'if'
2502     ;; # case end for file name test
2503     esac
2504
2505
2506     #
2507     # Fix Sun_Bogus_Ifdef
2508     #
2509     case "${file}" in ./hsfs/hsfs_spec.h | \
2510         ./hsfs/iso_spec.h )
2511     if ( test -n "`egrep '#ifdef __i386__ || __vax__' ${file}`"
2512        ) > /dev/null 2>&1 ; then
2513     fixlist="${fixlist}
2514       sun_bogus_ifdef"
2515     if [ ! -r ${DESTFILE} ]
2516     then infile=${file}
2517     else infile=${DESTFILE} ; fi 
2518
2519     sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
2520           < $infile > ${DESTDIR}/fixinc.tmp
2521     rm -f ${DESTFILE}
2522     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2523     fi # end of select 'if'
2524     ;; # case end for file name test
2525     esac
2526
2527
2528     #
2529     # Fix Sun_Bogus_Ifdef_Sun4c
2530     #
2531     case "${file}" in ./hsfs/hsnode.h )
2532     if ( test -n "`egrep '#ifdef __i386__ || __sun4c__' ${file}`"
2533        ) > /dev/null 2>&1 ; then
2534     fixlist="${fixlist}
2535       sun_bogus_ifdef_sun4c"
2536     if [ ! -r ${DESTFILE} ]
2537     then infile=${file}
2538     else infile=${DESTFILE} ; fi 
2539
2540     sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
2541           < $infile > ${DESTDIR}/fixinc.tmp
2542     rm -f ${DESTFILE}
2543     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2544     fi # end of select 'if'
2545     ;; # case end for file name test
2546     esac
2547
2548
2549     #
2550     # Fix Sun_Catmacro
2551     #
2552     case "${file}" in ./pixrect/memvar.h )
2553     if ( test -n "`egrep '^#define[     ]+CAT\\(a,b\\)' ${file}`"
2554        ) > /dev/null 2>&1 ; then
2555     fixlist="${fixlist}
2556       sun_catmacro"
2557     if [ ! -r ${DESTFILE} ]
2558     then infile=${file}
2559     else infile=${DESTFILE} ; fi 
2560
2561     sed -e '/^#define[  ]CAT(a,b)/ i\
2562 #ifdef __STDC__ \
2563 #define CAT(a,b) a##b\
2564 #else
2565 ' \
2566         -e '/^#define[  ]CAT(a,b)/ a\
2567 #endif
2568 ' \
2569           < $infile > ${DESTDIR}/fixinc.tmp
2570     rm -f ${DESTFILE}
2571     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2572     fi # end of select 'if'
2573     ;; # case end for file name test
2574     esac
2575
2576
2577     #
2578     # Fix Sun_Malloc
2579     #
2580     case "${file}" in ./malloc.h )
2581     fixlist="${fixlist}
2582       sun_malloc"
2583     if [ ! -r ${DESTFILE} ]
2584     then infile=${file}
2585     else infile=${DESTFILE} ; fi 
2586
2587     sed -e 's/typedef[  ]char \*        malloc_t/typedef void \*        malloc_t/g' \
2588         -e 's/int[      ][      ]*free/void     free/g' \
2589         -e 's/char\([   ]*\*[   ]*malloc\)/void\1/g' \
2590         -e 's/char\([   ]*\*[   ]*realloc\)/void\1/g' \
2591           < $infile > ${DESTDIR}/fixinc.tmp
2592     rm -f ${DESTFILE}
2593     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2594     ;; # case end for file name test
2595     esac
2596
2597
2598     #
2599     # Fix Sun_Rusers_Semi
2600     #
2601     case "${file}" in ./rpcsvc/rusers.h )
2602     if ( test -n "`egrep '_cnt$' ${file}`"
2603        ) > /dev/null 2>&1 ; then
2604     fixlist="${fixlist}
2605       sun_rusers_semi"
2606     if [ ! -r ${DESTFILE} ]
2607     then infile=${file}
2608     else infile=${DESTFILE} ; fi 
2609
2610     sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' \
2611           < $infile > ${DESTDIR}/fixinc.tmp
2612     rm -f ${DESTFILE}
2613     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2614     fi # end of select 'if'
2615     ;; # case end for file name test
2616     esac
2617
2618
2619     #
2620     # Fix Sun_Signal
2621     #
2622     case "${file}" in ./sys/signal.h | \
2623         ./signal.h )
2624     if ( test -n "`egrep '^void \\(\\*signal\\(\\)\\)\\(\\);' ${file}`"
2625        ) > /dev/null 2>&1 ; then
2626     fixlist="${fixlist}
2627       sun_signal"
2628     if [ ! -r ${DESTFILE} ]
2629     then infile=${file}
2630     else infile=${DESTFILE} ; fi 
2631
2632     sed -e '/^void      (\*signal())();$/i\
2633 #ifdef __cplusplus\
2634 void    (*signal(...))(...);\
2635 #else
2636 ' \
2637         -e '/^void      (\*signal())();$/a\
2638 #endif
2639 ' \
2640           < $infile > ${DESTDIR}/fixinc.tmp
2641     rm -f ${DESTFILE}
2642     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2643     fi # end of select 'if'
2644     ;; # case end for file name test
2645     esac
2646
2647
2648     #
2649     # Fix Sun_Auth_Proto
2650     #
2651     case "${file}" in ./rpc/auth.h | \
2652         ./rpc/clnt.h | \
2653         ./rpc/svc.h | \
2654         ./rpc/xdr.h )
2655     if ( test -n "`egrep '\\(\\*[a-z][a-z_]*\\)\\(\\)' ${file}`"
2656        ) > /dev/null 2>&1 ; then
2657     fixlist="${fixlist}
2658       sun_auth_proto"
2659     if [ ! -r ${DESTFILE} ]
2660     then infile=${file}
2661     else infile=${DESTFILE} ; fi 
2662
2663     sed -e 's/^\(.*(\*[a-z][a-z_]*)(\)\();.*\)/\
2664 #ifdef __cplusplus\
2665 \1...\2\
2666 #else\
2667 \1\2\
2668 #endif/' \
2669           < $infile > ${DESTDIR}/fixinc.tmp
2670     rm -f ${DESTFILE}
2671     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2672     fi # end of select 'if'
2673     ;; # case end for file name test
2674     esac
2675
2676
2677     #
2678     # Fix Sunos_Matherr_Decl
2679     #
2680     case "${file}" in ./math.h )
2681     if ( test -z "`egrep 'matherr.*struct exception' ${file}`"
2682        ) > /dev/null 2>&1 ; then
2683     fixlist="${fixlist}
2684       sunos_matherr_decl"
2685     if [ ! -r ${DESTFILE} ]
2686     then infile=${file}
2687     else infile=${DESTFILE} ; fi 
2688
2689     sed -e '/^struct exception/,$b' \
2690         -e '/matherr/i\
2691 struct exception;
2692 ' \
2693           < $infile > ${DESTDIR}/fixinc.tmp
2694     rm -f ${DESTFILE}
2695     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2696     fi # end of bypass 'if'
2697     ;; # case end for file name test
2698     esac
2699
2700
2701     #
2702     # Fix Sunos_Strlen
2703     #
2704     case "${file}" in ./strings.h )
2705     if ( test -n "`egrep 'int[  ]*strlen' ${file}`"
2706        ) > /dev/null 2>&1 ; then
2707     fixlist="${fixlist}
2708       sunos_strlen"
2709     if [ ! -r ${DESTFILE} ]
2710     then infile=${file}
2711     else infile=${DESTFILE} ; fi 
2712
2713     sed -e 's/int[      ]*strlen();/__SIZE_TYPE__ strlen();/' \
2714           < $infile > ${DESTDIR}/fixinc.tmp
2715     rm -f ${DESTFILE}
2716     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2717     fi # end of select 'if'
2718     ;; # case end for file name test
2719     esac
2720
2721
2722     #
2723     # Fix Systypes
2724     #
2725     case "${file}" in ./sys/types.h | \
2726         ./stdlib.h | \
2727         ./sys/stdtypes.h | \
2728         ./stddef.h | \
2729         ./memory.h | \
2730         ./unistd.h )
2731     if ( test -n "`egrep 'typedef[      ]+[a-z_][       a-z_]*[         ](size|ptrdiff|wchar)_t' ${file}`"
2732        ) > /dev/null 2>&1 ; then
2733     fixlist="${fixlist}
2734       systypes"
2735     if [ ! -r ${DESTFILE} ]
2736     then infile=${file}
2737     else infile=${DESTFILE} ; fi 
2738
2739     sed -e '/^[         ]*\*[   ]*typedef unsigned int size_t;/N' \
2740         -e 's/^\([      ]*\*[   ]*typedef unsigned int size_t;\n[       ]*\*\/\)/\1\
2741 #ifndef __SIZE_TYPE__\
2742 #define __SIZE_TYPE__ long unsigned int\
2743 #endif\
2744 typedef __SIZE_TYPE__ size_t;\
2745 /' \
2746         -e '/typedef[   ][      ]*[a-z_][       a-z_]*[         ]size_t/i\
2747 #ifndef __SIZE_TYPE__\
2748 #define __SIZE_TYPE__ long unsigned int\
2749 #endif
2750 ' \
2751         -e 's/typedef[  ][      ]*[a-z_][       a-z_]*[         ]size_t/typedef __SIZE_TYPE__ size_t/' \
2752         -e '/typedef[   ][      ]*[a-z_][       a-z_]*[         ]ptrdiff_t/i\
2753 #ifndef __PTRDIFF_TYPE__\
2754 #define __PTRDIFF_TYPE__ long int\
2755 #endif
2756 ' \
2757         -e 's/typedef[  ][      ]*[a-z_][       a-z_]*[         ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
2758         -e '/typedef[   ][      ]*[a-z_][       a-z_]*[         ]wchar_t/i\
2759 #ifndef __WCHAR_TYPE__\
2760 #define __WCHAR_TYPE__ int\
2761 #endif\
2762 #ifndef __cplusplus
2763 ' \
2764         -e '/typedef[   ][      ]*[a-z_][       a-z_]*[         ]wchar_t/a\
2765 #endif
2766 ' \
2767         -e 's/typedef[  ][      ]*[a-z_][       a-z_]*[         ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
2768           < $infile > ${DESTDIR}/fixinc.tmp
2769     rm -f ${DESTFILE}
2770     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2771     fi # end of select 'if'
2772     ;; # case end for file name test
2773     esac
2774
2775
2776     #
2777     # Fix Systypes_For_Aix
2778     #
2779     case "${file}" in ./sys/types.h )
2780     if ( test -n "`egrep 'typedef[      ][      ]*[A-Za-z_][    A-Za-z_]*[      ]size_t' ${file}`"
2781        ) > /dev/null 2>&1 ; then
2782     if ( test -z "`egrep '_GCC_SIZE_T' ${file}`"
2783        ) > /dev/null 2>&1 ; then
2784     fixlist="${fixlist}
2785       systypes_for_aix"
2786     if [ ! -r ${DESTFILE} ]
2787     then infile=${file}
2788     else infile=${DESTFILE} ; fi 
2789
2790     sed -e '/typedef[   ][      ]*[A-Za-z_][    A-Za-z_]*[      ]size_t/i\
2791 #ifndef _GCC_SIZE_T\
2792 #define _GCC_SIZE_T
2793 ' \
2794         -e '/typedef[   ][      ]*[A-Za-z_][    A-Za-z_]*[      ]size_t/a\
2795 #endif
2796 ' \
2797           < $infile > ${DESTDIR}/fixinc.tmp
2798     rm -f ${DESTFILE}
2799     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2800     fi # end of bypass 'if'
2801     fi # end of select 'if'
2802     ;; # case end for file name test
2803     esac
2804
2805
2806     #
2807     # Fix Sysv68_String
2808     #
2809     case "${file}" in ./string.h )
2810     fixlist="${fixlist}
2811       sysv68_string"
2812     if [ ! -r ${DESTFILE} ]
2813     then infile=${file}
2814     else infile=${DESTFILE} ; fi 
2815
2816     sed -e 's/extern[   ]*int[  ]*strlen();/extern unsigned int strlen();/' \
2817         -e 's/extern[   ]*int[  ]*ffs[  ]*(long);/extern int ffs(int);/' \
2818         -e 's/strdup(char \*s1);/strdup(const char *s1);/' \
2819         -e '/^extern char$/N' \
2820         -e 's/^extern char\(\n  \*memccpy(),\)$/extern void\1/' \
2821         -e '/^  strncmp(),$/N' \
2822         -e 's/^\(       strncmp()\),\n\(        strlen(),\)$/\1;\
2823 extern unsigned int\
2824 \2/' \
2825         -e '/^extern int$/N' \
2826         -e 's/^extern int\(\n   strlen(),\)/extern size_t\1/' \
2827           < $infile > ${DESTDIR}/fixinc.tmp
2828     rm -f ${DESTFILE}
2829     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2830     ;; # case end for file name test
2831     esac
2832
2833
2834     #
2835     # Fix Sysz_Stdlib_For_Sun
2836     #
2837     case "${file}" in ./stdlib.h )
2838     fixlist="${fixlist}
2839       sysz_stdlib_for_sun"
2840     if [ ! -r ${DESTFILE} ]
2841     then infile=${file}
2842     else infile=${DESTFILE} ; fi 
2843
2844     sed -e 's/int       abort/void      abort/g' \
2845         -e 's/int       free/void       free/g' \
2846         -e 's/char[     ]*\*[   ]*calloc/void \*        calloc/g' \
2847         -e 's/char[     ]*\*[   ]*malloc/void \*        malloc/g' \
2848         -e 's/char[     ]*\*[   ]*realloc/void \*       realloc/g' \
2849         -e 's/char[     ]*\*[   ]*bsearch/void \*       bsearch/g' \
2850         -e 's/int[      ][      ]*exit/void     exit/g' \
2851         -e '/typedef[   a-zA-Z_]*[      ]size_t[        ]*;/i\
2852 #ifndef _GCC_SIZE_T\
2853 #define _GCC_SIZE_T
2854 ' \
2855         -e '/typedef[   a-zA-Z_]*[      ]size_t[        ]*;/a\
2856 #endif
2857 ' \
2858           < $infile > ${DESTDIR}/fixinc.tmp
2859     rm -f ${DESTFILE}
2860     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2861     ;; # case end for file name test
2862     esac
2863
2864
2865     #
2866     # Fix Sysz_Stdtypes_For_Sun
2867     #
2868     case "${file}" in ./sys/stdtypes.h )
2869     fixlist="${fixlist}
2870       sysz_stdtypes_for_sun"
2871     if [ ! -r ${DESTFILE} ]
2872     then infile=${file}
2873     else infile=${DESTFILE} ; fi 
2874
2875     sed -e '/[   ]size_t.*;/i\
2876 #ifndef _GCC_SIZE_T\
2877 #define _GCC_SIZE_T
2878 ' \
2879         -e '/[   ]size_t.*;/a\
2880 #endif
2881 ' \
2882         -e '/[   ]ptrdiff_t.*;/i\
2883 #ifndef _GCC_PTRDIFF_T\
2884 #define _GCC_PTRDIFF_T
2885 ' \
2886         -e '/[   ]ptrdiff_t.*;/a\
2887 #endif
2888 ' \
2889         -e '/[   ]wchar_t.*;/i\
2890 #ifndef _GCC_WCHAR_T\
2891 #define _GCC_WCHAR_T
2892 ' \
2893         -e '/[   ]wchar_t.*;/a\
2894 #endif
2895 ' \
2896           < $infile > ${DESTDIR}/fixinc.tmp
2897     rm -f ${DESTFILE}
2898     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2899     ;; # case end for file name test
2900     esac
2901
2902
2903     #
2904     # Fix Tinfo_Cplusplus
2905     #
2906     case "${file}" in ./tinfo.h )
2907     if ( test -n "`egrep '[     ]_cplusplus' ${file}`"
2908        ) > /dev/null 2>&1 ; then
2909     fixlist="${fixlist}
2910       tinfo_cplusplus"
2911     if [ ! -r ${DESTFILE} ]
2912     then infile=${file}
2913     else infile=${DESTFILE} ; fi 
2914
2915     sed -e 's/[         ]_cplusplus/ __cplusplus/' \
2916           < $infile > ${DESTDIR}/fixinc.tmp
2917     rm -f ${DESTFILE}
2918     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2919     fi # end of select 'if'
2920     ;; # case end for file name test
2921     esac
2922
2923
2924     #
2925     # Fix Ultrix_Fix_Fixproto
2926     #
2927     case "${file}" in ./sys/utsname.h )
2928     if ( test -n "`egrep 'ULTRIX' ${file}`"
2929        ) > /dev/null 2>&1 ; then
2930     fixlist="${fixlist}
2931       ultrix_fix_fixproto"
2932     if [ ! -r ${DESTFILE} ]
2933     then infile=${file}
2934     else infile=${DESTFILE} ; fi 
2935
2936     sed -e '/^[         ]*extern[       ]*int[  ]*uname();$/i\
2937 struct utsname;
2938 ' \
2939           < $infile > ${DESTDIR}/fixinc.tmp
2940     rm -f ${DESTFILE}
2941     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2942     fi # end of select 'if'
2943     ;; # case end for file name test
2944     esac
2945
2946
2947     #
2948     # Fix Ultrix_Atof_Param
2949     #
2950     case "${file}" in ./math.h )
2951     if ( test -n "`egrep 'atof\\([      ]*char' ${file}`"
2952        ) > /dev/null 2>&1 ; then
2953     fixlist="${fixlist}
2954       ultrix_atof_param"
2955     if [ ! -r ${DESTFILE} ]
2956     then infile=${file}
2957     else infile=${DESTFILE} ; fi 
2958
2959     sed -e 's@atof(\([  ]*char[         ]*\*[^)]*\))@atof(const \1)@' \
2960           < $infile > ${DESTDIR}/fixinc.tmp
2961     rm -f ${DESTFILE}
2962     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2963     fi # end of select 'if'
2964     ;; # case end for file name test
2965     esac
2966
2967
2968     #
2969     # Fix Ultrix_Const
2970     #
2971     case "${file}" in ./stdio.h )
2972     fixlist="${fixlist}
2973       ultrix_const"
2974     if [ ! -r ${DESTFILE} ]
2975     then infile=${file}
2976     else infile=${DESTFILE} ; fi 
2977
2978     sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
2979         -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
2980         -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
2981         -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
2982         -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
2983         -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
2984         -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
2985         -e 's@popen(char \*, char \*);@popen(const char *, const char *);@' \
2986         -e 's@tempnam(char\*,char\*);@tempnam(const char*,const char*);@' \
2987           < $infile > ${DESTDIR}/fixinc.tmp
2988     rm -f ${DESTFILE}
2989     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
2990     ;; # case end for file name test
2991     esac
2992
2993
2994     #
2995     # Fix Ultrix_Ifdef
2996     #
2997     case "${file}" in ./sys/file.h )
2998     if ( test -n "`egrep '#ifdef KERNEL' ${file}`"
2999        ) > /dev/null 2>&1 ; then
3000     fixlist="${fixlist}
3001       ultrix_ifdef"
3002     if [ ! -r ${DESTFILE} ]
3003     then infile=${file}
3004     else infile=${DESTFILE} ; fi 
3005
3006     sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' \
3007           < $infile > ${DESTDIR}/fixinc.tmp
3008     rm -f ${DESTFILE}
3009     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
3010     fi # end of select 'if'
3011     ;; # case end for file name test
3012     esac
3013
3014
3015     #
3016     # Fix Ultrix_Nested_Cmnt
3017     #
3018     case "${file}" in ./rpc/svc.h )
3019     fixlist="${fixlist}
3020       ultrix_nested_cmnt"
3021     if [ ! -r ${DESTFILE} ]
3022     then infile=${file}
3023     else infile=${DESTFILE} ; fi 
3024
3025     sed -e 's@^\( \*    int protocol;  \)/\*@\1*/ /*@' \
3026           < $infile > ${DESTDIR}/fixinc.tmp
3027     rm -f ${DESTFILE}
3028     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
3029     ;; # case end for file name test
3030     esac
3031
3032
3033     #
3034     # Fix Ultrix_Static
3035     #
3036     case "${file}" in ./machine/cpu.h )
3037     if ( test -n "`egrep '#include \"r[34]_cpu' ${file}`"
3038        ) > /dev/null 2>&1 ; then
3039     fixlist="${fixlist}
3040       ultrix_static"
3041     if [ ! -r ${DESTFILE} ]
3042     then infile=${file}
3043     else infile=${DESTFILE} ; fi 
3044
3045     sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' \
3046         -e 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/' \
3047         -e 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/' \
3048           < $infile > ${DESTDIR}/fixinc.tmp
3049     rm -f ${DESTFILE}
3050     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
3051     fi # end of select 'if'
3052     ;; # case end for file name test
3053     esac
3054
3055
3056     #
3057     # Fix Undefine_Null
3058     #
3059     if ( test -n "`egrep '^#[   ]*define[       ]*[     ]NULL[  ]' ${file}`"
3060        ) > /dev/null 2>&1 ; then
3061     if ( test -z "`egrep '#[    ]*(ifn|un)def[  ]*[     ]NULL($|[       ])' ${file}`"
3062        ) > /dev/null 2>&1 ; then
3063     fixlist="${fixlist}
3064       undefine_null"
3065     if [ ! -r ${DESTFILE} ]
3066     then infile=${file}
3067     else infile=${DESTFILE} ; fi 
3068
3069     sed -e '/^#[        ]*define[       ][      ]*NULL[         ]/i\
3070 #undef NULL
3071 ' \
3072           < $infile > ${DESTDIR}/fixinc.tmp
3073     rm -f ${DESTFILE}
3074     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
3075     fi # end of bypass 'if'
3076     fi # end of select 'if'
3077
3078
3079     #
3080     # Fix Unixware7_Byteorder_Fix
3081     #
3082     case "${file}" in ./arpa/inet.h )
3083     case "$target_canonical" in *-*-sysv4* | \
3084         i[34567]86-*-sysv5* | \
3085         i[34567]86-*-udk* | \
3086         i[34567]86-*-solaris2.[0-4] | \
3087         powerpcle-*-solaris2.[0-4] | \
3088         sparc-*-solaris2.[0-4] )
3089     if ( test -n "`egrep 'in_port_t' ${file}`"
3090        ) > /dev/null 2>&1 ; then
3091     fixlist="${fixlist}
3092       unixware7_byteorder_fix"
3093     if [ ! -r ${DESTFILE} ]
3094     then infile=${file}
3095     else infile=${DESTFILE} ; fi 
3096
3097     sed -e '/^extern.*htons.*(in_port_t)/d' \
3098         -e '/^extern.*ntohs.*(in_port_t)/d' \
3099           < $infile > ${DESTDIR}/fixinc.tmp
3100     rm -f ${DESTFILE}
3101     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
3102     fi # end of select 'if'
3103     ;; # case end for machine type test
3104     esac
3105     ;; # case end for file name test
3106     esac
3107
3108
3109     #
3110     # Fix Va_I960_Macro
3111     #
3112     case "${file}" in ./arch/i960/archI960.h )
3113     if ( test -n "`egrep '__(vsiz|vali|vpad|alignof__)' ${file}`"
3114        ) > /dev/null 2>&1 ; then
3115     fixlist="${fixlist}
3116       va_i960_macro"
3117     if [ ! -r ${DESTFILE} ]
3118     then infile=${file}
3119     else infile=${DESTFILE} ; fi 
3120
3121     sed -e 's/__vsiz/__vxvsiz/' \
3122         -e 's/__vali/__vxvali/' \
3123         -e 's/__vpad/__vxvpad/' \
3124         -e 's/__alignof__/__vxalignof__/' \
3125           < $infile > ${DESTDIR}/fixinc.tmp
3126     rm -f ${DESTFILE}
3127     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
3128     fi # end of select 'if'
3129     ;; # case end for file name test
3130     esac
3131
3132
3133     #
3134     # Fix Void_Null
3135     #
3136     case "${file}" in ./curses.h | \
3137         ./dbm.h | \
3138         ./locale.h | \
3139         ./stdio.h | \
3140         ./stdlib.h | \
3141         ./string.h | \
3142         ./time.h | \
3143         ./unistd.h | \
3144         ./sys/dir.h | \
3145         ./sys/param.h | \
3146         ./sys/types.h )
3147     if ( test -n "`egrep '#[    ]*define[       ][      ]*NULL[         ].*void' ${file}`"
3148        ) > /dev/null 2>&1 ; then
3149     fixlist="${fixlist}
3150       void_null"
3151     if [ ! -r ${DESTFILE} ]
3152     then infile=${file}
3153     else infile=${DESTFILE} ; fi 
3154
3155     sed -e 's/^#[       ]*define[       ]*NULL[         ]*((void[       ]*\*)0)/#define NULL 0/' \
3156           < $infile > ${DESTDIR}/fixinc.tmp
3157     rm -f ${DESTFILE}
3158     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
3159     fi # end of select 'if'
3160     ;; # case end for file name test
3161     esac
3162
3163
3164     #
3165     # Fix Vxworks_Gcc_Problem
3166     #
3167     case "${file}" in ./types/vxTypesBase.h )
3168     if ( test -n "`egrep '__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__' ${file}`"
3169        ) > /dev/null 2>&1 ; then
3170     fixlist="${fixlist}
3171       vxworks_gcc_problem"
3172     if [ ! -r ${DESTFILE} ]
3173     then infile=${file}
3174     else infile=${DESTFILE} ; fi 
3175
3176     sed -e 's/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/#if 1/' \
3177         -e '/[  ]size_t/i\
3178 #ifndef _GCC_SIZE_T\
3179 #define _GCC_SIZE_T
3180 ' \
3181         -e '/[  ]size_t/a\
3182 #endif
3183 ' \
3184         -e '/[  ]ptrdiff_t/i\
3185 #ifndef _GCC_PTRDIFF_T\
3186 #define _GCC_PTRDIFF_T
3187 ' \
3188         -e '/[  ]ptrdiff_t/a\
3189 #endif
3190 ' \
3191         -e '/[  ]wchar_t/i\
3192 #ifndef _GCC_WCHAR_T\
3193 #define _GCC_WCHAR_T
3194 ' \
3195         -e '/[  ]wchar_t/a\
3196 #endif
3197 ' \
3198           < $infile > ${DESTDIR}/fixinc.tmp
3199     rm -f ${DESTFILE}
3200     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
3201     fi # end of select 'if'
3202     ;; # case end for file name test
3203     esac
3204
3205
3206     #
3207     # Fix Vxworks_Needs_Vxtypes
3208     #
3209     case "${file}" in ./time.h )
3210     if ( test -n "`egrep 'uint_t[       ][      ]*_clocks_per_sec' ${file}`"
3211        ) > /dev/null 2>&1 ; then
3212     fixlist="${fixlist}
3213       vxworks_needs_vxtypes"
3214     if [ ! -r ${DESTFILE} ]
3215     then infile=${file}
3216     else infile=${DESTFILE} ; fi 
3217
3218     sed -e 's/uint_t/unsigned int/' \
3219           < $infile > ${DESTDIR}/fixinc.tmp
3220     rm -f ${DESTFILE}
3221     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
3222     fi # end of select 'if'
3223     ;; # case end for file name test
3224     esac
3225
3226
3227     #
3228     # Fix Vxworks_Needs_Vxworks
3229     #
3230     case "${file}" in ./sys/stat.h )
3231     if ( test -n "`egrep '#[    ]define[        ][      ]*__INCstath' ${file}`"
3232        ) > /dev/null 2>&1 ; then
3233     if ( test '('  -r types/vxTypesOld.h ')' -a \
3234               '('  -n "`egrep '#include' $file`" ')' -a \
3235               '('  -n "`egrep ULONG $file`" ')'
3236        ) > /dev/null 2>&1 ; then
3237     fixlist="${fixlist}
3238       vxworks_needs_vxworks"
3239     if [ ! -r ${DESTFILE} ]
3240     then infile=${file}
3241     else infile=${DESTFILE} ; fi 
3242
3243     sed -e '/#[         ]define[        ][      ]*__INCstath/a\
3244 #include <types/vxTypesOld.h>
3245 ' \
3246           < $infile > ${DESTDIR}/fixinc.tmp
3247     rm -f ${DESTFILE}
3248     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
3249     fi # end of test expression 'if'
3250     fi # end of select 'if'
3251     ;; # case end for file name test
3252     esac
3253
3254
3255     #
3256     # Fix Vxworks_Time
3257     #
3258     case "${file}" in ./time.h )
3259     if ( test -n "`egrep 'VOIDFUNCPTR' ${file}`"
3260        ) > /dev/null 2>&1 ; then
3261     if ( test '('  -r vxWorks.h ')'
3262        ) > /dev/null 2>&1 ; then
3263     fixlist="${fixlist}
3264       vxworks_time"
3265     if [ ! -r ${DESTFILE} ]
3266     then infile=${file}
3267     else infile=${DESTFILE} ; fi 
3268
3269     sed -e '/VOIDFUNCPTR/i\
3270 #ifndef __gcc_VOIDFUNCPTR_defined\
3271 #ifdef __cplusplus\
3272 typedef void (*__gcc_VOIDFUNCPTR) (...);\
3273 #else\
3274 typedef void (*__gcc_VOIDFUNCPTR) ();\
3275 #endif\
3276 #define __gcc_VOIDFUNCPTR_defined\
3277 #endif
3278 ' \
3279         -e 's/VOIDFUNCPTR/__gcc_VOIDFUNCPTR/g' \
3280           < $infile > ${DESTDIR}/fixinc.tmp
3281     rm -f ${DESTFILE}
3282     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
3283     fi # end of test expression 'if'
3284     fi # end of select 'if'
3285     ;; # case end for file name test
3286     esac
3287
3288
3289     #
3290     # Fix X11_Class
3291     #
3292     case "${file}" in ./X11/ShellP.h )
3293     if ( test -z "`egrep '__cplusplus' ${file}`"
3294        ) > /dev/null 2>&1 ; then
3295     fixlist="${fixlist}
3296       x11_class"
3297     if [ ! -r ${DESTFILE} ]
3298     then infile=${file}
3299     else infile=${DESTFILE} ; fi 
3300
3301     sed -e '/char \*class;/i\
3302 #ifdef __cplusplus\
3303         char *c_class;\
3304 #else
3305 ' \
3306         -e '/char \*class;/a\
3307 #endif
3308 ' \
3309           < $infile > ${DESTDIR}/fixinc.tmp
3310     rm -f ${DESTFILE}
3311     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
3312     fi # end of bypass 'if'
3313     ;; # case end for file name test
3314     esac
3315
3316
3317     #
3318     # Fix X11_Class_Usage
3319     #
3320     case "${file}" in ./Xm/BaseClassI.h )
3321     if ( test -z "`egrep '__cplusplus' ${file}`"
3322        ) > /dev/null 2>&1 ; then
3323     fixlist="${fixlist}
3324       x11_class_usage"
3325     if [ ! -r ${DESTFILE} ]
3326     then infile=${file}
3327     else infile=${DESTFILE} ; fi 
3328
3329     sed -e 's/ class[)]/ c_class)/g' \
3330           < $infile > ${DESTDIR}/fixinc.tmp
3331     rm -f ${DESTFILE}
3332     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
3333     fi # end of bypass 'if'
3334     ;; # case end for file name test
3335     esac
3336
3337
3338     #
3339     # Fix X11_New
3340     #
3341     case "${file}" in ./Xm/Traversal.h )
3342     if ( test -z "`egrep '__cplusplus' ${file}`"
3343        ) > /dev/null 2>&1 ; then
3344     fixlist="${fixlist}
3345       x11_new"
3346     if [ ! -r ${DESTFILE} ]
3347     then infile=${file}
3348     else infile=${DESTFILE} ; fi 
3349
3350     sed -e '/Widget     old, new;/i\
3351 #ifdef __cplusplus\
3352         Widget  old, c_new;\
3353 #else
3354 ' \
3355         -e '/Widget     old, new;/a\
3356 #endif
3357 ' \
3358         -e 's/Widget new,/Widget c_new,/g' \
3359           < $infile > ${DESTDIR}/fixinc.tmp
3360     rm -f ${DESTFILE}
3361     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
3362     fi # end of bypass 'if'
3363     ;; # case end for file name test
3364     esac
3365
3366
3367     #
3368     # Fix X11_Sprintf
3369     #
3370     case "${file}" in ./X11/Xmu.h | \
3371         ./X11/Xmu/Xmu.h )
3372     if ( test -n "`egrep 'sprintf\\(\\)' ${file}`"
3373        ) > /dev/null 2>&1 ; then
3374     fixlist="${fixlist}
3375       x11_sprintf"
3376     if [ ! -r ${DESTFILE} ]
3377     then infile=${file}
3378     else infile=${DESTFILE} ; fi 
3379
3380     sed -e 's,^extern char \*   sprintf();$,#ifndef __STDC__\
3381 extern char *   sprintf();\
3382 #endif /* !defined __STDC__ */,' \
3383           < $infile > ${DESTDIR}/fixinc.tmp
3384     rm -f ${DESTFILE}
3385     mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
3386     fi # end of select 'if'
3387     ;; # case end for file name test
3388     esac
3389     #  IF the output has been removed OR it is unchanged,
3390     #  THEN ensure the output is gone
3391     #  ELSE look for local directory include syntax
3392     #
3393     if ( test ! -f ${DESTFILE} || \
3394          cmp ${file} ${DESTFILE} ) > /dev/null 2>&1
3395     then
3396       rm -f ${DESTFILE}
3397     else
3398       echo "Fixed ${file}:${fixlist}"
3399
3400       # Find any include directives that use "file".
3401       #
3402       dir=`echo ${file} | sed -e s';/[^/]*$;;'`
3403       ddir=${DESTDIR}/$dir
3404
3405       for include in `
3406          egrep '^[      ]*#[    ]*include[      ]*"[^/]' ${DESTFILE} |
3407          sed -e 's/^[   ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`
3408       do
3409         required="$required ${SRCDIR} $dir/$include ${ddir}/$include"
3410       done
3411     fi
3412   done # for file in $files
3413
3414 done
3415
3416 ## Make sure that any include files referenced using double quotes
3417 ## exist in the fixed directory.  This comes last since otherwise
3418 ## we might end up deleting some of these files "because they don't
3419 ## need any change."
3420 set x `echo $required`
3421 shift
3422 while [ $# != 0 ]; do
3423   newreq=
3424   while [ $# != 0 ]; do
3425     # $1 is the directory to copy from,
3426     # $2 is the unfixed file,
3427     # $3 is the fixed file name.
3428     #
3429     cd ${INPUT}
3430     cd $1
3431     if [ -f $2 ] ; then
3432       if [ -r $2 ] && [ ! -r $3 ]; then
3433         cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2" >&2
3434         chmod +w $3 2>/dev/null
3435         chmod a+r $3 2>/dev/null
3436         if test $VERBOSE -gt 2
3437         then echo Copied $2 ; fi
3438         for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' $3 |
3439              sed -e 's/^[       ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`
3440         do
3441           dir=`echo $2 | sed -e s'|/[^/]*$||'`
3442           dir2=`echo $3 | sed -e s'|/[^/]*$||'`
3443           newreq="$newreq $1 $dir/$include $dir2/$include"
3444         done
3445       fi
3446     fi
3447     shift; shift; shift
3448   done
3449   set x $newreq
3450   shift
3451 done
3452
3453 if test $VERBOSE -gt 2
3454 then echo 'Cleaning up DONE files.' ; fi
3455 cd $LIB
3456 find . -name DONE -exec rm -f '{}' ';'
3457
3458 if test $VERBOSE -gt 1
3459 then echo 'Cleaning up unneeded directories:' ; fi
3460 cd $LIB
3461 all_dirs=`find . -type d \! -name '.' -print | sort -r`
3462 for file in $all_dirs; do
3463   rmdir $LIB/$file > /dev/null 2>&1
3464 done
3465
3466 if test $VERBOSE -gt 0
3467 then echo fixincludes is done ; fi
3468
3469 # # # # # # # # # # # # # # # # # # # # #
3470 #
3471 # End of for INPUT directories
3472 #
3473 done
3474 #
3475 # # # # # # # # # # # # # # # # # # # # #
3476
3477 if [ x${INSTALL_ASSERT_H} != x ] && [ -f ${srcdir}/assert.h ]
3478 then
3479   cd $ORIGDIR
3480   rm -f include/assert.h
3481   cp ${srcdir}/assert.h include/assert.h || exit 1
3482   chmod a+r include/assert.h
3483 fi