*
* Dependencies: Xlib, XForms
*
- * Copyright: (c) 1996, Alejandro Aguilar Sierra
+ * Copyright: 1996, Alejandro Aguilar Sierra
*
* Version: 0.8beta.
*
#include "support/lstrings.h"
#include "debug.h"
+using std::endl;
+
const int SizeInset = sizeof(char*) + 2;
const int SizeFont = 2;
// 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, size_t n )
+inline
+void my_memcpy( void * ps_in, const void * pt_in, size_t n )
{
char * ps = static_cast<char *>(ps_in);
char const * pt = static_cast<char const *>(pt_in);
{
if (IsFont()) {
fcode = array->bf[pos];
- ++pos;
+ pos++;
}
return array->bf[pos];
}
-byte * MathedIter::GetString(int& len)
+byte* MathedIter::GetString(int& len)
{
if (IsFont()) {
fcode = array->bf[++pos];
- ++pos;
+ pos++;
}
- byte * s = &array->bf[pos];
+ byte *s = &array->bf[pos];
len = pos;
- while (array->bf[pos] >= ' ' && pos<array->last) ++pos;
+ while (array->bf[pos]>= ' ' && pos<array->last) pos++;
len = pos-len;
return s;
MathedInset* MathedIter::GetInset()
{
if (IsInset()) {
- MathedInset * p;
+ MathedInset* p;
my_memcpy(&p, &array->bf[pos+1], sizeof(p));
return p;
} else {
if (array->bf[pos]<' ') {
fcode = -1;
- if (IsTab()) ++col;
+ if (IsTab()) col++;
if (IsCR()) {
col = 0;
- ++row;
+ row++;
}
}
if (IsInset())
pos += sizeof(char*) + 2;
else
- ++pos;
+ pos++;
if (IsFont()) {
fcode = array->bf[pos++];
if (IsFont() && array->bf[pos] == t) {
fcode = t;
- ++pos;
+ pos++;
} else
if (t!= fcode && pos>0 && MathIsFont(array->bf[pos-1])) {
- --pos;
- int k = pos - 1;
- for (; k >= 0 && array->bf[k]>= ' '; --k);
+ pos--;
+ int k;
+ for (k= pos-1; k>= 0 && array->bf[k]>= ' '; k--);
fcode = (k >= 0 && MathIsFont(array->bf[k])) ? array->bf[k]: -1;
}
short f = (array->bf[pos]<' ') ? 0: fcode;
int shift = (t == fcode) ? 1: ((f) ? 3: 2);
if (t == LM_TC_TAB || t == LM_TC_CR) {
- --shift;
+ shift--;
c = t;
if (t == LM_TC_CR) {
- ++row;
+ row++;
col = 0;
} else
- ++col;
+ col++;
}
if (pos < array->last)
bool fg = false;
if (array->bf[pos]>= ' ') {
if (pos> 0 && MathIsFont(array->bf[pos-1]))
- --pos;
+ pos--;
else {
fg = true;
- ++shift;
+ shift++;
}
}
array->Move(pos, shift);
// I assume that both pos and pos2 are legal positions
void MathedIter::join(int pos2)
{
- if (!OK() || pos2 <= pos)
+ if (!OK() || pos2<= pos)
return;
- short f = fcode;
- if (pos > 0 && array->bf[pos] >= ' ' && MathIsFont(array->bf[pos-1]))
- --pos;
+ short f= fcode;
+ if (pos>0 && array->bf[pos]>= ' ' && MathIsFont(array->bf[pos-1]))
+ pos--;
if (MathIsFont(array->bf[pos2-1]))
- --pos2;
+ pos2--;
- if (array->bf[pos2] >= ' ') {
- for (int p = pos2; p > 0; --p)
+ if (array->bf[pos2]>= ' ') {
+ for (int p= pos2; p>0; p--)
if (MathIsFont(array->bf[p])) {
f = array->bf[p];
break;
if (MathIsFont(array->bf[pos-1]) && array->bf[pos+1]<' ') {
int i;
shift = 2;
- --pos;
- for (i = pos - 1; i > 0 && !MathIsFont(array->bf[i]); --i);
+ pos--;
+ for (i= pos-1; i>0 && !MathIsFont(array->bf[i]); i--);
if (i>0 && MathIsFont(array->bf[i]))
fcode = array->bf[i];
} else
shift = sizeof(char*) + 2;
else
if (c == LM_TC_TAB || c == LM_TC_CR) {
- ++shift;
+ shift++;
// lyxerr <<"Es un tab.";
}
else {
// int posx = pos;
ipush();
- LyxArrayBase * t = array, *a;
+ LyxArrayBase *t= array, *a;
- if (pos1 > 0 || pos2 <= array->last) {
+ if (pos1>0 || pos2<= array->last) {
short fc= 0;
if (pos1>0 && array->bf[pos1]>' ') {
- for (int p = pos1; p >= 0; --p)
+ for (int p= pos1; p>= 0; p--)
if (MathIsFont(array->bf[p])) {
if (p!= pos1-1)
fc = array->bf[p];
else
- --pos1;
+ pos1--;
break;
}
}
- if (pos2 > 0 && array->bf[pos2] >= ' '
- && MathIsFont(array->bf[pos2-1]))
- --pos2;
+ if (pos2>0 && array->bf[pos2]>= ' ' && MathIsFont(array->bf[pos2-1]))
+ pos2--;
int dx = pos2 - pos1;
a = new LyxArrayBase(dx+LyxArrayBase::ARRAY_MIN_SIZE);
my_memcpy(&a->bf[(fc) ? 1: 0], &array->bf[pos1], dx);
if (fc) {
a->bf[0] = fc;
- ++dx;
+ dx++;
}
a->last = dx;
a->bf[dx] = '\0';
Reset();
while (OK()) {
if (IsInset()) {
- MathedInset * inset = GetInset();
+ MathedInset* inset = GetInset();
if (inset->GetType()!= LM_OT_MACRO_ARG)
delete inset;
Delete();
crow = r;
} else {
Delete();
- --pos2;
+ pos2--;
}
}
Next();
if (p) {
crow = p->getRowSt();
if (crow)
- for (int i = 0; i < row; ++i)
+ for (int i= 0; i<row; i++)
crow = crow->next;
}
}