Annotation of gcc/fixincludes, revision 1.1.1.5

1.1       root        1: #! /bin/sh
                      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.
                      5: 
                      6: # See README-fixinc for more information.
                      7: 
1.1.1.4   root        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-.}}
                     12: 
1.1       root       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}}
                     16: 
1.1.1.5 ! root       17: # Directory in which to store the results.
        !            18: LIB=${1?"fixincludes: output directory not specified"}
1.1.1.4   root       19: 
                     20: # Define PWDCMD as a command to use to get the working dir
                     21: # in the form that we want.
                     22: PWDCMD=pwd
                     23: case "`pwd`" in
                     24: //*)
                     25:        # On an Apollo, discard everything before `/usr'.
                     26:        PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
                     27:        ;;
                     28: esac
1.1       root       29: 
1.1.1.5 ! root       30: # Original directory.
        !            31: ORIGDIR=`${PWDCMD}`
1.1       root       32: 
                     33: # Make sure it exists.
                     34: if [ ! -d $LIB ]; then
                     35:   mkdir $LIB || exit 1
                     36: fi
                     37: 
1.1.1.5 ! root       38: # Make LIB absolute only if needed to avoid problems with the amd.
        !            39: case $LIB in
        !            40: /*)
        !            41:        ;;
        !            42: *)
        !            43:        cd $LIB; LIB=`${PWDCMD}`
        !            44:        ;;
        !            45: esac
        !            46: 
        !            47: # Make SRCDIR absolute only if needed to avoid problems with the amd.
        !            48: cd $ORIGDIR
        !            49: case $SRCDIR in
        !            50: /*)
        !            51:        ;;
        !            52: *)
        !            53:        cd $SRCDIR; SRCDIR=`${PWDCMD}`
        !            54:        ;;
        !            55: esac
1.1       root       56: 
                     57: # Fail if no arg to specify a directory for the output.
                     58: if [ x$1 = x ]
                     59: then echo fixincludes: no output directory specified
                     60: exit 1
                     61: fi
                     62: 
1.1.1.4   root       63: echo Building fixed headers in ${LIB}
1.1       root       64: 
                     65: # Determine whether this system has symbolic links.
                     66: if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
                     67:   rm -f $LIB/ShouldNotExist
                     68:   LINKS=true
                     69: else
                     70:   LINKS=false
                     71: fi
                     72: 
1.1.1.4   root       73: echo Finding directories and links to directories
1.1       root       74: cd ${INPUT}
1.1.1.2   root       75: # Find all directories and all symlinks that point to directories.
1.1.1.4   root       76: # Put the list in $files.
                     77: # Each time we find a symlink, add it to newdirs
                     78: # so that we do another find within the dir the link points to.
                     79: # Note that $files may have duplicates in it;
                     80: # later parts of this file are supposed to ignore them.
                     81: dirs="."
                     82: levels=2
                     83: while [ -n "$dirs" ] && [ $levels -gt 0 ]
                     84: do
                     85:     levels=`expr $levels - 1`
                     86:     newdirs=
                     87:     for d in $dirs
                     88:     do
                     89:        echo " Searching $INPUT/$d"
                     90:        if [ "$d" != . ]
                     91:        then
                     92:            d=$d/.
                     93:        fi
                     94: 
                     95:        # Find all directories under $d, relative to $d, excluding $d itself.
                     96:         files="$files `find $d -type d -print | \
                     97:                       sed -e '/\/\.$/d' -e '/^\.$/d'`"
                     98:        # Find all links to directories.
                     99:        # Using `-exec test -d' in find fails on some systems,
                    100:        # and trying to run test via sh fails on others,
                    101:        # so this is the simplest alternative left.
                    102:        # First find all the links, then test each one.
                    103:        theselinks=
                    104:        $LINKS && \
                    105:          theselinks=`find $d -type l -print`
                    106:        for d1 in $theselinks --dummy--
                    107:        do
                    108:            # If the link points to a directory,
                    109:            # add that dir to $newdirs
                    110:            if [ -d $d1 ]
                    111:            then
                    112:                newdirs="$newdirs $d1"
                    113:            fi
                    114:        done
                    115:     done
                    116: 
                    117:     files="$files $newdirs"
                    118:     dirs="$newdirs"
                    119: done
                    120: 
                    121: dirs=
                    122: echo "All directories (including links to directories):"
                    123: echo $files
                    124: 
1.1       root      125: for file in $files; do
                    126:   rm -rf $LIB/$file
                    127:   if [ ! -d $LIB/$file ]
                    128:   then mkdir $LIB/$file
                    129:   fi
                    130: done
1.1.1.4   root      131: mkdir $LIB/root
1.1       root      132: 
                    133: # treetops gets an alternating list
                    134: # of old directories to copy
                    135: # and the new directories to copy to.
                    136: treetops="${INPUT} ${LIB}"
                    137: 
                    138: if $LINKS; then
1.1.1.4   root      139:   echo 'Making symbolic directory links'
1.1       root      140:   for file in $files; do
                    141:     dest=`ls -ld $file | sed -n 's/.*-> //p'`
                    142:     if [ "$dest" ]; then    
1.1.1.4   root      143:       cwd=`${PWDCMD}`
1.1       root      144:       # In case $dest is relative, get to $file's dir first.
                    145:       cd ${INPUT}
                    146:       cd `echo ./$file | sed -n 's&[^/]*$&&p'`
                    147:       # Check that the target directory exists.
                    148:       # Redirections changed to avoid bug in sh on Ultrix.
                    149:       (cd $dest) > /dev/null 2>&1
                    150:       if [ $? = 0 ]; then
                    151:        cd $dest
                    152:        # X gets the dir that the link actually leads to.
1.1.1.4   root      153:        x=`${PWDCMD}`
                    154:        # If a link points to ., make a similar link to .
                    155:        if [ $x = $INPUT ]; then
                    156:          echo $file '->' . ': Making link'
                    157:          rm -fr ${LIB}/$file > /dev/null 2>&1
                    158:          ln -s . ${LIB}/$file > /dev/null 2>&1
1.1       root      159:        # If link leads back into ${INPUT},
                    160:        # make a similar link here.
1.1.1.4   root      161:        elif expr $x : "${INPUT}/.*" > /dev/null; then
1.1       root      162:          # Y gets the actual target dir name, relative to ${INPUT}.
                    163:          y=`echo $x | sed -n "s&${INPUT}/&&p"`
                    164:          echo $file '->' $y ': Making link'
                    165:          rm -fr ${LIB}/$file > /dev/null 2>&1
                    166:          ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
                    167:        else
1.1.1.4   root      168:          # If the link is to a dir $target outside ${INPUT},
                    169:          # repoint the link at ${INPUT}/root$target
                    170:          # and process $target into ${INPUT}/root$target
1.1       root      171:          # treat this directory as if it actually contained the files.
1.1.1.4   root      172:          echo $file '->' root$x ': Making link'
                    173:          if [ -d $LIB/root$x ]
                    174:          then true
                    175:          else
                    176:            dirname=root$x/
                    177:            dirmade=.
                    178:            cd $LIB
                    179:            while [ x$dirname != x ]; do
                    180:              component=`echo $dirname | sed -e 's|/.*$||'`
                    181:              mkdir $component >/dev/null 2>&1
                    182:              cd $component
                    183:              dirmade=$dirmade/$component
                    184:              dirname=`echo $dirname | sed -e 's|[^/]*/||'`
                    185:            done
                    186:          fi
