From: Jean-Marc Lasgouttes Date: Wed, 10 Jan 2001 14:09:56 +0000 (+0000) Subject: Another fix for lyxstring::rfind X-Git-Tag: 1.6.10~21739 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=7a837013fd0914f5494dd994c7ca7ad288c67f59;p=features.git Another fix for lyxstring::rfind git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1311 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/ChangeLog b/ChangeLog index 062a642304..b58c0e3e47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-01-10 Jean-Marc Lasgouttes + + * src/support/lyxstring.C (rfind): better fix (from Dekel). + + * src/tabular.h: add a couple std:: qualifiers. + 2001-01-10 Lars Gullik Bjønnes * src/support/lyxstring.C (rfind): also test the first char in the diff --git a/src/support/lyxstring.C b/src/support/lyxstring.C index 967fd88650..515e90533b 100644 --- a/src/support/lyxstring.C +++ b/src/support/lyxstring.C @@ -23,6 +23,8 @@ #include "LAssert.h" +#include "debug.h" + using std::min; using std::istream; using std::ostream; @@ -1027,11 +1029,13 @@ lyxstring::size_type lyxstring::rfind(value_type c, size_type i) const { TestlyxstringInvariant(this); - size_type ii = min(rep->sz - 1, i); - for (size_type t = ii; t >= 0; --t) { - if (rep->s[t] == c) return t; - } - return npos; + size_type const sz = rep->sz; + if (sz < 1) return npos; + size_type ii = min(sz - 1, i); + do { + if (rep->s[ii] == c) return ii; + } while (ii-- > 0); + return npos; } diff --git a/src/tabular.h b/src/tabular.h index 7b51a08e2a..c68ec96f31 100644 --- a/src/tabular.h +++ b/src/tabular.h @@ -455,10 +455,10 @@ private: ////////////////////////////////////////////////////////////////// typedef std::vector column_vector; /// - void ReadNew(Buffer const * buf, istream & is, + void ReadNew(Buffer const * buf, std::istream & is, LyXLex & lex, string const & l); /// - void ReadOld(Buffer const * buf, istream & is, + void ReadOld(Buffer const * buf, std::istream & is, LyXLex & lex, string const & l); /// int rows_;