head	1.1;
branch	1.1.1;
access;
symbols
	RELENG_9_1_0_RELEASE:1.1.1.2
	RELENG_9_1:1.1.1.2.0.48
	RELENG_9_1_BP:1.1.1.2
	RELENG_8_3_0_RELEASE:1.1.1.2
	RELENG_8_3:1.1.1.2.0.46
	RELENG_8_3_BP:1.1.1.2
	RELENG_9_0_0_RELEASE:1.1.1.2
	RELENG_9_0:1.1.1.2.0.44
	RELENG_9_0_BP:1.1.1.2
	RELENG_9:1.1.1.2.0.42
	RELENG_9_BP:1.1.1.2
	RELENG_7_4_0_RELEASE:1.1.1.2
	RELENG_8_2_0_RELEASE:1.1.1.2
	RELENG_7_4:1.1.1.2.0.40
	RELENG_7_4_BP:1.1.1.2
	RELENG_8_2:1.1.1.2.0.38
	RELENG_8_2_BP:1.1.1.2
	RELENG_8_1_0_RELEASE:1.1.1.2
	RELENG_8_1:1.1.1.2.0.36
	RELENG_8_1_BP:1.1.1.2
	RELENG_7_3_0_RELEASE:1.1.1.2
	RELENG_7_3:1.1.1.2.0.34
	RELENG_7_3_BP:1.1.1.2
	RELENG_8_0_0_RELEASE:1.1.1.2
	RELENG_8_0:1.1.1.2.0.32
	RELENG_8_0_BP:1.1.1.2
	RELENG_8:1.1.1.2.0.30
	RELENG_8_BP:1.1.1.2
	RELENG_7_2_0_RELEASE:1.1.1.2
	RELENG_7_2:1.1.1.2.0.28
	RELENG_7_2_BP:1.1.1.2
	RELENG_7_1_0_RELEASE:1.1.1.2
	RELENG_6_4_0_RELEASE:1.1.1.2
	RELENG_7_1:1.1.1.2.0.26
	RELENG_7_1_BP:1.1.1.2
	RELENG_6_4:1.1.1.2.0.24
	RELENG_6_4_BP:1.1.1.2
	RELENG_7_0_0_RELEASE:1.1.1.2
	RELENG_6_3_0_RELEASE:1.1.1.2
	RELENG_7_0:1.1.1.2.0.22
	RELENG_7_0_BP:1.1.1.2
	RELENG_6_3:1.1.1.2.0.20
	RELENG_6_3_BP:1.1.1.2
	RELENG_7:1.1.1.2.0.18
	RELENG_7_BP:1.1.1.2
	RELENG_6_2_0_RELEASE:1.1.1.2
	RELENG_6_2:1.1.1.2.0.16
	RELENG_6_2_BP:1.1.1.2
	RELENG_5_5_0_RELEASE:1.1.1.2
	RELENG_5_5:1.1.1.2.0.14
	RELENG_5_5_BP:1.1.1.2
	RELENG_6_1_0_RELEASE:1.1.1.2
	RELENG_6_1:1.1.1.2.0.12
	RELENG_6_1_BP:1.1.1.2
	RELENG_6_0_0_RELEASE:1.1.1.2
	RELENG_6_0:1.1.1.2.0.10
	RELENG_6_0_BP:1.1.1.2
	RELENG_6:1.1.1.2.0.8
	RELENG_6_BP:1.1.1.2
	RELENG_5_4_0_RELEASE:1.1.1.2
	RELENG_5_4:1.1.1.2.0.6
	RELENG_5_4_BP:1.1.1.2
	RELENG_5_3_0_RELEASE:1.1.1.2
	RELENG_5_3:1.1.1.2.0.4
	RELENG_5_3_BP:1.1.1.2
	RELENG_5:1.1.1.2.0.2
	RELENG_5_BP:1.1.1.2
	RELENG_5_2_1_RELEASE:1.1.1.1
	RELENG_5_2_0_RELEASE:1.1.1.1
	RELENG_5_2:1.1.1.1.0.6
	RELENG_5_2_BP:1.1.1.1
	RELENG_5_1_0_RELEASE:1.1.1.1
	RELENG_5_1:1.1.1.1.0.4
	RELENG_5_1_BP:1.1.1.1
	gcc_3_2_2_20030205:1.1.1.1
	RELENG_5_0_0_RELEASE:1.1.1.1
	RELENG_5_0:1.1.1.1.0.2
	RELENG_5_0_BP:1.1.1.1
	gcc_3_2_1:1.1.1.1
	BEFORE_GCC_3_2_1:1.1.1.1
	gcc_3_2_anoncvs_20021009:1.1.1.1
	gcc_3_2_anoncvs_20020916:1.1.1.1
	gcc_3_2_anoncvs_20020901:1.1.1.1
	gcc_3_1_anoncvs_20020509:1.1.1.1
	FSF:1.1.1;
