16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 00:49:19 +02:00

Fix infinite loop loading non-scenery files (e.g. .fiz) via cParser

The buffer-based tokenizer reads the source into memory once at construction, so
the underlying stream fail bit never flips at end-of-input. cParser::ok() was
not stream.fail(), so while( parser.ok() ) loops (TMoverParameters::LoadFIZ and
similar) never terminated -- they spun on empty tokens past EOF, hanging the
vehicle/.fiz load. Redefine ok() as "input still remains" (buffer not exhausted,
or for replay not exhausted), which terminates those loops while staying true
right after opening a non-empty file (the open checks if(!ok())).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
maj00r
2026-06-22 19:13:38 +02:00
parent eec5986056
commit 8a91559895

View File

@@ -82,7 +82,14 @@ class cParser //: public std::stringstream
inline
bool
ok() {
return ( !mStream->fail() ); };
// historically !stream.fail(); with the in-memory buffer the stream is read
// only once at construction, so its fail bit never flips at end-of-input.
// ok() now means "there is still input to read", which is what the common
// `while( parser.ok() )` loops rely on, and is true right after opening a
// non-empty file (the `if( !ok() )` open checks) / false if the open failed
// (empty buffer) or once everything has been consumed.
if( m_replay ) { return ( false == m_replayexhausted ); }
return ( m_bufferpos < m_buffer.size() ); };
cParser &
autoclear( bool const Autoclear );
inline