From 4894fbc987aa3167829573443fa1a2624af1472f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Wed, 20 Oct 1999 01:53:59 +0000 Subject: [PATCH] hopefully solve some of the lyxstring problems. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@217 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 9 +++++++++ src/support/lyxstring.C | 13 ++++++++----- src/support/lyxstring.h | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 549534c922..65db604ee7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +1999-10-20 Lars Gullik Bjønnes + + * 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 * Makefile.am (rpmdist): fixed to have non static package and diff --git a/src/support/lyxstring.C b/src/support/lyxstring.C index 8f85a8b18b..c76af29334 100644 --- a/src/support/lyxstring.C +++ b/src/support/lyxstring.C @@ -120,7 +120,7 @@ void lyxstringInvariant::helper() const Assert(object->rep->res); // always some space allocated Assert(object->size() <= object->rep->res); 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 // 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, - size_type n) const +lyxstring::size_type lyxstring::find_last_not_of(value_type const * ptr, + size_type i, + size_type n) const { Assert(ptr); TestlyxstringInvariant(this); + if (!n) return npos; 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) { 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) { // very bad solution - char nome[1024]; + char * nome = new char[1024]; is >> nome; lyxstring tmp(nome); + delete [] nome; if (!tmp.empty()) s = tmp; return is; } diff --git a/src/support/lyxstring.h b/src/support/lyxstring.h index a2cba89b8f..48f0883009 100644 --- a/src/support/lyxstring.h +++ b/src/support/lyxstring.h @@ -98,7 +98,7 @@ public: typedef value_type & reference; /// - typedef const reference const_reference; + typedef value_type const & const_reference; /// typedef size_t size_type; -- 2.39.5