]> git.lyx.org Git - lyx.git/commitdiff
Allow specification of output filename of tex2lyx
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 25 Jul 2005 13:49:38 +0000 (13:49 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 25 Jul 2005 13:49:38 +0000 (13:49 +0000)
fix tex2lyx invocation in configure.m4

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10353 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ChangeLog
lib/configure.m4
src/tex2lyx/ChangeLog
src/tex2lyx/tex2lyx.C

index 9f9b58abc1af293a20e5f2058e299f4b5a1ec757..b8c52bf6f67de01318f6040ff9c7807c39b597a3 100644 (file)
@@ -1,3 +1,7 @@
+2005-07-25  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * configure.m4: fix invocation of tex2lyx again.
+
 2005-07-19  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * configure.m4: fi invocation of tex2lyx.
index f34c9a31a15d6c6c880a985beca5d33ae5b35e3b..c40e0a712333d54c2fe297747996b0126609b50c 100644 (file)
@@ -260,7 +260,7 @@ SEARCH_PROG([for a raster image editor], RASTERIMAGE_EDITOR, gimp)
 SEARCH_PROG([for a text editor], TEXT_EDITOR, xemacs gvim kedit kwrite kate nedit gedit notepad)
 
 # Search for an installed tex2lyx or a ready-to-install one
-SEARCH_PROG([for a LaTeX -> LyX converter],tex_to_lyx_command, "$PWD/../src/tex2lyx/tex2lyx -f \$\$i >\$\$o" "tex2lyx$version_suffix -f \$\$i >\$\$o")
+SEARCH_PROG([for a LaTeX -> LyX converter],tex_to_lyx_command, "$PWD/../src/tex2lyx/tex2lyx -f \$\$i \$\$o" "tex2lyx$version_suffix -f \$\$i \$\$o")
 
 SEARCH_PROG([for a Noweb -> LyX converter],literate_to_lyx_command,"noweb2lyx \$\$i \$\$o")
 literate_to_lyx_command=`echo $literate_to_lyx_command | sed "s,noweb2lyx,noweb2lyx$version_suffix,"`
index 15442a971c130c296b9274f42a45ad8cff0aaf27..55b51b3a90bc87a1e093cdbf37c39aaed54ba14f 100644 (file)
@@ -1,3 +1,7 @@
+2005-07-25  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * tex2lyx.C (main): allow specification of output file name
+
 2005-07-18  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
        * Makefile.am (EXTRA_DIST): add tex2lyx.man
index b3d4da3031e1df2f74ad911e1e8c4f07a5008b91..29b4bd5d16859eb13fa4fc603bad1ed8cc4bdd3c 100644 (file)
@@ -267,7 +267,7 @@ typedef boost::function<int(string const &, string const &)> cmd_helper;
 
 int parse_help(string const &, string const &)
 {
-       cerr << "Usage: tex2lyx [ command line switches ] <infile.tex>\n"
+       cerr << "Usage: tex2lyx [ command line switches ] <infile.tex> [<outfile.lyx>]\n"
                "Command line switches (case sensitive):\n"
                "\t-help              summarize tex2lyx usage\n"
                "\t-f                 Force creation of .lyx files even if they exist already\n"
@@ -482,7 +482,7 @@ int main(int argc, char * argv[])
        easyParse(argc, argv);
 
        if (argc <= 1) {
-               cerr << "Usage: tex2lyx [ command line switches ] <infile.tex>\n"
+               cerr << "Usage: tex2lyx [ command line switches ] <infile.tex> [<outfile.lyx>]\n"
                          "See tex2lyx -help." << endl;
                return 2;
        }
@@ -491,6 +491,13 @@ int main(int argc, char * argv[])
        lyx::support::init_package(argv[0], cl_system_support, cl_user_support,
                                   lyx::support::top_build_dir_is_two_levels_up);
 
+       // Now every known option is parsed. Look for input and output
+       // file name (the latter is optional).
+       string const infilename = MakeAbsPath(argv[1]);
+       string outfilename;
+       if (argc > 2)
+               outfilename = MakeAbsPath(argv[2]);
+
        string const system_syntaxfile = lyx::support::LibFileSearch("", "syntax.default");
        if (system_syntaxfile.empty()) {
                cerr << "Error: Could not find syntax file \"syntax.default\"." << endl;
@@ -500,14 +507,20 @@ int main(int argc, char * argv[])
        if (!syntaxfile.empty())
                read_syntaxfile(syntaxfile);
 
-       string const infilename = MakeAbsPath(argv[1]);
        masterFilePath = OnlyPath(infilename);
        parentFilePath = masterFilePath;
 
-       if (tex2lyx(infilename, cout))
-               return EXIT_SUCCESS;
-       else
-               return EXIT_FAILURE;
+       if (outfilename.empty() || outfilename == "-") {
+               if (tex2lyx(infilename, cout))
+                       return EXIT_SUCCESS;
+               else
+                       return EXIT_FAILURE;
+       } else {
+               if (tex2lyx(infilename, outfilename))
+                       return EXIT_SUCCESS;
+               else
+                       return EXIT_FAILURE;
+       }
 }
 
 // }])