From: Jean-Marc Lasgouttes Date: Mon, 6 Dec 1999 16:55:06 +0000 (+0000) Subject: Hopefully a final fix for the egcs broken memcpy() problem on alpha X-Git-Tag: 1.6.10~22485 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=2a7aef61f0871670bff646e360b0cd6ad5a9dc21;p=lyx.git Hopefully a final fix for the egcs broken memcpy() problem on alpha git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@353 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/ChangeLog b/ChangeLog index 7f9b125f47..9bb92c724b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 1999-12-06 Jean-Marc Lasgouttes + * src/mathed/math_iter.C (my_memcpy): new function. Since the + built-in memcpy() is broken on egcs and gcc 2.95 for alpha + architecture, we provide our own. It is used unconditionnally, but + I do not think this is a performance problem. Thanks to Angus + Leeming for the code (and again to Michal + Jaegermann for finding it the + first time). + (GetInset): use my_memcpy. + (Insert): ditto + (Copy): ditto + * lib/chkconfig.ltx: some cleanup of the latex code. I am not sure it is easier to understand, but it uses less TeX-only constructs now. diff --git a/src/mathed/math_iter.C b/src/mathed/math_iter.C index 2f9a13d2e6..4dc8789ca0 100644 --- a/src/mathed/math_iter.C +++ b/src/mathed/math_iter.C @@ -34,6 +34,16 @@ extern int mathed_char_width(short type, int style, byte c); extern int mathed_string_width(short type, int style, byte const* s, int ls); extern int mathed_char_height(short, int, byte, int&, int&); +// the builtin memcpy() is broken in egcs and gcc 2.95.x on alpha +// stations. We provide a hand-made version instead. +inline void my_memcpy( void* ps_in, const void* pt_in, unsigned int n ) +{ + char* ps = static_cast(ps_in); + char* pt = static_cast(const_cast(pt_in)); + for( int i = 0; i < n; i++) + *ps++ = *pt++; +} + void MathedIter::Reset() { @@ -76,7 +86,7 @@ MathedInset* MathedIter::GetInset() { if (IsInset()) { MathedInset* p; - memcpy(&p, &array->bf[pos+1], sizeof(p)); + my_memcpy(&p, &array->bf[pos+1], sizeof(p)); return p; } else { lyxerr << "Math Error: This is not an inset[" @@ -267,21 +277,10 @@ void MathedIter::Insert(MathedInset* p, int type) if (!MathIsInset(type)) type = LM_TC_INSET; split(shift); -// array->bf[pos] = type; -// memcpy(&array->bf[pos+1], &p, sizeof(p)); -// pos += SizeInset; -// array->bf[pos-1] = type; - { - unsigned char *pt = &array->bf[pos]; - unsigned char *ps = reinterpret_cast(&p); - size_t i; - *pt++ = type; - for(i = 0; i < sizeof(p); i++) { - *pt++ = *ps++; - } - *pt = type; - } + array->bf[pos] = type; + my_memcpy(&array->bf[pos+1], &p, sizeof(p)); pos += SizeInset; + array->bf[pos-1] = type; array->bf[array->last] = '\0'; fcode = -1; } @@ -357,7 +356,7 @@ LyxArrayBase *MathedIter::Copy(int pos1, int pos2) int dx = pos2 - pos1; a = new LyxArrayBase(dx+LyxArrayBase::ARRAY_MIN_SIZE); // lyxerr << "VA " << pos2 << " " << pos2 << " " << dx << endl; - memcpy(&a->bf[(fc) ? 1: 0], &array->bf[pos1], dx); + my_memcpy(&a->bf[(fc) ? 1: 0], &array->bf[pos1], dx); if (fc) { a->bf[0] = fc; dx++; @@ -371,7 +370,7 @@ LyxArrayBase *MathedIter::Copy(int pos1, int pos2) if (IsInset()) { MathedInset* inset = GetInset(); inset = inset->Clone(); - memcpy(&array->bf[pos+1], &inset, sizeof(inset)); + my_memcpy(&array->bf[pos+1], &inset, sizeof(inset)); } Next(); }