]> git.lyx.org Git - features.git/commitdiff
adaptablize a functor, remove a warning
authorLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 7 Jan 2004 18:30:14 +0000 (18:30 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 7 Jan 2004 18:30:14 +0000 (18:30 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8326 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/ChangeLog
src/tex2lyx/text.C

index e9aa267f95bcc903199969d2dc95b9c3d690253e..b3da5fbbb11cf42401b9c1dd5c4be0ea0b299f36 100644 (file)
@@ -1,3 +1,11 @@
+2004-01-07  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * text.C: reorder the using statements.
+       (translate_len): remove usage of a uninitialized variable.
+       (isLayout): make it adaptable and constify operator()
+       (findLayout): reformat slightly and dont use the same var for
+       different things.
+
 2004-01-06  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
 
        * text.C: fix status tag output for ERT inset
index e8a651270f23cb6993693fd786adf296c2329db7..543fe707fe441180586483899c41c05784f118b3 100644 (file)
 #include <sstream>
 #include <vector>
 
+using lyx::support::rtrim;
+using lyx::support::suffixIs;
+using lyx::support::contains;
+
 using std::cerr;
 using std::endl;
 
@@ -36,10 +40,6 @@ using std::istringstream;
 using std::string;
 using std::vector;
 
-using lyx::support::rtrim;
-using lyx::support::suffixIs;
-using lyx::support::contains;
-
 
 // thin wrapper around parse_text using a string
 string parse_text(Parser & p, unsigned flags, const bool outer,
@@ -160,7 +160,7 @@ bool translate_len(string const & length, string & valstring, string & unit)
        // a normal length
        if (unit.empty() || unit[0] != '\\')
                return true;
-       const string::size_type i = unit.find(" ", i);
+       string::size_type const i = unit.find(' ');
        string const endlen = (i == string::npos) ? string() : string(unit, i);
        if (unit == "\\textwidth") {
                valstring = percentval;
@@ -286,10 +286,11 @@ void handle_comment(ostream & os, string const & s, Context & context)
 }
 
 
-struct isLayout {
+class isLayout : public std::unary_function<LyXLayout_ptr, bool> {
+public:
        isLayout(string const name) : name_(name) {}
-       bool operator()(LyXLayout_ptr const & ptr) {
-               return ptr.get() && ptr->latexname() == name_;
+       bool operator()(LyXLayout_ptr const & ptr) const {
+               return ptr->latexname() == name_;
        }
 private:
        string const name_;
@@ -299,9 +300,12 @@ private:
 LyXLayout_ptr findLayout(LyXTextClass const & textclass,
                         string const & name)
 {
-       LyXTextClass::const_iterator it  = textclass.begin();
+       LyXTextClass::const_iterator beg  = textclass.begin();
        LyXTextClass::const_iterator end = textclass.end();
-       it = std::find_if(it, end, isLayout(name));
+
+       LyXTextClass::const_iterator
+               it = std::find_if(beg, end, isLayout(name));
+
        return (it == end) ? LyXLayout_ptr() : *it;
 }