The R Project SVN R

Rev

Rev 21786 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 21786 Rev 25447
Line 1... Line 1...
1
### $Id: pkg2tex.pl,v 1.3 2002/11/03 17:32:29 hornik Exp $
1
### $Id: pkg2tex.pl,v 1.4 2003/07/29 10:35:13 ripley Exp $
2
 
2
 
3
## Create a single pkgname-pkg.tex file from the Latex subdirectories
3
## Create a single pkgname-pkg.tex file from the Latex subdirectories
4
## Copyright (C) 1998 Douglas M. Bates <bates@stat.wisc.edu>
4
## Copyright (C) 1998 Douglas M. Bates <bates@stat.wisc.edu>
5
 
5
 
6
## This file is free software; you can redistribute it and/or modify
6
## This file is free software; you can redistribute it and/or modify
Line 26... Line 26...
26
 
26
 
27
use strict;
27
use strict;
28
use FileHandle;
28
use FileHandle;
29
use Carp;
29
use Carp;
30
use Getopt::Long;
30
use Getopt::Long;
-
 
31
use R::Utils;
31
 
32
 
32
my $help;
33
my $help;
33
 
34
 
34
my $revision = ' $Revision: 1.3 $ ';
35
my $revision = ' $Revision: 1.4 $ ';
35
my $version;
36
my $version;
36
my $name;
37
my $name;
37
 
38
 
38
($name = $0) =~ s|.*/||;
39
($name = $0) =~ s|.*/||;
39
$revision =~ / ([\d\.]*) /;
40
$revision =~ / ([\d\.]*) /;
Line 53... Line 54...
53
 
54
 
54
for (@ARGV) {
55
for (@ARGV) {
55
    my $latexDir = $RLIB . "/" . $_ . "/latex/";
56
    my $latexDir = $RLIB . "/" . $_ . "/latex/";
56
    carp "latex subdirectory for library $_ does not exist!\n", next
57
    carp "latex subdirectory for library $_ does not exist!\n", next
57
	unless -d $latexDir;
58
	unless -d $latexDir;
-
 
59
    my $was_zipped = 0;
-
 
60
    if(-f $latexDir . "Rhelp.zip") {
-
 
61
	$was_zipped = 1;
-
 
62
	my $cmd = "cd $latexDir; unzip -qo Rhelp.zip";
-
 
63
	croak "Cannot unzip latex files\n" if R_system($cmd);
-
 
64
    }
58
    my $out = new FileHandle "> " . $_ . "-pkg.tex" or
65
    my $out = new FileHandle "> " . $_ . "-pkg.tex" or
59
	croak "unable to open file $_-pkg.tex: $!\n";
66
	croak "unable to open file $_-pkg.tex: $!\n";
60
    &do_header($_, $out);
67
    &do_header($_, $out);
61
    &do_tex_files($latexDir, $out);
68
    &do_tex_files($latexDir, $out);
62
    &do_trailer($out);
69
    &do_trailer($out);
63
    $out->close;
70
    $out->close;
-
 
71
    if($was_zipped) {
-
 
72
	croak "Removing unzipped latex files failed.\n" if
-
 
73
	    R_system("rm -f $latexDir*.tex");
-
 
74
    }
64
}
75
}
65
 
76
 
66
sub do_header {
77
sub do_header {
67
    my( $pkgname, $outfile ) = @_;
78
    my( $pkgname, $outfile ) = @_;
68
    $outfile->print("\n\\chapter\{The \\texttt\{$pkgname\} package\}\n");
79
    $outfile->print("\n\\chapter\{The \\texttt\{$pkgname\} package\}\n");