Skip to content

Commit

Permalink
Update dictionary initializer syntax and fix a memory leak.
Browse files Browse the repository at this point in the history
  • Loading branch information
c-lipka committed Nov 16, 2016
1 parent d1a61d6 commit 03b9654
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion source/base/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#define OFFICIAL_VERSION_STRING "3.7.1"
#define OFFICIAL_VERSION_NUMBER 371

#define POV_RAY_PRERELEASE "x.dictionary.8877181"
#define POV_RAY_PRERELEASE "x.dictionary.8877243"

#if (POV_RAY_IS_AUTOBUILD == 1) && ((POV_RAY_IS_OFFICIAL == 1) || (POV_RAY_IS_SEMI_OFFICIAL == 1))
#ifdef POV_RAY_PRERELEASE
Expand Down
24 changes: 21 additions & 3 deletions source/parser/parser_tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,8 @@ void Parser::Read_Symbol()
{
case ARRAY_ID_TOKEN:
{
dictIndex = NULL;
if (dictIndex)
POV_FREE (dictIndex);

Skip_Spaces();
c = Echo_getc();
Expand Down Expand Up @@ -1442,7 +1443,8 @@ void Parser::Read_Symbol()

case DICTIONARY_ID_TOKEN:
{
dictIndex = NULL;
if (dictIndex)
POV_FREE (dictIndex);

Skip_Spaces();
c = Echo_getc();
Expand Down Expand Up @@ -3664,6 +3666,7 @@ Parser::SYM_TABLE *Parser::Parse_Dictionary_Declare()
SYM_TABLE *newDictionary;
SYM_ENTRY *newEntry;
bool oldParseRawIdentifiers;
char *dictIndex;

newDictionary = Create_Sym_Table (true);

Expand All @@ -3682,7 +3685,22 @@ Parser::SYM_TABLE *Parser::Parse_Dictionary_Declare()
Expectation_Error ("dictionary element identifier");
newEntry = Add_Symbol (newDictionary, Token.Token_String, IDENTIFIER_TOKEN);

GET (EQUALS_TOKEN);
GET (COLON_TOKEN);

if (!Parse_RValue (IDENTIFIER_TOKEN, &(newEntry->Token_Number), &(newEntry->Data), newEntry, false, false, true, true, false, MAX_NUMBER_OF_TABLES))
Expectation_Error("RValue");

Parse_Comma();
END_CASE

CASE (LEFT_SQUARE_TOKEN)
dictIndex = Parse_C_String();
newEntry = Add_Symbol (newDictionary, dictIndex, IDENTIFIER_TOKEN);
POV_PARSER_ASSERT (newDictionary->namesAreCopies);
POV_FREE (dictIndex);

GET (RIGHT_SQUARE_TOKEN);
GET (COLON_TOKEN);

if (!Parse_RValue (IDENTIFIER_TOKEN, &(newEntry->Token_Number), &(newEntry->Data), newEntry, false, false, true, true, false, MAX_NUMBER_OF_TABLES))
Expectation_Error("RValue");
Expand Down
2 changes: 1 addition & 1 deletion unix/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.1-x.dictionary.8877181
3.7.1-x.dictionary.8877243

0 comments on commit 03b9654

Please sign in to comment.