Skip to content

Commit 39ef6ec

Browse files
committed
[parser] Minor change to handling of super-fatal errors.
1 parent d515dc6 commit 39ef6ec

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

source/core/coretypes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/// @parblock
99
///
1010
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
11-
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
11+
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd.
1212
///
1313
/// POV-Ray is free software: you can redistribute it and/or modify
1414
/// it under the terms of the GNU Affero General Public License as
@@ -626,7 +626,7 @@ struct SourceInfo : MessageContext
626626
SourcePosition position;
627627
SourceInfo() = default;
628628
SourceInfo(const MessageContext& o) : fileName(o.GetFileName()), position(o.GetLine(), o.GetColumn(), o.GetOffset()) {}
629-
SourceInfo(const UCS2String& fn, SourcePosition& p) : fileName(fn), position(p) {}
629+
SourceInfo(const UCS2String& fn, const SourcePosition& p) : fileName(fn), position(p) {}
630630
virtual UCS2String GetFileName() const override { return fileName; }
631631
virtual POV_LONG GetLine() const override { return position.line; }
632632
virtual POV_LONG GetColumn() const override { return position.column; }

source/parser/parser.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,8 @@ Parser::~Parser()
176176
/* Parse the file. */
177177
void Parser::Run()
178178
{
179-
int error_line = -1;
180-
int error_col = -1;
181-
UCS2String error_filename(POV_FILENAME_BUFFER_CHARS, 0); // Pre-claim some memory, so we can handle an out-of-memory error.
182-
POV_OFF_T error_pos = -1;
179+
SourceInfo errorInfo(UCS2String(POV_FILENAME_BUFFER_CHARS, 0), // Pre-claim some memory, so we can handle an out-of-memory error.
180+
SourcePosition(-1,-1,-1));
183181

184182
// Outer try/catch block to handle out-of-memory conditions
185183
// occurring during regular error handling.
@@ -301,10 +299,8 @@ void Parser::Run()
301299
{
302300
// take a (local) copy of error location prior to freeing token data
303301
// NB error_filename has been pre-allocated for strings up to POV_FILENAME_BUFFER_CHARS
304-
error_filename = CurrentFileName();
305-
error_line = CurrentFilePosition().line;
306-
error_col = CurrentFilePosition().column;
307-
error_pos = CurrentFilePosition().offset;
302+
errorInfo.fileName = CurrentFileName();
303+
errorInfo.position = CurrentFilePosition();
308304
}
309305

310306
// free up some memory before proceeding with error notification.
@@ -313,8 +309,8 @@ void Parser::Run()
313309
Default_Texture = nullptr;
314310
Destroy_Random_Generators();
315311

316-
if (error_line != -1)
317-
mMessageFactory.ErrorAt(POV_EXCEPTION_CODE(kOutOfMemoryErr), error_filename, error_line, error_col, error_pos, "Out of memory.");
312+
if (errorInfo.position.line != -1)
313+
mMessageFactory.ErrorAt(POV_EXCEPTION_CODE(kOutOfMemoryErr), errorInfo, "Out of memory.");
318314
else
319315
Error("Out of memory.");
320316
}

0 commit comments

Comments
 (0)