#!/usr/bin/perl
# ISDK - Information System Development Kit
# Copyright (C) 1998-1999 Szilard Hajba, Peter Vazsonyi
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the Free
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

# Variables:
#	$fml_obj{form}{name}=tag
#	$fml_tbl{form}=table
#	$sql_obj{table}{name}=type

sub parse_ec {
    my ($file)=@_;
    my ($lnum, $ln)=(0);
    open FILE, $file;
    while ($ln=<FILE>) {
	if ($ln =~ /^(\w+\s+.*)\b(\w+)\s*\(/) {
	    push @tags, "$2\t$file\t/^$1$2\\.\\*(/;\"\tf\n";
	} elsif ($ln =~ /^(\@func\s*)(\w+)\s*.*{/) {
	    push @tags, "$2\t$file\t/^$1$2\\.\\*{/;\"\tf\n";
	}
	$lnum++;
    }
    close FILE;
}

if ($ARGV[0] eq '-a') {
    open FILE, "tags";
    @tags=grep {!/^!/} <FILE>;
    close FILE;
    shift;
}
while ($ARGV[0]) {
    parse_ec($ARGV[0]);
    shift;
}

open FILE, ">tags";
print FILE "!_TAG_FILE_FORMAT\t2\t/extended format; --format=1 will not append ;\"\n";
print FILE "!_TAG_FILE_SORTED\t1\t/0=unsorted, 1=sorted/\n";
print FILE "!_TAG_PROGRAM_AUTHOR\tSzilard Hajba  /szilu\@revai.hu/\n";
print FILE "!_TAG_PROGRAM_NAME\tectags\t//\n";
print FILE "!_TAG_PROGRAM_VERSION\t1.99.0\n";
print FILE (sort @tags);
close FILE;
