PageRenderTime 27ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/libreoffice-3.6.0.2/mythes/mythes-1.2.0-vanilla-th-gen-idx.patch

#
Patch | 97 lines | 93 code | 4 blank | 0 comment | 0 complexity | e05e76a6174c782f507fbe0fce18adb4 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.1, AGPL-1.0, BSD-3-Clause-No-Nuclear-License-2014, GPL-3.0, LGPL-3.0
  1. --- misc/mythes-1.2.2.orig/th_gen_idx.pl
  2. +++ misc/build/mythes-1.2.2/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. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  14. +#
  15. +# Copyright 2000, 2010 Oracle and/or its affiliates.
  16. +#
  17. +# OpenOffice.org - a multi-platform office productivity suite
  18. +#
  19. +# This file is part of OpenOffice.org.
  20. +#
  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.
  24. +#
  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).
  30. #
  31. -# typically 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.
  37. #
  38. +#*************************************************************************
  39. sub by_entry {
  40. my ($aent, $aoff) = split('\|',$a);
  41. @@ -13,6 +34,27 @@ sub by_entry {
  42. $aent cmp $bent;
  43. }
  44. +#FIXME: someone may want "infile" or even parameter parsing
  45. +sub get_outfile {
  46. + my $next_is_file = 0;
  47. + foreach ( @ARGV ) {
  48. + if ( $next_is_file ) {
  49. + return $_
  50. + }
  51. + if ( $_ eq "-o" ) {
  52. + $next_is_file = 1;
  53. + }
  54. + }
  55. + return "";
  56. +}
  57. +
  58. +sub usage {
  59. + print "usage:\n";
  60. + print "$0 -o outfile < input\n";
  61. +
  62. + exit 99;
  63. +}
  64. +
  65. # main routine
  66. my $ne = 0; # number of entries in index
  67. my @tindex=(); # the index itself
  68. @@ -24,6 +66,10 @@ my $nm=0; # number of meaning fo
  69. my $meaning=""; # current meaning and synonyms
  70. my $p; # misc uses
  71. my $encoding; # encoding used by text file
  72. +my $outfile = "";
  73. +
  74. +$outfile = get_outfile();
  75. +usage() if ( $outfile eq "" );
  76. # top line of thesaurus provides encoding
  77. $encoding=<STDIN>;
  78. @@ -51,9 +97,13 @@ while ($rec=<STDIN>){
  79. # now we have all of the information
  80. # so sort it and then output the encoding, count and index data
  81. @tindex = sort by_entry @tindex;
  82. -print STDOUT "$encoding\n";
  83. -print STDOUT "$ne\n";
  84. +
  85. +print "$outfile\n";
  86. +open OUTFILE, ">$outfile" or die "ERROR: Can't open $outfile for writing!";
  87. +print OUTFILE "$encoding\n";
  88. +print OUTFILE "$ne\n";
  89. foreach $one (@tindex) {
  90. - print STDOUT "$one\n";
  91. + print OUTFILE "$one\n";
  92. }
  93. +close OUTFILE;