Reimport of package namazu from japanese/namazu2 into textproc/namazu2.
[pkgsrcv2.git] / textproc / namazu2 / patches / patch-an
1 $NetBSD$
2
3 --- filter/msword.pl.orig       Fri Jul 13 10:14:26 2001
4 +++ filter/msword.pl
5 @@ -25,6 +25,7 @@
6  
7  package msword;
8  use strict;
9 +use File::Basename;
10  use File::Copy;
11  require 'util.pl';
12  require 'gfilter.pl';
13 @@ -33,6 +34,7 @@
14  my $wordconvpath  = undef;
15  my $utfconvpath   = undef;
16  my $wvversionpath = undef;
17 +my $wordconvname = undef;
18  
19  sub mediatype() {
20      return ('application/msword');
21 @@ -80,7 +82,10 @@
22        = @_;
23      my $err = undef;
24   
25 -    if (util::checkcmd('wvHtml')) {
26 +    if (not defined $wordconvname) {
27 +       $wordconvname = basename($wordconvpath);
28 +    }
29 +    if ($wordconvname =~ /wvhtml/i) {
30      $err = filter_wv($orig_cfile, $cont, $weighted_str, $headings, $fields);
31      } else { 
32      $err = filter_doccat($orig_cfile, $cont, $weighted_str, $headings, $fields);
33 @@ -95,7 +100,7 @@
34  
35      my $tmpfile  = util::tmpnam('NMZ.word');
36      my $tmpfile2 = util::tmpnam('NMZ.word2');
37 -
38 +    my ($ofile, $tpath, $options, $version);
39  
40      if (util::islang("ja")) {
41      }
42 @@ -107,8 +112,17 @@
43         print $fh $$cont;
44      }
45  
46 +    $version = `$wordconvpath --version 2>/dev/null`;
47 +    chomp $version;
48 +    if ($version ne "" and $version !~ /usage/i and $version ge "0.7") {
49 +       ($ofile, $tpath) = fileparse($tmpfile2);
50 +       $options = "--targetdir=$tpath";
51 +    } else {
52 +       $ofile = $tmpfile2;
53 +    }
54 +
55      if (!util::islang("ja")) {
56 -       system("$wordconvpath $tmpfile $tmpfile2");
57 +       system("$wordconvpath $options $tmpfile $ofile");
58      } else {
59         my $version = "unknown";
60         my $supported = undef;
61 @@ -125,7 +139,7 @@
62             }
63         }
64         return _("Unsupported format: ") .  $version unless $supported;
65 -       system("$wordconvpath $tmpfile $tmpfile2");
66 +       system("$wordconvpath $options $tmpfile $ofile");
67          system("$utfconvpath -Iu8 -Oej $tmpfile2 > $tmpfile");
68         unlink($tmpfile2);
69         rename($tmpfile, $tmpfile2);