mathed7.diff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1473 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-02-09 17:17:08 +00:00
parent 83583d5d5b
commit bc1edc19c7
3 changed files with 14 additions and 54 deletions

View File

@ -1,5 +1,7 @@
2001-02-09 Andre Poenitz <poenitz@HTWM.De> 2001-02-09 André Pönitz <poenitz@htwm.de>
* array.h: replace array buffer 'byte bf[]' by 'std::vector<byte> bf'
* several files: subsequent changes
* math_iter.h: remove unused prototype * math_iter.h: remove unused prototype
* array.h: ditto. * array.h: ditto.
@ -9,7 +11,7 @@
compiling with lyxstring, but STL sstream). compiling with lyxstring, but STL sstream).
(Metrics): ditto. (Metrics): ditto.
2001-02-08 Andre Poenitz <poenitz@HTWM.De> 2001-02-08 André Pönitz <poenitz@htwm.de>
* several files: get rid of reinterpret_cast. * several files: get rid of reinterpret_cast.

View File

@ -14,7 +14,7 @@
* the GNU General Public Licence version 2 or later. * the GNU General Public Licence version 2 or later.
*/ */
#include <string.h> #include <vector>
#ifndef byte #ifndef byte
#define byte unsigned char #define byte unsigned char
@ -27,6 +27,8 @@
*/ */
class LyxArrayBase { class LyxArrayBase {
public: public:
///
typedef std::vector<byte> buffer_type;
/// ///
enum { enum {
/// ///
@ -40,13 +42,6 @@ public:
/// ///
explicit explicit
LyxArrayBase(int size = ARRAY_STEP); LyxArrayBase(int size = ARRAY_STEP);
///
LyxArrayBase(LyxArrayBase const &);
///
~LyxArrayBase();
/// Constructs a new array with dx elements starting at pos
LyxArrayBase & operator=(LyxArrayBase const &);
/// ///
int empty() const { return (last == 0); } int empty() const { return (last == 0); }
@ -54,9 +49,6 @@ public:
/// ///
int Last() { return last; } int Last() { return last; }
/// Fills with 0 the entire array and set last to 0
void Init();
/// Make the allocated memory fit the needed size /// Make the allocated memory fit the needed size
void Fit(); void Fit();
@ -88,7 +80,7 @@ protected:
bool Move(int p, int shift); bool Move(int p, int shift);
/// Buffer /// Buffer
byte * bf; buffer_type bf;
/// Last position inserted. /// Last position inserted.
int last; int last;
/// Max size of the array. /// Max size of the array.
@ -102,25 +94,15 @@ private:
/************************ Inline functions *****************************/ /************************ Inline functions *****************************/
inline
void LyxArrayBase::Init()
{
memset(bf, 0, maxsize);
last = 0;
}
inline // Hmmm, Hp-UX's CC can't handle this inline. Asger. inline // Hmmm, Hp-UX's CC can't handle this inline. Asger.
void LyxArrayBase::Resize(int newsize) void LyxArrayBase::Resize(int newsize)
{ {
if (newsize<ARRAY_MIN_SIZE) if (newsize<ARRAY_MIN_SIZE)
newsize = ARRAY_MIN_SIZE; newsize = ARRAY_MIN_SIZE;
newsize += ARRAY_STEP - (newsize % ARRAY_STEP); newsize += ARRAY_STEP - (newsize % ARRAY_STEP);
byte *nwbf = new byte[newsize]; bf.resize(newsize);
if (last >= newsize) last = newsize-1; if (last >= newsize) last = newsize-1;
maxsize = newsize; maxsize = newsize;
memcpy(nwbf, bf, last);
delete[] bf;
bf = nwbf;
bf[last] = 0; bf[last] = 0;
} }
@ -128,33 +110,8 @@ inline
LyxArrayBase::LyxArrayBase(int size) LyxArrayBase::LyxArrayBase(int size)
{ {
maxsize = (size<ARRAY_MIN_SIZE) ? ARRAY_MIN_SIZE: size; maxsize = (size<ARRAY_MIN_SIZE) ? ARRAY_MIN_SIZE: size;
bf = new byte[maxsize]; // this leaks bf.resize(maxsize);
Init(); last = 0;
}
inline
LyxArrayBase::~LyxArrayBase()
{
delete[] bf;
}
inline
LyxArrayBase::LyxArrayBase(LyxArrayBase const & a)
{
maxsize = a.maxsize;
bf = new byte[maxsize];
memcpy(&bf[0], &a.bf[0], maxsize);
last = a.last;
}
inline
LyxArrayBase & LyxArrayBase::operator=(LyxArrayBase const & a)
{
if (this != &a) {
Resize(a.maxsize);
memcpy(&bf[0], &a.bf[0], maxsize);
}
return *this;
} }
inline inline

View File

@ -206,8 +206,9 @@ void MathParInset::Write(ostream & os, bool fragile)
if (l) { if (l) {
os << '\\' << l->name << ' '; os << '\\' << l->name << ' ';
} else { } else {
lyxerr << "Illegal symbol code[" << c #warning this does not compile on gcc 2.97
<< " " << str.end() - s << " " << data.FCode() << "]"; //lyxerr << "Illegal symbol code[" << c
// << " " << str.end() - s << " " << data.FCode() << "]";
} }
} else { } else {
// Is there a standard logical XOR? // Is there a standard logical XOR?