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 where gcc sources (and sometimes special include files) live.
9 # fixincludes doesn't use this, but fixinc.svr4 does, and I want to make
10 # sure somebody doesn't try to use arg3 for something incompatible. -- gumby
11 SRCDIR
=${3-${SRCDIR-.}}
13 # Directory containing the original header files.
14 # (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
15 INPUT
=${2-${INPUT-/usr/include}}
17 # Directory in which to store the results.
18 LIB
=${1?"fixincludes: output directory not specified"}
20 # Define PWDCMD as a command to use to get the working dir
21 # in the form that we want.
25 # On an Apollo, discard everything before `/usr'.
26 PWDCMD
="eval pwd | sed -e 's,.*/usr/,/usr/,'"
33 # Make sure it exists.
34 if [ ! -d $LIB ]; then
38 # Make LIB absolute only if needed to avoid problems with the amd.
43 cd $LIB; LIB
=`${PWDCMD}`
47 # Make SRCDIR absolute only if needed to avoid problems with the amd.
53 cd $SRCDIR; SRCDIR
=`${PWDCMD}`
57 # Fail if no arg to specify a directory for the output.
59 then echo fixincludes
: no output directory specified
63 echo Building fixed headers
in ${LIB}
65 # Determine whether this system has symbolic links.
66 if ln -s X
$LIB/ShouldNotExist
2>/dev
/null
; then
67 rm -f $LIB/ShouldNotExist
69 elif ln -s X
/tmp
/ShouldNotExist
2>/dev
/null
; then
70 rm -f /tmp
/ShouldNotExist
76 echo Finding directories and links to directories
78 # Find all directories and all symlinks that point to directories.
79 # Put the list in $files.
80 # Each time we find a symlink, add it to newdirs
81 # so that we do another find within the dir the link points to.
82 # Note that $files may have duplicates in it;
83 # later parts of this file are supposed to ignore them.
86 while [ -n "$dirs" ] && [ $levels -gt 0 ]
88 levels
=`expr $levels - 1`
92 echo " Searching $INPUT/$d"
98 # Find all directories under $d, relative to $d, excluding $d itself.
99 files
="$files `find $d -type d -print | \
100 sed -e '/\/\.$/d' -e '/^\.$/d'`"
101 # Find all links to directories.
102 # Using `-exec test -d' in find fails on some systems,
103 # and trying to run test via sh fails on others,
104 # so this is the simplest alternative left.
105 # First find all the links, then test each one.
108 theselinks
=`find $d -type l -print`
109 for d1
in $theselinks --dummy--
111 # If the link points to a directory,
112 # add that dir to $newdirs
115 newdirs
="$newdirs $d1"
120 files
="$files $newdirs"
125 echo "All directories (including links to directories):"
128 for file in $files; do
130 if [ ! -d $LIB/$file ]
131 then mkdir
$LIB/$file
136 # treetops gets an alternating list
137 # of old directories to copy
138 # and the new directories to copy to.
139 treetops
="${INPUT} ${LIB}"
142 echo 'Making symbolic directory links'
143 for file in $files; do
144 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
147 # In case $dest is relative, get to $file's dir first.
149 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
150 # Check that the target directory exists.
151 # Redirections changed to avoid bug in sh on Ultrix.
152 (cd $dest) > /dev
/null
2>&1
155 # X gets the dir that the link actually leads to.
157 # If a link points to ., make a similar link to .
158 if [ $x = $INPUT ]; then
159 echo $file '->' .
': Making link'
160 rm -fr ${LIB}/$file > /dev
/null
2>&1
161 ln -s .
${LIB}/$file > /dev
/null
2>&1
162 # If link leads back into ${INPUT},
163 # make a similar link here.
164 elif expr $x : "${INPUT}/.*" > /dev
/null
; then
165 # Y gets the actual target dir name, relative to ${INPUT}.
166 y
=`echo $x | sed -n "s&${INPUT}/&&p"`
167 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
169 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
170 echo $file '->' $dots$y ': Making link'
171 rm -fr ${LIB}/$file > /dev
/null
2>&1
172 ln -s $dots$y ${LIB}/$file > /dev
/null
2>&1
174 # If the link is to a dir $target outside ${INPUT},
175 # repoint the link at ${INPUT}/root$target
176 # and process $target into ${INPUT}/root$target
177 # treat this directory as if it actually contained the files.
178 echo $file '->' root
$x ': Making link'
179 if [ -d $LIB/root
$x ]
185 while [ x
$dirname != x
]; do
186 component
=`echo $dirname | sed -e 's|/.*$||'`
187 mkdir
$component >/dev
/null
2>&1
189 dirmade
=$dirmade/$component
190 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
193 # Duplicate directory structure created in ${LIB}/$file in new
195 for file2
in $files; do
198 dupdir
=${LIB}/root
$x/`echo $file2 | sed -n "s|^${file}/||p"`
199 echo "Duplicating ${file}'s ${dupdir}"
210 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
212 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
213 rm -fr ${LIB}/$file > /dev
/null
2>&1
214 ln -s ${dots}root
$x ${LIB}/$file > /dev
/null
2>&1
215 treetops
="$treetops $x ${LIB}/root$x"
226 while [ $# != 0 ]; do
227 # $1 is an old directory to copy, and $2 is the new directory to copy to.
230 # The same dir can appear more than once in treetops.
231 # There's no need to scan it more than once.
237 echo Fixing directory
$1 into
$2
238 # Check .h files which are symlinks as well as those which are files.
239 # A link to a header file will not be processed by anything but this.
241 files
=`find . -name '*.h' \( -type f -o -type l \) -print`
243 files
=`find . -name '*.h' -type f -print`
245 echo Checking header files
247 # Note that BSD43_* are used on recent MIPS systems.
248 for file in $files; do
249 # This call to egrep is essential, since checking a file with egrep
250 # is much faster than actually trying to fix it.
251 # It is also essential that most files *not* match!
252 # Thus, matching every #endif is unacceptable.
253 # But the argument to egrep must be kept small, or many versions of egrep
254 # won't be able to handle it.
256 # We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment
257 # following #else or #endif because some buggy egreps think [^/] matches
258 # newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'.
260 # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
261 # following #if or #elif that is not surrounded by __. The `a-ce-km-z'
262 # in this pattern lacks `d' and `l'; this means we don't worry about
263 # identifiers starting with `d' or `l'. This is OK, since none of the
264 # identifiers below start with `d' or `l'. It also greatly improves
265 # performance, since many files contain lines of the form `#if ... defined ...'
267 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
268 if [ -r $file ]; then
269 cp $file $2/$file >/dev
/null
2>&1 \
270 ||
echo "Can't copy $file"
273 # Here is how the sed commands in braces work.
274 # (It doesn't work to put the comments inside the sed commands.)
275 # Surround each word with spaces, to simplify matching below.
276 # ANSIfy each pre-ANSI machine-dependent symbol
277 # by surrounding it with __ __.
278 # Remove the spaces that we inserted around each word.
283 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
284 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
285 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
286 s%^\([ ]*#[ ]*endif\)[ ]*\*[^/].*%\1%
287 s%^\([ ]*#[ ]*endif\)[ ]*[^/* ].*%\1%
288 /\/\/[^*]/ s|//\(.*\)$|/*\1*/|
289 /[ ]_IO[A-Z]*[ ]*(/ s/\(_IO[A-Z]*[ ]*(\)\(.\),/\1'\''\2'\'',/
290 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
291 /#define._IO/ s/'\''\([cgxtf]\)'\''/\1/g
292 /#define.BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g
293 /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
294 /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
295 /#define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g
296 /#define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g
297 /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g
299 s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
301 s/ bsd4\([0-9]\) / __bsd4\1__ /g
302 s/ _*host_mips / __host_mips__ /g
303 s/ _*i386 / __i386__ /g
304 s/ is68k / __is68k__ /g
305 s/ m68k / __m68k__ /g
306 s/ mc680\([0-9]\)0 / __mc680\10__ /g
307 s/ _*mips / __mips__ /g
308 s/ news\([0-9]*\) / __news\1__ /g
309 s/ ns32000 / __ns32000__ /g
311 s/ sony_news / __sony_news__ /g
312 s/ sparc / __sparc__ /g
313 s/ sun\([a-z0-9]*\) / __sun\1__ /g
314 s/ unix / __unix__ /g
316 s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g
317 s/ _*R\([34]\)000 / __R\1000__ /g
318 s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g
320 s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
322 /^#define.NULL[ ]/ i\
324 ' $2/$file > $2/$file.
325 mv $2/$file.
$2/$file
326 if cmp $file $2/$file >/dev
/null
2>&1; then
330 # Find any include directives that use "file".
331 for include
in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $2/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
332 dir
=`echo $file | sed -e s'|/[^/]*$||'`
333 required
="$required $1 $dir/$include $2/$dir/$include"
344 # Install the proper definition of size_t in header files that it comes from.
345 for file in sys
/types.h stdlib.h sys
/stdtypes.h stddef.h memory.h unistd.h
; do
346 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
347 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
348 chmod +w
${LIB}/$file 2>/dev
/null
349 chmod a
+r
${LIB}/$file 2>/dev
/null
352 if [ -r ${LIB}/$file ]; then
353 echo Fixing size_t
in $file
354 sed -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
355 #ifndef __SIZE_TYPE__\
356 #define __SIZE_TYPE__ long unsigned int\
358 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' ${LIB}/$file > ${LIB}/${file}.
sed
359 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
360 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
366 # Fix one other error in this file: a mismatched quote not inside a C comment.
367 file=sundev
/vuid_event.h
368 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
369 mkdir
${LIB}/sundev
2>/dev
/null
370 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
371 chmod +w
${LIB}/$file 2>/dev
/null
372 chmod a
+r
${LIB}/$file 2>/dev
/null
375 if [ -r ${LIB}/$file ]; then
376 echo Fixing
$file comment
377 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.
sed
378 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
379 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
384 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
385 file=sunwindow
/win_cursor.h
386 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
387 # mkdir ${LIB}/sunwindow 2>/dev/null
388 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
389 chmod +w
${LIB}/$file 2>/dev
/null
391 if [ -r ${LIB}/$file ]; then
393 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.
sed
394 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
395 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
399 file=sunwindow
/win_lock.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
414 # Fix this Sun file to avoid interfering with stddef.h.
416 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
417 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
418 chmod +w
${LIB}/$file 2>/dev
/null
419 chmod a
+r
${LIB}/$file 2>/dev
/null
422 if [ -r ${LIB}/$file ]; then
424 sed -e '/[ ]size_t.*;/i\
426 #define _GCC_SIZE_T' \
429 -e '/[ ]ptrdiff_t.*;/i\
430 #ifndef _GCC_PTRDIFF_T\
431 #define _GCC_PTRDIFF_T' \
432 -e '/[ ]ptrdiff_t.*;/a\
434 -e '/[ ]wchar_t.*;/i\
435 #ifndef _GCC_WCHAR_T\
436 #define _GCC_WCHAR_T' \
437 -e '/[ ]wchar_t.*;/a\
438 #endif' ${LIB}/$file > ${LIB}/${file}.
sed
439 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
440 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
445 # Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
448 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
449 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
450 chmod +w
${LIB}/$file 2>/dev
/null
451 chmod a
+r
${LIB}/$file 2>/dev
/null
454 if [ -r ${LIB}/$file ]; then
456 sed -e "s/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
457 -e "s/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
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 file to avoid interfering with stddef.h, but don't mistakenly
466 # match ssize_t present in AIX for the ps/2, or typedefs which use (but do not
469 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
470 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
471 chmod +w
${LIB}/$file 2>/dev
/null
472 chmod a
+r
${LIB}/$file 2>/dev
/null
475 if [ -r ${LIB}/$file ]; then
477 sed -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
479 #define _GCC_SIZE_T' \
480 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/a\
481 #endif' ${LIB}/$file > ${LIB}/${file}.
sed
482 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
483 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
488 # Fix HP's use of ../machine/inline.h to refer to
489 # /usr/include/machine/inline.h
491 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
492 cp $file ${LIB}/$file
494 if [ -r ${LIB}/$file ] ; then
496 sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
497 -e 's,"../machine/psl.h",<machine/psl.h>,' \
498 ${LIB}/$file > ${LIB}/${file}.
sed
499 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
500 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
505 # Fix an error in this file: the #if says _cplusplus, not the double
506 # underscore __cplusplus that it should be
508 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
509 mkdir
${LIB}/rpcsvc
2>/dev
/null
510 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
511 chmod +w
${LIB}/$file 2>/dev
/null
512 chmod a
+r
${LIB}/$file 2>/dev
/null
515 if [ -r ${LIB}/$file ]; then
516 echo Fixing
$file, __cplusplus macro
517 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${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: a missing semi-colon at the end of the statsswtch
525 # structure definition.
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, definition of statsswtch
536 sed -e 's/boottime$/boottime;/' ${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 nodeent
544 # structure definition.
545 file=netdnet
/dnetdb.h
546 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
547 mkdir
${LIB}/netdnet
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 nodeent
555 sed -e 's/char.*na_addr *$/char *na_addr;/' ${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 # Check for bad #ifdef line (in Ultrix 4.1)
564 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
565 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
566 chmod +w
${LIB}/$file 2>/dev
/null
567 chmod a
+r
${LIB}/$file 2>/dev
/null
570 if [ -r ${LIB}/$file ]; then
571 echo Fixing
$file, bad \
#ifdef line
572 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.
sed
573 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
574 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
579 # Check for superfluous `static' (in Ultrix 4.2)
581 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
582 mkdir
${LIB}/machine
2>/dev
/null
583 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
584 chmod +w
${LIB}/$file 2>/dev
/null
585 chmod a
+r
${LIB}/$file 2>/dev
/null
588 if [ -r ${LIB}/$file ]; then
589 echo Fixing
$file, superfluous static
590 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' ${LIB}/$file > ${LIB}/${file}.
sed
591 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
592 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
595 # This file has an alternative name, mips/cpu.h. Fix that name, too.
596 if cmp machine
/cpu.h mips
/cpu.h
> /dev
/null
2>&1; then
597 mkdir
${LIB}/mips
2>&-
598 ln ${LIB}/$file ${LIB}/mips
/cpu.h
603 # Incorrect sprintf declaration in X11/Xmu.h
605 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
606 mkdir
${LIB}/X11
2>/dev
/null
607 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
608 chmod +w
${LIB}/$file 2>/dev
/null
609 chmod a
+r
${LIB}/$file 2>/dev
/null
612 if [ -r ${LIB}/$file ]; then
613 echo Fixing
$file sprintf declaration
614 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
615 extern char * sprintf();\
616 #endif /* !defined __STDC__ */,' ${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
623 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
624 # (It's not clear whether the right file name is this or X11/Xmu.h.)
626 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
627 mkdir
${LIB}/X11
/Xmu
2>/dev
/null
628 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
629 chmod +w
${LIB}/$file 2>/dev
/null
630 chmod a
+r
${LIB}/$file 2>/dev
/null
633 if [ -r ${LIB}/$file ]; then
634 echo Fixing
$file sprintf declaration
635 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
636 extern char * sprintf();\
637 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.
sed
638 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
639 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
644 # Check for missing ';' in struct
646 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
647 mkdir
${LIB}/netinet
2>/dev
/null
648 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
649 chmod +w
${LIB}/$file 2>/dev
/null
650 chmod a
+r
${LIB}/$file 2>/dev
/null
653 if [ -r ${LIB}/$file ]; then
655 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.
sed
656 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
657 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
662 # Fix the CAT macro in SunOS memvar.h.
663 file=pixrect
/memvar.h
664 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
665 mkdir
${LIB}/pixrect
2>/dev
/null
666 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
667 chmod +w
${LIB}/$file 2>/dev
/null
668 chmod a
+r
${LIB}/$file 2>/dev
/null
671 if [ -r ${LIB}/$file ]; then
673 sed -e '/^#define.CAT(a,b)/ i\
675 #define CAT(a,b) a##b\
677 /^#define.CAT(a,b)/ a\
679 ' ${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 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
688 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
689 mkdir
${LIB}/rpcsvc
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 '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.
sed
698 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
699 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
704 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
705 # Also wrap protection around size_t for m88k-sysv3 systems.
707 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
708 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
709 chmod +w
${LIB}/$file 2>/dev
/null
710 chmod a
+r
${LIB}/$file 2>/dev
/null
713 if [ -r ${LIB}/$file ]; then
715 sed -e 's/int abort/void abort/g' \
716 -e 's/int free/void free/g' \
717 -e 's/char \* calloc/void \* calloc/g' \
718 -e 's/char \* malloc/void \* malloc/g' \
719 -e 's/char \* realloc/void \* realloc/g' \
720 -e 's/int exit/void exit/g' \
721 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\
723 #define _GCC_SIZE_T' \
724 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\
726 ${LIB}/$file > ${LIB}/${file}.
sed
727 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
728 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
733 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
735 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
736 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
737 chmod +w
${LIB}/$file 2>/dev
/null
738 chmod a
+r
${LIB}/$file 2>/dev
/null
741 if [ -r ${LIB}/$file ]; then
743 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
744 -e 's/int[ ][ ]*free/void free/g' \
745 ${LIB}/$file > ${LIB}/${file}.
sed
746 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
747 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
752 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
753 file=hsfs
/hsfs_spec.h
754 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
755 mkdir
${LIB}/hsfs
2>/dev
/null
756 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
757 chmod +w
${LIB}/$file 2>/dev
/null
758 chmod a
+r
${LIB}/$file 2>/dev
/null
761 if [ -r ${LIB}/$file ]; then
763 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
764 ${LIB}/$file > ${LIB}/${file}.
765 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
766 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
771 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
773 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
774 mkdir
${LIB}/hsfs
2>/dev
/null
775 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
776 chmod +w
${LIB}/$file 2>/dev
/null
777 chmod a
+r
${LIB}/$file 2>/dev
/null
780 if [ -r ${LIB}/$file ]; then
782 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
783 ${LIB}/$file > ${LIB}/${file}.
sed
784 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
785 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
790 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
792 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
793 mkdir
${LIB}/hsfs
2>/dev
/null
794 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
795 chmod +w
${LIB}/$file 2>/dev
/null
796 chmod a
+r
${LIB}/$file 2>/dev
/null
799 if [ -r ${LIB}/$file ]; then
801 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
802 ${LIB}/$file > ${LIB}/${file}.
sed
803 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
804 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
809 # Incorrect #include in Sony News-OS 3.2.
810 file=machine
/machparam.h
811 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
812 mkdir
${LIB}/machine
2>/dev
/null
813 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
814 chmod +w
${LIB}/$file 2>/dev
/null
815 chmod a
+r
${LIB}/$file 2>/dev
/null
818 if [ -r ${LIB}/$file ]; then
819 echo Fixing
$file, incorrect \
#include
820 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
821 ${LIB}/$file > ${LIB}/${file}.
822 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
823 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
828 # Multiline comment after typedef on IRIX 4.0.1.
830 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
831 mkdir
${LIB}/sys
2>/dev
/null
832 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
833 chmod +w
${LIB}/$file 2>/dev
/null
834 chmod a
+r
${LIB}/$file 2>/dev
/null
837 if [ -r ${LIB}/$file ]; then
838 echo Fixing
$file, comment
in the middle of \
#ifdef
839 sed -e 's@type of the result@type of the result */@' \
840 -e 's@of the sizeof@/* of the sizeof@' \
841 ${LIB}/$file > ${LIB}/${file}.
sed
842 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
843 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
848 # Turning // comments into /* */ comments trashes this IRIX 4.0.1
849 # header file, which embeds // comments inside multi-line /* */
850 # comments. If this looks like the IRIX header file, we refix it by
851 # just throwing away the // comments.
853 if [ -r ${LIB}/$file ]; then
854 if egrep indigo.esd
${LIB}/$file > /dev
/null
; then
855 echo Fixing
$file, overeager
sed script
857 sed -e 's|//.*$||g' $file > ${LIB}/$file
858 chmod +w
${LIB}/$file 2>/dev
/null
859 chmod a
+r
${LIB}/$file 2>/dev
/null
863 # Some IRIX header files contains the string "//"
864 for file in elf_abi.h elf.h
; do
865 if [ -r ${LIB}/$file ]; then
866 echo Fixing
$file, overeager
sed script
867 sed -e 's|"/\*"\*/|"//"|' ${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
875 # IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr in prototype without
876 # previous definition.
878 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
879 mkdir
${LIB}/rpc
2>/dev
/null
880 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
881 chmod +w
${LIB}/$file 2>/dev
/null
882 chmod a
+r
${LIB}/$file 2>/dev
/null
885 if [ -r ${LIB}/$file ]; then
886 echo Fixing
$file, undefined
type
887 sed -e '/authdes_create.*struct sockaddr/i\
889 ${LIB}/$file > ${LIB}/$file.
sed
890 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
891 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
896 # IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s in prototype without previous
899 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
900 mkdir
${LIB}/rpc
2>/dev
/null
901 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
902 chmod +w
${LIB}/$file 2>/dev
/null
903 chmod a
+r
${LIB}/$file 2>/dev
/null
906 if [ -r ${LIB}/$file ]; then
907 echo Fixing
$file, undefined
type
908 sed -e '/xdrstdio_create.*struct __file_s/i\
910 ${LIB}/$file > ${LIB}/$file.
sed
911 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
912 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
917 # Same problem with a file from SunOS 4.1.3 : a header file containing
918 # the string "//" embedded in "/**/"
919 file=sbusdev
/audiovar.h
920 if [ -r ${LIB}/$file ]; then
921 echo Fixing
$file, overeager
sed script
923 sed -e 's|//.*$||g' $file > ${LIB}/$file
924 chmod +w
${LIB}/$file 2>/dev
/null
925 chmod a
+r
${LIB}/$file 2>/dev
/null
928 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
929 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
930 # many other systems have similar text but correct versions of the file.
931 # To ensure only Sun's is fixed, we grep for a likely unique string.
933 if [ -r $file ] && egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev
/null
; then
934 if [ ! -r ${LIB}/$file ]; then
935 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
936 chmod +w
${LIB}/$file 2>/dev
/null
937 chmod a
+r
${LIB}/$file 2>/dev
/null
939 if [ -r ${LIB}/$file ]; then
941 cat > ${LIB}/$file << EOF
942 /* This file was generated by fixincludes */
947 extern void *memccpy();
948 extern void *memchr();
949 extern void *memcpy();
950 extern void *memset();
952 extern char *memccpy();
953 extern char *memchr();
954 extern char *memcpy();
955 extern char *memset();
956 #endif /* __STDC__ */
960 #endif /* __memory_h__ */
965 # parameters not const on DECstation Ultrix V4.0.
967 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
968 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
969 chmod +w
${LIB}/$file 2>/dev
/null
970 chmod a
+r
${LIB}/$file 2>/dev
/null
973 if [ -r ${LIB}/$file ]; then
974 echo Fixing
$file, non-const arg
975 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
976 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
977 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
978 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
979 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
980 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
981 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
982 ${LIB}/$file > ${LIB}/${file}.
sed
983 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
984 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
989 # parameters conflict with C++ new on rs/6000
990 for file in stdio.h unistd.h
; do
991 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
992 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
993 chmod +w
${LIB}/$file 2>/dev
/null
996 if [ -r ${LIB}/$file ]; then
997 echo Fixing
$file, parameter name conflicts
998 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
999 ${LIB}/$file > ${LIB}/${file}.
sed
1000 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1001 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1007 # function class(double x) conflicts with C++ keyword on rs/6000
1009 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1010 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1011 chmod +w
${LIB}/$file 2>/dev
/null
1012 chmod a
+r
${LIB}/$file 2>/dev
/null
1015 if [ -r ${LIB}/$file ]; then
1016 if grep 'class[(]' ${LIB}/$file >/dev
/null
; then
1018 sed -e '/class[(]/i\
1019 #ifndef __cplusplus' \
1021 #endif' ${LIB}/$file > ${LIB}/${file}.
sed
1022 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1023 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1029 # Wrong fchmod prototype on RS/6000.
1031 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1032 mkdir
${LIB}/sys
2>/dev
/null
1033 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1034 chmod +w
${LIB}/$file 2>/dev
/null
1035 chmod a
+r
${LIB}/$file 2>/dev
/null
1038 if [ -r ${LIB}/$file ]; then
1039 echo Fixing
$file, fchmod prototype
1040 sed -e 's/fchmod(char \*/fchmod(int/' \
1041 ${LIB}/$file > ${LIB}/$file.
sed
1042 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1043 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1048 # There are several name conflicts with C++ reserved words in X11
1049 # header files. These are fixed in some versions, so don't do the
1050 # fixes if we find __cplusplus in the file. These were found on the
1053 # class in X11/ShellP.h
1055 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1056 mkdir
${LIB}/sys
2>/dev
/null
1057 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1058 chmod +w
${LIB}/$file 2>/dev
/null
1059 chmod a
+r
${LIB}/$file 2>/dev
/null
1062 if [ -r ${LIB}/$file ]; then
1063 if grep __cplusplus
${LIB}/$file >/dev
/null
2>/dev
/null
; then
1066 echo Fixing
$file, field class
1067 sed -e '/char [*]class;/i\
1071 -e '/char [*]class;/a\
1072 #endif' ${LIB}/$file > ${LIB}/${file}.
sed
1073 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1075 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1079 # new in Xm/Traversal.h
1081 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1082 mkdir
${LIB}/sys
2>/dev
/null
1083 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1084 chmod +w
${LIB}/$file 2>/dev
/null
1085 chmod a
+r
${LIB}/$file 2>/dev
/null
1088 if [ -r ${LIB}/$file ]; then
1089 if grep __cplusplus
${LIB}/$file >/dev
/null
2>/dev
/null
; then
1092 echo Fixing
$file, uses of new
1093 sed -e '/Widget old, new;/i\
1097 -e '/Widget old, new;/a\
1099 -e 's/Widget new,/Widget c_new,/g' ${LIB}/$file > ${LIB}/${file}.
sed
1100 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1102 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1106 # class in Xm/BaseClassI.h
1107 file=Xm
/BaseClassI.h
1108 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1109 mkdir
${LIB}/sys
2>/dev
/null
1110 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1111 chmod +w
${LIB}/$file 2>/dev
/null
1112 chmod a
+r
${LIB}/$file 2>/dev
/null
1115 if [ -r ${LIB}/$file ]; then
1116 if grep __cplusplus
${LIB}/$file >/dev
/null
2>/dev
/null
; then
1119 echo Fixing
$file, prototype parameter name
1120 sed -e 's/ class[)]/ c_class)/g' ${LIB}/$file > ${LIB}/${file}.
sed
1121 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1123 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1129 # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1130 # Note that version 3 of the NeXT system has wait.h in a different directory,
1131 # so that this code won't do anything. But wait.h in version 3 has a
1132 # conditional, so it doesn't need this fix. So everything is okay.
1134 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1135 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1136 chmod +w
${LIB}/$file 2>/dev
/null
1139 if [ -r ${LIB}/$file ] \
1140 && grep 'wait[(]union wait' ${LIB}/$file >/dev
/null
; then
1141 echo Fixing
$file, bad
wait formal
1142 sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.
sed
1143 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1144 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1149 # Don't use or define the name va_list in stdio.h.
1150 # This is for ANSI and also to interoperate properly with gvarargs.h.
1152 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1153 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1154 chmod +w
${LIB}/$file 2>/dev
/null
1155 chmod a
+r
${LIB}/$file 2>/dev
/null
1158 if [ -r ${LIB}/$file ]; then
1159 echo Fixing
$file, use of va_list
1160 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
1161 (echo "#define __need___va_list"
1162 echo "#include <stdarg.h>") > ${LIB}/${file}.
sed
1163 # Use __gnuc_va_list in arg types in place of va_list.
1164 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
1165 # trailing parentheses and semicolon save all other systems from this.
1166 # Define __va_list__ (something harmless and unused) instead of va_list.
1167 # Don't claim to have defined va_list.
1168 sed -e 's@ va_list @ __gnuc_va_list @' \
1169 -e 's@ va_list)@ __gnuc_va_list)@' \
1170 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1171 -e 's@ va_list@ __va_list__@' \
1172 -e 's@\*va_list@*__va_list__@' \
1173 -e 's@ __va_list)@ __gnuc_va_list)@' \
1174 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
1175 -e 's@VA_LIST@DUMMY_VA_LIST@' \
1176 -e 's@_NEED___Va_LIST@_NEED___VA_LIST@' \
1177 ${LIB}/$file >> ${LIB}/${file}.
sed
1179 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1180 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1185 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
1187 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1188 if grep -s ULTRIX
$file; then
1189 echo "/* This file intentionally left blank. */" > $LIB/$file
1193 # parameter to atof not const on DECstation Ultrix V4.0.
1194 # also get rid of bogus inline definitions in HP-UX 8.0
1196 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1197 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1198 chmod +w
${LIB}/$file 2>/dev
/null
1199 chmod a
+r
${LIB}/$file 2>/dev
/null
1202 if [ -r ${LIB}/$file ]; then
1203 echo Fixing
$file, non-const arg
1204 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
1205 -e 's@inline int abs(int [a-z][a-z]*) {.*}@@' \
1206 -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
1207 -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
1208 -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
1209 ${LIB}/$file > ${LIB}/${file}.
sed
1210 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1211 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1216 # Avoid nested comments on Ultrix 4.3.
1218 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1219 mkdir
${LIB}/rpc
2>/dev
/null
1220 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1221 chmod +w
${LIB}/$file 2>/dev
/null
1222 chmod a
+r
${LIB}/$file 2>/dev
/null
1225 if [ -r ${LIB}/$file ]; then
1226 echo Fixing
$file, nested comment
1227 sed -e 's@^\( \* int protocol; \)/\*@\1*/ /*@' \
1228 ${LIB}/$file > ${LIB}/$file.
sed
1229 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1230 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1235 # This file in RISC/os uses /**/ to concatenate two tokens.
1237 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1238 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1239 chmod +w
${LIB}/$file 2>/dev
/null
1240 chmod a
+r
${LIB}/$file 2>/dev
/null
1242 if [ -r ${LIB}/$file ]; then
1243 sed -e 's|/\*\*/|##|' ${LIB}/$file > ${LIB}/${file}.
sed
1244 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1245 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1251 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1252 mkdir
${LIB}/rpc
2>/dev
/null
1253 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1254 chmod +w
${LIB}/$file 2>/dev
/null
1255 chmod a
+r
${LIB}/$file 2>/dev
/null
1258 if [ -r ${LIB}/$file ]; then
1259 echo Fixing
$file, nested comment
1260 sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \
1261 ${LIB}/$file > ${LIB}/$file.
sed
1262 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1263 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1268 # In limits.h, put #ifndefs around things that are supposed to be defined
1269 # in float.h to avoid redefinition errors if float.h is included first.
1270 # On HP/UX this patch does not work, because on HP/UX limits.h uses
1271 # multi line comments and the inserted #endif winds up inside the
1272 # comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1273 # we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1274 # are there, and we do not add them ourselves.
1275 for file in limits.h sys
/limits.h
; do
1276 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1277 mkdir
${LIB}/sys
2>/dev
/null
1278 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1279 chmod +w
${LIB}/$file 2>/dev
/null
1280 chmod a
+r
${LIB}/$file 2>/dev
/null
1283 if [ -r ${LIB}/$file ]; then
1284 if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev
/null
; then
1288 sed -e '/[ ]FLT_MIN[ ]/i\
1290 -e '/[ ]FLT_MIN[ ]/a\
1292 -e '/[ ]FLT_MAX[ ]/i\
1294 -e '/[ ]FLT_MAX[ ]/a\
1296 -e '/[ ]FLT_DIG[ ]/i\
1298 -e '/[ ]FLT_DIG[ ]/a\
1300 -e '/[ ]DBL_MIN[ ]/i\
1302 -e '/[ ]DBL_MIN[ ]/a\
1304 -e '/[ ]DBL_MAX[ ]/i\
1306 -e '/[ ]DBL_MAX[ ]/a\
1308 -e '/[ ]DBL_DIG[ ]/i\
1310 -e '/[ ]DBL_DIG[ ]/a\
1312 ${LIB}/$file > ${LIB}/${file}.
sed
1313 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1315 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1316 echo Deleting
${LIB}/$file\
; no fixes were needed.
1322 # In math.h, put #ifndefs around things that might be defined in a gcc
1323 # specific math-*.h file.
1325 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1326 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1327 chmod +w
${LIB}/$file 2>/dev
/null
1328 chmod a
+r
${LIB}/$file 2>/dev
/null
1331 if [ -r ${LIB}/$file ]; then
1333 sed -e '/define[ ]HUGE_VAL[ ]/i\
1335 -e '/define[ ]HUGE_VAL[ ]/a\
1337 ${LIB}/$file > ${LIB}/${file}.
sed
1338 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1339 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1340 echo Deleting
${LIB}/$file\
; no fixes were needed.
1345 # Remove erroneous parentheses in sym.h on Alpha OSF/1.
1347 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1348 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1349 chmod +w
${LIB}/$file 2>/dev
/null
1350 chmod a
+r
${LIB}/$file 2>/dev
/null
1353 if [ -r ${LIB}/$file ]; then
1355 sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
1356 ${LIB}/$file > ${LIB}/${file}.
sed
1357 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1358 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1363 # Fix incorrect S_IF* definitions on m88k-sysv3.
1365 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1366 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1367 chmod +w
${LIB}/$file 2>/dev
/null
1368 chmod a
+r
${LIB}/$file 2>/dev
/null
1371 if [ -r ${LIB}/$file ]; then
1373 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)/' \
1374 -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
1375 ${LIB}/$file > ${LIB}/${file}.
sed
1376 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1377 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1382 # Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1.
1383 for file in stdio.h stdlib.h
; do
1384 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1385 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1386 chmod +w
${LIB}/$file 2>/dev
/null
1387 chmod a
+r
${LIB}/$file 2>/dev
/null
1390 if [ -r ${LIB}/$file ]; then
1391 echo Fixing
$file, getopt declaration
1392 sed -e 's/getopt(int, char \*\[\],char \*)/getopt(int, char *const[], const char *)/' \
1393 ${LIB}/$file > ${LIB}/${file}.
sed
1394 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1395 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1401 # These two files on SunOS 4 are included by other files
1402 # in the same directory, using "...". So we must make sure they exist
1403 # in the same directory as the other fixed files.
1404 if [ -r ${INPUT}/multimedia
/audio_errno.h
]
1406 ln -s ${INPUT}/multimedia
/audio_errno.h
${LIB}/multimedia
2>/dev
/null
1408 if [ -r ${INPUT}/multimedia
/audio_hdr.h
]
1410 ln -s ${INPUT}/multimedia
/audio_hdr.h
${LIB}/multimedia
2>/dev
/null
1413 # Determine if we're on Interactive Unix 2.2 or later, in which case we
1414 # need to fix some additional files. This is the same test for ISC that
1416 if test -d /etc
/conf
/kconfig.d \
1417 && grep _POSIX_VERSION
/usr
/include
/sys
/unistd.h
>/dev
/null
2>&1; then
1418 echo "Fixing ISC __STDC__ goof in several files..."
1419 for name
in stdio.h math.h ctype.h sys
/limits.h sys
/fcntl.h sys
/dirent.h
; do
1421 if test -r ${LIB}/$name; then
1426 # On Interactive 2.2, certain traditional Unix definitions
1427 # (notably getc and putc in stdio.h) are omitted if __STDC__ is
1428 # defined, not just if _POSIX_SOURCE is defined. This makes it
1429 # impossible to compile any nontrivial program except with -posix.
1431 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
1432 < $file > ${LIB}/$name.
1433 mv ${LIB}/$name.
${LIB}/$name
1436 echo "Fixing ISC fmod declaration"
1437 # This one's already been fixed for other things.
1439 sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
1442 echo "Fixing nested comments in ISC <sys/limits.h>"
1444 sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
1445 sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file.
>${LIB}/$file
1448 # These files in Sun OS 4.x use /**/ to concatenate tokens.
1449 for file in sparc
/asm_linkage.h sun
3/asm_linkage.h sun3x
/asm_linkage.h \
1450 sun
4/asm_linkage.h sun4c
/asm_linkage.h sun4m
/asm_linkage.h \
1451 sun4c
/debug
/asm_linkage.h sun4m
/debug
/asm_linkage.h
;
1453 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1454 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1455 chmod +w
${LIB}/$file 2>/dev
/null
1456 chmod a
+r
${LIB}/$file 2>/dev
/null
1459 if [ -r ${LIB}/$file ]; then
1460 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.
sed
1461 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1462 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1468 # These files in ARM/RISCiX use /**/ to concatenate tokens.
1469 for file in arm
/as_support.h
arm
/mc_type.h
arm
/xcb.h dev
/chardefmac.h \
1470 dev
/ps_irq.h dev
/screen.h dev
/scsi.h sys
/tty.h Xm.acorn
/XmP.h
1472 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1473 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
1474 chmod +w
${LIB}/$file 2>/dev
/null
1475 chmod a
+r
${LIB}/$file 2>/dev
/null
1478 if [ -r ${LIB}/$file ]; then
1479 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.
sed
1480 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1481 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
1487 # This file on SunOS 4 has a very large macro. When the sed loop
1488 # tries pull it in, it overflows the pattern space size of the SunOS
1489 # sed (GNU sed does not have this problem). Since the file does not
1490 # require fixing, we remove it from the fixed directory.
1491 file=sundev
/ipi_error.h
1492 if [ -r ${LIB}/$file ]; then
1493 echo "Removing incorrect fix to SunOS <sundev/ipi_error.h>"
1497 echo 'Removing unneeded directories:'
1499 files
=`find . -type d -print | sort -r`
1500 for file in $files; do
1501 rmdir $LIB/$file > /dev
/null
2>&1
1505 echo 'Making internal symbolic non-directory links'
1507 files
=`find . -type l -print`
1508 for file in $files; do
1509 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
1510 if expr "$dest" : '[^/].*' > /dev
/null
; then
1511 target
=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1512 if [ -f $target ]; then
1513 ln -s $dest ${LIB}/$file >/dev
/null
2>&1
1519 # Make sure that any include files referenced using double quotes
1520 # exist in the fixed directory. This comes last since otherwise
1521 # we might end up deleting some of these files "because they don't
1523 while [ -n "$required" ]; do
1527 while [ $# != 0 ]; do
1528 # $1 is the directory to copy from, $2 is the unfixed file,
1529 # $3 is the fixed file name.
1532 if [ -r $2 ] && [ ! -r $3 ]; then
1533 cp $2 $3 >/dev
/null
2>&1 ||
echo "Can't copy $2"
1534 chmod +w
$3 2>/dev
/null
1535 chmod a
+r
$3 2>/dev
/null
1537 for include
in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1538 dir
=`echo $2 | sed -e s'|/[^/]*$||'`
1539 dir2
=`echo $3 | sed -e s'|/[^/]*$||'`
1540 newreq
="$newreq $1 $dir/$include $dir2/$include"
1548 echo 'Cleaning up DONE files.'
1550 find .
-name DONE
-exec rm -f '{}' ';'