while (p.good()) {
Token const & t = p.get_token();
if (t.asInput() == ",") {
- options.push_back(trim(option));
+ options.push_back(trimSpaceAndEol(option));
option.erase();
} else if (t.asInput() == "=") {
option += '=';
}
if (!option.empty())
- options.push_back(trim(option));
+ options.push_back(trimSpaceAndEol(option));
return options;
}
vector<string>::const_iterator it = vecnames.begin();
vector<string>::const_iterator end = vecnames.end();
for (; it != end; ++it)
- handle_package(p, trim(*it), options,
+ handle_package(p, trimSpaceAndEol(*it), options,
in_lyx_preamble);
}
else if (t.cs() == "newcolumntype") {
string const name = p.getArg('{', '}');
- trim(name);
+ trimSpaceAndEol(name);
int nargs = 0;
string opts = p.getOpt();
if (!opts.empty()) {
break;
case '>': {
// text before the next column
- string const s = trim(p.verbatim_item());
+ string const s = trimSpaceAndEol(p.verbatim_item());
if (next.special.empty() &&
next.align == 'n') {
// Maybe this can be converted to a
}
case '<': {
// text after the last column
- string const s = trim(p.verbatim_item());
+ string const s = trimSpaceAndEol(p.verbatim_item());
if (colinfo.empty())
// This is not possible in LaTeX.
cerr << "Ignoring separator '<{"
{}
-string const trim(string const & a, char const * p)
+string const trimSpaceAndEol(string const & a)
{
- // LASSERT(p, /**/);
-
- if (a.empty() || !*p)
- return a;
-
- 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)
- return string();
-
- return a.substr(l, r - l + 1);
+ return trim(a, " \t\n\r");
}
/// in tex2lyx.cpp
-std::string const trim(std::string const & a, char const * p = " \t\n\r");
+std::string const trimSpaceAndEol(std::string const & a);
void split(std::string const & s, std::vector<std::string> & result,
char delim = ',');
keys.resize(v.size());
for (size_t i = 0; i < v.size(); ++i) {
size_t const pos = v[i].find('=');
- string const index = trim(v[i].substr(0, pos));
- string const value = trim(v[i].substr(pos + 1, string::npos));
+ string const index = trimSpaceAndEol(v[i].substr(0, pos));
+ string const value = trimSpaceAndEol(v[i].substr(pos + 1, string::npos));
res[index] = value;
keys[i] = index;
}
return false;
}
} else {
- value = trim(string(length, 0, i));
+ value = trimSpaceAndEol(string(length, 0, i));
}
if (value == "-")
value = "-1.0";
// 'cM' is a valid LaTeX length unit. Change it to 'cm'
if (contains(len, '\\'))
- unit = trim(string(len, i));
+ unit = trimSpaceAndEol(string(len, i));
else
- unit = ascii_lowercase(trim(string(len, i)));
+ unit = ascii_lowercase(trimSpaceAndEol(string(len, i)));
return true;
}
// try to see whether the string is in unicodesymbols
docstring rem;
string command = t.asInput() + "{"
- + trim(p.verbatim_item())
+ + trimSpaceAndEol(p.verbatim_item())
+ "}";
docstring s = encodings.fromLaTeXCommand(from_utf8(command), rem);
if (!s.empty()) {