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 # If a link points to ., make a similar link to .
146 if [ $x = $INPUT ]; then
147 echo $file '->' . ': Making link'
148 rm -fr ${LIB}/$file > /dev/null 2>&1
149 ln -s . ${LIB}/$file > /dev/null 2>&1
150 # If link leads back into ${INPUT},
151 # make a similar link here.
152 elif expr $x : "${INPUT}/.*" > /dev/null; then
153 # Y gets the actual target dir name, relative to ${INPUT}.
154 y=`echo $x | sed -n "s&${INPUT}/&&p"`
155 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
157 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
158 echo $file '->' $dots$y ': Making link'
159 rm -fr ${LIB}/$file > /dev/null 2>&1
160 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
162 # If the link is to a dir $target outside ${INPUT},
163 # repoint the link at ${INPUT}/root$target
164 # and process $target into ${INPUT}/root$target
165 # treat this directory as if it actually contained the files.
166 echo $file '->' root$x ': Making link'
167 if [ -d $LIB/root$x ]
173 while [ x$dirname != x ]; do
174 component=`echo $dirname | sed -e 's|/.*$||'`
175 mkdir $component >/dev/null 2>&1
177 dirmade=$dirmade/$component
178 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
181 # Duplicate directory structure created in ${LIB}/$file in new
183 for file2 in $files; do
186 dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
187 echo "Duplicating ${file}'s ${dupdir}"
198 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
200 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
201 rm -fr ${LIB}/$file > /dev/null 2>&1
202 ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1
203 treetops="$treetops $x ${LIB}/root$x"
214 while [ $# != 0 ]; do
215 # $1 is an old directory to copy, and $2 is the new directory to copy to.
218 # The same dir can appear more than once in treetops.
219 # There's no need to scan it more than once.
225 echo Fixing directory $1 into $2
226 # Check .h files which are symlinks as well as those which are files.
227 # A link to a header file will not be processed by anything but this.
229 files=`find . -name '*.h' \( -type f -o -type l \) -print`
231 files=`find . -name '*.h' -type f -print`
233 echo Checking header files
235 # Note that BSD43_* are used on recent MIPS systems.
236 for file in $files; do
237 # This call to egrep is essential, since checking a file with egrep
238 # is much faster than actually trying to fix it.
239 # It is also essential that most files *not* match!
240 # Thus, matching every #endif is unacceptable.
241 # But the argument to egrep must be kept small, or many versions of egrep
242 # won't be able to handle it.
244 # We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment
245 # following #else or #endif because some buggy egreps think [^/] matches
246 # newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'.
248 # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
249 # following #if or #elif that is not surrounded by __. The `a-ce-km-z'
250 # in this pattern lacks `d' and `l'; this means we don't worry about
251 # identifiers starting with `d' or `l'. This is OK, since none of the
252 # identifiers below start with `d' or `l'. It also greatly improves
253 # performance, since many files contain lines of the form `#if ... defined ...'
255 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
256 if [ -r $file ]; then
257 cp $file $2/$file >/dev/null 2>&1 \
258 || echo "Can't copy $file"
261 # Here is how the sed commands in braces work.
262 # (It doesn't work to put the comments inside the sed commands.)
263 # Surround each word with spaces, to simplify matching below.
264 # ANSIfy each pre-ANSI machine-dependent symbol
265 # by surrounding it with __ __.
266 # Remove the spaces that we inserted around each word.
271 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
272 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
273 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
274 s%^\([ ]*#[ ]*endif\)[ ]*\*[^/].*%\1%
275 s%^\([ ]*#[ ]*endif\)[ ]*[^/* ].*%\1%
276 /\/\/[^*]/ s|//\(.*\)$|/*\1*/|
277 /[ ]_IO[A-Z]*[ ]*(/ s/\(_IO[A-Z]*[ ]*(\)\(.\),/\1'\''\2'\'',/
278 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
279 /#define._IO/ s/'\''\([cgxtf]\)'\''/\1/g
280 /#define.BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g
281 /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
282 /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
283 /#define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g
284 /#define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g
285 /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g
287 s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
289 s/ bsd4\([0-9]\) / __bsd4\1__ /g
290 s/ _*host_mips / __host_mips__ /g
291 s/ _*i386 / __i386__ /g
293 s/ is68k / __is68k__ /g
294 s/ m68k / __m68k__ /g
295 s/ mc680\([0-9]\)0 / __mc680\10__ /g
296 s/ m88k / __m88k__ /g
297 s/ _*mips / __mips__ /g
298 s/ news\([0-9]*\) / __news\1__ /g
299 s/ ns32000 / __ns32000__ /g
300 s/ pdp11 / __pdp11__ /g
302 s/ sony_news / __sony_news__ /g
303 s/ sparc / __sparc__ /g
304 s/ sun\([a-z0-9]*\) / __sun\1__ /g
305 s/ tower\([_0-9]*\) / __tower\1__ /g
306 s/ u370 / __u370__ /g
307 s/ u3b\([0-9]*\) / __u3b\1__ /g
308 s/ unix / __unix__ /g
310 s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g
311 s/ _*R\([34]\)000 / __R\1000__ /g
312 s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g
314 s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
316 /^#define.NULL[ ]/ i\
318 ' $2/$file > $2/$file.
319 mv $2/$file. $2/$file
320 if cmp $file $2/$file >/dev/null 2>&1 \
321 || egrep 'This file is part of the GNU C Library' $2/$file >/dev/null 2>&1; then
325 # Find any include directives that use "file".
326 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $2/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
327 dir=`echo $file | sed -e s'|/[^/]*$||'`
328 required="$required $1 $dir/$include $2/$dir/$include"
339 # Install the proper definition of the three standard types in header files
340 # that they come from.
341 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
342 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
343 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
344 chmod +w ${LIB}/$file 2>/dev/null
345 chmod a+r ${LIB}/$file 2>/dev/null
348 if [ -r ${LIB}/$file ]; then
349 echo Fixing size_t, ptrdiff_t and wchar_t in $file
351 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
352 #ifndef __SIZE_TYPE__\
353 #define __SIZE_TYPE__ long unsigned int\
356 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
357 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
358 #ifndef __PTRDIFF_TYPE__\
359 #define __PTRDIFF_TYPE__ long int\
362 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
363 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
364 #ifndef __WCHAR_TYPE__\
365 #define __WCHAR_TYPE__ int\
368 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
369 ${LIB}/$file > ${LIB}/${file}.sed
370 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
371 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
377 # Fix one other error in this file: a mismatched quote not inside a C comment.
378 file=sundev/vuid_event.h
379 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
380 mkdir ${LIB}/sundev 2>/dev/null
381 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
382 chmod +w ${LIB}/$file 2>/dev/null
383 chmod a+r ${LIB}/$file 2>/dev/null
386 if [ -r ${LIB}/$file ]; then
387 echo Fixing $file comment
388 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
389 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
390 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
395 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
396 file=sunwindow/win_cursor.h
397 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
398 # mkdir ${LIB}/sunwindow 2>/dev/null
399 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
400 chmod +w ${LIB}/$file 2>/dev/null
402 if [ -r ${LIB}/$file ]; then
404 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
405 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
406 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
410 file=sunwindow/win_lock.h
411 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
412 # mkdir ${LIB}/sunwindow 2>/dev/null
413 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
414 chmod +w ${LIB}/$file 2>/dev/null
416 if [ -r ${LIB}/$file ]; then
418 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
419 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
420 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
425 # Fix this Sun file to avoid interfering with stddef.h.
427 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
428 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
429 chmod +w ${LIB}/$file 2>/dev/null
430 chmod a+r ${LIB}/$file 2>/dev/null
433 if [ -r ${LIB}/$file ]; then
435 sed -e '/[ ]size_t.*;/i\
442 -e '/[ ]ptrdiff_t.*;/i\
443 #ifndef _GCC_PTRDIFF_T\
444 #define _GCC_PTRDIFF_T
446 -e '/[ ]ptrdiff_t.*;/a\
449 -e '/[ ]wchar_t.*;/i\
450 #ifndef _GCC_WCHAR_T\
453 -e '/[ ]wchar_t.*;/a\
455 ' ${LIB}/$file > ${LIB}/${file}.sed
456 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
457 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
462 # Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
465 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
466 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
467 chmod +w ${LIB}/$file 2>/dev/null
468 chmod a+r ${LIB}/$file 2>/dev/null
471 if [ -r ${LIB}/$file ]; then
473 sed -e "s/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
474 -e "s/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
475 ${LIB}/$file > ${LIB}/${file}.sed
476 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
477 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
482 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
483 # match ssize_t present in AIX for the ps/2, or typedefs which use (but do not
486 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
487 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
488 chmod +w ${LIB}/$file 2>/dev/null
489 chmod a+r ${LIB}/$file 2>/dev/null
492 if [ -r ${LIB}/$file ]; then
494 sed -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/i\
498 -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/a\
500 ' ${LIB}/$file > ${LIB}/${file}.sed
501 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
502 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
507 # Fix HP's use of ../machine/inline.h to refer to
508 # /usr/include/machine/inline.h
510 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
511 cp $file ${LIB}/$file
513 if [ -r ${LIB}/$file ] ; then
515 sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
516 -e 's,"../machine/psl.h",<machine/psl.h>,' \
517 ${LIB}/$file > ${LIB}/${file}.sed
518 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
519 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
524 # Fix an error in this file: the #if says _cplusplus, not the double
525 # underscore __cplusplus that it should be
527 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
528 mkdir ${LIB}/rpcsvc 2>/dev/null
529 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
530 chmod +w ${LIB}/$file 2>/dev/null
531 chmod a+r ${LIB}/$file 2>/dev/null
534 if [ -r ${LIB}/$file ]; then
535 echo Fixing $file, __cplusplus macro
536 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
537 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
538 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
543 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
544 # structure definition.
546 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
547 mkdir ${LIB}/rpcsvc 2>/dev/null
548 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
549 chmod +w ${LIB}/$file 2>/dev/null
550 chmod a+r ${LIB}/$file 2>/dev/null
553 if [ -r ${LIB}/$file ]; then
554 echo Fixing $file, definition of statsswtch
555 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
556 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
557 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
562 # Fix an error in this file: a missing semi-colon at the end of the nodeent
563 # structure definition.
564 file=netdnet/dnetdb.h
565 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
566 mkdir ${LIB}/netdnet 2>/dev/null
567 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
568 chmod +w ${LIB}/$file 2>/dev/null
569 chmod a+r ${LIB}/$file 2>/dev/null
572 if [ -r ${LIB}/$file ]; then
573 echo Fixing $file, definition of nodeent
574 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
575 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
576 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
581 # Check for bad #ifdef line (in Ultrix 4.1)
583 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
584 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
585 chmod +w ${LIB}/$file 2>/dev/null
586 chmod a+r ${LIB}/$file 2>/dev/null
589 if [ -r ${LIB}/$file ]; then
590 echo Fixing $file, bad \#ifdef line
591 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
592 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
593 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
598 # Check for superfluous `static' (in Ultrix 4.2)
599 # On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
601 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
602 mkdir ${LIB}/machine 2>/dev/null
603 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
604 chmod +w ${LIB}/$file 2>/dev/null
605 chmod a+r ${LIB}/$file 2>/dev/null
608 if [ -r ${LIB}/$file ]; then
609 echo Fixing $file, superfluous static and broken includes of other files.
610 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' \
611 -e 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/' \
612 -e 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/' \
613 ${LIB}/$file > ${LIB}/${file}.sed
614 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
615 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
618 # This file has an alternative name, mips/cpu.h. Fix that name, too.
619 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
620 mkdir ${LIB}/mips 2>&-
621 # Don't remove the file first, they may be the same file!
622 ln ${LIB}/$file ${LIB}/mips/cpu.h > /dev/null 2>&1
627 # Incorrect sprintf declaration in X11/Xmu.h
629 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
630 mkdir ${LIB}/X11 2>/dev/null
631 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
632 chmod +w ${LIB}/$file 2>/dev/null
633 chmod a+r ${LIB}/$file 2>/dev/null
636 if [ -r ${LIB}/$file ]; then
637 echo Fixing $file sprintf declaration
638 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
639 extern char * sprintf();\
640 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
641 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
642 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
647 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
648 # (It's not clear whether the right file name is this or X11/Xmu.h.)
650 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
651 mkdir ${LIB}/X11/Xmu 2>/dev/null
652 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
653 chmod +w ${LIB}/$file 2>/dev/null
654 chmod a+r ${LIB}/$file 2>/dev/null
657 if [ -r ${LIB}/$file ]; then
658 echo Fixing $file sprintf declaration
659 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
660 extern char * sprintf();\
661 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
662 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
663 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
668 # Check for missing ';' in struct
670 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
671 mkdir ${LIB}/netinet 2>/dev/null
672 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
673 chmod +w ${LIB}/$file 2>/dev/null
674 chmod a+r ${LIB}/$file 2>/dev/null
677 if [ -r ${LIB}/$file ]; then
679 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
680 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
681 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
686 # Fix the CAT macro in SunOS memvar.h.
687 file=pixrect/memvar.h
688 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
689 mkdir ${LIB}/pixrect 2>/dev/null
690 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
691 chmod +w ${LIB}/$file 2>/dev/null
692 chmod a+r ${LIB}/$file 2>/dev/null
695 if [ -r ${LIB}/$file ]; then
697 sed -e '/^#define.CAT(a,b)/ i\
699 #define CAT(a,b) a##b\
701 /^#define.CAT(a,b)/ a\
703 ' ${LIB}/$file > ${LIB}/${file}.sed
704 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
705 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
710 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
712 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
713 mkdir ${LIB}/rpcsvc 2>/dev/null
714 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
715 chmod +w ${LIB}/$file 2>/dev/null
716 chmod a+r ${LIB}/$file 2>/dev/null
719 if [ -r ${LIB}/$file ]; then
721 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
722 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
723 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
728 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
729 # Also wrap protection around size_t for m88k-sysv3 systems.
731 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
732 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
733 chmod +w ${LIB}/$file 2>/dev/null
734 chmod a+r ${LIB}/$file 2>/dev/null
737 if [ -r ${LIB}/$file ]; then
739 sed -e 's/int abort/void abort/g' \
740 -e 's/int free/void free/g' \
741 -e 's/char \* calloc/void \* calloc/g' \
742 -e 's/char \* malloc/void \* malloc/g' \
743 -e 's/char \* realloc/void \* realloc/g' \
744 -e 's/int exit/void exit/g' \
745 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\
749 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\
752 ${LIB}/$file > ${LIB}/${file}.sed
753 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
754 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
759 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
761 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
762 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
763 chmod +w ${LIB}/$file 2>/dev/null
764 chmod a+r ${LIB}/$file 2>/dev/null
767 if [ -r ${LIB}/$file ]; then
769 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
770 -e 's/int[ ][ ]*free/void free/g' \
771 ${LIB}/$file > ${LIB}/${file}.sed
772 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
773 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
778 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
779 file=hsfs/hsfs_spec.h
780 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
781 mkdir ${LIB}/hsfs 2>/dev/null
782 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
783 chmod +w ${LIB}/$file 2>/dev/null
784 chmod a+r ${LIB}/$file 2>/dev/null
787 if [ -r ${LIB}/$file ]; then
789 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
790 ${LIB}/$file > ${LIB}/${file}.
791 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
792 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
797 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
799 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
800 mkdir ${LIB}/hsfs 2>/dev/null
801 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
802 chmod +w ${LIB}/$file 2>/dev/null
803 chmod a+r ${LIB}/$file 2>/dev/null
806 if [ -r ${LIB}/$file ]; then
808 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
809 ${LIB}/$file > ${LIB}/${file}.sed
810 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
811 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
816 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
818 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
819 mkdir ${LIB}/hsfs 2>/dev/null
820 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
821 chmod +w ${LIB}/$file 2>/dev/null
822 chmod a+r ${LIB}/$file 2>/dev/null
825 if [ -r ${LIB}/$file ]; then
827 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
828 ${LIB}/$file > ${LIB}/${file}.sed
829 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
830 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
835 # Incorrect #include in Sony News-OS 3.2.
836 file=machine/machparam.h
837 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
838 mkdir ${LIB}/machine 2>/dev/null
839 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
840 chmod +w ${LIB}/$file 2>/dev/null
841 chmod a+r ${LIB}/$file 2>/dev/null
844 if [ -r ${LIB}/$file ]; then
845 echo Fixing $file, incorrect \#include
846 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
847 ${LIB}/$file > ${LIB}/${file}.
848 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
849 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
854 # Multiline comment after typedef on IRIX 4.0.1.
856 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
857 mkdir ${LIB}/sys 2>/dev/null
858 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
859 chmod +w ${LIB}/$file 2>/dev/null
860 chmod a+r ${LIB}/$file 2>/dev/null
863 if [ -r ${LIB}/$file ]; then
864 echo Fixing $file, comment in the middle of \#ifdef
865 sed -e 's@type of the result@type of the result */@' \
866 -e 's@of the sizeof@/* of the sizeof@' \
867 ${LIB}/$file > ${LIB}/${file}.sed
868 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
869 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
874 # Turning // comments into /* */ comments trashes this IRIX 4.0.1
875 # header file, which embeds // comments inside multi-line /* */
876 # comments. If this looks like the IRIX header file, we refix it by
877 # just throwing away the // comments.
879 if [ -r ${LIB}/$file ]; then
880 if egrep indigo.esd ${LIB}/$file > /dev/null; then
881 echo Fixing $file, overeager sed script
883 sed -e 's|//.*$||g' $file > ${LIB}/$file
884 chmod +w ${LIB}/$file 2>/dev/null
885 chmod a+r ${LIB}/$file 2>/dev/null
889 # Some IRIX header files contains the string "//"
890 for file in elf_abi.h elf.h; do
891 if [ -r ${LIB}/$file ]; then
892 echo Fixing $file, overeager sed script
893 sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
894 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
895 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
901 # IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr in prototype without
902 # previous definition.
904 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
905 mkdir ${LIB}/rpc 2>/dev/null
906 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
907 chmod +w ${LIB}/$file 2>/dev/null
908 chmod a+r ${LIB}/$file 2>/dev/null
911 if [ -r ${LIB}/$file ]; then
912 echo Fixing $file, undefined type
913 sed -e '/authdes_create.*struct sockaddr/i\
916 ${LIB}/$file > ${LIB}/$file.sed
917 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
918 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
923 # IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s in prototype without previous
926 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
927 mkdir ${LIB}/rpc 2>/dev/null
928 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
929 chmod +w ${LIB}/$file 2>/dev/null
930 chmod a+r ${LIB}/$file 2>/dev/null
933 if [ -r ${LIB}/$file ]; then
934 echo Fixing $file, undefined type
935 sed -e '/xdrstdio_create.*struct __file_s/i\
938 ${LIB}/$file > ${LIB}/$file.sed
939 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
940 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
945 # Same problem with a file from SunOS 4.1.3 : a header file containing
946 # the string "//" embedded in "/**/"
947 file=sbusdev/audiovar.h
948 if [ -r ${LIB}/$file ]; then
949 echo Fixing $file, overeager sed script
951 sed -e 's|//.*$||g' $file > ${LIB}/$file
952 chmod +w ${LIB}/$file 2>/dev/null
953 chmod a+r ${LIB}/$file 2>/dev/null
956 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
957 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
958 # many other systems have similar text but correct versions of the file.
959 # To ensure only Sun's is fixed, we grep for a likely unique string.
961 if [ -r $file ] && egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
962 if [ ! -r ${LIB}/$file ]; then
963 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
964 chmod +w ${LIB}/$file 2>/dev/null
965 chmod a+r ${LIB}/$file 2>/dev/null
967 if [ -r ${LIB}/$file ]; then
969 cat > ${LIB}/$file << EOF
970 /* This file was generated by fixincludes */
975 extern void *memccpy();
976 extern void *memchr();
977 extern void *memcpy();
978 extern void *memset();
980 extern char *memccpy();
981 extern char *memchr();
982 extern char *memcpy();
983 extern char *memset();
984 #endif /* __STDC__ */
988 #endif /* __memory_h__ */
993 # parameters not const on DECstation Ultrix V4.0.
995 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
996 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
997 chmod +w ${LIB}/$file 2>/dev/null
998 chmod a+r ${LIB}/$file 2>/dev/null
1001 if [ -r ${LIB}/$file ]; then
1002 echo Fixing $file, non-const arg
1003 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
1004 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
1005 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
1006 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
1007 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
1008 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
1009 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
1010 ${LIB}/$file > ${LIB}/${file}.sed
1011 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1012 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1017 # parameters conflict with C++ new on rs/6000
1018 for file in stdio.h unistd.h ; do
1019 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1020 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1021 chmod +w ${LIB}/$file 2>/dev/null
1024 if [ -r ${LIB}/$file ]; then
1025 echo Fixing $file, parameter name conflicts
1026 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
1027 ${LIB}/$file > ${LIB}/${file}.sed
1028 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1029 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1035 # function class(double x) conflicts with C++ keyword on rs/6000
1037 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1038 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1039 chmod +w ${LIB}/$file 2>/dev/null
1040 chmod a+r ${LIB}/$file 2>/dev/null
1043 if [ -r ${LIB}/$file ]; then
1044 if grep 'class[(]' ${LIB}/$file >/dev/null; then
1046 sed -e '/class[(]/i\
1051 ' ${LIB}/$file > ${LIB}/${file}.sed
1052 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1053 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1059 # Wrong fchmod prototype on RS/6000.
1061 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1062 mkdir ${LIB}/sys 2>/dev/null
1063 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1064 chmod +w ${LIB}/$file 2>/dev/null
1065 chmod a+r ${LIB}/$file 2>/dev/null
1068 if [ -r ${LIB}/$file ]; then
1069 echo Fixing $file, fchmod prototype
1070 sed -e 's/fchmod(char \*/fchmod(int/' \
1071 ${LIB}/$file > ${LIB}/$file.sed
1072 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1073 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1078 # There are several name conflicts with C++ reserved words in X11
1079 # header files. These are fixed in some versions, so don't do the
1080 # fixes if we find __cplusplus in the file. These were found on the
1083 # class in X11/ShellP.h
1085 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1086 mkdir ${LIB}/sys 2>/dev/null
1087 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1088 chmod +w ${LIB}/$file 2>/dev/null
1089 chmod a+r ${LIB}/$file 2>/dev/null
1092 if [ -r ${LIB}/$file ]; then
1093 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1096 echo Fixing $file, field class
1097 sed -e '/char [*]class;/i\
1102 -e '/char [*]class;/a\
1104 ' ${LIB}/$file > ${LIB}/${file}.sed
1105 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1107 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1111 # new in Xm/Traversal.h
1113 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1114 mkdir ${LIB}/sys 2>/dev/null
1115 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1116 chmod +w ${LIB}/$file 2>/dev/null
1117 chmod a+r ${LIB}/$file 2>/dev/null
1120 if [ -r ${LIB}/$file ]; then
1121 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1124 echo Fixing $file, uses of new
1125 sed -e '/Widget old, new;/i\
1130 -e '/Widget old, new;/a\
1133 -e 's/Widget new,/Widget c_new,/g' ${LIB}/$file > ${LIB}/${file}.sed
1134 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1136 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1140 # class in Xm/BaseClassI.h
1141 file=Xm/BaseClassI.h
1142 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1143 mkdir ${LIB}/sys 2>/dev/null
1144 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1145 chmod +w ${LIB}/$file 2>/dev/null
1146 chmod a+r ${LIB}/$file 2>/dev/null
1149 if [ -r ${LIB}/$file ]; then
1150 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1153 echo Fixing $file, prototype parameter name
1154 sed -e 's/ class[)]/ c_class)/g' ${LIB}/$file > ${LIB}/${file}.sed
1155 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1157 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1163 # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1164 # Note that version 3 of the NeXT system has wait.h in a different directory,
1165 # so that this code won't do anything. But wait.h in version 3 has a
1166 # conditional, so it doesn't need this fix. So everything is okay.
1168 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1169 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1170 chmod +w ${LIB}/$file 2>/dev/null
1173 if [ -r ${LIB}/$file ] \
1174 && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
1175 echo Fixing $file, bad wait formal
1176 sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed
1177 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1178 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1183 # Don't use or define the name va_list in stdio.h.
1184 # This is for ANSI and also to interoperate properly with gcc's varargs.h.
1186 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1187 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1188 chmod +w ${LIB}/$file 2>/dev/null
1189 chmod a+r ${LIB}/$file 2>/dev/null
1192 if [ -r ${LIB}/$file ]; then
1193 echo Fixing $file, use of va_list
1194 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
1195 if egrep "__need___va_list" ${LIB}/$file >/dev/null 2>&1; then
1196 touch ${LIB}/${file}.sed
1198 (echo "#define __need___va_list"
1199 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
1201 # Use __gnuc_va_list in arg types in place of va_list.
1202 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
1203 # trailing parentheses and semicolon save all other systems from this.
1204 # Define __va_list__ (something harmless and unused) instead of va_list.
1205 # Don't claim to have defined va_list.
1206 sed -e 's@ va_list @ __gnuc_va_list @' \
1207 -e 's@ va_list)@ __gnuc_va_list)@' \
1208 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1209 -e 's@ va_list@ __va_list__@' \
1210 -e 's@\*va_list@*__va_list__@' \
1211 -e 's@ __va_list)@ __gnuc_va_list)@' \
1212 -e 's@GNUC_VA_LIST@GNUC_Va_LIST@' \
1213 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
1214 -e 's@VA_LIST@DUMMY_VA_LIST@' \
1215 -e 's@_Va_LIST@_VA_LIST@' \
1216 ${LIB}/$file >> ${LIB}/${file}.sed
1218 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1219 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1224 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
1226 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1227 if grep -s ULTRIX $file; then
1228 echo "/* This file intentionally left blank. */" > $LIB/$file
1232 # parameter to atof not const on DECstation Ultrix V4.0.
1233 # also get rid of bogus inline definitions in HP-UX 8.0
1235 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1236 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1237 chmod +w ${LIB}/$file 2>/dev/null
1238 chmod a+r ${LIB}/$file 2>/dev/null
1241 if [ -r ${LIB}/$file ]; then
1242 echo Fixing $file, non-const arg
1243 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
1244 -e 's@inline int abs(int [a-z][a-z]*) {.*}@@' \
1245 -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
1246 -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
1247 -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
1248 ${LIB}/$file > ${LIB}/${file}.sed
1249 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1250 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1255 # Avoid nested comments on Ultrix 4.3.
1257 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1258 mkdir ${LIB}/rpc 2>/dev/null
1259 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1260 chmod +w ${LIB}/$file 2>/dev/null
1261 chmod a+r ${LIB}/$file 2>/dev/null
1264 if [ -r ${LIB}/$file ]; then
1265 echo Fixing $file, nested comment
1266 sed -e 's@^\( \* int protocol; \)/\*@\1*/ /*@' \
1267 ${LIB}/$file > ${LIB}/$file.sed
1268 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1269 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1274 # This file in RISC/os uses /**/ to concatenate two tokens.
1276 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1277 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1278 chmod +w ${LIB}/$file 2>/dev/null
1279 chmod a+r ${LIB}/$file 2>/dev/null
1281 if [ -r ${LIB}/$file ]; then
1282 sed -e 's|/\*\*/|##|' ${LIB}/$file > ${LIB}/${file}.sed
1283 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1284 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1290 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1291 mkdir ${LIB}/rpc 2>/dev/null
1292 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1293 chmod +w ${LIB}/$file 2>/dev/null
1294 chmod a+r ${LIB}/$file 2>/dev/null
1297 if [ -r ${LIB}/$file ]; then
1298 echo Fixing $file, nested comment
1299 sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \
1300 ${LIB}/$file > ${LIB}/$file.sed
1301 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1302 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1307 # In limits.h, put #ifndefs around things that are supposed to be defined
1308 # in float.h to avoid redefinition errors if float.h is included first.
1309 # On HP/UX this patch does not work, because on HP/UX limits.h uses
1310 # multi line comments and the inserted #endif winds up inside the
1311 # comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1312 # we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1313 # are there, and we do not add them ourselves.
1314 for file in limits.h sys/limits.h; do
1315 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1316 mkdir ${LIB}/sys 2>/dev/null
1317 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1318 chmod +w ${LIB}/$file 2>/dev/null
1319 chmod a+r ${LIB}/$file 2>/dev/null
1322 if [ -r ${LIB}/$file ]; then
1323 if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then
1327 sed -e '/[ ]FLT_MIN[ ]/i\
1330 -e '/[ ]FLT_MIN[ ]/a\
1333 -e '/[ ]FLT_MAX[ ]/i\
1336 -e '/[ ]FLT_MAX[ ]/a\
1339 -e '/[ ]FLT_DIG[ ]/i\
1342 -e '/[ ]FLT_DIG[ ]/a\
1345 -e '/[ ]DBL_MIN[ ]/i\
1348 -e '/[ ]DBL_MIN[ ]/a\
1351 -e '/[ ]DBL_MAX[ ]/i\
1354 -e '/[ ]DBL_MAX[ ]/a\
1357 -e '/[ ]DBL_DIG[ ]/i\
1360 -e '/[ ]DBL_DIG[ ]/a\
1363 ${LIB}/$file > ${LIB}/${file}.sed
1364 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1366 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1367 echo Deleting ${LIB}/$file\; no fixes were needed.
1373 # In math.h, put #ifndefs around things that might be defined in a gcc
1374 # specific math-*.h file.
1376 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1377 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1378 chmod +w ${LIB}/$file 2>/dev/null
1379 chmod a+r ${LIB}/$file 2>/dev/null
1382 if [ -r ${LIB}/$file ]; then
1384 sed -e '/define[ ]HUGE_VAL[ ]/i\
1387 -e '/define[ ]HUGE_VAL[ ]/a\
1390 ${LIB}/$file > ${LIB}/${file}.sed
1391 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1393 # In addition, copy the definition of DBL_MAX from float.h
1394 # if math.h requires one. The Lynx math.h requires it.
1395 if egrep '#define[ ]*HUGE_VAL[ ]+DBL_MAX' $file >/dev/null 2>&1; then
1396 if egrep '#define[ ]+DBL_MAX[ ]+' $file >/dev/null 2>&1; then
1399 dbl_max_def=`egrep 'define[ ]+DBL_MAX[ ]+.*' float.h 2>/dev/null`
1400 if [ "$dbl_max_def" != "" ]; then
1401 dbl_max_def=`echo $dbl_max_def | sed 's/.*define[ ]*DBL_MAX[ ]*//'`
1402 sed -e "/define[ ]HUGE_VAL[ ]DBL_MAX/s/DBL_MAX/$dbl_max_def/" \
1403 ${LIB}/$file > ${LIB}/${file}.sed
1404 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1409 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1410 echo Deleting ${LIB}/$file\; no fixes were needed.
1415 # Remove erroneous parentheses in sym.h on Alpha OSF/1.
1417 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1418 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1419 chmod +w ${LIB}/$file 2>/dev/null
1420 chmod a+r ${LIB}/$file 2>/dev/null
1423 if [ -r ${LIB}/$file ]; then
1425 sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
1426 ${LIB}/$file > ${LIB}/${file}.sed
1427 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1428 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1433 # Correct the return type for strlen in string.h on Lynx.
1434 # Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
1436 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1437 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1438 chmod +w ${LIB}/$file 2>/dev/null
1439 chmod a+r ${LIB}/$file 2>/dev/null
1442 if [ -r ${LIB}/$file ]; then
1444 sed -e 's/extern[ ]*int[ ]*strlen();/extern unsigned int strlen();/' \
1445 -e 's/extern[ ]*int[ ]*ffs[ ]*(long);/extern int ffs(int);/' \
1446 ${LIB}/$file > ${LIB}/${file}.sed
1447 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1448 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1453 # Delete the '#define void int' line from curses.h on Lynx
1455 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1456 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1457 chmod +w ${LIB}/$file 2>/dev/null
1458 chmod a+r ${LIB}/$file 2>/dev/null
1461 if [ -r ${LIB}/$file ]; then
1463 sed -e '/#define[ ][ ]*void[ ]int/d' \
1464 ${LIB}/$file > ${LIB}/${file}.sed
1465 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1466 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1471 # For C++, avoid any typedef or macro definition of bool, and use the
1472 # built in type instead.
1473 for files in curses.h; do
1474 if [ -r $file ] && egrep bool $file >/dev/null 2>&1; then
1475 if [ ! -r ${LIB}/$file ]; then
1476 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1477 chmod +w ${LIB}/$file 2>/dev/null
1478 chmod a+r ${LIB}/$file 2>/dev/null
1482 sed -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/i\
1483 #ifndef __cplusplus'\
1484 -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/a\
1486 -e '/^typedef[ ][ ]*char[ ][ ]*bool;[ ]*$/i\
1487 #ifndef __cplusplus'\
1488 -e '/^typedef[ ][ ]*char[ ][ ]*bool;[ ]*$/a\
1490 ${LIB}/$file > ${LIB}/${file}.sed
1491 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1492 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1498 # Fix incorrect S_IF* definitions on m88k-sysv3.
1500 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1501 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1502 chmod +w ${LIB}/$file 2>/dev/null
1503 chmod a+r ${LIB}/$file 2>/dev/null
1506 if [ -r ${LIB}/$file ]; then
1508 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)/' \
1509 -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
1510 ${LIB}/$file > ${LIB}/${file}.sed
1511 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1512 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1517 # Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
1518 for file in stdio.h stdlib.h; do
1519 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1520 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1521 chmod +w ${LIB}/$file 2>/dev/null
1522 chmod a+r ${LIB}/$file 2>/dev/null
1525 if [ -r ${LIB}/$file ]; then
1526 echo Fixing $file, getopt declaration
1527 sed -e 's/getopt(int, char \*\[\],[ ]*char \*)/getopt(int, char *const[], const char *)/' \
1528 ${LIB}/$file > ${LIB}/${file}.sed
1529 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1530 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1536 # Determine if we're on Interactive Unix 2.2 or later, in which case we
1537 # need to fix some additional files. This is the same test for ISC that
1539 if test -d /etc/conf/kconfig.d \
1540 && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
1541 echo "Fixing ISC __STDC__ goof in several files..."
1542 for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
1544 if test -r ${LIB}/$name; then
1549 # On Interactive 2.2, certain traditional Unix definitions
1550 # (notably getc and putc in stdio.h) are omitted if __STDC__ is
1551 # defined, not just if _POSIX_SOURCE is defined. This makes it
1552 # impossible to compile any nontrivial program except with -posix.
1554 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
1555 < $file > ${LIB}/$name.
1556 mv ${LIB}/$name. ${LIB}/$name
1559 echo "Fixing ISC fmod declaration"
1560 # This one's already been fixed for other things.
1562 sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
1565 echo "Fixing nested comments in ISC <sys/limits.h>"
1567 sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
1568 sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
1571 # These files in Sun OS 4.x use /**/ to concatenate tokens.
1572 for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \
1573 sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h \
1574 sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h;
1576 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1577 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1578 chmod +w ${LIB}/$file 2>/dev/null
1579 chmod a+r ${LIB}/$file 2>/dev/null
1582 if [ -r ${LIB}/$file ]; then
1583 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
1584 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1585 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1591 # These files in ARM/RISCiX use /**/ to concatenate tokens.
1592 for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \
1593 dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.h
1595 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1596 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1597 chmod +w ${LIB}/$file 2>/dev/null
1598 chmod a+r ${LIB}/$file 2>/dev/null
1601 if [ -r ${LIB}/$file ]; then
1602 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
1603 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1604 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1610 # math.h on SunOS 4 puts the declaration of matherr before the definition
1611 # of struct exception, so the prototype (added by fixproto) causes havoc.
1613 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1614 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1615 chmod +w ${LIB}/$file 2>/dev/null
1616 chmod a+r ${LIB}/$file 2>/dev/null
1619 if [ -r ${LIB}/$file ]; then
1620 echo Fixing $file, matherr declaration
1621 sed -e '/^struct exception/,$b' \
1625 ${LIB}/$file > ${LIB}/${file}.sed
1626 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1627 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1632 # assert.h on HP/UX is not C++ ready, even though NO_IMPLICIT_EXTERN_C
1633 # is defined on HP/UX.
1635 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1636 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1637 chmod +w ${LIB}/$file 2>/dev/null
1638 chmod a+r ${LIB}/$file 2>/dev/null
1641 if [ -r ${LIB}/$file ]; then
1642 if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \
1643 || egrep '__BEGIN_DECLS' ${LIB}/$file >/dev/null 2>&1; then
1647 echo '#ifdef __cplusplus
1649 #endif' > ${LIB}/${file}.sed
1650 cat ${LIB}/${file} >> ${LIB}/${file}.sed
1651 echo '#ifdef __cplusplus
1653 #endif' >> ${LIB}/${file}.sed
1654 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1655 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1661 # check for broken assert.h that needs stdio.h or stdlib.h
1663 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1664 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1665 chmod +w ${LIB}/$file 2>/dev/null
1666 chmod a+r ${LIB}/$file 2>/dev/null
1669 if [ -r ${LIB}/$file ]; then
1670 if grep 'stderr' ${LIB}/$file >/dev/null 2>/dev/null; then
1671 if grep 'include.*stdio.h' ${LIB}/$file >/dev/null 2>/dev/null; then
1674 echo "Fixing $file (needs stdio.h)"
1675 echo '#include <stdio.h>' >>${LIB}/$file
1678 if grep 'exit *(' ${LIB}/$file >/dev/null 2>/dev/null ||
1679 grep 'abort *(' ${LIB}/$file >/dev/null 2>/dev/null; then
1680 if grep 'include.*stdlib.h' ${LIB}/$file >/dev/null 2>/dev/null; then
1683 echo "Fixing $file (needs stdlib.h)"
1684 echo '#include <stdlib.h>' >>${LIB}/$file
1687 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1692 # Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
1694 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1695 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1696 chmod +w ${LIB}/$file 2>/dev/null
1697 chmod a+r ${LIB}/$file 2>/dev/null
1700 if [ -r ${LIB}/$file ]; then
1701 echo Fixing $file, sbrk declaration
1702 sed -e 's/char\([ ]*\*[ ]*sbrk[ ]*(\)/void\1/' \
1703 ${LIB}/$file > ${LIB}/${file}.sed
1704 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1705 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1710 # This file on SunOS 4 has a very large macro. When the sed loop
1711 # tries pull it in, it overflows the pattern space size of the SunOS
1712 # sed (GNU sed does not have this problem). Since the file does not
1713 # require fixing, we remove it from the fixed directory.
1714 file=sundev/ipi_error.h
1715 if [ -r ${LIB}/$file ]; then
1716 echo "Removing incorrect fix to SunOS <sundev/ipi_error.h>"
1720 # Put cpp wrappers around these include files to avoid redeclaration
1721 # errors during multiple inclusion on m88k-tektronix-sysv3.
1722 for file in time.h sys/time.h ; do
1723 if egrep '#ifndef' $file >/dev/null 2>&1; then
1726 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1727 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1728 chmod +w ${LIB}/$file 2>/dev/null
1730 if [ -r ${LIB}/$file ]; then
1731 echo Fixing $file, to protect against multiple inclusion.
1732 cpp_wrapper=`echo $file | sed -e 's,\.,_,g' -e 's,/,_,g'`
1733 (echo "#ifndef __GCC_GOT_${cpp_wrapper}_"
1734 echo "#define __GCC_GOT_${cpp_wrapper}_"
1736 echo '#endif /* !_GCC_GOT_'${cpp_wrapper}_' */') > ${LIB}/${file}.new
1737 rm -f ${LIB}/$file; mv ${LIB}/${file}.new ${LIB}/$file
1742 echo 'Removing unneeded directories:'
1744 files=`find . -type d -print | sort -r`
1745 for file in $files; do
1746 rmdir $LIB/$file > /dev/null 2>&1
1750 echo 'Making internal symbolic non-directory links'
1752 files=`find . -type l -print`
1753 for file in $files; do
1754 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1755 if expr "$dest" : '[^/].*' > /dev/null; then
1756 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1757 if [ -f $target ]; then
1758 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1764 # Make sure that any include files referenced using double quotes
1765 # exist in the fixed directory. This comes last since otherwise
1766 # we might end up deleting some of these files "because they don't
1770 while [ $# != 0 ]; do
1772 while [ $# != 0 ]; do
1773 # $1 is the directory to copy from, $2 is the unfixed file,
1774 # $3 is the fixed file name.
1777 if [ -r $2 ] && [ ! -r $3 ]; then
1778 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
1779 chmod +w $3 2>/dev/null
1780 chmod a+r $3 2>/dev/null
1782 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1783 dir=`echo $2 | sed -e s'|/[^/]*$||'`
1784 dir2=`echo $3 | sed -e s'|/[^/]*$||'`
1785 newreq="$newreq $1 $dir/$include $dir2/$include"
1794 echo 'Cleaning up DONE files.'
1796 find . -name DONE -exec rm -f '{}' ';'