]> git.lyx.org Git - lyx.git/blobdiff - src/LayoutFile.cpp
Check return value of regex_match instead of looking at first match
[lyx.git] / src / LayoutFile.cpp
index d0fc248ee9f27cca309387873f5ab54b8a097c6b..ccf2838d119ba2bbbcba9061ebf7a562639ae2cf 100644 (file)
@@ -27,7 +27,6 @@
 #include "support/lassert.h"
 #include "support/lstrings.h"
 
-#include "support/bind.h"
 #include "support/regex.h"
 #include "support/TempFile.h"
 
@@ -44,7 +43,8 @@ LayoutFile::LayoutFile(string const & fn, string const & cln,
                       string const & desc, string const & prereq,
                       string const & category, bool texclassavail) 
 {
-       name_ = fn;
+       name_ = onlyFileName(fn);
+       path_ = fn.rfind('/') == string::npos ? string() : onlyPath(fn);
        latexname_ = cln;
        description_ = desc;
        prerequisites_ = prereq;
@@ -301,9 +301,9 @@ LayoutFileIndex  LayoutFileList::addLocalLayout(
        // which uses the following regex
        //     \Declare(LaTeX|DocBook)Class\s*(\[([^,]*)(,.*)*\])*\s*{(.*)}
        ifstream ifs(layout_file.toFilesystemEncoding().c_str());
-       static regex const reg("^#\\s*\\\\Declare(LaTeX|DocBook)Class\\s*"
+       static regex const reg("^\\s*#\\s*\\\\Declare(LaTeX|DocBook)Class\\s*"
                "(?:\\[([^,]*)(?:,.*)*\\])*\\s*\\{(.*)\\}\\s*");
-       static regex const catreg("^#\\s*\\\\DeclareCategory\\{(.*)\\}");
+       static regex const catreg("^\\s*#\\s*\\\\DeclareCategory\\{(.*)\\}\\s*");
        string line;
        string class_name;
        string class_prereq;
@@ -332,7 +332,8 @@ LayoutFileIndex  LayoutFileList::addLocalLayout(
                return string();
 
        LayoutFile * tmpl =
-               new LayoutFile(textclass, class_name, textclass, class_prereq, category, true);
+               new LayoutFile(addName(moved ? oldpath : path, textclass),
+                       class_name, textclass, class_prereq, category, true);
        //FIXME: The prerequisites are available from the layout file and
        //       can be extracted from the above regex, but for now this
        //       field is simply set to class_name + ".cls"