X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Farray.C;h=bc5b02596d7fb8a7704f6c016ce97a8cbc988018;hb=b5e793e7bbaee4db52c85fcc3b09cd117178d5d1;hp=2ef09bf7c9c2ef42f244ec2bf3f0d2b8563bd67a;hpb=4203d759adcd9bdcd726c9b5b54f9cbd520c74b1;p=lyx.git diff --git a/src/mathed/array.C b/src/mathed/array.C index 2ef09bf7c9..bc5b02596d 100644 --- a/src/mathed/array.C +++ b/src/mathed/array.C @@ -9,7 +9,11 @@ #include "math_iter.h" #include "math_inset.h" -// Is this still needed? (Lgb) +#include "support/LOstream.h" + +using std::ostream; +using std::endl; + static inline void * my_memcpy(void * ps_in, void const * pt_in, size_t n) { @@ -55,13 +59,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(); } @@ -195,18 +203,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(); } @@ -256,9 +254,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