2 # Install modified versions of certain ANSI-incompatible system header files
3 # which are fixed to work correctly with ANSI C
4 # and placed in a directory that GNU C will search.
6 # See README-fixinc for more information.
8 # Directory containing the original header files.
9 # (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
10 INPUT=${2-${INPUT-/usr/include}}
12 # Directory in which to store the results.
13 LIB=${1?"fixincludes: output directory not specified"}
15 # Define PWDCMD as a command to use to get the working dir
16 # in the form that we want.
20 # On an Apollo, discard everything before `/usr'.
21 PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
28 # Make sure it exists.
29 if [ ! -d $LIB ]; then
33 # Make LIB absolute only if needed to avoid problems with the amd.
38 cd $LIB; LIB=`${PWDCMD}`
42 # Fail if no arg to specify a directory for the output.
44 then echo fixincludes: no output directory specified
48 echo Building fixed headers in ${LIB}
50 # Determine whether this system has symbolic links.
51 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
52 rm -f $LIB/ShouldNotExist
54 elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
55 rm -f /tmp/ShouldNotExist
61 echo Finding directories and links to directories
63 # Find all directories and all symlinks that point to directories.
64 # Put the list in $files.
65 # Each time we find a symlink, add it to newdirs
66 # so that we do another find within the dir the link points to.
67 # Note that $files may have duplicates in it;
68 # later parts of this file are supposed to ignore them.
71 while [ -n "$dirs" ] && [ $levels -gt 0 ]
73 levels=`expr $levels - 1`
77 echo " Searching $INPUT/$d"
83 # Find all directories under $d, relative to $d, excluding $d itself.
84 files="$files `find $d -type d -print | \
85 sed -e '/\/\.$/d' -e '/^\.$/d'`"
86 # Find all links to directories.
87 # Using `-exec test -d' in find fails on some systems,
88 # and trying to run test via sh fails on others,
89 # so this is the simplest alternative left.
90 # First find all the links, then test each one.
93 theselinks=`find $d -type l -print`
94 for d1 in $theselinks --dummy--
96 # If the link points to a directory,
97 # add that dir to $newdirs
101 if [ "`ls -ld $d1 | sed -n 's/.*-> //p'`" != "." ]
103 newdirs="$newdirs $d1"
113 echo "All directories (including links to directories):"
116 for file in $files; do
118 if [ ! -d $LIB/$file ]
119 then mkdir $LIB/$file
124 # treetops gets an alternating list
125 # of old directories to copy
126 # and the new directories to copy to.
127 treetops="${INPUT} ${LIB}"
130 echo 'Making symbolic directory links'
131 for file in $files; do
132 dest=`ls -ld $file | sed -n 's/.*-> //p'`
135 # In case $dest is relative, get to $file's dir first.
137 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
138 # Check that the target directory exists.
139 # Redirections changed to avoid bug in sh on Ultrix.
140 (cd $dest) > /dev/null 2>&1
143 # X gets the dir that the link actually leads to.
145 # Canonicalize ${INPUT} now to minimize the time an
146 # automounter has to change the result of ${PWDCMD}.
147 cinput=`cd ${INPUT}; ${PWDCMD}`
148 # If a link points to ., make a similar link to .
149 if [ $x = ${cinput} ]; then
150 echo $file '->' . ': Making link'
151 rm -fr ${LIB}/$file > /dev/null 2>&1
152 ln -s . ${LIB}/$file > /dev/null 2>&1
153 # If link leads back into ${INPUT},
154 # make a similar link here.
155 elif expr $x : "${cinput}/.*" > /dev/null; then
156 # Y gets the actual target dir name, relative to ${INPUT}.
157 y=`echo $x | sed -n "s&${cinput}/&&p"`
158 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
160 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
161 echo $file '->' $dots$y ': Making link'
162 rm -fr ${LIB}/$file > /dev/null 2>&1
163 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
165 # If the link is to a dir $target outside ${INPUT},
166 # repoint the link at ${INPUT}/root$target
167 # and process $target into ${INPUT}/root$target
168 # treat this directory as if it actually contained the files.
169 echo $file '->' root$x ': Making link'
170 if [ -d $LIB/root$x ]
176 while [ x$dirname != x ]; do
177 component=`echo $dirname | sed -e 's|/.*$||'`
178 mkdir $component >/dev/null 2>&1
180 dirmade=$dirmade/$component
181 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
184 # Duplicate directory structure created in ${LIB}/$file in new
186 for file2 in $files; do
189 dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
190 echo "Duplicating ${file}'s ${dupdir}"
201 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
203 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
204 rm -fr ${LIB}/$file > /dev/null 2>&1
205 ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1
206 treetops="$treetops $x ${LIB}/root$x"
217 while [ $# != 0 ]; do
218 # $1 is an old directory to copy, and $2 is the new directory to copy to.
221 # The same dir can appear more than once in treetops.
222 # There's no need to scan it more than once.
228 echo Fixing directory $1 into $2
229 # Check .h files which are symlinks as well as those which are files.
230 # A link to a header file will not be processed by anything but this.
232 files=`find . -name '*.h' \( -type f -o -type l \) -print`
234 files=`find . -name '*.h' -type f -print`
236 echo Checking header files
238 # Note that BSD43_* are used on recent MIPS systems.
239 for file in $files; do
240 # This call to egrep is essential, since checking a file with egrep
241 # is much faster than actually trying to fix it.
242 # It is also essential that most files *not* match!
243 # Thus, matching every #endif is unacceptable.
244 # But the argument to egrep must be kept small, or many versions of egrep
245 # won't be able to handle it.
247 # We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment
248 # following #else or #endif because some buggy egreps think [^/] matches
249 # newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'.
251 # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
252 # following #if or #elif that is not surrounded by __. The `a-ce-km-z'
253 # in this pattern lacks `d' and `l'; this means we don't worry about
254 # identifiers starting with `d' or `l'. This is OK, since none of the
255 # identifiers below start with `d' or `l'. It also greatly improves
256 # performance, since many files contain lines of the form `#if ... defined ...'
258 if egrep '//|[ _]_IO|CTRL|^#define.NULL|^#e[nl][ds][ief]*[ ]+[!-.0-~]|^#[el]*if.*[^a-zA-Z0-9_][_a-ce-km-zA-Z][a-zA-Z0-9]' $file >/dev/null; then
259 if [ -r $file ]; then
260 cp $file $2/$file >/dev/null 2>&1 \
261 || echo "Can't copy $file"
264 # Here is how the sed commands in braces work.
265 # (It doesn't work to put the comments inside the sed commands.)
266 # Surround each word with spaces, to simplify matching below.
267 # ANSIfy each pre-ANSI machine-dependent symbol
268 # by surrounding it with __ __.
269 # Remove the spaces that we inserted around each word.
274 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
275 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
276 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
277 s%^\([ ]*#[ ]*endif\)[ ]*\*[^/].*%\1%
278 s%^\([ ]*#[ ]*endif\)[ ]*[^/* ].*%\1%
279 /\/\/[^*]/ s|//\(.*\)$|/*\1*/|
280 /[ ]_IO[A-Z]*[ ]*(/ s/\(_IO[A-Z]*[ ]*(\)\(.\),/\1'\''\2'\'',/
281 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
282 /#define._IO/ s/'\''\([cgxtf]\)'\''/\1/g
283 /#define.BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g
284 /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
285 /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
286 /#define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g
287 /#define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g
288 /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g
290 s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
292 s/ bsd4\([0-9]\) / __bsd4\1__ /g
293 s/ _*host_mips / __host_mips__ /g
294 s/ _*i386 / __i386__ /g
296 s/ is68k / __is68k__ /g
297 s/ m68k / __m68k__ /g
298 s/ mc680\([0-9]\)0 / __mc680\10__ /g
299 s/ m88k / __m88k__ /g
300 s/ _*mips / __mips__ /g
301 s/ news\([0-9]*\) / __news\1__ /g
302 s/ ns32000 / __ns32000__ /g
303 s/ pdp11 / __pdp11__ /g
305 s/ sony_news / __sony_news__ /g
306 s/ sparc / __sparc__ /g
307 s/ sun\([a-z0-9]*\) / __sun\1__ /g
308 s/ tower\([_0-9]*\) / __tower\1__ /g
309 s/ u370 / __u370__ /g
310 s/ u3b\([0-9]*\) / __u3b\1__ /g
311 s/ unix / __unix__ /g
313 s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g
314 s/ _*R\([34]\)000 / __R\1000__ /g
315 s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g
317 s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
319 /^#define.NULL[ ]/ i\
321 ' $2/$file > $2/$file.
322 mv $2/$file. $2/$file
323 if cmp $file $2/$file >/dev/null 2>&1 \
324 || egrep 'This file is part of the GNU C Library' $2/$file >/dev/null 2>&1; then
328 # Find any include directives that use "file".
329 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $2/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
330 dir=`echo $file | sed -e s'|/[^/]*$||'`
331 required="$required $1 $dir/$include $2/$dir/$include"
342 # Install the proper definition of the three standard types in header files
343 # that they come from.
344 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
345 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
346 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
347 chmod +w ${LIB}/$file 2>/dev/null
348 chmod a+r ${LIB}/$file 2>/dev/null
351 if [ -r ${LIB}/$file ]; then
352 echo Fixing size_t, ptrdiff_t and wchar_t in $file
354 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
355 #ifndef __SIZE_TYPE__\
356 #define __SIZE_TYPE__ long unsigned int\
359 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
360 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
361 #ifndef __PTRDIFF_TYPE__\
362 #define __PTRDIFF_TYPE__ long int\
365 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
366 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
367 #ifndef __WCHAR_TYPE__\
368 #define __WCHAR_TYPE__ int\
371 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
372 ${LIB}/$file > ${LIB}/${file}.sed
373 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
374 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
380 # Fix one other error in this file: a mismatched quote not inside a C comment.
381 file=sundev/vuid_event.h
382 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
383 mkdir ${LIB}/sundev 2>/dev/null
384 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
385 chmod +w ${LIB}/$file 2>/dev/null
386 chmod a+r ${LIB}/$file 2>/dev/null
389 if [ -r ${LIB}/$file ]; then
390 echo Fixing $file comment
391 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
392 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
393 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
398 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
399 file=sunwindow/win_cursor.h
400 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
401 # mkdir ${LIB}/sunwindow 2>/dev/null
402 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
403 chmod +w ${LIB}/$file 2>/dev/null
405 if [ -r ${LIB}/$file ]; then
407 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
408 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
409 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
413 file=sunwindow/win_lock.h
414 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
415 # mkdir ${LIB}/sunwindow 2>/dev/null
416 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
417 chmod +w ${LIB}/$file 2>/dev/null
419 if [ -r ${LIB}/$file ]; then
421 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
422 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
423 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
428 # Fix this Sun file to avoid interfering with stddef.h.
430 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
431 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
432 chmod +w ${LIB}/$file 2>/dev/null
433 chmod a+r ${LIB}/$file 2>/dev/null
436 if [ -r ${LIB}/$file ]; then
438 sed -e '/[ ]size_t.*;/i\
445 -e '/[ ]ptrdiff_t.*;/i\
446 #ifndef _GCC_PTRDIFF_T\
447 #define _GCC_PTRDIFF_T
449 -e '/[ ]ptrdiff_t.*;/a\
452 -e '/[ ]wchar_t.*;/i\
453 #ifndef _GCC_WCHAR_T\
456 -e '/[ ]wchar_t.*;/a\
458 ' ${LIB}/$file > ${LIB}/${file}.sed
459 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
460 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
465 # Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
468 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
469 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
470 chmod +w ${LIB}/$file 2>/dev/null
471 chmod a+r ${LIB}/$file 2>/dev/null
474 if [ -r ${LIB}/$file ]; then
476 sed -e "s/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
477 -e "s/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
478 ${LIB}/$file > ${LIB}/${file}.sed
479 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
480 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
485 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
486 # match ssize_t present in AIX for the ps/2, or typedefs which use (but do not
489 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
490 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
491 chmod +w ${LIB}/$file 2>/dev/null
492 chmod a+r ${LIB}/$file 2>/dev/null
495 if [ -r ${LIB}/$file ]; then
497 sed -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/i\
501 -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/a\
503 ' ${LIB}/$file > ${LIB}/${file}.sed
504 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
505 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
510 # Fix HP's use of ../machine/inline.h to refer to
511 # /usr/include/machine/inline.h
513 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
514 cp $file ${LIB}/$file
516 if [ -r ${LIB}/$file ] ; then
518 sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
519 -e 's,"../machine/psl.h",<machine/psl.h>,' \
520 ${LIB}/$file > ${LIB}/${file}.sed
521 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
522 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
527 # Fix an error in this file: the #if says _cplusplus, not the double
528 # underscore __cplusplus that it should be
530 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
531 mkdir ${LIB}/rpcsvc 2>/dev/null
532 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
533 chmod +w ${LIB}/$file 2>/dev/null
534 chmod a+r ${LIB}/$file 2>/dev/null
537 if [ -r ${LIB}/$file ]; then
538 echo Fixing $file, __cplusplus macro
539 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
540 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
541 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
546 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
547 # structure definition.
549 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
550 mkdir ${LIB}/rpcsvc 2>/dev/null
551 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
552 chmod +w ${LIB}/$file 2>/dev/null
553 chmod a+r ${LIB}/$file 2>/dev/null
556 if [ -r ${LIB}/$file ]; then
557 echo Fixing $file, definition of statsswtch
558 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
559 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
560 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
565 # Fix an error in this file: a missing semi-colon at the end of the nodeent
566 # structure definition.
567 file=netdnet/dnetdb.h
568 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
569 mkdir ${LIB}/netdnet 2>/dev/null
570 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
571 chmod +w ${LIB}/$file 2>/dev/null
572 chmod a+r ${LIB}/$file 2>/dev/null
575 if [ -r ${LIB}/$file ]; then
576 echo Fixing $file, definition of nodeent
577 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
578 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
579 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
584 # Check for bad #ifdef line (in Ultrix 4.1)
586 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
587 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
588 chmod +w ${LIB}/$file 2>/dev/null
589 chmod a+r ${LIB}/$file 2>/dev/null
592 if [ -r ${LIB}/$file ]; then
593 echo Fixing $file, bad \#ifdef line
594 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
595 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
596 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
601 # Check for superfluous `static' (in Ultrix 4.2)
602 # On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
604 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
605 mkdir ${LIB}/machine 2>/dev/null
606 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
607 chmod +w ${LIB}/$file 2>/dev/null
608 chmod a+r ${LIB}/$file 2>/dev/null
611 if [ -r ${LIB}/$file ]; then
612 echo Fixing $file, superfluous static and broken includes of other files.
613 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' \
614 -e 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/' \
615 -e 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/' \
616 ${LIB}/$file > ${LIB}/${file}.sed
617 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
618 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
621 # This file has an alternative name, mips/cpu.h. Fix that name, too.
622 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
623 mkdir ${LIB}/mips 2>&-
624 # Don't remove the file first, they may be the same file!
625 ln ${LIB}/$file ${LIB}/mips/cpu.h > /dev/null 2>&1
630 # Incorrect sprintf declaration in X11/Xmu.h
632 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
633 mkdir ${LIB}/X11 2>/dev/null
634 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
635 chmod +w ${LIB}/$file 2>/dev/null
636 chmod a+r ${LIB}/$file 2>/dev/null
639 if [ -r ${LIB}/$file ]; then
640 echo Fixing $file sprintf declaration
641 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
642 extern char * sprintf();\
643 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
644 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
645 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
650 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
651 # (It's not clear whether the right file name is this or X11/Xmu.h.)
653 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
654 mkdir ${LIB}/X11/Xmu 2>/dev/null
655 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
656 chmod +w ${LIB}/$file 2>/dev/null
657 chmod a+r ${LIB}/$file 2>/dev/null
660 if [ -r ${LIB}/$file ]; then
661 echo Fixing $file sprintf declaration
662 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
663 extern char * sprintf();\
664 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
665 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
666 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
671 # Check for missing ';' in struct
673 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
674 mkdir ${LIB}/netinet 2>/dev/null
675 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
676 chmod +w ${LIB}/$file 2>/dev/null
677 chmod a+r ${LIB}/$file 2>/dev/null
680 if [ -r ${LIB}/$file ]; then
682 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
683 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
684 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
689 # Fix the CAT macro in SunOS memvar.h.
690 file=pixrect/memvar.h
691 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
692 mkdir ${LIB}/pixrect 2>/dev/null
693 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
694 chmod +w ${LIB}/$file 2>/dev/null
695 chmod a+r ${LIB}/$file 2>/dev/null
698 if [ -r ${LIB}/$file ]; then
700 sed -e '/^#define.CAT(a,b)/ i\
702 #define CAT(a,b) a##b\
704 /^#define.CAT(a,b)/ a\
706 ' ${LIB}/$file > ${LIB}/${file}.sed
707 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
708 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
713 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
715 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
716 mkdir ${LIB}/rpcsvc 2>/dev/null
717 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
718 chmod +w ${LIB}/$file 2>/dev/null
719 chmod a+r ${LIB}/$file 2>/dev/null
722 if [ -r ${LIB}/$file ]; then
724 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
725 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
726 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
731 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
732 # Also wrap protection around size_t for m88k-sysv3 systems.
734 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
735 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
736 chmod +w ${LIB}/$file 2>/dev/null
737 chmod a+r ${LIB}/$file 2>/dev/null
740 if [ -r ${LIB}/$file ]; then
742 sed -e 's/int abort/void abort/g' \
743 -e 's/int free/void free/g' \
744 -e 's/char \* calloc/void \* calloc/g' \
745 -e 's/char \* malloc/void \* malloc/g' \
746 -e 's/char \* realloc/void \* realloc/g' \
747 -e 's/int exit/void exit/g' \
748 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\
752 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\
755 ${LIB}/$file > ${LIB}/${file}.sed
756 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
757 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
762 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
764 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
765 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
766 chmod +w ${LIB}/$file 2>/dev/null
767 chmod a+r ${LIB}/$file 2>/dev/null
770 if [ -r ${LIB}/$file ]; then
772 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
773 -e 's/int[ ][ ]*free/void free/g' \
774 ${LIB}/$file > ${LIB}/${file}.sed
775 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
776 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
781 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
782 file=hsfs/hsfs_spec.h
783 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
784 mkdir ${LIB}/hsfs 2>/dev/null
785 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
786 chmod +w ${LIB}/$file 2>/dev/null
787 chmod a+r ${LIB}/$file 2>/dev/null
790 if [ -r ${LIB}/$file ]; then
792 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
793 ${LIB}/$file > ${LIB}/${file}.
794 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
795 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
800 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
802 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
803 mkdir ${LIB}/hsfs 2>/dev/null
804 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
805 chmod +w ${LIB}/$file 2>/dev/null
806 chmod a+r ${LIB}/$file 2>/dev/null
809 if [ -r ${LIB}/$file ]; then
811 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
812 ${LIB}/$file > ${LIB}/${file}.sed
813 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
814 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
819 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
821 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
822 mkdir ${LIB}/hsfs 2>/dev/null
823 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
824 chmod +w ${LIB}/$file 2>/dev/null
825 chmod a+r ${LIB}/$file 2>/dev/null
828 if [ -r ${LIB}/$file ]; then
830 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
831 ${LIB}/$file > ${LIB}/${file}.sed
832 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
833 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
838 # Incorrect #include in Sony News-OS 3.2.
839 file=machine/machparam.h
840 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
841 mkdir ${LIB}/machine 2>/dev/null
842 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
843 chmod +w ${LIB}/$file 2>/dev/null
844 chmod a+r ${LIB}/$file 2>/dev/null
847 if [ -r ${LIB}/$file ]; then
848 echo Fixing $file, incorrect \#include
849 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
850 ${LIB}/$file > ${LIB}/${file}.
851 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
852 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
857 # Multiline comment after typedef on IRIX 4.0.1.
859 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
860 mkdir ${LIB}/sys 2>/dev/null
861 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
862 chmod +w ${LIB}/$file 2>/dev/null
863 chmod a+r ${LIB}/$file 2>/dev/null
866 if [ -r ${LIB}/$file ]; then
867 echo Fixing $file, comment in the middle of \#ifdef
868 sed -e 's@type of the result@type of the result */@' \
869 -e 's@of the sizeof@/* of the sizeof@' \
870 ${LIB}/$file > ${LIB}/${file}.sed
871 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
872 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
877 # Turning // comments into /* */ comments trashes this IRIX 4.0.1
878 # header file, which embeds // comments inside multi-line /* */
879 # comments. If this looks like the IRIX header file, we refix it by
880 # just throwing away the // comments.
882 if [ -r ${LIB}/$file ]; then
883 if egrep indigo.esd ${LIB}/$file > /dev/null; then
884 echo Fixing $file, overeager sed script
886 sed -e 's|//.*$||g' $file > ${LIB}/$file
887 chmod +w ${LIB}/$file 2>/dev/null
888 chmod a+r ${LIB}/$file 2>/dev/null
892 # Some IRIX header files contains the string "//"
893 for file in elf_abi.h elf.h; do
894 if [ -r ${LIB}/$file ]; then
895 echo Fixing $file, overeager sed script
896 sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
897 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
898 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
904 # IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr in prototype without
905 # previous definition.
907 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
908 mkdir ${LIB}/rpc 2>/dev/null
909 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
910 chmod +w ${LIB}/$file 2>/dev/null
911 chmod a+r ${LIB}/$file 2>/dev/null
914 if [ -r ${LIB}/$file ]; then
915 echo Fixing $file, undefined type
916 sed -e '/authdes_create.*struct sockaddr/i\
919 ${LIB}/$file > ${LIB}/$file.sed
920 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
921 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
926 # IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s in prototype without previous
929 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
930 mkdir ${LIB}/rpc 2>/dev/null
931 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
932 chmod +w ${LIB}/$file 2>/dev/null
933 chmod a+r ${LIB}/$file 2>/dev/null
936 if [ -r ${LIB}/$file ]; then
937 echo Fixing $file, undefined type
938 sed -e '/xdrstdio_create.*struct __file_s/i\
941 ${LIB}/$file > ${LIB}/$file.sed
942 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
943 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
948 # Same problem with a file from SunOS 4.1.3 : a header file containing
949 # the string "//" embedded in "/**/"
950 file=sbusdev/audiovar.h
951 if [ -r ${LIB}/$file ]; then
952 echo Fixing $file, overeager sed script
954 sed -e 's|//.*$||g' $file > ${LIB}/$file
955 chmod +w ${LIB}/$file 2>/dev/null
956 chmod a+r ${LIB}/$file 2>/dev/null
959 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
960 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
961 # many other systems have similar text but correct versions of the file.
962 # To ensure only Sun's is fixed, we grep for a likely unique string.
964 if [ -r $file ] && egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
965 if [ ! -r ${LIB}/$file ]; then
966 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
967 chmod +w ${LIB}/$file 2>/dev/null
968 chmod a+r ${LIB}/$file 2>/dev/null
970 if [ -r ${LIB}/$file ]; then
972 cat > ${LIB}/$file << EOF
973 /* This file was generated by fixincludes */
978 extern void *memccpy();
979 extern void *memchr();
980 extern void *memcpy();
981 extern void *memset();
983 extern char *memccpy();
984 extern char *memchr();
985 extern char *memcpy();
986 extern char *memset();
987 #endif /* __STDC__ */
991 #endif /* __memory_h__ */
996 # parameters not const on DECstation Ultrix V4.0.
998 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
999 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1000 chmod +w ${LIB}/$file 2>/dev/null
1001 chmod a+r ${LIB}/$file 2>/dev/null
1004 if [ -r ${LIB}/$file ]; then
1005 echo Fixing $file, non-const arg
1006 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
1007 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
1008 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
1009 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
1010 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
1011 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
1012 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
1013 ${LIB}/$file > ${LIB}/${file}.sed
1014 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1015 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1020 # parameters conflict with C++ new on rs/6000
1021 for file in stdio.h unistd.h ; do
1022 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1023 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1024 chmod +w ${LIB}/$file 2>/dev/null
1027 if [ -r ${LIB}/$file ]; then
1028 echo Fixing $file, parameter name conflicts
1029 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
1030 ${LIB}/$file > ${LIB}/${file}.sed
1031 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1032 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1038 # function class(double x) conflicts with C++ keyword on rs/6000
1040 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1041 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1042 chmod +w ${LIB}/$file 2>/dev/null
1043 chmod a+r ${LIB}/$file 2>/dev/null
1046 if [ -r ${LIB}/$file ]; then
1047 if grep 'class[(]' ${LIB}/$file >/dev/null; then
1049 sed -e '/class[(]/i\
1054 ' ${LIB}/$file > ${LIB}/${file}.sed
1055 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1056 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1062 # Wrong fchmod prototype on RS/6000.
1064 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1065 mkdir ${LIB}/sys 2>/dev/null
1066 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1067 chmod +w ${LIB}/$file 2>/dev/null
1068 chmod a+r ${LIB}/$file 2>/dev/null
1071 if [ -r ${LIB}/$file ]; then
1072 echo Fixing $file, fchmod prototype
1073 sed -e 's/fchmod(char \*/fchmod(int/' \
1074 ${LIB}/$file > ${LIB}/$file.sed
1075 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1076 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1081 # There are several name conflicts with C++ reserved words in X11
1082 # header files. These are fixed in some versions, so don't do the
1083 # fixes if we find __cplusplus in the file. These were found on the
1086 # class in X11/ShellP.h
1088 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1089 mkdir ${LIB}/sys 2>/dev/null
1090 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1091 chmod +w ${LIB}/$file 2>/dev/null
1092 chmod a+r ${LIB}/$file 2>/dev/null
1095 if [ -r ${LIB}/$file ]; then
1096 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1099 echo Fixing $file, field class
1100 sed -e '/char [*]class;/i\
1105 -e '/char [*]class;/a\
1107 ' ${LIB}/$file > ${LIB}/${file}.sed
1108 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1110 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1114 # new in Xm/Traversal.h
1116 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1117 mkdir ${LIB}/sys 2>/dev/null
1118 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1119 chmod +w ${LIB}/$file 2>/dev/null
1120 chmod a+r ${LIB}/$file 2>/dev/null
1123 if [ -r ${LIB}/$file ]; then
1124 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1127 echo Fixing $file, uses of new
1128 sed -e '/Widget old, new;/i\
1133 -e '/Widget old, new;/a\
1136 -e 's/Widget new,/Widget c_new,/g' ${LIB}/$file > ${LIB}/${file}.sed
1137 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1139 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1143 # class in Xm/BaseClassI.h
1144 file=Xm/BaseClassI.h
1145 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1146 mkdir ${LIB}/sys 2>/dev/null
1147 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1148 chmod +w ${LIB}/$file 2>/dev/null
1149 chmod a+r ${LIB}/$file 2>/dev/null
1152 if [ -r ${LIB}/$file ]; then
1153 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1156 echo Fixing $file, prototype parameter name
1157 sed -e 's/ class[)]/ c_class)/g' ${LIB}/$file > ${LIB}/${file}.sed
1158 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1160 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1166 # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1167 # Note that version 3 of the NeXT system has wait.h in a different directory,
1168 # so that this code won't do anything. But wait.h in version 3 has a
1169 # conditional, so it doesn't need this fix. So everything is okay.
1171 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1172 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1173 chmod +w ${LIB}/$file 2>/dev/null
1176 if [ -r ${LIB}/$file ] \
1177 && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
1178 echo Fixing $file, bad wait formal
1179 sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed
1180 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1181 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1186 # Don't use or define the name va_list in stdio.h.
1187 # This is for ANSI and also to interoperate properly with gcc's varargs.h.
1189 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1190 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1191 chmod +w ${LIB}/$file 2>/dev/null
1192 chmod a+r ${LIB}/$file 2>/dev/null
1195 if [ -r ${LIB}/$file ]; then
1196 echo Fixing $file, use of va_list
1197 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
1198 if egrep "__need___va_list" ${LIB}/$file >/dev/null 2>&1; then
1199 touch ${LIB}/${file}.sed
1201 (echo "#define __need___va_list"
1202 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
1204 # Use __gnuc_va_list in arg types in place of va_list.
1205 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
1206 # trailing parentheses and semicolon save all other systems from this.
1207 # Define __va_list__ (something harmless and unused) instead of va_list.
1208 # Don't claim to have defined va_list.
1209 sed -e 's@ va_list @ __gnuc_va_list @' \
1210 -e 's@ va_list)@ __gnuc_va_list)@' \
1211 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1212 -e 's@ va_list@ __va_list__@' \
1213 -e 's@\*va_list@*__va_list__@' \
1214 -e 's@ __va_list)@ __gnuc_va_list)@' \
1215 -e 's@GNUC_VA_LIST@GNUC_Va_LIST@' \
1216 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
1217 -e 's@VA_LIST@DUMMY_VA_LIST@' \
1218 -e 's@_Va_LIST@_VA_LIST@' \
1219 ${LIB}/$file >> ${LIB}/${file}.sed
1221 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1222 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1227 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
1229 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1230 if grep -s ULTRIX $file; then
1231 echo "/* This file intentionally left blank. */" > $LIB/$file
1235 # parameter to atof not const on DECstation Ultrix V4.0.
1236 # also get rid of bogus inline definitions in HP-UX 8.0
1238 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1239 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1240 chmod +w ${LIB}/$file 2>/dev/null
1241 chmod a+r ${LIB}/$file 2>/dev/null
1244 if [ -r ${LIB}/$file ]; then
1245 echo Fixing $file, non-const arg
1246 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
1247 -e 's@inline int abs(int [a-z][a-z]*) {.*}@@' \
1248 -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
1249 -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
1250 -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
1251 ${LIB}/$file > ${LIB}/${file}.sed
1252 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1253 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1258 # Avoid nested comments on Ultrix 4.3.
1260 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1261 mkdir ${LIB}/rpc 2>/dev/null
1262 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1263 chmod +w ${LIB}/$file 2>/dev/null
1264 chmod a+r ${LIB}/$file 2>/dev/null
1267 if [ -r ${LIB}/$file ]; then
1268 echo Fixing $file, nested comment
1269 sed -e 's@^\( \* int protocol; \)/\*@\1*/ /*@' \
1270 ${LIB}/$file > ${LIB}/$file.sed
1271 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1272 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1277 # This file in RISC/os uses /**/ to concatenate two tokens.
1279 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1280 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1281 chmod +w ${LIB}/$file 2>/dev/null
1282 chmod a+r ${LIB}/$file 2>/dev/null
1284 if [ -r ${LIB}/$file ]; then
1285 sed -e 's|/\*\*/|##|' ${LIB}/$file > ${LIB}/${file}.sed
1286 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1287 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1293 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1294 mkdir ${LIB}/rpc 2>/dev/null
1295 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1296 chmod +w ${LIB}/$file 2>/dev/null
1297 chmod a+r ${LIB}/$file 2>/dev/null
1300 if [ -r ${LIB}/$file ]; then
1301 echo Fixing $file, nested comment
1302 sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \
1303 ${LIB}/$file > ${LIB}/$file.sed
1304 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1305 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1310 # In limits.h, put #ifndefs around things that are supposed to be defined
1311 # in float.h to avoid redefinition errors if float.h is included first.
1312 # On HP/UX this patch does not work, because on HP/UX limits.h uses
1313 # multi line comments and the inserted #endif winds up inside the
1314 # comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1315 # we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1316 # are there, and we do not add them ourselves.
1317 for file in limits.h sys/limits.h; do
1318 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1319 mkdir ${LIB}/sys 2>/dev/null
1320 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1321 chmod +w ${LIB}/$file 2>/dev/null
1322 chmod a+r ${LIB}/$file 2>/dev/null
1325 if [ -r ${LIB}/$file ]; then
1326 if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then
1330 sed -e '/[ ]FLT_MIN[ ]/i\
1333 -e '/[ ]FLT_MIN[ ]/a\
1336 -e '/[ ]FLT_MAX[ ]/i\
1339 -e '/[ ]FLT_MAX[ ]/a\
1342 -e '/[ ]FLT_DIG[ ]/i\
1345 -e '/[ ]FLT_DIG[ ]/a\
1348 -e '/[ ]DBL_MIN[ ]/i\
1351 -e '/[ ]DBL_MIN[ ]/a\
1354 -e '/[ ]DBL_MAX[ ]/i\
1357 -e '/[ ]DBL_MAX[ ]/a\
1360 -e '/[ ]DBL_DIG[ ]/i\
1363 -e '/[ ]DBL_DIG[ ]/a\
1366 ${LIB}/$file > ${LIB}/${file}.sed
1367 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1369 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1370 echo Deleting ${LIB}/$file\; no fixes were needed.
1376 # In math.h, put #ifndefs around things that might be defined in a gcc
1377 # specific math-*.h file.
1379 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1380 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1381 chmod +w ${LIB}/$file 2>/dev/null
1382 chmod a+r ${LIB}/$file 2>/dev/null
1385 if [ -r ${LIB}/$file ]; then
1387 sed -e '/define[ ]HUGE_VAL[ ]/i\
1390 -e '/define[ ]HUGE_VAL[ ]/a\
1393 ${LIB}/$file > ${LIB}/${file}.sed
1394 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1396 # In addition, copy the definition of DBL_MAX from float.h
1397 # if math.h requires one. The Lynx math.h requires it.
1398 if egrep '#define[ ]*HUGE_VAL[ ]+DBL_MAX' $file >/dev/null 2>&1; then
1399 if egrep '#define[ ]+DBL_MAX[ ]+' $file >/dev/null 2>&1; then
1402 dbl_max_def=`egrep 'define[ ]+DBL_MAX[ ]+.*' float.h 2>/dev/null`
1403 if [ "$dbl_max_def" != "" ]; then
1404 dbl_max_def=`echo $dbl_max_def | sed 's/.*define[ ]*DBL_MAX[ ]*//'`
1405 sed -e "/define[ ]HUGE_VAL[ ]DBL_MAX/s/DBL_MAX/$dbl_max_def/" \
1406 ${LIB}/$file > ${LIB}/${file}.sed
1407 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1412 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1413 echo Deleting ${LIB}/$file\; no fixes were needed.
1418 # Remove erroneous parentheses in sym.h on Alpha OSF/1.
1420 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1421 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1422 chmod +w ${LIB}/$file 2>/dev/null
1423 chmod a+r ${LIB}/$file 2>/dev/null
1426 if [ -r ${LIB}/$file ]; then
1428 sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
1429 ${LIB}/$file > ${LIB}/${file}.sed
1430 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1431 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1436 # Correct the return type for strlen in string.h on Lynx.
1437 # Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
1439 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1440 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1441 chmod +w ${LIB}/$file 2>/dev/null
1442 chmod a+r ${LIB}/$file 2>/dev/null
1445 if [ -r ${LIB}/$file ]; then
1447 sed -e 's/extern[ ]*int[ ]*strlen();/extern unsigned int strlen();/' \
1448 -e 's/extern[ ]*int[ ]*ffs[ ]*(long);/extern int ffs(int);/' \
1449 ${LIB}/$file > ${LIB}/${file}.sed
1450 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1451 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1456 # Delete the '#define void int' line from curses.h on Lynx
1458 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1459 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1460 chmod +w ${LIB}/$file 2>/dev/null
1461 chmod a+r ${LIB}/$file 2>/dev/null
1464 if [ -r ${LIB}/$file ]; then
1466 sed -e '/#define[ ][ ]*void[ ]int/d' \
1467 ${LIB}/$file > ${LIB}/${file}.sed
1468 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1469 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1474 # For C++, avoid any typedef or macro definition of bool, and use the
1475 # built in type instead.
1476 for files in curses.h; do
1477 if [ -r $file ] && egrep bool $file >/dev/null 2>&1; then
1478 if [ ! -r ${LIB}/$file ]; then
1479 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1480 chmod +w ${LIB}/$file 2>/dev/null
1481 chmod a+r ${LIB}/$file 2>/dev/null
1485 sed -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/i\
1486 #ifndef __cplusplus'\
1487 -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/a\
1489 -e '/^typedef[ ][ ]*char[ ][ ]*bool;[ ]*$/i\
1490 #ifndef __cplusplus'\
1491 -e '/^typedef[ ][ ]*char[ ][ ]*bool;[ ]*$/a\
1493 ${LIB}/$file > ${LIB}/${file}.sed
1494 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1495 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1501 # Fix incorrect S_IF* definitions on m88k-sysv3.
1503 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1504 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1505 chmod +w ${LIB}/$file 2>/dev/null
1506 chmod a+r ${LIB}/$file 2>/dev/null
1509 if [ -r ${LIB}/$file ]; then
1511 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)/' \
1512 -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
1513 ${LIB}/$file > ${LIB}/${file}.sed
1514 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1515 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1520 # Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
1521 for file in stdio.h stdlib.h; do
1522 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1523 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1524 chmod +w ${LIB}/$file 2>/dev/null
1525 chmod a+r ${LIB}/$file 2>/dev/null
1528 if [ -r ${LIB}/$file ]; then
1529 echo Fixing $file, getopt declaration
1530 sed -e 's/getopt(int, char \*\[\],[ ]*char \*)/getopt(int, char *const[], const char *)/' \
1531 ${LIB}/$file > ${LIB}/${file}.sed
1532 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1533 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1539 # Determine if we're on Interactive Unix 2.2 or later, in which case we
1540 # need to fix some additional files. This is the same test for ISC that
1542 if test -d /etc/conf/kconfig.d \
1543 && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
1544 echo "Fixing ISC __STDC__ goof in several files..."
1545 for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
1547 if test -r ${LIB}/$name; then
1552 # On Interactive 2.2, certain traditional Unix definitions
1553 # (notably getc and putc in stdio.h) are omitted if __STDC__ is
1554 # defined, not just if _POSIX_SOURCE is defined. This makes it
1555 # impossible to compile any nontrivial program except with -posix.
1557 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
1558 < $file > ${LIB}/$name.
1559 mv ${LIB}/$name. ${LIB}/$name
1562 echo "Fixing ISC fmod declaration"
1563 # This one's already been fixed for other things.
1565 sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
1568 echo "Fixing nested comments in ISC <sys/limits.h>"
1570 sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
1571 sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
1574 # These files in Sun OS 4.x use /**/ to concatenate tokens.
1575 for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \
1576 sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h \
1577 sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h;
1579 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1580 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1581 chmod +w ${LIB}/$file 2>/dev/null
1582 chmod a+r ${LIB}/$file 2>/dev/null
1585 if [ -r ${LIB}/$file ]; then
1586 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
1587 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1588 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1594 # These files in ARM/RISCiX use /**/ to concatenate tokens.
1595 for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \
1596 dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.h
1598 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1599 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1600 chmod +w ${LIB}/$file 2>/dev/null
1601 chmod a+r ${LIB}/$file 2>/dev/null
1604 if [ -r ${LIB}/$file ]; then
1605 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
1606 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1607 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1613 # math.h on SunOS 4 puts the declaration of matherr before the definition
1614 # of struct exception, so the prototype (added by fixproto) causes havoc.
1616 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1617 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1618 chmod +w ${LIB}/$file 2>/dev/null
1619 chmod a+r ${LIB}/$file 2>/dev/null
1622 if [ -r ${LIB}/$file ]; then
1623 echo Fixing $file, matherr declaration
1624 sed -e '/^struct exception/,$b' \
1628 ${LIB}/$file > ${LIB}/${file}.sed
1629 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1630 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1635 # assert.h on HP/UX is not C++ ready, even though NO_IMPLICIT_EXTERN_C
1636 # is defined on HP/UX.
1638 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1639 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1640 chmod +w ${LIB}/$file 2>/dev/null
1641 chmod a+r ${LIB}/$file 2>/dev/null
1644 if [ -r ${LIB}/$file ]; then
1645 if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \
1646 || egrep '__BEGIN_DECLS' ${LIB}/$file >/dev/null 2>&1; then
1650 echo '#ifdef __cplusplus
1652 #endif' > ${LIB}/${file}.sed
1653 cat ${LIB}/${file} >> ${LIB}/${file}.sed
1654 echo '#ifdef __cplusplus
1656 #endif' >> ${LIB}/${file}.sed
1657 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1658 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1664 # check for broken assert.h that needs stdio.h or stdlib.h
1666 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1667 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1668 chmod +w ${LIB}/$file 2>/dev/null
1669 chmod a+r ${LIB}/$file 2>/dev/null
1672 if [ -r ${LIB}/$file ]; then
1673 if grep 'stderr' ${LIB}/$file >/dev/null 2>/dev/null; then
1674 if grep 'include.*stdio.h' ${LIB}/$file >/dev/null 2>/dev/null; then
1677 echo "Fixing $file (needs stdio.h)"
1678 echo '#include <stdio.h>' >>${LIB}/$file
1681 if grep 'exit *(' ${LIB}/$file >/dev/null 2>/dev/null ||
1682 grep 'abort *(' ${LIB}/$file >/dev/null 2>/dev/null; then
1683 if grep 'include.*stdlib.h' ${LIB}/$file >/dev/null 2>/dev/null; then
1686 echo "Fixing $file (needs stdlib.h)"
1687 echo '#include <stdlib.h>' >>${LIB}/$file
1690 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1695 # Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
1697 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1698 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1699 chmod +w ${LIB}/$file 2>/dev/null
1700 chmod a+r ${LIB}/$file 2>/dev/null
1703 if [ -r ${LIB}/$file ]; then
1704 echo Fixing $file, sbrk declaration
1705 sed -e 's/char\([ ]*\*[ ]*sbrk[ ]*(\)/void\1/' \
1706 ${LIB}/$file > ${LIB}/${file}.sed
1707 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1708 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1713 # This file on SunOS 4 has a very large macro. When the sed loop
1714 # tries pull it in, it overflows the pattern space size of the SunOS
1715 # sed (GNU sed does not have this problem). Since the file does not
1716 # require fixing, we remove it from the fixed directory.
1717 file=sundev/ipi_error.h
1718 if [ -r ${LIB}/$file ]; then
1719 echo "Removing incorrect fix to SunOS <sundev/ipi_error.h>"
1723 # Put cpp wrappers around these include files to avoid redeclaration
1724 # errors during multiple inclusion on m88k-tektronix-sysv3.
1725 for file in time.h sys/time.h ; do
1726 if egrep '#ifndef' $file >/dev/null 2>&1; then
1729 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1730 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1731 chmod +w ${LIB}/$file 2>/dev/null
1733 if [ -r ${LIB}/$file ]; then
1734 echo Fixing $file, to protect against multiple inclusion.
1735 cpp_wrapper=`echo $file | sed -e 's,\.,_,g' -e 's,/,_,g'`
1736 (echo "#ifndef __GCC_GOT_${cpp_wrapper}_"
1737 echo "#define __GCC_GOT_${cpp_wrapper}_"
1739 echo '#endif /* !_GCC_GOT_'${cpp_wrapper}_' */') > ${LIB}/${file}.new
1740 rm -f ${LIB}/$file; mv ${LIB}/${file}.new ${LIB}/$file
1745 echo 'Removing unneeded directories:'
1747 files=`find . -type d -print | sort -r`
1748 for file in $files; do
1749 rmdir $LIB/$file > /dev/null 2>&1
1753 echo 'Making internal symbolic non-directory links'
1755 files=`find . -type l -print`
1756 for file in $files; do
1757 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1758 if expr "$dest" : '[^/].*' > /dev/null; then
1759 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1760 if [ -f $target ]; then
1761 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1767 # Make sure that any include files referenced using double quotes
1768 # exist in the fixed directory. This comes last since otherwise
1769 # we might end up deleting some of these files "because they don't
1773 while [ $# != 0 ]; do
1775 while [ $# != 0 ]; do
1776 # $1 is the directory to copy from, $2 is the unfixed file,
1777 # $3 is the fixed file name.
1780 if [ -r $2 ] && [ ! -r $3 ]; then
1781 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
1782 chmod +w $3 2>/dev/null
1783 chmod a+r $3 2>/dev/null
1785 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1786 dir=`echo $2 | sed -e s'|/[^/]*$||'`
1787 dir2=`echo $3 | sed -e s'|/[^/]*$||'`
1788 newreq="$newreq $1 $dir/$include $dir2/$include"
1797 echo 'Cleaning up DONE files.'
1799 find . -name DONE -exec rm -f '{}' ';'