.. this would otherwise cause a memory use error in the unusual case
where a numeric identifer held more letters than expected.
For instance, passing the following file as the input to tst_inverse_attr3:
ISO-10303-21;
HEADER;
FILE_DESCRIPTION(('SCL test file'),'2;1');
FILE_NAME('test_inverse_attr.p21','2012-06-30T',('mp'),(''),'0','1','2');
FILE_SCHEMA(('test_inverse_attr'));
ENDSEC;
DATA;
ENDSEC;
END-ISO-10303-21;
and running it under valgrind can cause a diagnostic similar to the following to be displayed:
Mismatched free() / delete / delete []
at 0x4C2D2DB: operator delete(void*) (vg_replace_malloc.c:576)
by 0x507A5A6: sectionReader::readInstanceNumber() (sectionReader.cc:224)
by 0x507CCC7: lazyP21DataSectionReader::nextInstance() (lazyP21DataSectionReader.cc:53)
by 0x507C797: lazyP21DataSectionReader::lazyP21DataSectionReader(lazyFileReader*, std::basic_ifstream<char, std::char_traits<char> >&, std::fpos<__mbstate_t>, unsigned short) (lazyP21DataSectionReader.cc:11)
by 0x50699F2: lazyFileReader::initP21() (lazyFileReader.cc:14)
by 0x5069E5D: lazyFileReader::lazyFileReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, lazyInstMgr*, unsigned short) (lazyFileReader.cc:61)
] and delete[]
by 0x506AAA7: lazyInstMgr::openFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (lazyInstMgr.cc:103)
by 0x4023A1: main (inverse_attr3.cc:35)
Address 0x6a861a0 is 0 bytes inside a block of size 21 alloc'd
at 0x4C2C93F: operator new[](unsigned long) (vg_replace_malloc.c:423)
by 0x507A3A7: sectionReader::readInstanceNumber() (sectionReader.cc:202)
This problem is also reported in static analysis by clang, and as such can be seen in travis ci build logs.
- change way states are used, could give a substantial performance improvement
- implement a more flexible approach for exchange_file start token search (more extensibile for subclassing)
- rework/standardise keyword implementation for DATA token
Parser improvements
- implement error handling for duplicate entity instances
* parser catches the error, logs it
* resyncs and continues (the duplicate is ignored)
- rework the exchange_file structure detection
* added parser.reset() to allow a more flexible approach to subclassing
- replace another dict comprehension
- ensure new style classes are used in Python 2.6
- change the way the tokens list is used (improves ability to subclass)