#include <config.h>
-
#include "tex_helpers.h"
#include "debug.h"
#include "support/path.h"
#include "support/lyxalgo.h"
+#include <boost/cregex.hpp>
#include <vector>
#include <fstream>
#include <algorithm>
+using namespace lyx::support;
+
using std::vector;
using std::endl;
using std::sort;
extern string user_lyxdir; // home of *Files.lst
-namespace {
-
-vector<string> listWithoutPath(vector<string> & dbase)
-{
- vector<string>::iterator it = dbase.begin();
- vector<string>::iterator end = dbase.end();
- for (; it != end; ++it)
- *it = OnlyFilename(*it);
- return dbase;
-}
-
-} // namespace anon
// build filelists of all availabe bst/cls/sty-files. done through
// kpsewhich and an external script, saved in *Files.lst
}
-string const getTexFileList(string const & filename, bool withFullPath)
+void getTexFileList(string const & filename, std::vector<string> & list)
{
+ list.clear();
string const file = LibFileSearch("", filename);
if (file.empty())
- return string();
+ return;
- vector<string> dbase =
- getVectorFromString(GetFileContents(file), "\n");
+ list = getVectorFromString(GetFileContents(file), "\n");
- if (withFullPath) {
- lyx::eliminate_duplicates(dbase);
- string const str_out =
- getStringFromVector(dbase, "\n");
- return str_out;
+ // Normalise paths like /foo//bar ==> /foo/bar
+ boost::RegEx regex("/{2,}");
+ std::vector<string>::iterator it = list.begin();
+ std::vector<string>::iterator end = list.end();
+ for (; it != end; ++it) {
+ *it = STRCONV(regex.Merge(STRCONV((*it)), "/"));
}
- vector<string> dbaseWP = listWithoutPath(dbase);
- lyx::eliminate_duplicates(dbaseWP);
- string const str_out =
- getStringFromVector(dbaseWP, "\n");
- return str_out;
+
+ lyx::eliminate_duplicates(list);
}
string optionList = string();
std::ifstream is(filename.c_str());
while (is) {
- string s;
- is >> s;
- if (contains(s,"DeclareOption")) {
- s = s.substr(s.find("DeclareOption"));
- s = split(s,'{'); // cut front
- s = token(s,'}',0); // cut end
- optionList += (s + '\n');
- }
+ string s;
+ is >> s;
+ if (contains(s,"DeclareOption")) {
+ s = s.substr(s.find("DeclareOption"));
+ s = split(s,'{'); // cut front
+ s = token(s,'}',0); // cut end
+ optionList += (s + '\n');
+ }
}
return optionList;
}