From: Georg Baum Date: Mon, 25 Jul 2005 13:49:38 +0000 (+0000) Subject: Allow specification of output filename of tex2lyx X-Git-Tag: 1.6.10~14002 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=8ce79c6fd3fae1794c8b1c50e0dfd221a6a1a6c8;p=features.git Allow specification of output filename of tex2lyx fix tex2lyx invocation in configure.m4 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10353 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/lib/ChangeLog b/lib/ChangeLog index 9f9b58abc1..b8c52bf6f6 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,7 @@ +2005-07-25 Georg Baum + + * configure.m4: fix invocation of tex2lyx again. + 2005-07-19 Jean-Marc Lasgouttes * configure.m4: fi invocation of tex2lyx. diff --git a/lib/configure.m4 b/lib/configure.m4 index f34c9a31a1..c40e0a7123 100644 --- a/lib/configure.m4 +++ b/lib/configure.m4 @@ -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,"` diff --git a/src/tex2lyx/ChangeLog b/src/tex2lyx/ChangeLog index 15442a971c..55b51b3a90 100644 --- a/src/tex2lyx/ChangeLog +++ b/src/tex2lyx/ChangeLog @@ -1,3 +1,7 @@ +2005-07-25 Georg Baum + + * tex2lyx.C (main): allow specification of output file name + 2005-07-18 Lars Gullik Bjønnes * Makefile.am (EXTRA_DIST): add tex2lyx.man diff --git a/src/tex2lyx/tex2lyx.C b/src/tex2lyx/tex2lyx.C index b3d4da3031..29b4bd5d16 100644 --- a/src/tex2lyx/tex2lyx.C +++ b/src/tex2lyx/tex2lyx.C @@ -267,7 +267,7 @@ typedef boost::function cmd_helper; int parse_help(string const &, string const &) { - cerr << "Usage: tex2lyx [ command line switches ] \n" + cerr << "Usage: tex2lyx [ command line switches ] []\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 ] \n" + cerr << "Usage: tex2lyx [ command line switches ] []\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; + } } // }])