From 381972c92372681846575919a47685dfb6d7605b Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 26 Feb 2010 19:50:44 -0500 Subject: [PATCH] Fix Mac OS-X compile issues, bug217. --- Changes | 2 ++ src/Makefile_obj.in | 9 +++++---- src/V3PreLex.h | 13 +++++++++++-- src/flexfix | 6 ++++++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Changes b/Changes index 21aae1aa5..e2995f9e2 100644 --- a/Changes +++ b/Changes @@ -11,6 +11,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Skip SystemC tests if not installed. [Iztok Jeras] +**** Fix Mac OS-X compile issues, bug217. [Joshua Wise, Trevor Williams] + **** Fix make uninstall, bug216. [Iztok Jeras] **** Fix parametrized defines with empty arguments. diff --git a/src/Makefile_obj.in b/src/Makefile_obj.in index d6add2ccc..854a47807 100644 --- a/src/Makefile_obj.in +++ b/src/Makefile_obj.in @@ -121,6 +121,7 @@ HEADERS = $(wildcard V*.h v*.h) ASTGEN = $(srcdir)/astgen BISONPRE = $(srcdir)/bisonpre +FLEXFIX = $(srcdir)/flexfix ###################################################################### #### Top level @@ -296,15 +297,15 @@ V3Lexer_pregen.yy.cpp: verilog.l V3ParseBison.h $(HEADERS) ${LEX} --version ${LEX} ${LFLAGS} -o$@ $< -V3Lexer.yy.cpp: V3Lexer_pregen.yy.cpp - $(PERL) $(srcdir)/flexfix <$< >$@ +V3Lexer.yy.cpp: V3Lexer_pregen.yy.cpp $(FLEXFIX) + $(PERL) $(FLEXFIX) V3Lexer <$< >$@ V3PreLex_pregen.yy.cpp: V3PreLex.l $(HEADERS) ${LEX} --version ${LEX} ${LFLAGS} -o$@ $< -V3PreLex.yy.cpp: V3PreLex_pregen.yy.cpp - $(PERL) $(srcdir)/flexfix <$< >$@ +V3PreLex.yy.cpp: V3PreLex_pregen.yy.cpp $(FLEXFIX) + $(PERL) $(FLEXFIX) V3PreLex <$< >$@ ###################################################################### ###################################################################### diff --git a/src/V3PreLex.h b/src/V3PreLex.h index d11cbb147..6c28b4ec1 100644 --- a/src/V3PreLex.h +++ b/src/V3PreLex.h @@ -90,19 +90,28 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; # define YY_BUF_SIZE 16384 #endif +// Older flex'es don't have this defined, so make everyone happy +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + extern int yylex(); extern void yyrestart(FILE*); extern char* yytext; -extern int yyleng; +extern yy_size_t yyleng; + YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ); void yy_delete_buffer( YY_BUFFER_STATE b ); //====================================================================== -// Class entry for each per-lexter state #define KEEPCMT_SUB 2 +//====================================================================== +// Class entry for each per-lexter state + class V3PreLex { public: // Used only by V3PreLex.cpp and V3PreProc.cpp FileLine* m_curFilelinep; // Current processing point diff --git a/src/flexfix b/src/flexfix index e9e715c19..3c85d89d8 100755 --- a/src/flexfix +++ b/src/flexfix @@ -15,6 +15,8 @@ # DESCRIPTION: Edits flex output to get around various broken flex issues. +my $Opt_Prefix = $ARGV[0] or die "%Error: No prefix specified,"; + foreach my $line () { # Fix flex 2.5.4 namespace omission $line =~ s/^class istream;/\#include \nusing namespace std;\n/; @@ -28,6 +30,10 @@ foreach my $line () { $line =~ s!for \( n = 0; n < max_size && !for ( n = 0; ((size_t)n < (size_t)max_size) && !g; # Fix flex 2.5.4 and GCC 4.0.2 under FLEX_DEBUG $line =~ s!--accepting rule at line %d !--accepting rule at line %ld !g; + # Fix flex 2.5.35 to match patches on Mac OS-X + $line =~ s!(extern |)int (${Opt_Prefix}leng;)!#ifndef YY_TYPEDEF_YY_SIZE_T\n#define YY_TYPEDEF_YY_SIZE_T\ntypedef size_t yy_size_t;\n#endif\n$1yy_size_t $2;!; + # Fix compiler warning filenames + $line =~ s!(#line \d+ ".*)_pretmp!$1!; print "$line"; }