From 39f0c4cf1a2a6b43d94499c8fedeb435f9d37202 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 12 Jun 2017 12:56:16 +0200 Subject: [PATCH 1/6] BUG: flex symbol conflict (issue #494) --- src/fileFormats/stl/STLReaderASCII.L | 207 ++++++++++++++------------- 1 file changed, 111 insertions(+), 96 deletions(-) diff --git a/src/fileFormats/stl/STLReaderASCII.L b/src/fileFormats/stl/STLReaderASCII.L index 0ea759151c..1e60c2a241 100644 --- a/src/fileFormats/stl/STLReaderASCII.L +++ b/src/fileFormats/stl/STLReaderASCII.L @@ -23,9 +23,10 @@ License \*---------------------------------------------------------------------------*/ -%{ +%option prefix="yySTL" +%option yyclass="yySTLFlexLexer" -#undef yyFlexLexer +%{ /* ------------------------------------------------------------------------ *\ ------ local definitions @@ -35,9 +36,9 @@ License #include "OSspecific.H" using namespace Foam; - // Dummy yyFlexLexer::yylex() to keep the linker happy. It is not called //! \cond dummy +#if YY_FLEX_MAJOR_VERSION <= 2 && YY_FLEX_MINOR_VERSION <= 5 && YY_FLEX_SUBMINOR_VERSION < 34 int yyFlexLexer::yylex() { FatalErrorInFunction @@ -45,29 +46,29 @@ int yyFlexLexer::yylex() << abort(FatalError); return 0; } +#endif //! \endcond // Dummy yywrap to keep yylex happy at compile time. // It is called by yylex but is not used as the mechanism to change file. // See <> //! \cond dummy -#if YY_FLEX_MINOR_VERSION < 6 && YY_FLEX_SUBMINOR_VERSION < 34 +#if YY_FLEX_MAJOR_VERSION <= 2 && YY_FLEX_MINOR_VERSION <= 5 && YY_FLEX_SUBMINOR_VERSION < 34 extern "C" int yywrap() #else -int yyFlexLexer::yywrap() +int yySTLFlexLexer::yywrap() #endif { return 1; } //! \endcond - //- A lexer for parsing STL ASCII files. // Returns DynamicList(s) of points and facets (zoneIds). // The facets are within a solid/endsolid grouping class STLASCIILexer : - public yyFlexLexer + public yySTLFlexLexer { // Private data @@ -95,7 +96,7 @@ public: //- The lexer function itself int lex(); - // Access + // Access //- Do all the solid groups appear in order? inline bool sorted() const @@ -132,7 +133,7 @@ public: STLASCIILexer::STLASCIILexer(istream* is, const label approxNpoints) : - yyFlexLexer(is), + yySTLFlexLexer(is), sorted_(true), groupID_(-1), lineNo_(1), @@ -145,6 +146,7 @@ STLASCIILexer::STLASCIILexer(istream* is, const label approxNpoints) ------ cppLexer::yylex() \* ------------------------------------------------------------------------ */ +#undef YY_DECL #define YY_DECL int STLASCIILexer::lex() %} @@ -202,9 +204,9 @@ endsolid {space}("endsolid"|"ENDSOLID")({some_space}{word})* // End of read character pointer returned by strtof // char* endPtr; - STLpoint normal; + label cmpt = 0; // Component index when reading vertex STLpoint vertex; - label cmpt = 0; // component index used for reading vertex + // STLpoint normal; static const char* stateNames[7] = { @@ -237,154 +239,167 @@ endsolid {space}("endsolid"|"ENDSOLID")({some_space}{word})* /* ------ Reading control header ------ */ {solid} { - BEGIN(readSolidName); - } + BEGIN(readSolidName); +} {string} { - word name(Foam::string::validate(YYText())); + const word solidName(Foam::string::validate(YYText())); - HashTable