Do less indenting.

This commit is contained in:
Richard Heck 2013-04-11 21:41:52 -04:00
parent b447587aa9
commit 0c61991c9a

View File

@ -273,62 +273,62 @@ LayoutFileIndex LayoutFileList::addLocalLayout(
string fullName = addName(path, textclass + ".layout"); string fullName = addName(path, textclass + ".layout");
FileName const layout_file(fullName); FileName const layout_file(fullName);
if (layout_file.exists()) { if (!layout_file.exists())
LYXERR(Debug::TCLASS, "Adding class " << textclass << " from directory " << path); return string();
// Read .layout file and get description, real latex classname etc
// LYXERR(Debug::TCLASS, "Adding class " << textclass << " from directory " << path);
// This is a C++ version of function processLayoutFile in configure.py, // Read .layout file and get description, real latex classname etc
// which uses the following regex //
// \Declare(LaTeX|DocBook)Class\s*(\[([^,]*)(,.*)*\])*\s*{(.*)} // This is a C++ version of function processLayoutFile in configure.py,
ifstream ifs(layout_file.toFilesystemEncoding().c_str()); // which uses the following regex
static regex const reg("^#\\s*\\\\Declare(LaTeX|DocBook)Class\\s*" // \Declare(LaTeX|DocBook)Class\s*(\[([^,]*)(,.*)*\])*\s*{(.*)}
"(?:\\[([^,]*)(?:,.*)*\\])*\\s*\\{(.*)\\}\\s*"); ifstream ifs(layout_file.toFilesystemEncoding().c_str());
static regex const catreg("^#\\s*\\\\DeclareCategory\\{(.*)\\}"); static regex const reg("^#\\s*\\\\Declare(LaTeX|DocBook)Class\\s*"
string line; "(?:\\[([^,]*)(?:,.*)*\\])*\\s*\\{(.*)\\}\\s*");
string class_name; static regex const catreg("^#\\s*\\\\DeclareCategory\\{(.*)\\}");
string class_prereq; string line;
string category; string class_name;
bool have_declaration = false; string class_prereq;
while (getline(ifs, line)) { string category;
// look for the \DeclareXXXClass line bool have_declaration = false;
smatch sub; while (getline(ifs, line)) {
if (regex_match(line, sub, reg)) { // look for the \DeclareXXXClass line
// returns: whole string, classtype (not used here), class name, description smatch sub;
LASSERT(sub.size() == 4, /**/); if (regex_match(line, sub, reg)) {
// now, create a TextClass with description containing path information // returns: whole string, classtype (not used here), class name, description
class_name = (sub.str(2) == "" ? textclass : sub.str(2)); LASSERT(sub.size() == 4, /**/);
class_prereq = class_name + ".cls"; // now, create a TextClass with description containing path information
have_declaration = true; class_name = (sub.str(2) == "" ? textclass : sub.str(2));
} class_prereq = class_name + ".cls";
else if (regex_match(line, sub, catreg)) { have_declaration = true;
category = sub.str(1);
}
if (have_declaration && !category.empty())
break;
} }
if (have_declaration) { else if (regex_match(line, sub, catreg)) {
LayoutFile * tmpl = category = sub.str(1);
new LayoutFile(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"
// This textclass is added on request so it will definitely be
// used. Load it now because other load() calls may fail if they
// are called in a context without buffer path information.
tmpl->load(path);
// There will be only one textclass with this name, even if different
// layout files are loaded from different directories.
if (haveClass(textclass)) {
LYXERR0("Existing textclass " << textclass << " is redefined by " << fullName);
delete classmap_[textclass];
}
classmap_[textclass] = tmpl;
return textclass;
} }
if (have_declaration && !category.empty())
break;
} }
// If .layout is not in local directory, or an invalid layout
// is found, return null if (!have_declaration)
return string(); return string();
LayoutFile * tmpl =
new LayoutFile(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"
// This textclass is added on request so it will definitely be
// used. Load it now because other load() calls may fail if they
// are called in a context without buffer path information.
tmpl->load(path);
// There will be only one textclass with this name, even if different
// layout files are loaded from different directories.
if (haveClass(textclass)) {
LYXERR0("Existing textclass " << textclass << " is redefined by " << fullName);
delete classmap_[textclass];
}
classmap_[textclass] = tmpl;
return textclass;
} }