tex2lyx: disambiguate duplicate trim() function by reusing trim() from src/support.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39870 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2011-10-16 08:22:20 +00:00
parent fc8ba5776e
commit 27f3327fa1
5 changed files with 15 additions and 27 deletions

View File

@ -274,7 +274,7 @@ vector<string> split_options(string const & input)
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 += '=';
@ -286,7 +286,7 @@ vector<string> split_options(string const & input)
}
if (!option.empty())
options.push_back(trim(option));
options.push_back(trimSpaceAndEol(option));
return options;
}
@ -949,7 +949,7 @@ void parse_preamble(Parser & p, ostream & os,
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);
}
@ -986,7 +986,7 @@ void parse_preamble(Parser & p, ostream & os,
else if (t.cs() == "newcolumntype") {
string const name = p.getArg('{', '}');
trim(name);
trimSpaceAndEol(name);
int nargs = 0;
string opts = p.getOpt();
if (!opts.empty()) {

View File

@ -321,7 +321,7 @@ void handle_colalign(Parser & p, vector<ColInfo> & colinfo,
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
@ -341,7 +341,7 @@ void handle_colalign(Parser & p, vector<ColInfo> & colinfo,
}
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 '<{"

View File

@ -94,21 +94,9 @@ void lyx_exit(int)
{}
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");
}

View File

@ -82,7 +82,7 @@ void handle_tabular(Parser & p, std::ostream & os, bool is_long_tabular,
/// 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 = ',');

View File

@ -233,8 +233,8 @@ void split_map(string const & s, map<string, string> & res, vector<string> & key
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;
}
@ -265,15 +265,15 @@ bool splitLatexLength(string const & len, string & value, string & unit)
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;
}
@ -2824,7 +2824,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
// 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()) {