Link checktestdata statically against non-standard libraries.
Replace flex++ by more modern flexc++.

This fixes a missing build dependency on FlexLexer.h and cleans up
an kludgy way to generate C++ code based on flex C code.
Move parse_t output stream function to separate file
to prevent multiple definition in object files.
Improve string escape tests for checktestdata.
Make sure that checktestdata parse_t objects cannot be called
implicitly as cast operators from string or char.
Catch exceptions for better error reporting.
Fix buffer overflow found by Coverity scan.

Also remove redundant check at end of loop, document variables.