hopefully solve some of the lyxstring problems.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@217 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 1999-10-20 01:53:59 +00:00
parent ee3e9f6fe8
commit 4894fbc987
3 changed files with 18 additions and 6 deletions

View File

@ -1,3 +1,12 @@
1999-10-20 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/support/lyxstring.C (helper): changed to use
sizeof(object->rep->ref).
(operator>>): changed to use a pointer instead.
* src/support/lyxstring.h: changed const reference & to value_type
const & lets see if that helps.
1999-10-19 Lars Gullik Bjønnes <larsbj@lyx.org> 1999-10-19 Lars Gullik Bjønnes <larsbj@lyx.org>
* Makefile.am (rpmdist): fixed to have non static package and * Makefile.am (rpmdist): fixed to have non static package and

View File

@ -120,7 +120,7 @@ void lyxstringInvariant::helper() const
Assert(object->rep->res); // always some space allocated Assert(object->rep->res); // always some space allocated
Assert(object->size() <= object->rep->res); Assert(object->size() <= object->rep->res);
Assert(object->rep->ref >= 1); // its in use so it must be referenced Assert(object->rep->ref >= 1); // its in use so it must be referenced
Assert(object->rep->ref < (1 << 8*sizeof(lyxstring::Srep::ref)) - 1); Assert(object->rep->ref < (1 << 8*sizeof(object->rep->ref)) - 1);
// if it does ever == then we should be generating a new copy // if it does ever == then we should be generating a new copy
// and starting again. (Is char always 8-bits?) // and starting again. (Is char always 8-bits?)
} }
@ -1129,14 +1129,16 @@ lyxstring::size_type lyxstring::find_last_not_of(lyxstring const & a,
} }
lyxstring::size_type lyxstring::find_last_not_of(value_type const * ptr, size_type i, lyxstring::size_type lyxstring::find_last_not_of(value_type const * ptr,
size_type i,
size_type n) const size_type n) const
{ {
Assert(ptr); Assert(ptr);
TestlyxstringInvariant(this); TestlyxstringInvariant(this);
if (!n) return npos;
size_type ii = min(length() - 1, i); size_type ii = min(length() - 1, i);
if (!n) return (ii >= 0) ? ii : npos; //if (!n) return (ii >= 0) ? ii : npos;
for (int t = ii; t >= 0; --t) { for (int t = ii; t >= 0; --t) {
if(memchr(ptr, rep->s[t], n) == 0) return t; if(memchr(ptr, rep->s[t], n) == 0) return t;
} }
@ -1591,9 +1593,10 @@ lyxstring operator+(lyxstring const & a, lyxstring::value_type b)
istream & operator>>(istream & is, lyxstring & s) istream & operator>>(istream & is, lyxstring & s)
{ {
// very bad solution // very bad solution
char nome[1024]; char * nome = new char[1024];
is >> nome; is >> nome;
lyxstring tmp(nome); lyxstring tmp(nome);
delete [] nome;
if (!tmp.empty()) s = tmp; if (!tmp.empty()) s = tmp;
return is; return is;
} }

View File

@ -98,7 +98,7 @@ public:
typedef value_type & reference; typedef value_type & reference;
/// ///
typedef const reference const_reference; typedef value_type const & const_reference;
/// ///
typedef size_t size_type; typedef size_t size_type;