#!/usr/athena/bin/perl
###############################################################################
#
# File:         makeoffsets
# RCS:          $Header: $
# Description:  
# Author:       Darryl Okahata
# Created:      Tue Dec 17 15:26:46 1991
# Modified:     Wed Dec 18 16:47:49 1991 (Darryl Okahata) darrylo@hpsrdmo
# Language:     Perl
# Package:      N/A
#
###############################################################################

$thesaurus = "roget.txt";
$index_file = "offsets";

###############################################################################
require 'getopts.pl' || die "can't `require 'getopts.pl''";

&Getopts('v');

$location = 0;

open (INPUT, "<$thesaurus") || die "Can't open \"$thesaurus\": $!\n";

dbmopen(%indices, "$index_file", 0644) ||
    die "Can't open \"$thesaurus\": $!\n";

$phase = 0;
while (<INPUT>) {
    if ($phase == 0) {
	if (/^[ \t]*\#([0-9]+)\./oi) {
	    $index = $1;
	    $indices{$index} = $location;
	    print "$index $location\n" if ($opt_v);
	    $phase = 1;
	}
    } elsif ($phase == 1) {
	if (/^[ \t]*$/o) {
	    $phase = 0;
	}
    }
    $location = tell(INPUT);
}

dbmclose(%indices) || die "$!";

exit (0);


#
# Local Variables:
# mode: perl
# perl-indent-level:			 4
# perl-continued-statement-offset:	 4
# perl-continued-brace-offset:		 0
# perl-brace-offset:			-4
# perl-brace-imaginary-offset:		 0
# perl-label-offset:			-4
# End:
#
