From 11b9d83d4c1da81c9564c5e6baf0fe9e56a4b915 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 28 Mar 2015 10:50:32 +0100 Subject: [PATCH] openddlparser: latest greatest ( contains fix for correct handling of data array lists ). Signed-off-by: Kim Kulling --- contrib/openddlparser/code/OpenDDLParser.cpp | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/contrib/openddlparser/code/OpenDDLParser.cpp b/contrib/openddlparser/code/OpenDDLParser.cpp index 1c9006f38..104471965 100644 --- a/contrib/openddlparser/code/OpenDDLParser.cpp +++ b/contrib/openddlparser/code/OpenDDLParser.cpp @@ -856,6 +856,14 @@ char *OpenDDLParser::parseDataList( char *in, char *end, Value **data, size_t &n return in; } +DataArrayList *createDataArrayList( Value *currentValue, size_t numValues ) { + DataArrayList *dataList = new DataArrayList; + dataList->m_dataList = currentValue; + dataList->m_numItems = numValues; + + return dataList; + +} char *OpenDDLParser::parseDataArrayList( char *in, char *end, DataArrayList **dataList ) { *dataList = ddl_nullptr; if( ddl_nullptr == in || in == end ) { @@ -865,20 +873,19 @@ char *OpenDDLParser::parseDataArrayList( char *in, char *end, DataArrayList **da in = lookForNextToken( in, end ); if( *in == Grammar::OpenBracketToken[ 0 ] ) { in++; - Value *current( ddl_nullptr ); + Value *currentValue( ddl_nullptr ); Reference *refs( ddl_nullptr ); DataArrayList *prev( ddl_nullptr ), *currentDataList( ddl_nullptr ); do { size_t numRefs( 0 ), numValues( 0 ); - in = parseDataList( in, end, ¤t, numValues, &refs, numRefs ); - if( ddl_nullptr != current ) { + currentValue = ddl_nullptr; + in = parseDataList( in, end, ¤tValue, numValues, &refs, numRefs ); + if( ddl_nullptr != currentValue ) { if( ddl_nullptr == prev ) { - *dataList = new DataArrayList; - ( *dataList )->m_dataList = current; - ( *dataList )->m_numItems = numValues; + *dataList = createDataArrayList( currentValue, numValues ); prev = *dataList; } else { - currentDataList = new DataArrayList; + currentDataList = createDataArrayList( currentValue, numValues ); if( ddl_nullptr != prev ) { prev->m_next = currentDataList; prev = currentDataList;