Update git submodules
[LibreOffice.git] / external / mythes / mythes-1.2.0-vanilla-th-gen-idx.patch
blob3752e291200e188ff2c5a473ddcbbb4f1c35e3c5
1 --- misc/mythes-1.2.3.orig/th_gen_idx.pl
2 +++ misc/build/mythes-1.2.3/th_gen_idx.pl
3 @@ -1,11 +1,25 @@
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;
12 +# This file is part of the LibreOffice project.
14 +# This Source Code Form is subject to the terms of the Mozilla Public
15 +# License, v. 2.0. If a copy of the MPL was not distributed with this
16 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
18 +# This file incorporates work covered by the following license notice:
20 +# Licensed to the Apache Software Foundation (ASF) under one or more
21 +# contributor license agreements. See the NOTICE file distributed
22 +# with this work for additional information regarding copyright
23 +# ownership. The ASF licenses this file to you under the Apache
24 +# License, Version 2.0 (the "License"); you may not use this file
25 +# except in compliance with the License. You may obtain a copy of
26 +# the License at http://www.apache.org/licenses/LICENSE-2.0 .
29 -# typically invoked as follows:
30 -# cat th_en_US_new.dat | ./th_gen_idx.pl > th_en_US_new.idx
33 sub by_entry {
34 my ($aent, $aoff) = split('\|',$a);
35 @@ -13,6 +34,27 @@ sub by_entry {
36 $aent cmp $bent;
39 +#FIXME: someone may want "infile" or even parameter parsing
40 +sub get_outfile {
41 + my $next_is_file = 0;
42 + foreach ( @ARGV ) {
43 + if ( $next_is_file ) {
44 + return $_
45 + }
46 + if ( $_ eq "-o" ) {
47 + $next_is_file = 1;
48 + }
49 + }
50 + return "";
53 +sub usage {
54 + print "usage:\n";
55 + print "$0 -o outfile < input\n";
57 + exit 99;
60 # main routine
61 my $ne = 0; # number of entries in index
62 my @tindex=(); # the index itself
63 @@ -24,6 +66,10 @@ my $nm=0; # number of meaning fo
64 my $meaning=""; # current meaning and synonyms
65 my $p; # misc uses
66 my $encoding; # encoding used by text file
67 +my $outfile = "";
69 +$outfile = get_outfile();
70 +usage() if ( $outfile eq "" );
72 # top line of thesaurus provides encoding
73 $encoding=<STDIN>;
74 @@ -51,9 +97,13 @@ while ($rec=<STDIN>){
75 # now we have all of the information
76 # so sort it and then output the encoding, count and index data
77 @tindex = sort by_entry @tindex;
78 -print STDOUT "$encoding\n";
79 -print STDOUT "$ne\n";
81 +print "$outfile\n";
82 +open OUTFILE, ">$outfile" or die "ERROR: Can't open $outfile for writing!";
83 +print OUTFILE "$encoding\n";
84 +print OUTFILE "$ne\n";
85 foreach $one (@tindex) {
86 - print STDOUT "$one\n";
87 + print OUTFILE "$one\n";
89 +close OUTFILE;