|
|
|
@ -42,9 +42,11 @@ LINEPTR LineNew(CONST_STRPTR buffer) |
|
|
|
|
struct Line* result = NULL; |
|
|
|
|
if( buffer != 0 ) |
|
|
|
|
{ |
|
|
|
|
int bufferlen = strlen(buffer); |
|
|
|
|
result = AllocVec(sizeof(struct Line), MEMF_CLEAR); |
|
|
|
|
result->rawText = AllocVec(strlen(buffer)+1, MEMF_CLEAR); |
|
|
|
|
CopyMem(buffer, result->rawText, strlen(buffer));
|
|
|
|
|
result->rawText = AllocVec(bufferlen+1, 0L); |
|
|
|
|
CopyMem(buffer, result->rawText, bufferlen); |
|
|
|
|
result->rawText[bufferlen] = '\0'; |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
@ -242,17 +244,19 @@ SECTIONPTR SectionCreateWithNameAndSubname(CONST_STRPTR primary, CONST_STRPTR se |
|
|
|
|
|
|
|
|
|
if( primary != NULL ) |
|
|
|
|
{ |
|
|
|
|
ULONG length = strlen(primary); |
|
|
|
|
int primarylen = strlen(primary); |
|
|
|
|
int secondarylen = secondary ? strlen(secondary) : 0; |
|
|
|
|
result = AllocVec(sizeof(struct Section), MEMF_CLEAR); |
|
|
|
|
result->insertPos = 0; |
|
|
|
|
result->primary = AllocVec(length+1, MEMF_CLEAR); |
|
|
|
|
CopyMem(primary, (STRPTR)result->primary, length); |
|
|
|
|
result->primary = AllocVec(primarylen+1, 0L); |
|
|
|
|
CopyMem(primary, (STRPTR)result->primary, primarylen); |
|
|
|
|
((STRPTR)result->primary)[primarylen] = '\0'; |
|
|
|
|
|
|
|
|
|
if( secondary != NULL && strlen(secondary) > 0 ) |
|
|
|
|
if( secondary != NULL && secondarylen > 0 ) |
|
|
|
|
{ |
|
|
|
|
ULONG length = strlen(secondary); |
|
|
|
|
result->secondary = AllocVec(length+1, MEMF_CLEAR); |
|
|
|
|
CopyMem(secondary, (STRPTR)result->secondary, length); |
|
|
|
|
result->secondary = AllocVec(secondarylen+1, 0L); |
|
|
|
|
CopyMem(secondary, (STRPTR)result->secondary, secondarylen); |
|
|
|
|
((STRPTR)result->secondary)[secondarylen] = '\0'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
result->lines = LineArrayNew(); |
|
|
|
@ -327,8 +331,10 @@ VOID SectionCollectLinesForVariable(SECTIONPTR abstractSection, CONST_STRPTR var |
|
|
|
|
{ |
|
|
|
|
ULONG lineCount = SizeOfArray(section->lines); |
|
|
|
|
ULONG index = 0; |
|
|
|
|
STRPTR normalizedKey = AllocVec(strlen(varKey)+1, MEMF_CLEAR); |
|
|
|
|
CopyMem(varKey, normalizedKey, strlen(varKey)); |
|
|
|
|
int varKeylen = strlen(varKey); |
|
|
|
|
STRPTR normalizedKey = AllocVec(varKeylen+1, 0L); |
|
|
|
|
CopyMem(varKey, normalizedKey, varKeylen); |
|
|
|
|
normalizedKey[varKeylen] = '\0'; |
|
|
|
|
downcaseString(normalizedKey); |
|
|
|
|
|
|
|
|
|
for( index = 0; index < lineCount; index++ ) |
|
|
|
@ -356,8 +362,10 @@ VOID SectionRemoveLinesForVariable(SECTIONPTR abstractSection, CONST_STRPTR varK |
|
|
|
|
ULONG index = 0; |
|
|
|
|
ULONG newInsertPos = 0; |
|
|
|
|
LineArray newLineArray = LineArrayNew(); |
|
|
|
|
STRPTR normalizedKey = AllocVec(strlen(varKey)+1, MEMF_CLEAR); |
|
|
|
|
CopyMem(varKey, normalizedKey, strlen(varKey)); |
|
|
|
|
int varKeylen = strlen(varKey); |
|
|
|
|
STRPTR normalizedKey = AllocVec(varKeylen+1, 0L); |
|
|
|
|
CopyMem(varKey, normalizedKey, varKeylen); |
|
|
|
|
normalizedKey[varKeylen] = '\0'; |
|
|
|
|
downcaseString(normalizedKey); |
|
|
|
|
|
|
|
|
|
for( index = 0; index < lineCount; index++ ) |
|
|
|
@ -423,7 +431,7 @@ CONST_STRPTR SectionSerialize(SECTIONPTR abstractSection) |
|
|
|
|
}
|
|
|
|
|
size += 2; // ]\n
|
|
|
|
|
|
|
|
|
|
result = AllocVec(size+1, MEMF_CLEAR); |
|
|
|
|
result = AllocVec(size+1, 0L); |
|
|
|
|
if( section->secondary == NULL ) |
|
|
|
|
{ |
|
|
|
|
sprintf(result, "[%s]\n", section->primary); |
|
|
|
@ -482,7 +490,7 @@ CONST_STRPTR SectionCanonicalName(SECTIONPTR abstractSection) |
|
|
|
|
totalLength += secondaryLength; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
result = AllocVec(totalLength+1, MEMF_CLEAR); |
|
|
|
|
result = AllocVec(totalLength+1, 0L); |
|
|
|
|
|
|
|
|
|
CopyMem(section->primary, result, primaryLength); |
|
|
|
|
if( secondaryLength > 0 ) |
|
|
|
@ -504,19 +512,22 @@ VARIABLEPTR VariableCreate(CONST_STRPTR key, CONST_STRPTR rawValue) |
|
|
|
|
struct Variable* result = NULL; |
|
|
|
|
if( key != NULL ) |
|
|
|
|
{
|
|
|
|
|
ULONG length = strlen(key); |
|
|
|
|
int keylen = strlen(key); |
|
|
|
|
result = AllocVec(sizeof(struct Variable), MEMF_CLEAR); |
|
|
|
|
result->key = AllocVec(length+1, MEMF_CLEAR); |
|
|
|
|
CopyMem(key, (STRPTR)result->key, length); |
|
|
|
|
result->normalizedKey = AllocVec(length+1, MEMF_CLEAR); |
|
|
|
|
CopyMem(key, (STRPTR)result->normalizedKey, length); |
|
|
|
|
result->key = AllocVec(keylen+1, 0L); |
|
|
|
|
CopyMem(key, (STRPTR)result->key, keylen); |
|
|
|
|
((STRPTR)result->key)[keylen] = '\0'; |
|
|
|
|
result->normalizedKey = AllocVec(keylen+1, 0L); |
|
|
|
|
CopyMem(key, (STRPTR)result->normalizedKey, keylen); |
|
|
|
|
((STRPTR)result->normalizedKey)[keylen] = '\0'; |
|
|
|
|
downcaseString((STRPTR)result->normalizedKey); |
|
|
|
|
} |
|
|
|
|
if( rawValue != NULL ) |
|
|
|
|
{ |
|
|
|
|
ULONG length = strlen(rawValue); |
|
|
|
|
result->stringValue = AllocVec(length+1, MEMF_CLEAR); |
|
|
|
|
CopyMem(rawValue, (STRPTR)result->stringValue, length); |
|
|
|
|
int rawValuelen = strlen(rawValue); |
|
|
|
|
result->stringValue = AllocVec(rawValuelen+1, 0L); |
|
|
|
|
CopyMem(rawValue, (STRPTR)result->stringValue, rawValuelen); |
|
|
|
|
((STRPTR)result->stringValue)[rawValuelen] = '\0'; |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
@ -573,7 +584,7 @@ CONST_STRPTR VariableSerialize(VARIABLEPTR abstractVariable) |
|
|
|
|
if( variable != NULL && variable->normalizedKey != NULL && variable->stringValue != NULL ) |
|
|
|
|
{ |
|
|
|
|
ULONG size = 1 + strlen(variable->normalizedKey) + 3 + strlen(variable->stringValue) + 1 + 1; |
|
|
|
|
result = AllocVec(size, MEMF_CLEAR); |
|
|
|
|
result = AllocVec(size, 0L); |
|
|
|
|
sprintf(result, "\t%s = %s\n", variable->normalizedKey, variable->stringValue); |
|
|
|
|
} |
|
|
|
|
return (CONST_STRPTR)result; |
|
|
|
@ -592,8 +603,10 @@ StringArray CompoundKeySplitKeyCompletely(CONST_STRPTR key) |
|
|
|
|
|
|
|
|
|
STRPTR token = NULL; |
|
|
|
|
// we need to make a copy of the key because strtok modifies it.
|
|
|
|
|
STRPTR keyCopy = AllocVec(strlen(key)+1, MEMF_CLEAR); |
|
|
|
|
CopyMem(key, keyCopy, strlen(key)); |
|
|
|
|
int keylen = strlen(key); |
|
|
|
|
STRPTR keyCopy = AllocVec(keylen+1, 0L); |
|
|
|
|
CopyMem(key, keyCopy, keylen); |
|
|
|
|
keyCopy[keylen] = '\0'; |
|
|
|
|
|
|
|
|
|
token = strtok(keyCopy, "."); |
|
|
|
|
while (token != NULL) |
|
|
|
@ -650,8 +663,10 @@ StringArray CompoundKeySplitKeyForVar(CONST_STRPTR key) |
|
|
|
|
|
|
|
|
|
STRPTR token = NULL; |
|
|
|
|
// we need to make a copy of the key because strtok modifies it.
|
|
|
|
|
STRPTR keyCopy = AllocVec(strlen(key)+1, MEMF_CLEAR); |
|
|
|
|
CopyMem(key, keyCopy, strlen(key)); |
|
|
|
|
int keylen = strlen(key); |
|
|
|
|
STRPTR keyCopy = AllocVec(keylen+1, 0L); |
|
|
|
|
CopyMem(key, keyCopy, keylen); |
|
|
|
|
keyCopy[keylen] = '\0'; |
|
|
|
|
|
|
|
|
|
token = strtok(keyCopy, "."); |
|
|
|
|
while (token != NULL) |
|
|
|
|