#
# This code usually gets called by the reLyX wrapper executable
#
-# $Id: reLyXmain.pl,v 1.2 2000/03/29 23:02:36 karger Exp $
+# $Id: reLyXmain.pl,v 1.6 2004/10/28 14:35:19 leeming Exp $
#
require 5.002; # Perl 5.001 doesn't work. Perl 4 REALLY doesn't work.
$dot_lyxdir
$Success
@File_List
+ @Suffix_List
+ $LyXFormat
);
use Cwd; # getcwd etc.
use Getopt::Std; # read in command-line options
if (!defined($lyxname)) {$lyxname = "lyx"}
# there's a use vars in the wrapper, so we only need these if running w/out it
use vars qw($lyxdir $lyxname);
-
+
# variables that a user might want to change
-my @Suffix_List = '\.(ltx|latex|tex)'; # allowed suffixes for LaTeX file
-my $LyXFormat = "2.15"; #What to print in \lyxformat command in .lyx file
+@Suffix_List = '\.(ltx|latex|tex)'; # allowed suffixes for LaTeX file
+$LyXFormat = "2.15"; #What to print in \lyxformat command in .lyx file
my $syntaxname = "syntax.default"; # name of the default syntax file
$dot_lyxdir = $ENV{'HOME'} . "/.$lyxname"; # personal .lyx directory
#
# Print welcome message including version info
-my $version_info = '$Date: 2000/03/29 23:02:36 $'; # RCS puts checkin date here
+my $version_info = '$Date: 2004/10/28 14:35:19 $'; # RCS puts checkin date here
$version_info =~ s&.*?(\d+/\d+/\d+).*&$1&; # take out just the date info
warn "reLyX, the LaTeX to LyX translator. Revision date $version_info\n\n";
-o output all LyX files to directory "outputdir"
Otherwise, LyX file is created in directory the LaTeX file is in
-p translate LaTeX fragments or include files (requires -c)
- I.e., files without \documentclass commands
+ I.e., files without \\documentclass commands
-r give reLyX a (list of) regular environment(s)
-s give reLyX a (list of) additional syntax file(s) to read
# Read personal syntax.default, or system-wide if there isn't a personal one
# Then read other syntax files, given by the -s option
my $default_file = "$dot_lyxdir/reLyX/$syntaxname";
-if (! -e $default_file) {
+if (! -f $default_file) {
$default_file = "$lyxdir/reLyX/$syntaxname";
- die "cannot find default syntax file $default_file" unless -e $default_file;
+ die "cannot find default syntax file $default_file" unless -f $default_file;
}
my @syntaxfiles = ($default_file);
push (@syntaxfiles, (split(/,/,$opt_s))) if defined $opt_s;
#$path .= '/' unless $path =~ /\/$/; # fix BUG in perl5.002 fileparse!
# Try adding .tex to filename if you can't find the file the user input
- unless (-e $File) {
+ unless (-f $File) {
if (! $suffix) { # didn't have a valid suffix. Try adding one
- if (-e "$File.tex") {
+ if (-f "$File.tex") {
$suffix = ".tex";
} else {
warn "\nCan't find input file $File or $File.tex\n";
# Check for files that already exist
my $lname = $PathBase . ".lyx";
if (-e $lname) {
- if ($opt_f) {
+ if (-d $lname) {
+ warn "\nLyX file $lname already exists and is a directory.\n";
+ return @return_error;
+ } elsif ($opt_f) {
warn "Will overwrite file $lname\n" if $opt_d;
} else {
warn "\nLyX file $lname already exists. Use -f to overwrite\n";
my ($basename, $path, $suffix) = fileparse($File, @Suffix_List);
my $realpath = &my_fast_abs_path($path);
# add / at end
- $realpath .= '/' unless $realpath =~ /\/$/;
+ $realpath .= '/' unless $realpath =~ /\/$/;
my $name = "$realpath$basename$suffix";
return $name;
}