|
|
|
@ -109,7 +109,7 @@ CONFIGFILEPTR ConfigFileRead(CONST_STRPTR filename) |
|
|
|
|
result->sectionStore = SectionStoreNew(); |
|
|
|
|
result->lines = LineArrayNew(); |
|
|
|
|
InitialisePatterns(); |
|
|
|
|
while( (line = LineReadIncludingContinuation(configFile, currentSection)) != NULL ) |
|
|
|
|
while( (line = LineReadIncludingContinuation(configFile, result->sectionStore, currentSection)) != NULL ) |
|
|
|
|
{ |
|
|
|
|
// add it to the flat list of lines
|
|
|
|
|
LineArrayAppend(result->lines, line); |
|
|
|
@ -131,7 +131,7 @@ VOID ConfigFileSave(CONFIGFILEPTR config) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
LINEPTR LineCreate(CONST_STRPTR buffer, ULONG size) |
|
|
|
|
LINEPTR LineCreate(CONST_STRPTR buffer, ULONG size, SECTIONSTOREPTR sectionStore) |
|
|
|
|
{ |
|
|
|
|
struct Line* result = NULL; |
|
|
|
|
StringArray matches = NULL; |
|
|
|
@ -144,13 +144,19 @@ LINEPTR LineCreate(CONST_STRPTR buffer, ULONG size) |
|
|
|
|
|
|
|
|
|
if( matches = RunPattern(result->rawText, sectionPatternProgram) )
|
|
|
|
|
{ |
|
|
|
|
SECTIONPTR section = NULL; |
|
|
|
|
if( SizeOfArray(matches) == 3 ) |
|
|
|
|
{ |
|
|
|
|
result->section = SectionCreateWithName(StringArrayValues(matches)[1]); |
|
|
|
|
section = SectionCreateWithName(StringArrayValues(matches)[1]); |
|
|
|
|
} |
|
|
|
|
else if( SizeOfArray(matches) == 5 ) |
|
|
|
|
{ |
|
|
|
|
result->section = SectionCreateWithNameAndSubname(StringArrayValues(matches)[1], StringArrayValues(matches)[3]); |
|
|
|
|
section = SectionCreateWithNameAndSubname(StringArrayValues(matches)[1], StringArrayValues(matches)[3]); |
|
|
|
|
} |
|
|
|
|
if( section != NULL ) |
|
|
|
|
{ |
|
|
|
|
SectionStoreAddSection(sectionStore, section); |
|
|
|
|
result->section = section; |
|
|
|
|
} |
|
|
|
|
StringArrayFree(matches); |
|
|
|
|
} |
|
|
|
@ -217,7 +223,7 @@ VOID LineDump(LINEPTR abstractLine) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
LINEPTR LineReadIncludingContinuation(BPTR file, SECTIONPTR currentSection) |
|
|
|
|
LINEPTR LineReadIncludingContinuation(BPTR file, SECTIONSTOREPTR sectionStore, SECTIONPTR currentSection) |
|
|
|
|
{ |
|
|
|
|
UBYTE* buffer = AllocVec(512, MEMF_CLEAR); |
|
|
|
|
ULONG bufLength = 512; |
|
|
|
@ -236,7 +242,7 @@ LINEPTR LineReadIncludingContinuation(BPTR file, SECTIONPTR currentSection) |
|
|
|
|
// make a line
|
|
|
|
|
if( bytesReadTotal > 0 ) |
|
|
|
|
{ |
|
|
|
|
result = LineCreate(buffer, bytesReadTotal); |
|
|
|
|
result = LineCreate(buffer, bytesReadTotal, sectionStore); |
|
|
|
|
if( result->variable != NULL && result->section == NULL ) |
|
|
|
|
{ |
|
|
|
|
result->section = currentSection; |
|
|
|
@ -276,12 +282,7 @@ VOID LineFree(LINEPTR abstractLine) |
|
|
|
|
{ |
|
|
|
|
FreeVec(line->rawText); |
|
|
|
|
} |
|
|
|
|
if( line->section != NULL && line->variable == NULL ) |
|
|
|
|
{ |
|
|
|
|
//only free the section in a section line,
|
|
|
|
|
//not a variable line as thats just a weak ref
|
|
|
|
|
SectionFree(line->section); |
|
|
|
|
} |
|
|
|
|
// we dont free the section as its stored in the section store
|
|
|
|
|
if( line->variable != NULL ) |
|
|
|
|
{ |
|
|
|
|
VariableFree(line->variable); |
|
|
|
|