cosmetics

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21544 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-11-10 13:44:50 +00:00
parent 873ee23697
commit 8d06b3049b
22 changed files with 239 additions and 195 deletions

View File

@ -1313,7 +1313,7 @@ int Buffer::runChktex()
string const name = addName(path.absFilename(), latexName());
string const org_path = filePath();
support::Path p(path); // path to LaTeX file
support::PathChanger p(path); // path to LaTeX file
message(_("Running chktex..."));
// Generate the LaTeX file if neccessary

View File

@ -350,7 +350,7 @@ bool Converters::convert(Buffer const * buffer,
string const path(onlyPath(from_file.absFilename()));
// Prevent the compiler from optimizing away p
FileName pp(path);
support::Path p(pp);
support::PathChanger p(pp);
// empty the error list before any new conversion takes place.
errorList.clear();

View File

@ -139,7 +139,7 @@ void reconfigureUserLyXDir()
string const configure_command = package().configure_command();
lyxerr << to_utf8(_("LyX: reconfiguring user directory")) << endl;
support::Path p(package().user_support());
support::PathChanger p(package().user_support());
Systemcall one;
one.startscript(Systemcall::Wait, configure_command);
lyxerr << "LyX: " << to_utf8(_("Done!")) << endl;

View File

@ -216,7 +216,7 @@ void reconfigure(LyXView & lv, string const & option)
lv.message(_("Running configure..."));
// Run configure in user lyx directory
support::Path p(package().user_support());
support::PathChanger p(package().user_support());
string configure_command = package().configure_command();
configure_command += option;
Systemcall one;
@ -1176,7 +1176,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
string const path = buffer->temppath();
// Prevent the compiler from optimizing away p
FileName pp(path);
support::Path p(pp);
support::PathChanger p(pp);
// there are three cases here:
// 1. we print to a file

View File

@ -56,7 +56,7 @@ int VCS::doVCCommand(string const & cmd, FileName const & path)
{
LYXERR(Debug::LYXVC) << "doVCCommand: " << cmd << endl;
Systemcall one;
support::Path p(path);
support::PathChanger p(path);
int const ret = one.startscript(Systemcall::Wait, cmd);
return ret;
}

View File

@ -304,11 +304,11 @@ docstring browseDir(docstring const & pathname, docstring const & title,
void rescanTexStyles()
{
// Run rescan in user lyx directory
support::Path p(package().user_support());
support::PathChanger p(package().user_support());
FileName const command = libFileSearch("scripts", "TeXFiles.py");
Systemcall one;
int const status = one.startscript(Systemcall::Wait,
lyx::support::os::python() + ' ' +
support::os::python() + ' ' +
quoteName(command.toFilesystemEncoding()));
if (status == 0)
return;

View File

@ -235,7 +235,7 @@ TemplateManager::getPreambleDefByName(string const & name) const
void TemplateManager::readTemplates(support::FileName const & path)
{
support::Path p(path);
support::PathChanger p(path);
enum TemplateTags {
TM_PREAMBLEDEF = 1,

View File

@ -336,7 +336,7 @@ int InsetBibtex::latex(Buffer const & buffer, odocstream & os,
vector<FileName> const InsetBibtex::getFiles(Buffer const & buffer) const
{
FileName path(buffer.filePath());
support::Path p(path);
support::PathChanger p(path);
vector<FileName> vec;

View File

@ -21,8 +21,6 @@
#include <sstream>
using lyx::docstring;
using std::distance;
using std::ostringstream;
using std::string;
@ -83,7 +81,7 @@ string const convert_brace_glob(string const & glob)
namespace lyx {
namespace support {
FileFilterList::Filter::Filter(lyx::docstring const & description,
FileFilterList::Filter::Filter(docstring const & description,
std::string const & globs)
: desc_(description)
{
@ -104,9 +102,9 @@ FileFilterList::Filter::Filter(lyx::docstring const & description,
FileFilterList::FileFilterList(docstring const & qt_style_filter)
{
// FIXME UNICODE
string const filter = lyx::to_utf8(qt_style_filter)
string const filter = to_utf8(qt_style_filter)
+ (qt_style_filter.empty() ? string() : ";;")
+ lyx::to_utf8(_("All files (*)"));
+ to_utf8(_("All files (*)"));
// Split data such as "TeX documents (*.tex);;LyX Documents (*.lyx)"
// into individual filters.
@ -144,7 +142,7 @@ void FileFilterList::parse_filter(string const & filter)
filters_.push_back(Filter(docstring(), trim(filter)));
} else {
// FIXME UNICODE
docstring const desc = lyx::from_utf8(string(what[1].first, what[1].second));
docstring const desc = from_utf8(string(what[1].first, what[1].second));
string const globs = string(what[2].first, what[2].second);
filters_.push_back(Filter(trim(desc), trim(globs)));
}
@ -169,7 +167,7 @@ docstring const FileFilterList::as_string() const
bool const has_description = !fit->description().empty();
if (has_description)
ss << lyx::to_utf8(fit->description()) << " (";
ss << to_utf8(fit->description()) << " (";
for (Filter::glob_iterator git = gbegin; git != gend; ++git) {
if (git != gbegin)
@ -181,7 +179,7 @@ docstring const FileFilterList::as_string() const
ss << ')';
}
return lyx::from_utf8(ss.str());
return from_utf8(ss.str());
}
} // namespace support

View File

@ -30,17 +30,17 @@ class FileFilterList {
public:
// FIXME UNICODE: globs_ should be unicode...
class Filter {
lyx::docstring desc_;
docstring desc_;
std::vector<std::string> globs_;
public:
/* \param description text describing the filters.
* \param one or more wildcard patterns, separated by
* whitespace.
*/
Filter(lyx::docstring const & description,
Filter(docstring const & description,
std::string const & globs);
lyx::docstring const & description() const { return desc_; }
docstring const & description() const { return desc_; }
typedef std::vector<std::string>::const_iterator glob_iterator;
glob_iterator begin() const { return globs_.begin(); }
@ -51,8 +51,8 @@ public:
* Eg. "TeX documents (*.tex);;LyX Documents (*.lyx)".
* The "All files (*)" filter is always added to the list.
*/
explicit FileFilterList(lyx::docstring const & qt_style_filter =
lyx::docstring());
explicit FileFilterList(docstring const & qt_style_filter =
docstring());
typedef std::vector<Filter>::size_type size_type;
@ -65,7 +65,7 @@ public:
* although any brace expressions are expanded.
* (E.g. "*.{png,jpg}" -> "*.png *.jpg")
*/
lyx::docstring const as_string() const;
docstring const as_string() const;
private:
void parse_filter(std::string const & filter);

View File

@ -76,7 +76,7 @@ public:
if (secs > 0) {
new Murder(secs, pid);
} else if (pid != 0) {
lyx::support::kill(pid, SIGKILL);
support::kill(pid, SIGKILL);
}
}
@ -84,7 +84,7 @@ public:
void kill()
{
if (pid_ != 0) {
lyx::support::kill(pid_, SIGKILL);
support::kill(pid_, SIGKILL);
}
lyxerr << "Killed " << pid_ << std::endl;
delete this;
@ -166,7 +166,7 @@ bool ForkedProcess::running() const
#endif
// Racy of course, but it will do.
if (lyx::support::kill(pid(), 0) && errno == ESRCH)
if (support::kill(pid(), 0) && errno == ESRCH)
return false;
return true;
}
@ -188,7 +188,7 @@ void ForkedProcess::kill(int tol)
Murder::killItDead(0, pid());
} else {
int ret = lyx::support::kill(pid(), SIGHUP);
int ret = support::kill(pid(), SIGHUP);
// The process is already dead if wait_for_death is false
bool const wait_for_death = (ret == 0 && errno != ESRCH);

View File

@ -10,20 +10,19 @@
#include <config.h>
// Needed to prevent the definition of the unnamed_Path macro in the header file.
// Needed to prevent the definition of the unnamed_Path macro
// in the header file.
#define PATH_C
#include "support/Path.h"
#include "support/lyxlib.h"
using std::string;
namespace lyx {
namespace support {
Path::Path(FileName const & path)
PathChanger::PathChanger(FileName const & path)
: popped_(false)
{
if (!path.empty()) {
@ -38,13 +37,14 @@ Path::Path(FileName const & path)
}
Path::~Path()
PathChanger::~PathChanger()
{
if (!popped_) pop();
if (!popped_)
pop();
}
int Path::pop()
int PathChanger::pop()
{
if (popped_) {
// should throw an exception

View File

@ -14,9 +14,6 @@
#include "support/FileName.h"
#include <boost/noncopyable.hpp>
#include <string>
namespace lyx {
namespace support {
@ -34,17 +31,21 @@ namespace support {
*
* At the end of p's scope the cwd is reset to its previous value.
*/
class Path : boost::noncopyable {
class PathChanger {
public:
/// change to the given directory
explicit Path(FileName const & path);
explicit PathChanger(FileName const & path);
/// set cwd to the previous value if needed
~Path();
~PathChanger();
/// set cwd to the previous value if needed
int pop();
private:
/// noncopyable
PathChanger(PathChanger const &);
void operator=(PathChanger const &);
/// whether we are in the new cwd or not
bool popped_;
/// the previous cwd

View File

@ -20,7 +20,7 @@ namespace lyx {
#endif
void lyx::support::abort()
void support::abort()
{
::abort();
}

View File

@ -1,5 +1,5 @@
/**
* \file tostr.C
* \file convert.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
@ -22,8 +22,6 @@
namespace lyx {
using lyx::docstring;
using boost::lexical_cast;
using std::string;
@ -60,7 +58,7 @@ string convert<string>(int i)
template<>
docstring convert<docstring>(int i)
{
return lyx::from_ascii(lexical_cast<string>(i));
return from_ascii(lexical_cast<string>(i));
}
@ -74,7 +72,7 @@ string convert<string>(unsigned int ui)
template<>
docstring convert<docstring>(unsigned int ui)
{
return lyx::from_ascii(lexical_cast<string>(ui));
return from_ascii(lexical_cast<string>(ui));
}
@ -88,7 +86,7 @@ string convert<string>(unsigned long ul)
template<>
docstring convert<docstring>(unsigned long ul)
{
return lyx::from_ascii(lexical_cast<string>(ul));
return from_ascii(lexical_cast<string>(ul));
}
@ -102,7 +100,7 @@ string convert<string>(long l)
template<>
docstring convert<docstring>(long l)
{
return lyx::from_ascii(lexical_cast<string>(l));
return from_ascii(lexical_cast<string>(l));
}
@ -130,7 +128,7 @@ int convert<int>(string const s)
template<>
int convert<int>(docstring const s)
{
return strtol(lyx::to_ascii(s).c_str(), 0, 10);
return strtol(to_ascii(s).c_str(), 0, 10);
}

View File

@ -16,7 +16,7 @@
#ifndef CONVERT_H
#define CONVERT_H
#include "support/docstring.h"
#include "support/strfwd.h"
namespace lyx {
@ -30,15 +30,15 @@ template<> std::string convert<std::string>(short unsigned int sui);
template<> std::string convert<std::string>(int i);
template<> docstring convert<docstring>(int i);
template<> std::string convert<std::string>(unsigned int ui);
template<> docstring convert<lyx::docstring>(unsigned int ui);
template<> docstring convert<docstring>(unsigned int ui);
template<> std::string convert<std::string>(unsigned long ul);
template<> docstring convert<lyx::docstring>(unsigned long ul);
template<> docstring convert<docstring>(unsigned long ul);
template<> std::string convert<std::string>(long l);
template<> docstring convert<lyx::docstring>(long l);
template<> docstring convert<docstring>(long l);
template<> std::string convert<std::string>(float f);
template<> std::string convert<std::string>(double d);
template<> int convert<int>(std::string const s);
template<> int convert<int>(lyx::docstring const s);
template<> int convert<int>(docstring const s);
template<> unsigned int convert<unsigned int>(std::string const s);
template<> unsigned long convert<unsigned long>(std::string const s);
template<> double convert<double>(std::string const s);

View File

@ -23,16 +23,16 @@
#endif
namespace lyx {
using std::ifstream;
using std::ofstream;
using std::ios;
using std::string;
bool lyx::support::chmod(FileName const & file, unsigned long int mode)
namespace lyx {
namespace support {
bool chmod(FileName const & file, unsigned long int mode)
{
#if defined (HAVE_CHMOD) && defined (HAVE_MODE_T)
if (::chmod(file.toFilesystemEncoding().c_str(), mode_t(mode)) != 0)
@ -44,14 +44,15 @@ bool lyx::support::chmod(FileName const & file, unsigned long int mode)
}
bool lyx::support::copy(FileName const & from, FileName const & to, unsigned long int mode)
bool copy(FileName const & from, FileName const & to, unsigned long int mode)
{
ifstream ifs(from.toFilesystemEncoding().c_str(), ios::binary | ios::in);
if (!ifs)
return false;
if (mode != (unsigned long int)-1) {
ofstream ofs(to.toFilesystemEncoding().c_str(), ios::binary | ios::out | ios::trunc);
ofstream ofs(to.toFilesystemEncoding().c_str(),
ios::binary | ios::out | ios::trunc);
if (!ofs)
return false;
ofs.close();
@ -59,7 +60,8 @@ bool lyx::support::copy(FileName const & from, FileName const & to, unsigned lon
return false;
}
ofstream ofs(to.toFilesystemEncoding().c_str(), ios::binary | ios::out | ios::trunc);
ofstream ofs(to.toFilesystemEncoding().c_str(),
ios::binary | ios::out | ios::trunc);
if (!ofs)
return false;
@ -67,5 +69,5 @@ bool lyx::support::copy(FileName const & from, FileName const & to, unsigned lon
return ofs.good();
}
} // namespace support
} // namespace lyx

View File

@ -355,21 +355,71 @@ odocstream & operator<<(odocstream & os, char c)
// a bug in gcc. The implementation here does not do anything useful, since
// it is overriden in iconv_codecvt_facet.
namespace std {
template<> codecvt<lyx::char_type, char, mbstate_t>::result
codecvt<lyx::char_type, char, mbstate_t>::do_out(mbstate_t &, const lyx::char_type *, const lyx::char_type *, const lyx::char_type *&,
char *, char *, char *&) const { return error; }
template<> codecvt<lyx::char_type, char, mbstate_t>::result
codecvt<lyx::char_type, char, mbstate_t>::do_unshift(mbstate_t &, char *, char *, char *&) const { return error; }
template<> codecvt<lyx::char_type, char, mbstate_t>::result
codecvt<lyx::char_type, char, mbstate_t>::do_in(mbstate_t &, const char *, const char *, const char *&,
lyx::char_type *, lyx::char_type *, lyx::char_type *&) const { return error; }
template<> int codecvt<lyx::char_type, char, mbstate_t>::do_encoding() const throw() { return 0; }
template<> bool codecvt<lyx::char_type, char, mbstate_t>::do_always_noconv() const throw() { return true; }
#if __GNUC__ == 3 && __GNUC_MINOR__ < 4
template<> int codecvt<lyx::char_type, char, mbstate_t>::do_length(mbstate_t const &, const char *, const char *, size_t) const { return 1; }
#else
template<> int codecvt<lyx::char_type, char, mbstate_t>::do_length(mbstate_t &, const char *, const char *, size_t) const { return 1; }
#endif
template<> int codecvt<lyx::char_type, char, mbstate_t>::do_max_length() const throw() { return 4; }
codecvt<lyx::char_type, char, mbstate_t>::do_out(
mbstate_t &, const lyx::char_type *, const lyx::char_type *,
const lyx::char_type *&, char *, char *, char *&) const
{
return error;
}
template<> codecvt<lyx::char_type, char, mbstate_t>::result
codecvt<lyx::char_type, char, mbstate_t>::do_unshift(
mbstate_t &, char *, char *, char *&) const
{
return error;
}
template<> codecvt<lyx::char_type, char, mbstate_t>::result
codecvt<lyx::char_type, char, mbstate_t>::do_in(
mbstate_t &, const char *, const char *, const char *&,
lyx::char_type *, lyx::char_type *, lyx::char_type *&) const
{
return error;
}
template<>
int codecvt<lyx::char_type, char, mbstate_t>::do_encoding() const throw()
{
return 0;
}
template<>
bool codecvt<lyx::char_type, char, mbstate_t>::do_always_noconv() const throw()
{
return true;
}
#if __GNUC__ == 3 && __GNUC_MINOR__ < 4
template<>
int codecvt<lyx::char_type, char, mbstate_t>::do_length(
mbstate_t const &, const char *, const char *, size_t) const
{
return 1;
}
#else
template<>
int codecvt<lyx::char_type, char, mbstate_t>::do_length(
mbstate_t &, const char *, const char *, size_t) const
{
return 1;
}
#endif
template<>
int codecvt<lyx::char_type, char, mbstate_t>::do_max_length() const throw()
{
return 4;
}
} // namespace std
#endif

View File

@ -425,9 +425,7 @@ struct local_uppercase {
};
template<typename Char> struct local_ascii_lowercase {
Char operator()(Char c) const {
return ascii_tolower(c);
}
Char operator()(Char c) const { return ascii_tolower(c); }
};
} // end of anon namespace
@ -476,25 +474,23 @@ bool prefixIs(docstring const & a, char_type c)
bool prefixIs(string const & a, string const & pre)
{
string::size_type const prelen = pre.length();
string::size_type const alen = a.length();
size_t const prelen = pre.length();
size_t const alen = a.length();
if (prelen > alen || a.empty())
return false;
else {
#if defined(STD_STRING_IS_GOOD)
return a.compare(0, prelen, pre) == 0;
return a.compare(0, prelen, pre) == 0;
#else
return ::strncmp(a.c_str(), pre.c_str(), prelen) == 0;
return ::strncmp(a.c_str(), pre.c_str(), prelen) == 0;
#endif
}
}
bool prefixIs(docstring const & a, docstring const & pre)
{
docstring::size_type const prelen = pre.length();
docstring::size_type const alen = a.length();
size_t const prelen = pre.length();
size_t const alen = a.length();
if (prelen > alen || a.empty())
return false;
@ -520,19 +516,18 @@ bool suffixIs(docstring const & a, char_type c)
bool suffixIs(string const & a, string const & suf)
{
string::size_type const suflen = suf.length();
string::size_type const alen = a.length();
size_t const suflen = suf.length();
size_t const alen = a.length();
if (suflen > alen) {
if (suflen > alen)
return false;
} else {
#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
string tmp(a, alen - suflen);
return ::strncmp(tmp.c_str(), suf.c_str(), suflen) == 0;
string tmp(a, alen - suflen);
return ::strncmp(tmp.c_str(), suf.c_str(), suflen) == 0;
#else
return a.compare(alen - suflen, suflen, suf) == 0;
return a.compare(alen - suflen, suflen, suf) == 0;
#endif
}
}
@ -546,19 +541,24 @@ bool containsOnly(string const & s, string const & cset)
// rewritten to use new string (Lgb)
string const token(string const & a, char delim, int n)
{
if (a.empty()) return string();
if (a.empty())
return string();
string::size_type k = 0;
string::size_type i = 0;
size_t k = 0;
size_t i = 0;
// Find delimiter or end of string
for (; n--;)
for (; n--;) {
if ((i = a.find(delim, i)) == string::npos)
break;
else
++i; // step delim
}
// i is now the n'th delim (or string::npos)
if (i == string::npos) return string();
if (i == string::npos)
return string();
k = a.find(delim, i);
// k is now the n'th + 1 delim (or string::npos)
@ -570,17 +570,21 @@ docstring const token(docstring const & a, char_type delim, int n)
{
if (a.empty()) return docstring();
string::size_type k = 0;
string::size_type i = 0;
size_t k = 0;
size_t i = 0;
// Find delimiter or end of string
for (; n--;)
for (; n--;) {
if ((i = a.find(delim, i)) == docstring::npos)
break;
else
++i; // step delim
}
// i is now the n'th delim (or string::npos)
if (i == docstring::npos) return docstring();
if (i == docstring::npos)
return docstring();
k = a.find(delim, i);
// k is now the n'th + 1 delim (or string::npos)
@ -593,7 +597,7 @@ docstring const token(docstring const & a, char_type delim, int n)
int tokenPos(string const & a, char delim, string const & tok)
{
int i = 0;
string str(a);
string str = a;
string tmptok;
while (!str.empty()) {
@ -644,8 +648,8 @@ String const subst_string(String const & a,
{
BOOST_ASSERT(!oldstr.empty());
String lstr = a;
typename String::size_type i = 0;
typename String::size_type const olen = oldstr.length();
size_t i = 0;
size_t const olen = oldstr.length();
while ((i = lstr.find(oldstr, i)) != string::npos) {
lstr.replace(i, olen, newstr);
i += newstr.length(); // We need to be sure that we dont
@ -659,8 +663,8 @@ docstring const subst_string(docstring const & a,
{
BOOST_ASSERT(!oldstr.empty());
docstring lstr = a;
docstring::size_type i = 0;
docstring::size_type const olen = oldstr.length();
size_t i = 0;
size_t const olen = oldstr.length();
while ((i = lstr.find(oldstr, i)) != string::npos) {
lstr.replace(i, olen, newstr);
i += newstr.length(); // We need to be sure that we dont
@ -706,9 +710,9 @@ docstring const trim(docstring const & a, char const * p)
if (a.empty() || !*p)
return a;
docstring s = lyx::from_ascii(p);
docstring::size_type r = a.find_last_not_of(s);
docstring::size_type l = a.find_first_not_of(s);
docstring s = from_ascii(p);
size_t r = a.find_last_not_of(s);
size_t l = a.find_first_not_of(s);
// Is this the minimal test? (lgb)
if (r == docstring::npos && l == docstring::npos)
@ -725,8 +729,8 @@ string const trim(string const & a, char const * p)
if (a.empty() || !*p)
return a;
string::size_type r = a.find_last_not_of(p);
string::size_type l = a.find_first_not_of(p);
size_t r = a.find_last_not_of(p);
size_t l = a.find_first_not_of(p);
// Is this the minimal test? (lgb)
if (r == string::npos && l == string::npos)
@ -743,7 +747,7 @@ string const rtrim(string const & a, char const * p)
if (a.empty() || !*p)
return a;
string::size_type r = a.find_last_not_of(p);
size_t r = a.find_last_not_of(p);
// Is this test really needed? (Lgb)
if (r == string::npos)
@ -760,7 +764,7 @@ docstring const rtrim(docstring const & a, char const * p)
if (a.empty() || !*p)
return a;
docstring::size_type r = a.find_last_not_of(from_ascii(p));
size_t r = a.find_last_not_of(from_ascii(p));
// Is this test really needed? (Lgb)
if (r == docstring::npos)
@ -775,7 +779,7 @@ string const ltrim(string const & a, char const * p)
BOOST_ASSERT(p);
if (a.empty() || !*p)
return a;
string::size_type l = a.find_first_not_of(p);
size_t l = a.find_first_not_of(p);
if (l == string::npos)
return string();
return a.substr(l, string::npos);
@ -799,7 +803,7 @@ template<typename String, typename Char> inline
String const doSplit(String const & a, String & piece, Char delim)
{
String tmp;
typename String::size_type i = a.find(delim);
size_t i = a.find(delim);
if (i == a.length() - 1) {
piece = a.substr(0, i);
} else if (i != String::npos) {
@ -818,7 +822,7 @@ template<typename Char> inline
docstring const doSplit(docstring const & a, docstring & piece, Char delim)
{
docstring tmp;
typename docstring::size_type i = a.find(delim);
size_t i = a.find(delim);
if (i == a.length() - 1) {
piece = a.substr(0, i);
} else if (i != docstring::npos) {
@ -851,7 +855,7 @@ docstring const split(docstring const & a, docstring & piece, char_type delim)
string const split(string const & a, char delim)
{
string tmp;
string::size_type i = a.find(delim);
size_t i = a.find(delim);
if (i != string::npos) // found delim
tmp = a.substr(i + 1);
return tmp;
@ -862,7 +866,7 @@ string const split(string const & a, char delim)
string const rsplit(string const & a, string & piece, char delim)
{
string tmp;
string::size_type i = a.rfind(delim);
size_t i = a.rfind(delim);
if (i != string::npos) { // delimiter was found
piece = a.substr(0, i);
tmp = a.substr(i + 1);
@ -878,7 +882,7 @@ docstring const escape(docstring const & lab)
char_type hexdigit[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
docstring enc;
for (docstring::size_type i = 0; i < lab.length(); ++i) {
for (size_t i = 0; i < lab.length(); ++i) {
char_type c = lab[i];
if (c >= 128 || c == '=' || c == '%') {
// Although char_type is a 32 bit type we know that
@ -915,8 +919,8 @@ getVectorFromStringT(String const & str, String const & delim)
if (str.empty())
return vec;
String keys = rtrim(str);
for(;;) {
typename String::size_type const idx = keys.find(delim);
while (true) {
size_t const idx = keys.find(delim);
if (idx == String::npos) {
vec.push_back(ltrim(keys));
break;
@ -924,7 +928,7 @@ getVectorFromStringT(String const & str, String const & delim)
String const key = trim(keys.substr(0, idx));
if (!key.empty())
vec.push_back(key);
typename String::size_type const start = idx + delim.size();
size_t const start = idx + delim.size();
keys = keys.substr(start);
}
return vec;
@ -937,7 +941,7 @@ getVectorFromStringT(String const & str, String const & delim)
#endif
}
} // anon
} // namespace anon
vector<string> const getVectorFromString(string const & str,
@ -992,7 +996,7 @@ docstring const externalLineEnding(docstring const & str)
return subst(str, '\n', '\r');
#elif defined (_WIN32) || (defined (__CYGWIN__) && defined (X_DISPLAY_MISSING))
// Windows clipboard uses \r\n for lineendings, and we use \n
return subst(str, lyx::from_ascii("\n"), lyx::from_ascii("\r\n"));
return subst(str, from_ascii("\n"), from_ascii("\r\n"));
#else
return str;
#endif
@ -1001,8 +1005,7 @@ docstring const externalLineEnding(docstring const & str)
docstring const internalLineEnding(docstring const & str)
{
docstring const s = subst(str,
lyx::from_ascii("\r\n"), lyx::from_ascii("\n"));
docstring const s = subst(str, from_ascii("\r\n"), from_ascii("\n"));
return subst(s, '\r', '\n');
}
@ -1010,91 +1013,91 @@ docstring const internalLineEnding(docstring const & str)
template<>
docstring bformat(docstring const & fmt, int arg1)
{
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$d")));
docstring const str = subst(fmt, lyx::from_ascii("%1$d"), convert<docstring>(arg1));
return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%"));
BOOST_ASSERT(contains(fmt, from_ascii("%1$d")));
docstring const str = subst(fmt, from_ascii("%1$d"), convert<docstring>(arg1));
return subst(str, from_ascii("%%"), from_ascii("%"));
}
template<>
docstring bformat(docstring const & fmt, long arg1)
{
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$d")));
docstring const str = subst(fmt, lyx::from_ascii("%1$d"), convert<docstring>(arg1));
return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%"));
BOOST_ASSERT(contains(fmt, from_ascii("%1$d")));
docstring const str = subst(fmt, from_ascii("%1$d"), convert<docstring>(arg1));
return subst(str, from_ascii("%%"), from_ascii("%"));
}
template<>
docstring bformat(docstring const & fmt, unsigned int arg1)
{
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$d")));
docstring const str = subst(fmt, lyx::from_ascii("%1$d"), convert<docstring>(arg1));
return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%"));
BOOST_ASSERT(contains(fmt, from_ascii("%1$d")));
docstring const str = subst(fmt, from_ascii("%1$d"), convert<docstring>(arg1));
return subst(str, from_ascii("%%"), from_ascii("%"));
}
template<>
docstring bformat(docstring const & fmt, docstring arg1)
{
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$s")));
docstring const str = subst(fmt, lyx::from_ascii("%1$s"), arg1);
return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%"));
BOOST_ASSERT(contains(fmt, from_ascii("%1$s")));
docstring const str = subst(fmt, from_ascii("%1$s"), arg1);
return subst(str, from_ascii("%%"), from_ascii("%"));
}
template<>
docstring bformat(docstring const & fmt, char * arg1)
{
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$s")));
docstring const str = subst(fmt, lyx::from_ascii("%1$s"), lyx::from_ascii(arg1));
return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%"));
BOOST_ASSERT(contains(fmt, from_ascii("%1$s")));
docstring const str = subst(fmt, from_ascii("%1$s"), from_ascii(arg1));
return subst(str, from_ascii("%%"), from_ascii("%"));
}
template<>
docstring bformat(docstring const & fmt, docstring arg1, docstring arg2)
{
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$s")));
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%2$s")));
docstring str = subst(fmt, lyx::from_ascii("%1$s"), arg1);
str = subst(str, lyx::from_ascii("%2$s"), arg2);
return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%"));
BOOST_ASSERT(contains(fmt, from_ascii("%1$s")));
BOOST_ASSERT(contains(fmt, from_ascii("%2$s")));
docstring str = subst(fmt, from_ascii("%1$s"), arg1);
str = subst(str, from_ascii("%2$s"), arg2);
return subst(str, from_ascii("%%"), from_ascii("%"));
}
template<>
docstring bformat(docstring const & fmt, char const * arg1, docstring arg2)
{
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$s")));
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%2$s")));
docstring str = subst(fmt, lyx::from_ascii("%1$s"), lyx::from_ascii(arg1));
str = subst(fmt, lyx::from_ascii("%2$s"), arg2);
return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%"));
BOOST_ASSERT(contains(fmt, from_ascii("%1$s")));
BOOST_ASSERT(contains(fmt, from_ascii("%2$s")));
docstring str = subst(fmt, from_ascii("%1$s"), from_ascii(arg1));
str = subst(fmt, from_ascii("%2$s"), arg2);
return subst(str, from_ascii("%%"), from_ascii("%"));
}
template<>
docstring bformat(docstring const & fmt, int arg1, int arg2)
{
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$d")));
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%2$d")));
docstring str = subst(fmt, lyx::from_ascii("%1$d"), convert<docstring>(arg1));
str = subst(str, lyx::from_ascii("%2$d"), convert<docstring>(arg2));
return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%"));
BOOST_ASSERT(contains(fmt, from_ascii("%1$d")));
BOOST_ASSERT(contains(fmt, from_ascii("%2$d")));
docstring str = subst(fmt, from_ascii("%1$d"), convert<docstring>(arg1));
str = subst(str, from_ascii("%2$d"), convert<docstring>(arg2));
return subst(str, from_ascii("%%"), from_ascii("%"));
}
template<>
docstring bformat(docstring const & fmt, docstring arg1, docstring arg2, docstring arg3)
{
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$s")));
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%2$s")));
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%3$s")));
docstring str = subst(fmt, lyx::from_ascii("%1$s"), arg1);
str = subst(str, lyx::from_ascii("%2$s"), arg2);
str = subst(str, lyx::from_ascii("%3$s"), arg3);
return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%"));
BOOST_ASSERT(contains(fmt, from_ascii("%1$s")));
BOOST_ASSERT(contains(fmt, from_ascii("%2$s")));
BOOST_ASSERT(contains(fmt, from_ascii("%3$s")));
docstring str = subst(fmt, from_ascii("%1$s"), arg1);
str = subst(str, from_ascii("%2$s"), arg2);
str = subst(str, from_ascii("%3$s"), arg3);
return subst(str, from_ascii("%%"), from_ascii("%"));
}
@ -1102,15 +1105,15 @@ template<>
docstring bformat(docstring const & fmt,
docstring arg1, docstring arg2, docstring arg3, docstring arg4)
{
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$s")));
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%2$s")));
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%3$s")));
BOOST_ASSERT(contains(fmt, lyx::from_ascii("%4$s")));
docstring str = subst(fmt, lyx::from_ascii("%1$s"), arg1);
str = subst(str, lyx::from_ascii("%2$s"), arg2);
str = subst(str, lyx::from_ascii("%3$s"), arg3);
str = subst(str, lyx::from_ascii("%4$s"), arg4);
return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%"));
BOOST_ASSERT(contains(fmt, from_ascii("%1$s")));
BOOST_ASSERT(contains(fmt, from_ascii("%2$s")));
BOOST_ASSERT(contains(fmt, from_ascii("%3$s")));
BOOST_ASSERT(contains(fmt, from_ascii("%4$s")));
docstring str = subst(fmt, from_ascii("%1$s"), arg1);
str = subst(str, from_ascii("%2$s"), arg2);
str = subst(str, from_ascii("%3$s"), arg3);
str = subst(str, from_ascii("%4$s"), arg4);
return subst(str, from_ascii("%%"), from_ascii("%"));
}
} // namespace support

View File

@ -66,9 +66,9 @@ bool isStrUnsignedInt(std::string const & str);
///
bool isStrDbl(std::string const & str);
bool isHex(lyx::docstring const & str);
bool isHex(docstring const & str);
int hexToInt(lyx::docstring const & str);
int hexToInt(docstring const & str);
/// is \p str pure ascii?
bool isAscii(docstring const & str);

View File

@ -30,8 +30,6 @@
using std::endl;
using std::string;
using lyx::support::contains;
namespace lyx {
namespace support {

View File

@ -66,9 +66,6 @@
using std::endl;
using std::string;
using lyx::support::runCommand;
using lyx::support::split;
namespace lyx {
namespace support {
@ -174,9 +171,9 @@ string current_root()
docstring::size_type common_path(docstring const & p1, docstring const & p2)
{
docstring::size_type i = 0;
docstring::size_type const p1_len = p1.length();
docstring::size_type const p2_len = p2.length();
size_t i = 0;
size_t const p1_len = p1.length();
size_t const p2_len = p2.length();
while (i < p1_len && i < p2_len && uppercase(p1[i]) == uppercase(p2[i]))
++i;
if ((i < p1_len && i < p2_len)
@ -204,9 +201,7 @@ string external_path(string const & p)
}
namespace {
string const get_long_path(string const & short_path)
static string const get_long_path(string const & short_path)
{
// GetLongPathName needs the path in file system encoding.
// We can use to_local8bit, since file system encoding and the
@ -225,8 +220,6 @@ string const get_long_path(string const & short_path)
return (result == 0) ? short_path : to_utf8(from_filesystem8bit(&long_path[0]));
}
} // namespace anon
string internal_path(string const & p)
{
@ -386,8 +379,9 @@ bool canAutoOpenFile(string const & ext, auto_open_mode const mode)
bool autoOpenFile(string const & filename, auto_open_mode const mode)
{
// reference: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc
// /platform/shell/reference/functions/shellexecute.asp
// reference: http://msdn.microsoft.com/library/default.asp
// ?url=/library/en-us/shellcc/platform/shell/reference/functions/
// shellexecute.asp
char const * action = (mode == VIEW) ? "open" : "edit";
return reinterpret_cast<int>(ShellExecute(NULL, action,
to_local8bit(from_utf8(filename)).c_str(), NULL, NULL, 1)) > 32;