#!/bin/sh
#
# SUMMARY:      Build feature tags for default C construct classes.
# USAGE:        <script-name> <etags-program> <tags-file-to-build> <root-dir-to-search> [... <root-dir-to-search>]
#
# AUTHOR:       Bob Weiner
# ORG:          InfoDock Associates
#
# ORIG-DATE:     3-May-95 at 10:39:37
# LAST-MOD:     21-Feb-97 at 17:39:07 by Bob Weiner
#
# DESCRIPTION:  
# DESCRIP-END.

# A claim has been made that under NT, one must remove the -h option from the
# following call, but it is unclear to the author of this script how the
# script will then work properly, although once again, the claim is made that
# it does.  
EGREP=\egrep -h

etags=$1
tags_file=$2
shift 2
\find $* -name SCCS -prune -o -name RCS -prune \
   -o -name "*.[mchMCH]" -print -o -name "*.[chCH][chpCHP]" -print \
   -o -name "*.[chCH][chpCHPx][pPx]" -print | ${etags} - -o- | tr '\014' '@' \
  | $EGREP '^[^ 	]*\.[^ 	]*$|@|^(#define|struct|union|typedef|enum)[ \t]' \
  | tr '@\177\001' '\014@@' \
  | sed -e 's/^\([^ 	\n][^ 	\n]*\)\([^@]*\)@\([^@]*\)@.*/\1^^- \3^^\1\2/' \
        -e 's/^\(\([^ 	\n][^ 	\n]*\)[^@]*[ 	][*&]*\([^ 	\n(){};&*][^ 	\n(){};&*]*\).*\)@.*/\2^^- \3^^\1/' \
        -e 's/@.*//' -e 's/,[0-9][0-9]*//' -e 's/\^\^/@/g' \
        -e 's/^\(#define\)\(@.*(\)/[macro]\2/' -e 's/^#define/[constant]/' \
        -e 's/^enum/[enumeration]/' -e 's/^struct/[structure]/' \
        -e 's/^typedef/[type]/' -e 's/^union/[union]/' \
    > $tags_file

