#include "qt_helpers.h"
+#include "FileDialog.h"
#include "LengthCombo.h"
-#include "debug.h"
-#include "gettext.h"
+#include "frontends/alert.h"
+
#include "Language.h"
#include "Length.h"
-#include "frontends/FileDialog.h"
-#include "frontends/alert.h"
-
+#include "support/debug.h"
#include "support/filetools.h"
+#include "support/gettext.h"
#include "support/lstrings.h"
#include "support/lyxalgo.h"
#include "support/os.h"
#include <algorithm>
#include <fstream>
+#include <locale>
-using std::string;
-using std::vector;
-using std::endl;
+using namespace std;
+using namespace lyx::support;
namespace lyx {
-
-using support::addName;
-using support::bformat;
-using support::FileFilterList;
-using support::FileName;
-using support::getExtension;
-using support::getVectorFromString;
-using support::libFileSearch;
-using support::makeAbsPath;
-using support::makeRelPath;
-using support::onlyFilename;
-using support::onlyPath;
-using support::package;
-using support::prefixIs;
-using support::quoteName;
-using support::removeExtension;
-using support::Systemcall;
-using support::token;
-using support::isStrDbl;
-
namespace frontend {
string widgetsToLength(QLineEdit const * input, LengthCombo const * combo)
namespace {
-struct Sorter
+class Sorter
{
+public:
+#if !defined(USE_WCHAR_T) && defined(__GNUC__)
bool operator()(LanguagePair const & lhs, LanguagePair const & rhs) const {
return lhs.first < rhs.first;
}
+#else
+ Sorter() : loc_ok(true)
+ {
+ try {
+ loc_ = locale("");
+ } catch (...) {
+ loc_ok = false;
+ }
+ };
+
+ bool operator()(LanguagePair const & lhs,
+ LanguagePair const & rhs) const {
+ if (loc_ok)
+ return loc_(lhs.first, rhs.first);
+ else
+ return lhs.first < rhs.first;
+ }
+private:
+ locale loc_;
+ bool loc_ok;
+#endif
};
vector<LanguagePair> const getLanguageData(bool character_dlg)
{
- vector<LanguagePair>::size_type const size = character_dlg ?
- languages.size() + 2 : languages.size();
+ size_t const size = languages.size() + (character_dlg ? 2 : 0);
vector<LanguagePair> langs(size);
langs[1].second = "reset";
}
- vector<string>::size_type i = character_dlg ? 2 : 0;
+ size_t i = character_dlg ? 2 : 0;
for (Languages::const_iterator cit = languages.begin();
cit != languages.end(); ++cit) {
langs[i].first = _(cit->second.display());
vector<LanguagePair>::iterator begin = character_dlg ?
langs.begin() + 2 : langs.begin();
- std::sort(begin, langs.end(), Sorter());
+ sort(begin, langs.end(), Sorter());
return langs;
}
void rescanTexStyles()
{
// Run rescan in user lyx directory
- support::PathChanger p(package().user_support());
+ PathChanger p(package().user_support());
FileName const command = libFileSearch("scripts", "TeXFiles.py");
Systemcall one;
int const status = one.startscript(Systemcall::Wait,
- support::os::python() + ' ' +
+ os::python() + ' ' +
quoteName(command.toFilesystemEncoding()));
if (status == 0)
return;
}
-void getTexFileList(string const & filename, std::vector<string> & list)
+void getTexFileList(string const & filename, vector<string> & list)
{
list.clear();
FileName const file = libFileSearch("", filename);
if (file.empty())
return;
- list = getVectorFromString(file.fileContents(), "\n");
+ // FIXME Unicode.
+ vector<docstring> doclist =
+ getVectorFromString(file.fileContents("UTF-8"), from_ascii("\n"));
// 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();
+ vector<docstring>::iterator it = doclist.begin();
+ vector<docstring>::iterator end = doclist.end();
for (; it != end; ++it)
- *it = regex.Merge((*it), "/");
+ list.push_back(regex.Merge(to_utf8(*it), "/"));
// remove empty items and duplicates
- list.erase(std::remove(list.begin(), list.end(), ""), list.end());
+ list.erase(remove(list.begin(), list.end(), ""), list.end());
eliminate_duplicates(list);
}