merged tag ooo/DEV300_m102
[LibreOffice.git] / mythes / mythes-1.2.0-vanilla-th-gen-idx.patch
blob776fac46a08efbb6f80ab7b431ede8bb3fc3c061
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
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 +#*************************************************************************
13 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
15 +# Copyright 2000, 2010 Oracle and/or its affiliates.
17 +# OpenOffice.org - a multi-platform office productivity suite
19 +# This file is part of OpenOffice.org.
21 +# OpenOffice.org is free software: you can redistribute it and/or modify
22 +# it under the terms of the GNU Lesser General Public License version 3
23 +# only, as published by the Free Software Foundation.
25 +# OpenOffice.org is distributed in the hope that it will be useful,
26 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
27 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 +# GNU Lesser General Public License version 3 for more details
29 +# (a copy is included in the LICENSE file that accompanied this code).
31 -# typcially invoked as follows:
32 -# cat th_en_US_new.dat | ./th_gen_idx.pl > th_en_US_new.idx
33 +# You should have received a copy of the GNU Lesser General Public License
34 +# version 3 along with OpenOffice.org. If not, see
35 +# <http://www.openoffice.org/license.html>
36 +# for a copy of the LGPLv3 License.
38 +#*************************************************************************
40 sub by_entry {
41 my ($aent, $aoff) = split('\|',$a);
42 @@ -13,6 +34,27 @@ sub by_entry {
43 $aent cmp $bent;
46 +#FIXME: someone may want "infile" or even parameter parsing
47 +sub get_outfile {
48 + my $next_is_file = 0;
49 + foreach ( @ARGV ) {
50 + if ( $next_is_file ) {
51 + return $_
52 + }
53 + if ( $_ eq "-o" ) {
54 + $next_is_file = 1;
55 + }
56 + }
57 + return "";
60 +sub usage {
61 + print "usage:\n";
62 + print "$0 -o outfile < input\n";
64 + exit 99;
67 # main routine
68 my $ne = 0; # number of entries in index
69 my @tindex=(); # the index itself
70 @@ -24,6 +66,10 @@ my $nm=0; # number of meaning fo
71 my $meaning=""; # current meaning and synonyms
72 my $p; # misc uses
73 my $encoding; # encoding used by text file
74 +my $outfile = "";
76 +$outfile = get_outfile();
77 +usage() if ( $outfile eq "" );
79 # top line of thesaurus provides encoding
80 $encoding=<STDIN>;
81 @@ -51,9 +97,13 @@ while ($rec=<STDIN>){
82 # now we have all of the information
83 # so sort it and then output the encoding, count and index data
84 @tindex = sort by_entry @tindex;
85 -print STDOUT "$encoding\n";
86 -print STDOUT "$ne\n";
88 +print "$outfile\n";
89 +open OUTFILE, ">$outfile" or die "ERROR: Can't open $outfile for writing!";
90 +print OUTFILE "$encoding\n";
91 +print OUTFILE "$ne\n";
92 foreach $one (@tindex) {
93 - print STDOUT "$one\n";
94 + print OUTFILE "$one\n";
96 +close OUTFILE;