locks; strict;
comment	@# @;


1.1
date	2002.05.28.16.15.49;	author obrien;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2002.05.28.16.15.49;	author obrien;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	2004.01.05.21.04.33;	author kan;	state dead;
branches;
next	;


desc
@@


1.1
log
@Initial revision
@
text
@#!/usr/bin/env bash
#
# usage: inclosure [ -I dir ] ... [ -G header-name ] ... header-name ...
#
# Locates each standard header and argument header-name in the
# specified "-I" include path (default is /usr/include) and parses 
# any header names out of its #include directives.  These names are 
# treated recursively to identify a _transitive_closure_ of standard
# header names, which is sorted and sent to standard output.  Headers 
# not specified with -G, and included somewhere but not located are 
# reported.
#
# Each header reported by this program must be "shadowed" by a 
# file of the same name in a C++ header.  See 
#   http://www.cantrip.org/cheaders.html
#
# BUGS: 
#  - Cannot cope with header file names that contain spaces
#  - Ignores comment-block delimiters
#  - Ignores sub-includes under #include_next headers.

OLDH=/tmp/old$$
echo "this-compensates-for-a-stupid-bug-in-GNU-fgrep." >$OLDH
HDRS=/tmp/hdrs$$
>$HDRS
NEW=/tmp/new$$
>$NEW
IGNORES=/tmp/ignores$$
echo "this-compensates-for-a-stupid-bug-in-GNU-fgrep.">$IGNORES

trap "rm -f $NEW $HDRS $OLDH $IGNORES" 0

# process arguments
unset INCPATH
while [ $# != 0 -a "$1" != "${1#-}" ]; do
  FLAG="${1%%${1##-?}}"
  case "$FLAG" in -I|-G)
    ARG="${1##${FLAG}}"
    if [ "$ARG" = "" ]; then
      if [ $# != 0 ]; then 
        shift;
        ARG="$1"
      else
        echo "$0: $FLAG needs an argument."
	exit
      fi
    fi ;;
  esac
  shift
  case "$FLAG" in 
    -I) INCPATH="$INCPATH $ARG" ;;
    -G) echo " $ARG " >>$IGNORES ;;
  esac
done
INCPATH=${INCPATH-"/usr/include"}  

# identify headers

STDHDRS="assert.h ctype.h errno.h float.h limits.h \
 locale.h math.h setjmp.h signal.h stdarg.h stddef.h \
 stdio.h stdlib.h string.h time.h wchar.h wctype.h "
OTHERS="$*"

for file in $STDHDRS $OTHERS; do
  echo "$file" 
done >$HDRS

until cmp -s $OLDH $HDRS; do #  (until no new headers found)

  fgrep -v -f $OLDH $HDRS \
  | while read file; do
    found=no
    for dir in $INCPATH; do 
      name="$dir/$file"
      if [ -f "$name" ]; then 
        cat "$name"
	found=yes
        break;
      fi
    done
    if [ "$found" = no ]; then # && echo " $file " | fgrep -v -q -f $IGNORES 
      echo "$0: warning: header $file not found in include path." $1>&2
    fi
  done \
  | sed -n -e \
'/^[ 	]*#[ 	]*include[ 	]*<[^>]*>/s/^[^<]*<\([^>]*\)>.*/\1/p' \
  | while read file; do
     drop=no
     for ignore in `cat $IGNORES`; do
       if [ "$ignore" = "$file" ]; then drop=yes; fi
     done
     case "$file" in /*) drop=yes;; esac   # no absolute paths
     case $drop in no) echo "$file";; esac
  done >$NEW
  mv $HDRS $OLDH
  cat $OLDH $NEW | sort -u -o $HDRS

done
cat $HDRS



@


1.1.1.1
log
@Gcc 3.1.0 pre-release's C++ support bits from the FSF anoncvs repo
on 9-May-2002 15:57:15 EDT.
@
text
@@


1.1.1.2
log
@Remove bits which are not part of GCC 3.3.x anymore.
@
text
@@

