]> git.lyx.org Git - features.git/commitdiff
tex2lyx: disambiguate duplicate trim() function by reusing trim() from src/support.
authorAbdelrazak Younes <younes@lyx.org>
Sun, 16 Oct 2011 08:22:20 +0000 (08:22 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 16 Oct 2011 08:22:20 +0000 (08:22 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39870 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/preamble.cpp
src/tex2lyx/table.cpp
src/tex2lyx/tex2lyx.cpp
src/tex2lyx/tex2lyx.h
src/tex2lyx/text.cpp

index df9462dbe97300e59258e706e002cf2331a1e877..de58439643c9ffd2d113de49461c984eecfe3c58 100644 (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()) {
index 436078339455e16a7ff308de6ef86718e897d4c5..e5862d043411afc697a9b1ca632a2abed3494cca 100644 (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 '<{"
index 40890b9667aabaf45f42ef9071c04a45c504686f..a999b333c60d17394a72ff82112305f6a1f0ac61 100644 (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");
 }
 
 
index f2bde2e8cb5fe1cd55608556d3aa723c2d6f9265..c9d9d3d5989b8c922beb65fa8bf94e742398042a 100644 (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 = ',');
index 346922fc2c03703283bc3067e97b2b5440903b67..27625c0df250d47037f2e57e5e0ddf08cd7cd0a4 100644 (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()) {