]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/tex2lyx.C
some tabular fixes for the problems reported by Helge
[lyx.git] / src / tex2lyx / tex2lyx.C
index 0c26d02d03f3d69b83f15e6e95114aca0a680c5a..f32fdcca28e7519bff747cddc947801b2a389d25 100644 (file)
 
 #include "debug.h"
 #include "lyxtextclass.h"
+
+#include "support/convert.h"
 #include "support/filetools.h"
+#include "support/fs_extras.h"
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
 #include "support/os.h"
 #include "support/package.h"
 
 #include <boost/function.hpp>
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
 
 #include <cctype>
 #include <fstream>
@@ -50,9 +55,10 @@ using std::map;
 using lyx::support::isStrUnsignedInt;
 using lyx::support::ltrim;
 using lyx::support::rtrim;
-using lyx::support::strToUnsignedInt;
 using lyx::support::IsFileReadable;
-using lyx::support::IsFileWriteable;
+
+namespace fs = boost::filesystem;
+
 
 // Hacks to allow the thing to link in the lyxlayout stuff
 LyXErr lyxerr(std::cerr.rdbuf());
@@ -129,7 +135,7 @@ void add_known_command(string const & command, string const & o1,
        // definition                      o1    o2    invocation result
        // \newcommand{\foo}{bar}          ""    false \foo       bar
        // \newcommand{\foo}[1]{bar #1}    "[1]" false \foo{x}    bar x
-       // \newcommand{\foo}[1][]{bar #1}  "[1]" true  \foo       bar 
+       // \newcommand{\foo}[1][]{bar #1}  "[1]" true  \foo       bar
        // \newcommand{\foo}[1][]{bar #1}  "[1]" true  \foo[x]    bar x
        // \newcommand{\foo}[1][x]{bar #1} "[1]" true  \foo[x]    bar x
        unsigned int nargs = 0;
@@ -137,7 +143,7 @@ void add_known_command(string const & command, string const & o1,
        string const opt1 = rtrim(ltrim(o1, "["), "]");
        if (isStrUnsignedInt(opt1)) {
                // The command has arguments
-               nargs = strToUnsignedInt(opt1);
+               nargs = convert<unsigned int>(opt1);
                if (nargs > 0 && o2) {
                        // The first argument is optional
                        arguments.push_back(optional);
@@ -357,7 +363,7 @@ void tex2lyx(std::istream &is, std::ostream &os)
 
 bool tex2lyx(string const &infilename, string const &outfilename)
 {
-       if (!(IsFileReadable(infilename) && IsFileWriteable(outfilename))) {
+       if (!(IsFileReadable(infilename) && fs::is_writable(outfilename))) {
                return false;
        }
        if (!overwrite_files && IsFileReadable(outfilename)) {
@@ -376,6 +382,8 @@ bool tex2lyx(string const &infilename, string const &outfilename)
 
 int main(int argc, char * argv[])
 {
+       fs::path::default_name_check(fs::no_check);
+
        easyParse(argc, argv);
 
        if (argc <= 1) {
@@ -385,7 +393,8 @@ int main(int argc, char * argv[])
        }
 
        lyx::support::os::init(argc, argv);
-       lyx::support::init_package(argv[0], cl_system_support, cl_user_support);
+       lyx::support::init_package(argv[0], cl_system_support, cl_user_support,
+                                  lyx::support::top_build_dir_is_two_levels_up);
 
        string const system_syntaxfile = lyx::support::LibFileSearch("reLyX", "syntax.default");
        if (system_syntaxfile.empty()) {