1.1.1.5 ! root      187:          # Duplicate directory structure created in ${LIB}/$file in new
        !           188:          # root area.
        !           189:          for file2 in $files; do
        !           190:            case $file2 in
        !           191:              $file/./*)
        !           192:                dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
        !           193:                echo "Duplicating ${file}'s ${dupdir}"
        !           194:                if [ -d ${dupdir} ]
        !           195:                then true
        !           196:                else
        !           197:                  mkdir ${dupdir}
        !           198:                fi
        !           199:                ;;
        !           200:              *)
        !           201:                ;;
        !           202:            esac
        !           203:           done
1.1.1.4   root      204:          rm -fr ${LIB}/$file > /dev/null 2>&1
                    205:          ln -s ${LIB}/root$x ${LIB}/$file > /dev/null 2>&1
                    206:          treetops="$treetops $x ${LIB}/root$x"
1.1       root      207:        fi
                    208:       fi
                    209:       cd $cwd
                    210:     fi
                    211:   done
                    212: fi
                    213: 
1.1.1.5 ! root      214: set x $treetops
        !           215: shift
1.1       root      216: while [ $# != 0 ]; do
                    217:   # $1 is an old directory to copy, and $2 is the new directory to copy to.
                    218:   cd ${INPUT}
                    219:   cd $1
1.1.1.4   root      220: # The same dir can appear more than once in treetops.
                    221: # There's no need to scan it more than once.
                    222:   if [ -f $2/DONE ]
                    223:   then
                    224:     files=
                    225:   else
                    226:     touch $2/DONE
                    227:     echo Fixing directory $1 into $2
                    228: # Check .h files which are symlinks as well as those which are files.
                    229: # A link to a header file will not be processed by anything but this.
                    230:     if $LINKS; then
                    231:       files=`find . -name '*.h' \( -type f -o -type l \) -print`
                    232:     else
                    233:       files=`find . -name '*.h' -type f -print`
                    234:     fi
                    235:     echo Checking header files
                    236:   fi
1.1       root      237: # Note that BSD43_* are used on recent MIPS systems.
                    238:   for file in $files; do
                    239: # This call to egrep is essential, since checking a file with egrep
                    240: # is much faster than actually trying to fix it.
1.1.1.2   root      241: # It is also essential that most files *not* match!
                    242: # Thus, matching every #endif is unacceptable.
1.1       root      243: # But the argument to egrep must be kept small, or many versions of egrep
                    244: # won't be able to handle it.
1.1.1.5 ! root      245: #
        !           246: # We use the pattern [!-.0-~] instead of [^/   ] to match a noncomment
        !           247: # following #else or #endif because some buggy egreps think [^/] matches
        !           248: # newline, and they thus think `#else ' matches `#e[ndiflse]*[         ]+[^/   ]'.
        !           249: #
        !           250: # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
        !           251: # following #if or #elif that is not surrounded by __.  The `a-ce-km-z'
        !           252: # in this pattern lacks `d' and `l'; this means we don't worry about
        !           253: # identifiers starting with `d' or `l'.  This is OK, since none of the
        !           254: # identifiers below start with `d' or `l'.  It also greatly improves
        !           255: # performance, since many files contain lines of the form `#if ... defined ...'
        !           256: # or `#if lint'.
        !           257:     if egrep '//|[     _]_IO|CTRL|^#define.NULL|^#e[nl][ds][ief]*[     ]+[!-.0-~]|^#[el]*if.*[^a-zA-Z0-9_][_a-ce-km-z][a-z0-9]' $file >/dev/null; then
1.1       root      258:       if [ -r $file ]; then
                    259:        cp $file $2/$file >/dev/null 2>&1       \
                    260:        || echo "Can't copy $file"
                    261:        chmod +w $2/$file
1.1.1.5 ! root      262:        chmod a+r $2/$file
        !           263:        # Here is how the sed commands in braces work.
        !           264:        # (It doesn't work to put the comments inside the sed commands.)
        !           265:                # Surround each word with spaces, to simplify matching below.
        !           266:                # ANSIfy each pre-ANSI machine-dependent symbol
        !           267:                # by surrounding it with __ __.
        !           268:                # Remove the spaces that we inserted around each word.
1.1       root      269:        sed -e '
                    270:                                   :loop
                    271:          /\\$/                 N
                    272:          /\\$/                 b loop
1.1.1.5 ! root      273:          s%^\([        ]*#[    ]*endif[        ]*\)\([^/       ].*\)$%\1/* \2 */%
        !           274:          s%^\([        ]*#[    ]*else[         ]*\)\([^/       ].*\)$%\1/* \2 */%
        !           275:          /\/\/[^*]/                    s|//\(.*\)$|/*\1*/|
        !           276:          /[    ]_IO[A-Z]*[     ]*(/    s/\(_IO[A-Z]*[  ]*(\)\(.\),/\1'\''\2'\'',/
1.1       root      277:          /[    ]BSD43__IO[A-Z]*[       ]*(/    s/(\(.\),/('\''\1'\'',/
1.1.1.5 ! root      278:          /#define._IO/                 s/'\''\([cgx]\)'\''/\1/g
        !           279:          /#define.BSD43__IO/           s/'\''\([cgx]\)'\''/\1/g
        !           280:          /[^A-Z0-9_]CTRL[      ]*(/            s/\([^'\'']\))/'\''\1'\'')/
        !           281:          /[^A-Z0-9]_CTRL[      ]*(/            s/\([^'\'']\))/'\''\1'\'')/
        !           282:          /#define.CTRL/                s/'\''\([cgx]\)'\''/\1/g
        !           283:          /#define._CTRL/               s/'\''\([cgx]\)'\''/\1/g
        !           284:          /#define.BSD43_CTRL/          s/'\''\([cgx]\)'\''/\1/g
        !           285:          /#[el]*if/{
        !           286:                s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
        !           287: 
        !           288:                s/ bsd4\([0-9]\) / __bsd4\1__ /g
        !           289:                s/ _*i386 / __i386__ /g
        !           290:                s/ is68k / __is68k__ /g
        !           291:                s/ m68k / __m68k__ /g
        !           292:                s/ mc680\([0-9]\)0 / __mc680\10__ /g
        !           293:                s/ news\([0-9]*\) / __news\1__ /g
        !           294:                s/ ns32000 / __ns32000__ /g
        !           295:                s/ pyr / __pyr__ /g
        !           296:                s/ sony_news / __sony_news__ /g
        !           297:                s/ sparc / __sparc__ /g
        !           298:                s/ sun\([a-z0-9]*\) / __sun\1__ /g
        !           299:                s/ unix / __unix__ /g
        !           300:                s/ vax / __vax__ /g
        !           301: 
        !           302:                s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
        !           303:          }
1.1.1.3   root      304:          /^#define.NULL[       ]/      i\
1.1       root      305:                #undef NULL
1.1.1.5 ! root      306:        ' $2/$file > $2/$file.
        !           307:        mv $2/$file. $2/$file
1.1       root      308:        if cmp $file $2/$file >/dev/null 2>&1; then
                    309:           rm $2/$file
1.1.1.5 ! root      310:        else
        !           311:           echo Fixed $file
1.1       root      312:        fi
                    313:       fi
                    314:     fi
                    315:   done
                    316:   shift; shift
                    317: done
                    318: 
                    319: cd ${INPUT}
                    320: 
1.1.1.5 ! root      321: # Install the proper definition of size_t in header files that it comes from.
        !           322: for file in sys/types.h sys/stdtypes.h;
        !           323: do
        !           324:   if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
        !           325:     cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
        !           326:     chmod +w ${LIB}/$file 2>/dev/null
        !           327:     chmod a+r ${LIB}/$file 2>/dev/null
        !           328:   fi
        !           329: 
        !           330:   if [ -r ${LIB}/$file ]; then
        !           331:     echo Fixing $file comment
        !           332:     # Extract the definition of SIZE_TYPE, if any.
        !           333:     # (This file must be called something.c).
        !           334:     echo "#include \"tm.h\"
        !           335: gobblegobble SIZE_TYPE" > ${LIB}/types.c
        !           336:     foo=`cd ${LIB}; cc -E -I${ORIGDIR} -I${SRCDIR} -I${SRCDIR}/config types.c | grep gobblegobble | sed -e "s/gobblegobble[    ]*//"`
        !           337:     rm -f ${LIB}/types.c
        !           338:     # Default to our preferred type.
        !           339:     if [ "$foo" = SIZE_TYPE ]; then foo="unsigned long int"; else foo=`echo $foo | sed -e 's/^.*"\(.*\)".*$/\1/'`; fi
        !           340:     sed -e "s/typedef[         a-z_]*[         ]size_t/typedef $foo size_t/" ${LIB}/$file > ${LIB}/${file}.sed
        !           341:     rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
        !           342:     if cmp $file ${LIB}/$file >/dev/null 2>&1; then
        !           343:       rm ${LIB}/$file
        !           344:     fi
        !           345:   fi
        !           346: done
        !           347: 
1.1       root      348: # Fix one other error in this file: a mismatched quote not inside a C comment.
                    349: file=sundev/vuid_event.h
1.1.1.2   root      350: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    351:   mkdir ${LIB}/sundev 2>/dev/null
                    352:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    353:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      354:   chmod a+r ${LIB}/$file 2>/dev/null
1.1       root      355: fi
                    356: 
                    357: if [ -r ${LIB}/$file ]; then
                    358:   echo Fixing $file comment
1.1.1.5 ! root      359:   sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
        !           360:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
        !           361:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
        !           362:     rm ${LIB}/$file
        !           363:   fi
        !           364: fi
        !           365: 
        !           366: # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
        !           367: file=sunwindow/win_cursor.h
        !           368: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
        !           369: #  mkdir ${LIB}/sunwindow 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: fi
        !           373: if [ -r ${LIB}/$file ]; then
        !           374:   echo Fixing $file
        !           375:   sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
        !           376:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
        !           377:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
        !           378:     rm ${LIB}/$file
        !           379:   fi
        !           380: fi
        !           381: file=sunwindow/win_lock.h
        !           382: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
        !           383: #  mkdir ${LIB}/sunwindow 2>/dev/null
        !           384:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
        !           385:   chmod +w ${LIB}/$file 2>/dev/null
        !           386: fi
        !           387: if [ -r ${LIB}/$file ]; then
        !           388:   echo Fixing $file
        !           389:   sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
        !           390:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1.1       root      391:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    392:     rm ${LIB}/$file
                    393:   fi
                    394: fi
                    395: 
1.1.1.3   root      396: # Fix this Sun file to avoid interfering with stddef.h.
1.1       root      397: file=sys/stdtypes.h
1.1.1.2   root      398: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    399:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    400:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      401:   chmod a+r ${LIB}/$file 2>/dev/null
1.1       root      402: fi
                    403: 
                    404: if [ -r ${LIB}/$file ]; then
1.1.1.2   root      405:   echo Fixing $file
1.1.1.5 ! root      406: sed -e '/size_t.*;/i\
        !           407: #ifndef _GCC_SIZE_T\
        !           408: #define _GCC_SIZE_T' \
        !           409:     -e '/size_t.*;/a\
        !           410: #endif' \
        !           411:     -e '/ptrdiff_t.*;/i\
        !           412: #ifndef _GCC_PTRDIFF_T\
        !           413: #define _GCC_PTRDIFF_T' \
        !           414:     -e '/ptrdiff_t.*;/a\
        !           415: #endif' \
        !           416:     -e '/wchar_t.*;/i\
        !           417: #ifndef _GCC_WCHAR_T\
        !           418: #define _GCC_WCHAR_T' \
        !           419:     -e '/wchar_t.*;/a\
        !           420: #endif' ${LIB}/$file > ${LIB}/${file}.sed
        !           421:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1.1       root      422:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    423:     rm ${LIB}/$file
                    424:   fi
                    425: fi
                    426: 
1.1.1.4   root      427: # Fix this file to avoid interfering with stddef.h, but don't mistakenly
                    428: # match e.g. ssize_t present in AIX for the ps/2.
1.1       root      429: file=sys/types.h
1.1.1.2   root      430: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    431:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    432:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      433:   chmod a+r ${LIB}/$file 2>/dev/null
1.1       root      434: fi
                    435: 
                    436: if [ -r ${LIB}/$file ]; then
1.1.1.2   root      437:   echo Fixing $file
1.1.1.5 ! root      438: sed -e '/[     ]size_t.*;/i\
        !           439: #ifndef _GCC_SIZE_T\
        !           440: #define _GCC_SIZE_T' \
        !           441:     -e '/[     ]size_t.*;/a\
        !           442: #endif' ${LIB}/$file > ${LIB}/${file}.sed
        !           443:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1.1       root      444:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    445:     rm ${LIB}/$file
                    446:   fi
                    447: fi
                    448: 
1.1.1.4   root      449: # Fix an error in this file: the #if says _cplusplus, not the double
                    450: # underscore __cplusplus that it should be
                    451: file=tinfo.h
                    452: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    453:   mkdir ${LIB}/rpcsvc 2>/dev/null
                    454:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    455:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      456:   chmod a+r ${LIB}/$file 2>/dev/null
1.1.1.4   root      457: fi
                    458: 
                    459: if [ -r ${LIB}/$file ]; then
                    460:   echo Fixing $file, __cplusplus macro
                    461:   sed -e 's/[  ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
                    462:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    463:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    464:     rm ${LIB}/$file
                    465:   fi
                    466: fi
                    467: 
1.1       root      468: # Fix an error in this file: a missing semi-colon at the end of the statsswtch
                    469: # structure definition.
                    470: file=rpcsvc/rstat.h
1.1.1.2   root      471: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    472:   mkdir ${LIB}/rpcsvc 2>/dev/null
                    473:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    474:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      475:   chmod a+r ${LIB}/$file 2>/dev/null
1.1       root      476: fi
                    477: 
                    478: if [ -r ${LIB}/$file ]; then
                    479:   echo Fixing $file, definition of statsswtch
1.1.1.5 ! root      480:   sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
        !           481:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1.1       root      482:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    483:     rm ${LIB}/$file
                    484:   fi
                    485: fi
                    486: 
                    487: # Fix an error in this file: a missing semi-colon at the end of the nodeent
                    488: # structure definition.
                    489: file=netdnet/dnetdb.h
1.1.1.2   root      490: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    491:   mkdir ${LIB}/netdnet 2>/dev/null
                    492:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    493:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      494:   chmod a+r ${LIB}/$file 2>/dev/null
1.1       root      495: fi
                    496: 
                    497: if [ -r ${LIB}/$file ]; then
                    498:   echo Fixing $file, definition of nodeent
1.1.1.5 ! root      499:   sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
        !           500:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1.1       root      501:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    502:     rm ${LIB}/$file
                    503:   fi
                    504: fi
                    505: 
                    506: # Check for bad #ifdef line (in Ultrix 4.1)
                    507: file=sys/file.h
1.1.1.2   root      508: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    509:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    510:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      511:   chmod a+r ${LIB}/$file 2>/dev/null
1.1       root      512: fi
                    513: 
                    514: if [ -r ${LIB}/$file ]; then
                    515:   echo Fixing $file, bad \#ifdef line
1.1.1.5 ! root      516:   sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
        !           517:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1.1       root      518:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    519:     rm ${LIB}/$file
                    520:   fi
                    521: fi
                    522: 
1.1.1.2   root      523: # Remove nested comments created by #endifs in a comment (Ultrix 4.1)
                    524: # Only needed if commenting out junk after #endif.
1.1.1.5 ! root      525: file=signal.h
        !           526: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
        !           527:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
        !           528:   chmod +w ${LIB}/$file 2>/dev/null
        !           529:   chmod a+r ${LIB}/$file 2>/dev/null
        !           530: fi
        !           531: 
        !           532: if [ -r ${LIB}/$file ]; then
        !           533:   echo Fixing $file, nested comments
        !           534:   sed -e 's/^[         ]*#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed
        !           535:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
        !           536:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
        !           537:     rm -f ${LIB}/$file
        !           538:   fi
        !           539: fi
1.1       root      540: 
1.1.1.2   root      541: # Check for superfluous `static' (in Ultrix 4.2)
1.1       root      542: file=machine/cpu.h
1.1.1.2   root      543: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    544:   mkdir ${LIB}/machine 2>/dev/null
                    545:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    546:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      547:   chmod a+r ${LIB}/$file 2>/dev/null
1.1       root      548: fi
                    549: 
                    550: if [ -r ${LIB}/$file ]; then
                    551:   echo Fixing $file, superfluous static
1.1.1.5 ! root      552:   sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' ${LIB}/$file > ${LIB}/${file}.sed
        !           553:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1.1       root      554:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    555:     rm ${LIB}/$file
                    556:   else
                    557: # This file has an alternative name, mips/cpu.h.  Fix that name, too.
                    558:     if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then
                    559:       mkdir ${LIB}/mips 2>&-
                    560:       ln ${LIB}/$file ${LIB}/mips/cpu.h 
                    561:     fi
                    562:   fi
                    563: fi
                    564: 
1.1.1.2   root      565: # Incorrect sprintf declaration in X11/Xmu.h
1.1       root      566: file=X11/Xmu.h
1.1.1.2   root      567: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    568:   mkdir ${LIB}/X11 2>/dev/null
                    569:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    570:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      571:   chmod a+r ${LIB}/$file 2>/dev/null
1.1       root      572: fi
                    573: 
                    574: if [ -r ${LIB}/$file ]; then
                    575:   echo Fixing $file sprintf declaration
1.1.1.5 ! root      576:   sed -e 's,^extern char \*    sprintf();$,#ifndef __STDC__\
        !           577: extern char *  sprintf();\
        !           578: #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
        !           579:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1.1       root      580:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    581:     rm ${LIB}/$file
                    582:   fi
                    583: fi
                    584: 
1.1.1.4   root      585: # Incorrect sprintf declaration in X11/Xmu/Xmu.h
                    586: # (It's not clear whether the right file name is this or X11/Xmu.h.)
                    587: file=X11/Xmu/Xmu.h
                    588: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    589:   mkdir ${LIB}/X11/Xmu 2>/dev/null
                    590:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    591:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      592:   chmod a+r ${LIB}/$file 2>/dev/null
1.1.1.4   root      593: fi
                    594: 
                    595: if [ -r ${LIB}/$file ]; then
                    596:   echo Fixing $file sprintf declaration
1.1.1.5 ! root      597:   sed -e 's,^extern char \*    sprintf();$,#ifndef __STDC__\
        !           598: extern char *  sprintf();\
        !           599: #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
        !           600:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1.1.1.4   root      601:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    602:     rm ${LIB}/$file
                    603:   fi
                    604: fi
                    605: 
1.1       root      606: # Check for missing ';' in struct
                    607: file=netinet/ip.h
1.1.1.2   root      608: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    609:   mkdir ${LIB}/netinet 2>/dev/null
                    610:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    611:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      612:   chmod a+r ${LIB}/$file 2>/dev/null
1.1       root      613: fi
                    614: 
1.1.1.2   root      615: if [ -r ${LIB}/$file ]; then
                    616:   echo Fixing $file
                    617:   sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
                    618:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    619:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    620:     rm -f ${LIB}/$file
                    621:   fi
                    622: fi
1.1       root      623: 
1.1.1.2   root      624: # Fix the CAT macro in SunOS memvar.h.
1.1       root      625: file=pixrect/memvar.h
1.1.1.2   root      626: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    627:   mkdir ${LIB}/pixrect 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
1.1.1.5 ! root      630:   chmod a+r ${LIB}/$file 2>/dev/null
1.1.1.2   root      631: fi
                    632: 
                    633: if [ -r ${LIB}/$file ]; then
                    634:   echo Fixing $file
                    635:   sed -e '/^#define.CAT(a,b)/ i\
1.1       root      636: #ifdef __STDC__ \
                    637: #define CAT(a,b) a##b\
                    638: #else
                    639: /^#define.CAT(a,b)/ a\
                    640: #endif
1.1.1.2   root      641: ' ${LIB}/$file > ${LIB}/${file}.sed
                    642:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    643:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    644:     rm -f ${LIB}/$file
1.1       root      645:   fi
                    646: fi
                    647: 
                    648: # Check for yet more missing ';' in struct (in SunOS 4.0.x)
                    649: file=rpcsvc/rusers.h
1.1.1.2   root      650: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    651:   mkdir ${LIB}/rpcsvc 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
1.1.1.5 ! root      654:   chmod a+r ${LIB}/$file 2>/dev/null
1.1.1.2   root      655: fi
                    656: 
                    657: if [ -r ${LIB}/$file ]; then
                    658:   echo Fixing $file
                    659:   sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
                    660:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    661:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    662:     rm -f ${LIB}/$file
1.1       root      663:   fi
                    664: fi
                    665: 
                    666: # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
                    667: file=stdlib.h
1.1.1.2   root      668: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    669:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    670:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      671:   chmod a+r ${LIB}/$file 2>/dev/null
1.1       root      672: fi
1.1.1.2   root      673: 
                    674: if [ -r ${LIB}/$file ]; then
                    675:   echo Fixing $file
                    676:   sed -e 's/int        abort/void      abort/g' \
1.1.1.3   root      677:   -e 's/int    free/void       free/g' \
                    678:   -e 's/char \*        calloc/void \*  calloc/g' \
                    679:   -e 's/char \*        malloc/void \*  malloc/g' \
                    680:   -e 's/char \*        realloc/void \* realloc/g' \
1.1.1.2   root      681:   -e 's/int    exit/void       exit/g' ${LIB}/$file > ${LIB}/${file}.sed
                    682:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    683:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1.1       root      684:     rm -f ${LIB}/$file
                    685:   fi
                    686: fi
                    687: 
1.1.1.3   root      688: # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
                    689: file=malloc.h
                    690: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    691:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    692:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      693:   chmod a+r ${LIB}/$file 2>/dev/null
1.1.1.3   root      694: fi
                    695: 
                    696: if [ -r ${LIB}/$file ]; then
                    697:   echo Fixing $file
                    698:   sed -e 's/typedef[   ]char \*        malloc_t/typedef void \*        malloc_t/g' \
                    699:   -e 's/int[   ][      ]*free/void     free/g' \
                    700:   ${LIB}/$file > ${LIB}/${file}.sed
                    701:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    702:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    703:     rm -f ${LIB}/$file
                    704:   fi
                    705: fi
                    706: 
                    707: 
1.1       root      708: # Fix bogus comment in <locale.h> on SunOS 4.1.
                    709: file=locale.h
1.1.1.2   root      710: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    711:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    712:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      713:   chmod a+r ${LIB}/$file 2>/dev/null
1.1       root      714: fi
1.1.1.2   root      715: 
                    716: if [ -r ${LIB}/$file ]; then
                    717:   echo Fixing $file
                    718:   sed -e 's%#endif / \*%#endif /\* %g' ${LIB}/$file > ${LIB}/${file}.sed
                    719:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    720:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1.1       root      721:     rm -f ${LIB}/$file
                    722:   fi
                    723: fi
                    724: 
                    725: # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
                    726: file=hsfs/hsfs_spec.h
1.1.1.2   root      727: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    728:   mkdir ${LIB}/hsfs 2>/dev/null
                    729:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    730:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      731:   chmod a+r ${LIB}/$file 2>/dev/null
1.1.1.2   root      732: fi
                    733: 
1.1       root      734: if [ -r ${LIB}/$file ]; then
1.1.1.2   root      735:   echo Fixing $file
                    736:   sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
1.1.1.5 ! root      737:     ${LIB}/$file > ${LIB}/${file}.
        !           738:   rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
1.1.1.2   root      739:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1.1       root      740:     rm -f ${LIB}/$file
                    741:   fi
                    742: fi
                    743: 
                    744: # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
                    745: file=hsfs/hsnode.h
1.1.1.2   root      746: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    747:   mkdir ${LIB}/hsfs 2>/dev/null
                    748:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    749:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      750:   chmod a+r ${LIB}/$file 2>/dev/null
1.1.1.2   root      751: fi
                    752: 
1.1       root      753: if [ -r ${LIB}/$file ]; then
1.1.1.2   root      754:   echo Fixing $file
                    755:   sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
                    756:     ${LIB}/$file > ${LIB}/${file}.sed
                    757:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    758:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1.1       root      759:     rm -f ${LIB}/$file
                    760:   fi
                    761: fi
                    762: 
                    763: # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
                    764: file=hsfs/iso_spec.h
1.1.1.2   root      765: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    766:   mkdir ${LIB}/hsfs 2>/dev/null
                    767:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    768:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      769:   chmod a+r ${LIB}/$file 2>/dev/null
1.1.1.2   root      770: fi
                    771: 
1.1       root      772: if [ -r ${LIB}/$file ]; then
1.1.1.2   root      773:   echo Fixing $file
                    774:   sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
                    775:     ${LIB}/$file > ${LIB}/${file}.sed
                    776:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    777:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    778:     rm -f ${LIB}/$file
                    779:   fi
                    780: fi
                    781: 
                    782: # Incorrect #include in Sony News-OS 3.2.
                    783: file=machine/machparam.h
                    784: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    785:   mkdir ${LIB}/machine 2>/dev/null
                    786:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    787:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      788:   chmod a+r ${LIB}/$file 2>/dev/null
1.1.1.2   root      789: fi
                    790: 
                    791: if [ -r ${LIB}/$file ]; then
                    792:   echo Fixing $file, incorrect \#include
                    793:   sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
1.1.1.5 ! root      794:     ${LIB}/$file > ${LIB}/${file}.
        !           795:   rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
1.1.1.2   root      796:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    797:     rm -f ${LIB}/$file
                    798:   fi
                    799: fi
                    800: 
                    801: # Multiline comment after typedef on IRIX 4.0.1.
                    802: file=sys/types.h
                    803: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    804:   mkdir ${LIB}/sys 2>/dev/null
                    805:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    806:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      807:   chmod a+r ${LIB}/$file 2>/dev/null
1.1.1.2   root      808: fi
                    809: 
                    810: if [ -r ${LIB}/$file ]; then
                    811:   echo Fixing $file, comment in the middle of \#ifdef
                    812:   sed -e 's@type of the result@type of the result */@' \
                    813:     -e 's@of the sizeof@/* of the sizeof@' \
                    814:     ${LIB}/$file > ${LIB}/${file}.sed
                    815:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    816:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1.1.1.5 ! root      817:     rm -f ${LIB}/$file
        !           818:   fi
        !           819: fi
        !           820: 
        !           821: # Fix line in IRIX 4.0.1 header file.  The sed script turns
        !           822: # #define EM_CTRL              (CUTIOC|0x1)
        !           823: # into
        !           824: # #define EM_CTRL              (CUTIOC|0x'1')
        !           825: file=sys/t3270reg.h
        !           826: if [ -r ${LIB}/$file ]; then
        !           827:   echo Fixing $file, overeager sed script
        !           828:   sed -e "s/0x'1'/0x1/" ${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
        !           831:     rm -f ${LIB}/$file
        !           832:   fi
        !           833: fi
        !           834: 
        !           835: # Turning // comments into /* */ comments trashes this IRIX 4.0.1
        !           836: # header file, which embeds // comments inside multi-line /* */
        !           837: # comments.  If this looks like the IRIX header file, we refix it by
        !           838: # just throwing away the // comments.
        !           839: file=fam.h
        !           840: if [ -r ${LIB}/$file ]; then
        !           841:   if egrep indigo.esd ${LIB}/$file > /dev/null; then
        !           842:     echo Fixing $file, overeager sed script
        !           843:     rm ${LIB}/$file
        !           844:     sed -e 's|//.*$||g' $file > ${LIB}/$file
        !           845:     chmod +w ${LIB}/$file 2>/dev/null
        !           846:     chmod a+r ${LIB}/$file 2>/dev/null
        !           847:   fi
        !           848: fi
        !           849: 
        !           850: # Another IRIX 4.0.1 header file contains the string "//"
        !           851: file=elf_abi.h
        !           852: if [ -r ${LIB}/$file ]; then
        !           853:   echo Fixing $file, overeager sed script
        !           854:   sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
        !           855:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
        !           856:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1.1       root      857:     rm -f ${LIB}/$file
                    858:   fi
                    859: fi
                    860: 
1.1.1.3   root      861: # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
                    862: # declaration on Sun OS 4.x.  We must only fix this on Sun OS 4.x, because
                    863: # many other systems have similar text but correct versions of the file.
                    864: # To ensure only Sun's is fixed, we grep for a likely unique string.
                    865: file=memory.h
1.1.1.5 ! root      866: if [ -r $file ] && egrep '/\*  @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2   \*/' $file > /dev/null; then
        !           867:   if [ ! -r ${LIB}/$file ]; then
1.1.1.3   root      868:     cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    869:     chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      870:     chmod a+r ${LIB}/$file 2>/dev/null
1.1.1.3   root      871:   fi
                    872:   if [ -r ${LIB}/$file ]; then
                    873:     echo Replacing $file
                    874:     cat > ${LIB}/$file << EOF
                    875: /* This file was generated by fixincludes */
                    876: #ifndef __memory_h__
                    877: #define __memory_h__
                    878: 
                    879: #ifdef __STDC__
                    880: extern void *memccpy();
                    881: extern void *memchr();
                    882: extern void *memcpy();
                    883: extern void *memset();
                    884: #else
                    885: extern char *memccpy();
                    886: extern char *memchr();
                    887: extern char *memcpy();
                    888: extern char *memset();
                    889: #endif /* __STDC__ */
                    890: 
                    891: extern int memcmp();
                    892: 
1.1.1.5 ! root      893: #endif /* __memory_h__ */
1.1.1.3   root      894: EOF
                    895:   fi
                    896: fi
                    897: 
                    898: # parameters not const on DECstation Ultrix V4.0.
                    899: file=stdio.h
                    900: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    901:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    902:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      903:   chmod a+r ${LIB}/$file 2>/dev/null
1.1.1.3   root      904: fi
                    905: 
                    906: if [ -r ${LIB}/$file ]; then
                    907:   echo Fixing $file, non-const arg
                    908:   sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
                    909:       -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
                    910:       -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
                    911:       -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
                    912:       -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
                    913:       -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
                    914:       -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
                    915:     ${LIB}/$file > ${LIB}/${file}.sed
                    916:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    917:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1.1.1.5 ! root      918:     rm -f ${LIB}/$file
        !           919:   fi
        !           920: fi
        !           921: 
        !           922: # parameters conflict with C++ new on rs/6000 
        !           923: file=stdio.h
        !           924: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
        !           925:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
        !           926:   chmod +w ${LIB}/$file 2>/dev/null
        !           927: fi
        !           928: 
        !           929: if [ -r ${LIB}/$file ]; then
        !           930:   echo Fixing $file, parameter name conflicts
        !           931:   sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
        !           932:     ${LIB}/$file > ${LIB}/${file}.sed
        !           933:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
        !           934:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1.1.1.3   root      935:     rm -f ${LIB}/$file
                    936:   fi
                    937: fi
                    938: 
1.1.1.4   root      939: # Don't use or define the name va_list in stdio.h.
                    940: # This is for ANSI and also to interoperate properly with gvarargs.h.
                    941: file=stdio.h
                    942: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    943:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    944:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      945:   chmod a+r ${LIB}/$file 2>/dev/null
1.1.1.4   root      946: fi
                    947: 
                    948: if [ -r ${LIB}/$file ]; then
                    949:   echo Fixing $file, use of va_list
                    950:   # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
                    951:   (echo "#define __need___va_list"
                    952:    echo "#include <stdarg.h>") > ${LIB}/${file}.sed
                    953:   # Use __gnuc_va_list in arg types in place of va_list.
1.1.1.5 ! root      954:   # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
        !           955:   # trailing parentheses and semicolon save all other systems from this.
1.1.1.4   root      956:   # Define __va_list__ (something harmless and unused) instead of va_list.
                    957:   # Don't claim to have defined va_list.
                    958:   sed -e 's@ va_list @ __gnuc_va_list @' \
1.1.1.5 ! root      959:       -e 's@ va_list)@ __gnuc_va_list)@' \
        !           960:       -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1.1.1.4   root      961:       -e 's@ va_list@ __va_list__@' \
                    962:       -e 's@\*va_list@*__va_list__@' \
                    963:       -e 's@VA_LIST@DUMMY_VA_LIST@' \
                    964:     ${LIB}/$file >> ${LIB}/${file}.sed
                    965:   
                    966:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    967:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    968:     rm -f ${LIB}/$file
                    969:   fi
                    970: fi
                    971: 
                    972: # Cancel out ansi_compat.h on Ultrix.  Replace it with empty file.
                    973: file=ansi_compat.h
                    974: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    975:   if grep -s ULTRIX $file; then
                    976:     echo "/* This file intentionally left blank.  */" > $LIB/$file
                    977:   fi
                    978: fi
                    979: 
1.1.1.3   root      980: # parameter to atof not const on DECstation Ultrix V4.0.
1.1.1.4   root      981: # also get rid of bogus inline definitions in HP-UX 8.0
1.1.1.3   root      982: file=math.h
                    983: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
                    984:   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
                    985:   chmod +w ${LIB}/$file 2>/dev/null
1.1.1.5 ! root      986:   chmod a+r ${LIB}/$file 2>/dev/null
1.1.1.3   root      987: fi
                    988: 
                    989: if [ -r ${LIB}/$file ]; then
                    990:   echo Fixing $file, non-const arg
                    991:   sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
1.1.1.4   root      992:       -e 's@inline int abs(int d) { return (d>0)?d:-d; }@@' \
                    993:       -e 's@inline double abs(double d) { return fabs(d); }@@' \
1.1.1.3   root      994:     ${LIB}/$file > ${LIB}/${file}.sed
                    995:   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
                    996:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1.1.1.5 ! root      997:     rm -f ${LIB}/$file
        !           998:   fi
        !           999: fi
        !          1000: 
        !          1001: # In limits.h, put #ifndefs around things that are supposed to be defined
        !          1002: # in float.h to avoid redefinition errors if float.h is included first.
        !          1003: # On HP/UX this patch does not work, because on HP/UX limits.h uses
        !          1004: # multi line comments and the inserted #endif winds up inside the
        !          1005: # comment.  Fortunately, HP/UX already uses #ifndefs in limits.h; if
        !          1006: # we find a #ifndef FLT_MIN we assume that all the required #ifndefs
        !          1007: # are there, and we do not add them ourselves.
        !          1008: file=limits.h
        !          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
        !          1013: fi
        !          1014: 
        !          1015: if [ -r ${LIB}/$file ]; then
        !          1016:   if egrep 'ifndef[    ]+FLT_MIN' ${LIB}/$file >/dev/null; then
        !          1017:     true
        !          1018:   else
        !          1019:     echo Fixing $file
        !          1020:     sed -e '/[         ]FLT_MIN[       ]/i\
        !          1021: #ifndef FLT_MIN'\
        !          1022:         -e '/[         ]FLT_MIN[       ]/a\
        !          1023: #endif'\
        !          1024:         -e '/[         ]FLT_MAX[       ]/i\
        !          1025: #ifndef FLT_MAX'\
        !          1026:         -e '/[         ]FLT_MAX[       ]/a\
        !          1027: #endif'\
        !          1028:         -e '/[         ]FLT_DIG[       ]/i\
        !          1029: #ifndef FLT_DIG'\
        !          1030:         -e '/[         ]FLT_DIG[       ]/a\
        !          1031: #endif'\
        !          1032:         -e '/[         ]DBL_MIN[       ]/i\
        !          1033: #ifndef DBL_MIN'\
        !          1034:         -e '/[         ]DBL_MIN[       ]/a\
        !          1035: #endif'\
        !          1036:         -e '/[         ]DBL_MAX[       ]/i\
        !          1037: #ifndef DBL_MAX'\
        !          1038:         -e '/[         ]DBL_MAX[       ]/a\
        !          1039: #endif'\
        !          1040:         -e '/[         ]DBL_DIG[       ]/i\
        !          1041: #ifndef DBL_DIG'\
        !          1042:         -e '/[         ]DBL_DIG[       ]/a\
        !          1043: #endif'\
        !          1044:       ${LIB}/$file > ${LIB}/${file}.sed
        !          1045:     rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
        !          1046:   fi
        !          1047:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1.1.1.3   root     1048:     echo Deleting ${LIB}/$file\; no fixes were needed.
                   1049:     rm -f ${LIB}/$file
                   1050:   fi
                   1051: fi
                   1052: 
1.1.1.4   root     1053: # These two files on SunOS 4 are included by other files
                   1054: # in the same directory, using "...".  So we must make sure they exist
                   1055: # in the same directory as the other fixed files.
                   1056: if [ -r ${INPUT}/multimedia/audio_errno.h ]
                   1057: then
                   1058:   ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
                   1059: fi
                   1060: if [ -r ${INPUT}/multimedia/audio_hdr.h ]
                   1061: then
                   1062:   ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
                   1063: fi
                   1064: 
1.1.1.5 ! root     1065: # Determine if we're on Interactive Unix 2.2 or later, in which case we
        !          1066: # need to fix some additional files.  This is the same test for ISC that
        !          1067: # Autoconf uses.
        !          1068: if test -d /etc/conf/kconfig.d \
        !          1069:     && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
        !          1070:   echo "Fixing ISC __STDC__ goof in several files..."
        !          1071:   for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
        !          1072:     echo $name
        !          1073:     if test -r ${LIB}/$name; then
        !          1074:       file=${LIB}/$name
        !          1075:     else
        !          1076:       file=${INPUT}/$name
        !          1077:     fi
        !          1078:     # On Interactive 2.2, certain traditional Unix definitions
        !          1079:     # (notably getc and putc in stdio.h) are omitted if __STDC__ is
        !          1080:     # defined, not just if _POSIX_SOURCE is defined.  This makes it
        !          1081:     # impossible to compile any nontrivial program except with -posix.
        !          1082:     sed \
        !          1083: 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
        !          1084:            < $file > ${LIB}/$name.
        !          1085:     mv ${LIB}/$name. ${LIB}/$name
        !          1086:   done
        !          1087:   
        !          1088:   echo "Fixing ISC fmod declaration"
        !          1089:   # This one's already been fixed for other things.
        !          1090:   file=${LIB}/math.h
        !          1091:   sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
        !          1092:   mv $file. $file
        !          1093:   
        !          1094:   echo "Fixing nested comments in ISC <sys/limits.h>"
        !          1095:   file=sys/limits.h
        !          1096:   sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
        !          1097:   sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
        !          1098: fi
        !          1099: 
        !          1100: # These files on Ultrix 4.2 put comments around instances of #endif
        !          1101: # __mips.  When the sed expression turns that into #endif /* __mips */
        !          1102: # the comment ends prematurely.
        !          1103: for file in sys/audit.h sys/signal.h; do
        !          1104:   if [ -r ${LIB}/${file} ]; then
        !          1105:     echo Fixing $file, early comment termination
        !          1106:     sed -e 's|^#endif /\*.*\*/|#endif|g' ${LIB}/${file} > ${LIB}/${file}.sed
        !          1107:     rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
        !          1108:   fi
        !          1109: done
        !          1110: 
1.1       root     1111: echo 'Removing unneeded directories:'
                   1112: cd $LIB
                   1113: files=`find . -type d -print | sort -r`
                   1114: for file in $files; do
                   1115:   rmdir $LIB/$file > /dev/null 2>&1
                   1116: done
                   1117: 
                   1118: if $LINKS; then
                   1119:   echo 'Making internal symbolic non-directory links'
                   1120:   cd ${INPUT}
                   1121:   files=`find . -type l -print`
                   1122:   for file in $files; do
                   1123:     dest=`ls -ld $file | sed -n 's/.*-> //p'`
                   1124:     if expr "$dest" : '[^/].*' > /dev/null; then    
                   1125:       target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
                   1126:       if [ -f $target ]; then
                   1127:         ln -s $dest ${LIB}/$file >/dev/null 2>&1
                   1128:       fi
                   1129:     fi
                   1130:   done
                   1131: fi
                   1132: 
1.1.1.5 ! root     1133: echo 'Cleaning up DONE files.'
        !          1134: cd $LIB
        !          1135: find . -name DONE -exec rm -f {} ';'
        !          1136: 
1.1       root     1137: exit 0

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.