1--- misc/mythes-1.2.0.orig/th_gen_idx.pl 2+++ misc/build/mythes-1.2.0/th_gen_idx.pl 3@@ -1,11 +1,32 @@ 4-#!/usr/bin/perl 5- 6-# perl program to take a thesaurus structured text data file 7-# and create the proper sorted index file (.idx) 8+: 9+eval 'exec perl -wS $0 ${1+"$@"}' 10+ if 0; 11+#************************************************************** 12+# 13+# Licensed to the Apache Software Foundation (ASF) under one 14+# or more contributor license agreements. See the NOTICE file 15+# distributed with this work for additional information 16+# regarding copyright ownership. The ASF licenses this file 17+# to you under the Apache License, Version 2.0 (the 18+# "License"); you may not use this file except in compliance 19+# with the License. You may obtain a copy of the License at 20+# 21+# http://www.apache.org/licenses/LICENSE-2.0 22+# 23+# Unless required by applicable law or agreed to in writing, 24+# software distributed under the License is distributed on an 25+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 26+# KIND, either express or implied. See the License for the 27+# specific language governing permissions and limitations 28+# under the License. 29+# 30+#************************************************************** 31 32 sub by_entry { 33 my ($aent, $aoff) = split('\|',$a); 34@@ -13,6 +34,27 @@ sub by_entry { 35 $aent cmp $bent; 36 } 37 38+#FIXME: someone may want "infile" or even parameter parsing 39+sub get_outfile { 40+ my $next_is_file = 0; 41+ foreach ( @ARGV ) { 42+ if ( $next_is_file ) { 43+ return $_ 44+ } 45+ if ( $_ eq "-o" ) { 46+ $next_is_file = 1; 47+ } 48+ } 49+ return ""; 50+} 51+ 52+sub usage { 53+ print "usage:\n"; 54+ print "$0 -o outfile < input\n"; 55+ 56+ exit 99; 57+} 58+ 59 # main routine 60 my $ne = 0; # number of entries in index 61 my @tindex=(); # the index itself 62@@ -24,6 +66,10 @@ my $nm=0; # number of meaning fo 63 my $meaning=""; # current meaning and synonyms 64 my $p; # misc uses 65 my $encoding; # encoding used by text file 66+my $outfile = ""; 67+ 68+$outfile = get_outfile(); 69+usage() if ( $outfile eq "" ); 70 71 # top line of thesaurus provides encoding 72 $encoding=<STDIN>; 73@@ -51,9 +97,13 @@ while ($rec=<STDIN>){ 74 # now we have all of the information 75 # so sort it and then output the encoding, count and index data 76 @tindex = sort by_entry @tindex; 77-print STDOUT "$encoding\n"; 78-print STDOUT "$ne\n"; 79+ 80+print "$outfile\n"; 81+open OUTFILE, ">$outfile" or die "ERROR: Can't open $outfile for writing!"; 82+print OUTFILE "$encoding\n"; 83+print OUTFILE "$ne\n"; 84 foreach $one (@tindex) { 85- print STDOUT "$one\n"; 86+ print OUTFILE "$one\n"; 87 } 88+close OUTFILE; 89 90