Canonical name

main
Alan Francis 1 year ago
parent 0caf66875c
commit 663dab64ed
  1. 29
      configmodel.c
  2. 3
      configmodel.h

@ -192,12 +192,16 @@ VOID LineDump(LINEPTR abstractLine)
else if( line->variable == NULL && line->section != NULL )
{
struct Section* section = (struct Section*)LineGetSection(abstractLine);
CONST_STRPTR canonical = NULL;
Printf("(new section %s", section->primary);
if( section->secondary )
{
Printf("[%s]", section->secondary);
}
Printf(")\n");
canonical = SectionCanonicalName(section);
Printf("...((%s))...\n", canonical);
FreeVec((STRPTR)canonical);
}
else
{
@ -350,6 +354,31 @@ VOID SectionFree(SECTIONPTR abstractSection)
}
}
CONST_STRPTR SectionCanonicalName(SECTIONPTR abstractSection)
{
struct Section* section = (struct Section*)abstractSection;
STRPTR result = NULL;
if(section != NULL)
{
ULONG primaryLength = 0;
ULONG secondaryLength = 0;
if(section->primary != NULL)
{
primaryLength = strlen(section->primary);
}
if(section->secondary != NULL)
{
secondaryLength = strlen(section->secondary);
}
result = AllocVec(primaryLength+1+secondaryLength+1, MEMF_CLEAR);
CopyMem(section->primary, result, primaryLength);
result[primaryLength] = '.';
CopyMem(section->secondary, result+primaryLength+1, secondaryLength);
}
return result;
}
VARIABLEPTR VariableCreate(CONST_STRPTR key, CONST_STRPTR rawValue)
{
struct Variable* result = NULL;

@ -22,7 +22,8 @@ CONST_STRPTR LineGetRawText(LINEPTR line);
SECTIONPTR SectionCreateWithName(CONST_STRPTR primary);
SECTIONPTR SectionCreateWithNameAndSubname(CONST_STRPTR primary, CONST_STRPTR secondary);
VOID SectionFree(SECTIONPTR abstractSection);
VOID SectionFree(SECTIONPTR section);
CONST_STRPTR SectionCanonicalName(SECTIONPTR section);
VARIABLEPTR VariableCreate(CONST_STRPTR key, CONST_STRPTR rawValue);
VOID VariableFree(VARIABLEPTR abstractVariable);

Loading…
Cancel
Save