fix 62658 handle non-zero yarn form fields for future history work, r=alecf, sr=sspitzer

This commit is contained in:
bienvenu%netscape.com 2001-05-09 13:34:08 +00:00
parent c6f551d382
commit 61a0025361
4 changed files with 100 additions and 4 deletions

View File

@ -453,7 +453,8 @@ morkBookAtom::EqualFormAndBody(morkEnv* ev, const morkBookAtom* inAtom) const
else
this->NonBookAtomTypeError(ev);
if ( body && thisBody && size == thisSize && form == thisForm )
// if atoms are empty, form is irrelevant
if ( body && thisBody && size == thisSize && (!size || form == thisForm ))
outEqual = (MORK_MEMCMP(body, thisBody, size) == 0);
return outEqual;

View File

@ -60,6 +60,10 @@
#include "morkCh.h"
#endif
#ifndef _MORKSTORE_
#include "morkStore.h"
#endif
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
// ````` ````` ````` ````` `````
@ -543,7 +547,13 @@ morkParser::ReadCell(morkEnv* ev)
}
else
{
cellBuf = this->ReadName(ev, c);
if (mParser_InMeta && c == morkStore_kFormColumn)
{
ReadCellForm(ev, c);
return;
}
else
cellBuf = this->ReadName(ev, c);
}
if ( ev->Good() )
{
@ -926,6 +936,77 @@ morkBuf* morkParser::ReadValue(morkEnv* ev)
return outBuf;
}
void morkParser::ReadDictForm(morkEnv *ev)
{
int nextChar;
morkStream* s = mParser_Stream;
nextChar = this->NextChar(ev);
if (nextChar == '(')
{
nextChar = this->NextChar(ev);
if (nextChar == morkStore_kFormColumn)
{
int dictForm;
nextChar = this->NextChar(ev);
if (nextChar == '=')
{
dictForm = this->NextChar(ev);
nextChar = this->NextChar(ev);
}
else if (nextChar == '^')
{
dictForm = this->ReadHex(ev, &nextChar);
}
else
{
ev->NewWarning("unexpected byte in dict form");
return;
}
mParser_ValueCoil.mText_Form = dictForm;
if (nextChar == ')')
{
nextChar = this->NextChar(ev);
if (nextChar == '>')
return;
}
}
}
ev->NewWarning("unexpected byte in dict form");
}
void morkParser::ReadCellForm(morkEnv *ev, int c)
{
MORK_ASSERT (c == morkStore_kFormColumn);
int nextChar;
morkStream* s = mParser_Stream;
nextChar = this->NextChar(ev);
int cellForm;
if (nextChar == '=')
{
cellForm = this->NextChar(ev);
nextChar = this->NextChar(ev);
}
else if (nextChar == '^')
{
cellForm = this->ReadHex(ev, &nextChar);
}
else
{
ev->NewWarning("unexpected byte in cell form");
return;
}
// ### not sure about this. Which form should we set?
// mBuilder_CellForm = mBuilder_RowForm = cellForm;
if (nextChar == ')')
{
OnCellForm(ev, cellForm);
return;
}
ev->NewWarning("unexpected byte in cell form");
}
void morkParser::ReadAlias(morkEnv* ev)
// zm:Alias ::= zm:S? '(' ('#')? zm:Hex+ zm:S? zm:Value ')'
// zm:Value ::= '=' ([^)$\] | '\' zm:NonCRLF | zm:Continue | zm:Dollar)*
@ -944,6 +1025,12 @@ void morkParser::ReadAlias(morkEnv* ev)
if ( ev->Good() )
{
if ( c == '<')
{
ReadDictForm(ev);
if (ev->Good())
c = this->NextChar(ev);
}
if ( c == '=' )
{
mParser_Mid.mMid_Buf = this->ReadValue(ev);
@ -951,6 +1038,9 @@ void morkParser::ReadAlias(morkEnv* ev)
{
// this->EndSpanOnThisByte(ev, &mParser_AliasSpan);
this->OnAlias(ev, mParser_AliasSpan, mParser_Mid);
// need to reset this somewhere.
mParser_ValueCoil.mText_Form = 0;
}
}
else

View File

@ -495,6 +495,8 @@ protected: // protected parser helper methods
morkBuf* ReadValue(morkEnv* ev);
morkBuf* ReadName(morkEnv* ev, int c);
mork_bool ReadMid(morkEnv* ev, morkMid* outMid);
void ReadDictForm(morkEnv *ev);
void ReadCellForm(morkEnv *ev, int c);
mork_bool MatchPattern(morkEnv* ev, const char* inPattern);

View File

@ -403,6 +403,8 @@ morkWriter::WriteYarn(morkEnv* ev, const mdbYarn* inYarn)
// implies that escaped line breaks will make the size value smaller
// than the entire yarn's size, since only part goes on a last line).
{
mork_size outSize = 0;
mork_size lineSize = mWriter_LineSize;
morkStream* stream = mWriter_Stream;
@ -412,6 +414,7 @@ morkWriter::WriteYarn(morkEnv* ev, const mdbYarn* inYarn)
{
register int c;
mork_fill fill = inYarn->mYarn_Fill;
const mork_u1* end = b + fill;
while ( b < end && ev->Good() )
{
@ -1561,7 +1564,7 @@ morkWriter::ChangeRowForm(morkEnv* ev, mork_cscode inNewForm)
*p++ = (char) morkStore_kFormColumn;
mork_size formSize = 1; // default to one byte
if ( inNewForm >= 0x80 )
if (! morkCh_IsValue(inNewForm))
{
*p++ = '^'; // indicates col is hex ID
formSize = ev->TokenAsHex(p, inNewForm);
@ -1603,7 +1606,7 @@ morkWriter::ChangeDictForm(morkEnv* ev, mork_cscode inNewForm)
*p++ = (char) morkStore_kFormColumn;
mork_size formSize = 1; // default to one byte
if ( inNewForm >= 0x80 )
if (! morkCh_IsValue(inNewForm))
{
*p++ = '^'; // indicates col is hex ID
formSize = ev->TokenAsHex(p, inNewForm);