From: Lars Gullik Bjønnes Date: Wed, 7 Jan 2004 18:30:14 +0000 (+0000) Subject: adaptablize a functor, remove a warning X-Git-Tag: 1.6.10~15592 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=c6c9bbdac26c1cc8e83714a5cd86b05b92a563ce;p=features.git adaptablize a functor, remove a warning git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8326 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/tex2lyx/ChangeLog b/src/tex2lyx/ChangeLog index e9aa267f95..b3da5fbbb1 100644 --- a/src/tex2lyx/ChangeLog +++ b/src/tex2lyx/ChangeLog @@ -1,3 +1,11 @@ +2004-01-07 Lars Gullik Bjonnes + + * 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 * text.C: fix status tag output for ERT inset diff --git a/src/tex2lyx/text.C b/src/tex2lyx/text.C index e8a651270f..543fe707fe 100644 --- a/src/tex2lyx/text.C +++ b/src/tex2lyx/text.C @@ -26,6 +26,10 @@ #include #include +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 { +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; }