From 35df50f78c43af48243773e4205f7fca10cb38ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Mon, 15 Nov 1999 14:45:17 +0000 Subject: [PATCH] some other things git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@317 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 9 +++++++++ src/mathed/math_parser.C | 2 +- src/support/LSubstring.C | 16 +++------------- src/support/LSubstring.h | 10 +++------- src/support/lyxstring.C | 16 ++++++++++++++++ src/support/lyxstring.h | 5 +++++ 6 files changed, 37 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5691c5a8db..1247802360 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 1999-11-15 Lars Gullik Bjønnes + * src/support/LSubstring.[Ch]: made the second arg of most of the + constructors be a const reference. + + * src/mathed/math_parser.C (LexInitCodes): small bug introduced by + me fixed. + + * src/support/lyxstring.[Ch] (swap): added missing member function + and specialization of swap(str, str); + * src/menus.C (ShowBufferMenu): to use the new BufferStorage * src/bufferlist.[Ch]: use the new BufferStorage class and remove all diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index be49f67e1d..d8db81f1c1 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -119,7 +119,7 @@ static void LexInitCodes() lexcode['%'] = LexComment; lexcode['#'] = LexArgument; lexcode['+'] = lexcode['-'] = lexcode['*'] = lexcode['/'] = - lexcode['<'] = lexcode['>'] = lexcode['= '] = LexBOP; + lexcode['<'] = lexcode['>'] = lexcode['='] = LexBOP; lexcode['!'] = lexcode[','] = lexcode[':'] = lexcode[';'] = LexMathSpace; lexcode['('] = lexcode[')'] = lexcode['|'] = lexcode['.'] = lexcode['?'] = LexOther; diff --git a/src/support/LSubstring.C b/src/support/LSubstring.C index b2c2ef05de..6c5509fdad 100644 --- a/src/support/LSubstring.C +++ b/src/support/LSubstring.C @@ -21,14 +21,14 @@ LSubstring::LSubstring(string & s, size_type i, size_type l) } -LSubstring::LSubstring(string & s, string & s2) +LSubstring::LSubstring(string & s, string const & s2) : ps(&s), n(s2.length()) { pos = s.find(s2); } -LSubstring::LSubstring(string & s, char * p) +LSubstring::LSubstring(string & s, string::value_type const * p) : ps(&s) { n = strlen(p); @@ -36,7 +36,7 @@ LSubstring::LSubstring(string & s, char * p) } -LSubstring::LSubstring(string & s, LRegex & r) +LSubstring::LSubstring(string & s, LRegex const & r) : ps(&s) { LRegex::MatchPair res = r.first_match(s); @@ -82,13 +82,3 @@ LSubstring::operator string() const { return string(*ps, pos, n); // copy from *ps } - - -#if 0 -LSubstring::operator char const * () const -{ - static string tr; - tr.assign(*ps, pos, n); - return tr.c_str(); -} -#endif diff --git a/src/support/LSubstring.h b/src/support/LSubstring.h index 96164f11b9..f5ec98b8f9 100644 --- a/src/support/LSubstring.h +++ b/src/support/LSubstring.h @@ -31,11 +31,11 @@ public: /// LSubstring(string & s, size_type i, size_type n); /// - LSubstring(string & s, string & s2); + LSubstring(string & s, string const & s2); /// - LSubstring(string & s, string::value_type * p); + LSubstring(string & s, string::value_type const * p); /// - LSubstring(string & s, LRegex & r); + LSubstring(string & s, LRegex const & r); /// LSubstring & operator=(string const &); /// @@ -46,10 +46,6 @@ public: LSubstring & operator=(string::value_type); /// operator string() const; -#if 0 - /// - operator char const * () const; -#endif private: /// string * ps; diff --git a/src/support/lyxstring.C b/src/support/lyxstring.C index 129cd75746..1083669415 100644 --- a/src/support/lyxstring.C +++ b/src/support/lyxstring.C @@ -1345,6 +1345,15 @@ lyxstring & lyxstring::replace(iterator i, iterator i2, } +void lyxstring::swap(lyxstring & str) +{ + if (rep == str.rep) return; + Srep * tmp = str.rep; + str.rep = rep; + rep = tmp; +} + + lyxstring & lyxstring::erase(size_type i, size_type n) { Assert(i <= rep->sz); // STD! @@ -1667,6 +1676,13 @@ lyxstring operator+(lyxstring const & a, lyxstring::value_type b) return tmp; } + +void swap(lyxstring & str1, lyxstring & str2) +{ + str1.swap(str2); +} + + #include istream & operator>>(istream & is, lyxstring & s) diff --git a/src/support/lyxstring.h b/src/support/lyxstring.h index 22e0b88cc3..f2cd44fbf3 100644 --- a/src/support/lyxstring.h +++ b/src/support/lyxstring.h @@ -449,6 +449,9 @@ public: /// lyxstring & replace(iterator i, iterator i2, iterator j, iterator j2); + /// + void swap(lyxstring & str); + /// Erase n chars from position i. lyxstring & erase(size_type i = 0, size_type n = npos); @@ -599,6 +602,8 @@ lyxstring operator+(lyxstring::value_type a, lyxstring const & b); lyxstring operator+(lyxstring const & a, lyxstring::value_type const * b); lyxstring operator+(lyxstring const & a, lyxstring::value_type b); +void swap(lyxstring & s1, lyxstring & s2); + istream & operator>>(istream &, lyxstring &); ostream & operator<<(ostream &, lyxstring const &); istream & getline(istream &, lyxstring &, lyxstring::value_type delim = '\n');