Annotation of gcc/fixincludes, revision 1.1.1.14

1.1.1.2   root        1: #! /bin/sh
1.1       root        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: # This works properly on a Sun in system version 3.4;
                      6: # for other versions, you had better check.
                      7: 
1.1.1.3   root        8: # Directory in which to store the results.
1.1.1.11  root        9: LIB=${LIB-/usr/local/lib/gcc-include}
                     10: 
                     11: # Make sure it exists.
1.1.1.12  root       12: if [ ! -d $LIB ]; then
                     13:   mkdir $LIB || exit 1
                     14: fi
1.1.1.3   root       15: 
1.1.1.10  root       16: # Determine whether this system has symbolic links.
                     17: if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
                     18:   rm -f $LIB/ShouldNotExist
                     19:   LINKS=true
                     20: else
                     21:   LINKS=false
                     22: fi
                     23: 
1.1.1.9   root       24: echo 'Making directories:'
                     25: cd /usr/include
1.1.1.10  root       26: if $LINKS; then
                     27:   files=`ls -LR | sed -n s/:$//p`
                     28: else
1.1.1.12  root       29:   files=`find . -type d -print | sed '/^.$/d'`
1.1.1.10  root       30: fi
1.1.1.9   root       31: for file in $files; do
1.1.1.12  root       32:   rm -rf $LIB/$file
                     33:   if [ ! -d $LIB/$file ]
                     34:   then mkdir $LIB/$file
                     35:   fi
1.1.1.9   root       36: done
1.1.1.6   root       37: 
1.1.1.10  root       38: # treetops gets an alternating list
                     39: # of old directories to copy
                     40: # and the new directories to copy to.
                     41: treetops="/usr/include ${LIB}"
                     42: 
                     43: if $LINKS; then
                     44:   echo 'Making internal symbolic directory links'
                     45:   for file in $files; do
                     46:     dest=`ls -ld $file | sed -n 's/.*-> //p'`
                     47:     if [ "$dest" ]; then    
1.1.1.12  root       48:       cwd=`pwd`
                     49:       # In case $dest is relative, get to $file's dir first.
                     50:       cd /usr/include
                     51:       cd `echo ./$file | sed -n 's&[^/]*$&&p'`
                     52:       # Check that the target directory exists.
                     53:       # Redirections changed to avoid bug in sh on Ultrix.
                     54:       (cd $dest) > /dev/null 2>&1
                     55:       if [ $? = 0 ]; then
                     56:        cd $dest
                     57:        # X gets the dir that the link actually leads to.
                     58:        x=`pwd`
                     59:        # If link leads back into /usr/include,
                     60:        # make a similar link here.
                     61:        if expr $x : '/usr/include/.*' > /dev/null; then
                     62:          # Y gets the actual target dir name, relative to /usr/include.
                     63:          y=`echo $x | sed -n 's&/usr/include/&&p'`
                     64:          echo $file '->' $y ': Making link'
                     65:          rm -fr ${LIB}/$file > /dev/null 2>&1
                     66:          ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
                     67:        else
                     68:          # If the link is to outside /usr/include,
                     69:          # treat this directory as if it actually contained the files.
                     70: # This line used to have $dest instead of $x.
                     71: # $dest seemed to be wrong for links found in subdirectories
                     72: # of /usr/include.  Does this change break anything?
                     73:          treetops="$treetops $x ${LIB}/$file"
                     74:        fi
