|
|
|
@ -15,7 +15,7 @@ struct Section |
|
|
|
|
CONST_STRPTR primary; |
|
|
|
|
CONST_STRPTR secondary; |
|
|
|
|
LineArray lines; |
|
|
|
|
BOOL lastLineWasEmpty; |
|
|
|
|
ULONG insertPos; // we want to add new entries at end, but before any blanks
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
enum VariableType
|
|
|
|
@ -248,7 +248,7 @@ SECTIONPTR SectionCreateWithNameAndSubname(CONST_STRPTR primary, CONST_STRPTR se |
|
|
|
|
{ |
|
|
|
|
ULONG length = strlen(primary); |
|
|
|
|
result = AllocVec(sizeof(struct Section), MEMF_CLEAR); |
|
|
|
|
result->lastLineWasEmpty = FALSE; |
|
|
|
|
result->insertPos = 0; |
|
|
|
|
result->primary = AllocVec(length+1, MEMF_CLEAR); |
|
|
|
|
CopyMem(primary, (STRPTR)result->primary, length); |
|
|
|
|
|
|
|
|
@ -269,7 +269,7 @@ VOID SectionAddSectionLine(SECTIONPTR abstractSection, LINEPTR abstractLine) |
|
|
|
|
{ |
|
|
|
|
// sets self onto line and then adds line to the collection
|
|
|
|
|
LineSetSection(abstractLine, abstractSection); |
|
|
|
|
SectionAddLine(abstractSection, abstractLine); |
|
|
|
|
SectionAddLine(abstractSection, abstractLine, FALSE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// we need to know if there are blank lines at the end and if this is a variable,
|
|
|
|
@ -290,32 +290,30 @@ VOID SectionAddSectionLine(SECTIONPTR abstractSection, LINEPTR abstractLine) |
|
|
|
|
// [baz]
|
|
|
|
|
// etc
|
|
|
|
|
|
|
|
|
|
VOID SectionAddLine(SECTIONPTR abstractSection, LINEPTR abstractLine) |
|
|
|
|
VOID SectionAddLine(SECTIONPTR abstractSection, LINEPTR abstractLine, BOOL addBeforeBlanks) |
|
|
|
|
{ |
|
|
|
|
struct Section* section = (struct Section*)abstractSection; |
|
|
|
|
if( section != NULL ) |
|
|
|
|
{ |
|
|
|
|
//Printf("\n\SAD1 (%ld bytes avail)\n\n", AvailMem(0));
|
|
|
|
|
|
|
|
|
|
// if the last line is empty and new line is NOT, insert new line before the blank.
|
|
|
|
|
if( section->lastLineWasEmpty && !LineIsEmpty(abstractLine) ) |
|
|
|
|
if( addBeforeBlanks==FALSE || section->insertPos == SizeOfArray(section->lines) ) |
|
|
|
|
{ |
|
|
|
|
LINEPTR lastLine = ArrayBackValue(LINEPTR, section->lines); |
|
|
|
|
ULONG lastIndex = SizeOfArray(section->lines)-1; |
|
|
|
|
//Printf("\n\SAD2 (%ld bytes avail)\n\n", AvailMem(0));
|
|
|
|
|
LineArrayValues(section->lines)[lastIndex] = abstractLine; |
|
|
|
|
LineArrayAppend(section->lines, lastLine);
|
|
|
|
|
//Printf("\n\SAD3 (%ld bytes avail)\n\n", AvailMem(0));
|
|
|
|
|
LineArrayAppend(section->lines, abstractLine); |
|
|
|
|
if(!LineIsEmpty(abstractLine) ) |
|
|
|
|
{ |
|
|
|
|
section->insertPos = SizeOfArray(section->lines); |
|
|
|
|
printf("xx (%s) insertpos = %lu\n", SectionCanonicalName(abstractSection), section->insertPos); |
|
|
|
|
LineDump(abstractLine); |
|
|
|
|
printf("xx\n"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
//Printf("\n\SAD4 (%ld bytes avail)\n\n", AvailMem(0));
|
|
|
|
|
LineArrayAppend(section->lines, abstractLine); |
|
|
|
|
//Printf("\n\SAD5 (%ld bytes avail)\n\n", AvailMem(0));
|
|
|
|
|
LineArrayInsert(section->lines, abstractLine, section->insertPos); |
|
|
|
|
section->insertPos += 1;
|
|
|
|
|
printf("yy (%s) insertpos = %lu\n", SectionCanonicalName(abstractSection), section->insertPos); |
|
|
|
|
LineDump(abstractLine); |
|
|
|
|
printf("yy\n"); |
|
|
|
|
} |
|
|
|
|
//Printf("\n\SAD6 (%ld bytes avail)\n\n", AvailMem(0));
|
|
|
|
|
section->lastLineWasEmpty = LineIsEmpty(abstractLine); |
|
|
|
|
//Printf("\n\SAD7 (%ld bytes avail)\n\n", AvailMem(0));
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|