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
* array.h: ditto.
@ -9,7 +11,7 @@
compiling with lyxstring, but STL sstream).
(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.

View File

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

View File

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