1.1.1.10  root       75:       fi
1.1.1.12  root       76:       cd $cwd
1.1.1.10  root       77:     fi
                     78:   done
                     79: fi
                     80: 
                     81: set - $treetops
                     82: while [ $# != 0 ]; do
                     83:   # $1 is an old directory to copy, and $2 is the new directory to copy to.
1.1.1.11  root       84:   echo "Finding header files in $1:"
                     85:   cd /usr/include
1.1.1.10  root       86:   cd $1
1.1.1.12  root       87:   files=`find . -name '*.h' -type f -print`
1.1.1.10  root       88:   echo 'Checking header files:'
1.1.1.14! root       89: # Note that BSD43_* are used on recent MIPS systems.
1.1.1.10  root       90:   for file in $files; do
1.1.1.14! root       91:     if egrep '[        ]_IO[A-Z]*\(|[   ]BSD43__IO[A-Z]*\(|#define._IO|#define.BSD43__IO|CTRL' $file > /dev/null; then
1.1.1.10  root       92:       echo Fixing $file
                     93:       if [ -r $file ]; then
                     94:        cp $file $2/$file >/dev/null 2>&1       \
                     95:        || echo "Can't copy $file"
                     96:        chmod +w $2/$file
1.1.1.11  root       97:        sed -e '
                     98:                                   :loop
                     99:          /\\$/                 N
                    100:          /\\$/                 b loop
1.1.1.12  root      101:          /[    ]_IO[A-Z]*[     ]*(/    s/(\(.\),/('\''\1'\'',/
1.1.1.14! root      102:          /[    ]BSD43__IO[A-Z]*[       ]*(/    s/(\(.\),/('\''\1'\'',/
1.1.1.11  root      103:          /#define._IO/         s/'\''x'\''/x/g
1.1.1.14! root      104:          /#define.BSD43__IO/           s/'\''x'\''/x/g
1.1.1.12  root      105:          /[^A-Z]CTRL[  ]*(/    s/\([^'\'']\))/'\''\1'\'')/
1.1.1.11  root      106:          /#define.CTRL/                s/'\''c'\''/c/g
1.1.1.12  root      107:          /#define._CTRL/               s/'\''c'\''/c/g
1.1.1.14! root      108:          /#define.BSD43_CTRL/          s/'\''c'\''/c/g
1.1.1.11  root      109:        ' $2/$file > $2/$file.sed
                    110:        mv $2/$file.sed $2/$file
1.1.1.10  root      111:        if cmp $file $2/$file >/dev/null 2>&1; then
                    112:           echo Deleting $2/$file\; no fixes were needed.
                    113:           rm $2/$file
                    114:        fi
1.1.1.8   root      115:       fi
1.1.1.5   root      116:     fi
1.1.1.10  root      117:   done
                    118:   shift; shift
1.1.1.2   root      119: done
                    120: 
1.1.1.11  root      121: cd /usr/include
                    122: 
1.1.1.5   root      123: # Fix one other error in this file: a mismatched quote not inside a C comment.
                    124: file=sundev/vuid_event.h
                    125: if [ -r $file ]; then
                    126:   if [ ! -r ${LIB}/$file ]; then
                    127:     cp $file ${LIB}/$file >/dev/null 2>&1      \
                    128:     || echo "Can't copy $file"
1.1.1.3   root      129:     chmod +w ${LIB}/$file
1.1.1.2   root      130:   fi
1.1.1.5   root      131: fi
1.1.1.4   root      132: 
1.1.1.12  root      133: if [ -r ${LIB}/$file ]; then
                    134:   echo Fixing $file comment
                    135:   ex ${LIB}/$file <<EOF
1.1.1.11  root      136:   g/doesn't/s/doesn't/does not/
                    137:   wq
                    138: EOF
1.1.1.12  root      139:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    140:     echo Deleting ${LIB}/$file\; no fixes were needed.
                    141:     rm ${LIB}/$file
                    142:   fi
                    143: fi
                    144: 
1.1.1.14! root      145: # Fix this Sun file to avoid intefering with stddef.h.
        !           146: 
        !           147: file=sys/stdtypes.h
        !           148: if [ -r $file ]; then
        !           149:   if [ ! -r ${LIB}/$file ]; then
        !           150:     cp $file ${LIB}/$file >/dev/null 2>&1      \
        !           151:     || echo "Can't copy $file"
        !           152:     chmod +w ${LIB}/$file
        !           153:   fi
        !           154: fi
        !           155: 
        !           156: if [ -r ${LIB}/$file ]; then
        !           157:   echo Fixing $file comment
        !           158:   ex ${LIB}/$file <<EOF
        !           159:   /size_t.*;/
        !           160:   i
        !           161: #ifndef _SIZE_T
        !           162: #define _SIZE_T
        !           163: .
        !           164:   /size_t/+1
        !           165:   i
        !           166: #endif
        !           167: .
        !           168:   /ptrdiff_t.*;/
        !           169:   i
        !           170: #ifndef _PTRDIFF_T
        !           171: #define _PTRDIFF_T
        !           172: .
        !           173:   /ptrdiff_t/+1
        !           174:   i
        !           175: #endif
        !           176: .
        !           177:   /wchar_t.*;/
        !           178:   i
        !           179: #ifndef _WCHAR_T
        !           180: #define _WCHAR_T
        !           181: .
        !           182:   /wchar_t/+1
        !           183:   i
        !           184: #endif
        !           185: .
        !           186:   wq
        !           187: EOF
        !           188:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
        !           189:     echo Deleting ${LIB}/$file\; no fixes were needed.
        !           190:     rm ${LIB}/$file
        !           191:   fi
        !           192: fi
        !           193: 
1.1.1.12  root      194: # Fix an error in this file: a missing semi-colon at the end of the statsswtch
                    195: # structure definition.
                    196: file=rpcsvc/rstat.h
                    197: if [ -r $file ]; then
                    198:   if [ ! -r ${LIB}/$file ]; then
                    199:     cp $file ${LIB}/$file >/dev/null 2>&1      \
                    200:     || echo "Can't copy $file"
                    201:     chmod +w ${LIB}/$file
                    202:   fi
                    203: fi
                    204: 
                    205: if [ -r ${LIB}/$file ]; then
                    206:   echo Fixing $file, definition of statsswtch
                    207:   ex ${LIB}/$file <<EOF
                    208:   g/boottime$/s//&;/
                    209:   wq
                    210: EOF
1.1.1.13  root      211:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    212:     echo Deleting ${LIB}/$file\; no fixes were needed.
                    213:     rm ${LIB}/$file
                    214:   fi
                    215: fi
                    216: 
1.1.1.14! root      217: # Fix an error in this file: a missing semi-colon at the end of the nodeent
        !           218: # structure definition.
        !           219: file=netdnet/dnetdb.h
        !           220: if [ -r $file ]; then
        !           221:   if [ ! -r ${LIB}/$file ]; then
        !           222:     cp $file ${LIB}/$file >/dev/null 2>&1      \
        !           223:     || echo "Can't copy $file"
        !           224:     chmod +w ${LIB}/$file
        !           225:   fi
        !           226: fi
        !           227: 
        !           228: if [ -r ${LIB}/$file ]; then
        !           229:   echo Fixing $file, definition of nodeent
        !           230:   ex ${LIB}/$file <<EOF
        !           231:   g/na_addr/s//&;/
        !           232:   wq
        !           233: EOF
        !           234:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
        !           235:     echo Deleting ${LIB}/$file\; no fixes were needed.
        !           236:     rm ${LIB}/$file
        !           237:   fi
        !           238: fi
        !           239: 
1.1.1.13  root      240: # Check for bad #ifdef line (in Ultrix 4.1)
                    241: 
                    242: file=sys/file.h
                    243: if [ -r $file ]; then
                    244:   if [ ! -r ${LIB}/$file ]; then
                    245:     mkdir ${LIB}/rpcsvc 2>&-
                    246:     cp $file ${LIB}/$file >/dev/null 2>&1      \
                    247:     || echo "Can't copy $file"
                    248:     chmod +w ${LIB}/$file
                    249:   fi
                    250: fi
                    251: 
                    252: if [ -r ${LIB}/$file ]; then
1.1.1.14! root      253:   echo Fixing $file, bad \#ifdef line
1.1.1.13  root      254:   ex ${LIB}/$file <<EOF
                    255:   g/^#ifdef KERNEL && !defined/
                    256:   s/#ifdef KERNEL && !defined/#if defined(KERNEL) \&\& !defined/
                    257:   wq
                    258: EOF
                    259:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    260:     echo Deleting ${LIB}/$file\; no fixes were needed.
                    261:     rm ${LIB}/$file
1.1.1.12  root      262:   fi
1.1.1.11  root      263: fi
                    264: 
1.1.1.14! root      265: # Check for superfluous `static' (in Ultrix 4.2)
        !           266: 
        !           267: file=machine/cpu.h
        !           268: if [ -r $file ]; then
        !           269:   if [ ! -r ${LIB}/$file ]; then
        !           270:     mkdir ${LIB}/machine 2>&-
        !           271:     cp $file ${LIB}/$file >/dev/null 2>&1      \
        !           272:     || echo "Can't copy $file"
        !           273:     chmod +w ${LIB}/$file
        !           274:   fi
        !           275: fi
        !           276: 
        !           277: if [ -r ${LIB}/$file ]; then
        !           278:   echo Fixing $file, superfluous static
        !           279:   ex ${LIB}/$file <<EOF
        !           280:   g/^static struct tlb_pid_state/
        !           281:   s/static//
        !           282:   wq
        !           283: EOF
        !           284:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
        !           285:     echo Deleting ${LIB}/$file\; no fixes were needed.
        !           286:     rm ${LIB}/$file
        !           287:   else
        !           288: # This file has an alternative name, mips/cpu.h.  Fix that name, too.
        !           289:     if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then
        !           290:       mkdir ${LIB}/mips 2>&-
        !           291:       ln ${LIB}/$file ${LIB}/mips/cpu.h 
        !           292:     fi
        !           293:   fi
        !           294: fi
        !           295: 
1.1.1.11  root      296: # Deal with yet another challenge, this in X11/Xmu.h
                    297: file=X11/Xmu.h
                    298: if [ -r $file ]; then
                    299:   if [ ! -r ${LIB}/$file ]; then
                    300:     mkdir ${LIB}/X11 2>&-
                    301:     cp $file ${LIB}/$file >/dev/null 2>&1      \
                    302:     || echo "Can't copy $file"
                    303:     chmod +w ${LIB}/$file
                    304:   fi
                    305: fi
                    306: 
                    307: if [ -r ${LIB}/$file ]; then
                    308:   echo Fixing $file sprintf declaration
                    309:   ex ${LIB}/$file <<EOF
                    310:   /^extern char \*     sprintf();$/c
                    311: #ifndef __STDC__
                    312: extern char *  sprintf();
                    313: #endif /* !defined __STDC__ */
                    314: .
1.1.1.5   root      315:   wq
1.1       root      316: EOF
1.1.1.12  root      317:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
                    318:     echo Deleting ${LIB}/$file\; no fixes were needed.
                    319:     rm ${LIB}/$file
                    320:   fi
                    321: fi
                    322: 
                    323: # Check for missing ';' in struct
                    324: 
                    325: file=netinet/ip.h
                    326: if [ -r $file ]; then
                    327:   if [ ! -r ${LIB}/$file ]; then
                    328:     mkdir ${LIB}/netinet 2>&-
                    329:     sed -e '/^struct/,/^};/s/}$/};/' $file > ${LIB}/$file
                    330:     cmp $file ${LIB}/$file >&- && rm -f ${LIB}/$file
                    331:   fi
                    332: fi
                    333: 
                    334: # Fix the CAT macro in memvar.h.
                    335: 
                    336: file=pixrect/memvar.h
                    337: if [ -r $file ]; then
                    338:   if [ ! -r ${LIB}/$file ]; then
                    339:     mkdir ${LIB}/pixrect 2>&-
                    340:     sed -e '/^#define.CAT(a,b)/ s/IDENT(a)b/a##b/g' $file > ${LIB}/$file
                    341:     cmp $file ${LIB}/$file >&- && rm -f ${LIB}/$file
                    342:   fi
                    343: fi
                    344: 
                    345: # Check for yet more missing ';' in struct (in SunOS 4.0.x)
                    346: 
                    347: file=rpcsvc/rusers.h
                    348: if [ -r $file ]; then
                    349:   if [ ! -r ${LIB}/$file ]; then
                    350:     mkdir ${LIB}/rpcsvc 2>&-
                    351:     sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' $file > ${LIB}/$file
                    352:     cmp $file ${LIB}/$file >&- && rm -f ${LIB}/$file
                    353:   fi
                    354: fi
                    355: 
1.1.1.10  root      356: echo 'Removing unneeded directories:'
                    357: cd $LIB
                    358: files=`find . -type d -print | sort -r`
                    359: for file in $files; do
                    360:   rmdir $LIB/$file > /dev/null 2>&1
                    361: done
                    362: 
1.1.1.11  root      363: if $LINKS; then
                    364:   echo 'Making internal symbolic non-directory links'
                    365:   cd /usr/include
                    366:   files=`find . -type l -print`
                    367:   for file in $files; do
                    368:     dest=`ls -ld $file | sed -n 's/.*-> //p'`
                    369:     if expr "$dest" : '[^/].*' > /dev/null; then    
                    370:       target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
                    371:       if [ -f $target ]; then
                    372:         ln -s $dest ${LIB}/$file >/dev/null 2>&1
                    373:       fi
                    374:     fi
                    375:   done
                    376: fi
                    377: 
                    378: exit 0

unix.superglobalmegacorp.com

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