From: Lars Gullik Bjønnes Date: Tue, 6 Mar 2001 10:24:45 +0000 (+0000) Subject: mathed41.diff X-Git-Tag: 1.6.10~21521 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=cb25ec231e335038cb52c9e6765d23ef7f20ea15;p=features.git mathed41.diff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1679 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 3e90e0f060..6be2e3dfde 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,5 +1,11 @@ -2001-02-14 André Pönitz +2001-03-06 André Pönitz + * array.[Ch]: factor out deep_copy, + remove third argument from raw_pointer_insert + + * mathiter.[Ch]: remove unused function Clear() + +2001-03-04 André Pönitz * math_macrotemplate.[Ch]: math_macro.C: move update() functionality to the macro diff --git a/src/mathed/array.C b/src/mathed/array.C index 9004200de8..234384cf79 100644 --- a/src/mathed/array.C +++ b/src/mathed/array.C @@ -60,13 +60,17 @@ MathedArray::MathedArray(MathedArray const & array) last_ = array.last_; // deep copy - // we'll not yet get exeption safety + deep_copy(); +} + +void MathedArray::deep_copy() +{ MathedIter it(this); while (it.OK()) { if (it.IsInset()) { MathedInset * inset = it.GetInset(); inset = inset->Clone(); - raw_pointer_insert(inset, it.getPos() + 1, sizeof(inset)); + raw_pointer_insert(inset, it.getPos() + 1); } it.Next(); } @@ -200,18 +204,8 @@ void MathedArray::shrink(int pos1, int pos2) a.last(dx); a[dx] = '\0'; - MathedIter it(&a); - it.Reset(); - - while (it.OK()) { - if (it.IsInset()) { - MathedInset * inset = it.GetInset(); - inset = inset->Clone(); - a.raw_pointer_insert(inset, it.getPos() + 1, sizeof(inset)); - } - it.Next(); - } swap(a); + deep_copy(); } @@ -261,9 +255,9 @@ MathedInset * MathedArray::getInset(int pos) } #else -void MathedArray::raw_pointer_insert(void * p, int pos, int len) +void MathedArray::raw_pointer_insert(void * p, int pos) { - my_memcpy(&bf_[pos], &p, len); + my_memcpy(&bf_[pos], &p, sizeof(p)); } #endif diff --git a/src/mathed/array.h b/src/mathed/array.h index 158affcdbf..f60f840667 100644 --- a/src/mathed/array.h +++ b/src/mathed/array.h @@ -96,7 +96,7 @@ public: MathedInset * getInset(int pos); #else /// - void raw_pointer_insert(void * p, int pos, int len); + void raw_pointer_insert(void * p, int pos); #endif /// void strange_copy(MathedArray * dest, int dpos, int spos, int len); @@ -113,6 +113,8 @@ public: void need_size(int needed); /// void dump(std::ostream &) const; + /// creates copies of all embedded insets + void deep_copy(); private: /// Buffer buffer_type bf_; diff --git a/src/mathed/math_iter.C b/src/mathed/math_iter.C index 39e32ea0e7..23c6b81e0a 100644 --- a/src/mathed/math_iter.C +++ b/src/mathed/math_iter.C @@ -325,7 +325,7 @@ void MathedIter::insertInset(MathedInset * p, int type) split(shift); (*array)[pos] = type; - array->raw_pointer_insert(p, pos + 1, sizeof(p)); + array->raw_pointer_insert(p, pos + 1); pos += SizeInset; (*array)[pos - 1] = type; (*array)[array->last()] = '\0'; @@ -376,27 +376,6 @@ bool MathedIter::Delete() return false; } - -void MathedIter::Clear() -{ - if (!array) { - lyxerr << "Math error: Attempting to clean a void array." << endl; - return; - } - - Reset(); - while (OK()) { - if (IsInset()) { - MathedInset * inset = GetInset(); - if (inset->GetType()!= LM_OT_MACRO_ARG) - delete inset; - Delete(); - } else - Next(); - } -} - - // Check consistency of tabs and crs void MathedIter::checkTabs() { diff --git a/src/mathed/math_iter.h b/src/mathed/math_iter.h index 2706fa2bb6..8099bf1f38 100644 --- a/src/mathed/math_iter.h +++ b/src/mathed/math_iter.h @@ -110,8 +110,6 @@ public: void setNumCols(int n) { ncols = n; } /// MathedArray * GetData() const; - /// Copy every object from position p1 to p2 - void Clear(); protected: /// void split(int);