1#!/usr/bin/perl -w 2###################################################################### 3# 4# Copyright 2002-2021 by Wilson Snyder. This program is free software; you 5# can redistribute it and/or modify it under the terms of either the GNU 6# Lesser General Public License Version 3 or the Perl Artistic License 7# Version 2.0. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14###################################################################### 15 16# DESCRIPTION: Edits flex output to get around various broken flex issues. 17 18my $Opt_Prefix = $ARGV[0] or die "%Error: No prefix specified,"; 19 20foreach my $line (<STDIN>) { 21 # Fix flex 2.6.0 warning 22 $line =~ s/ number_to_move == YY_MORE_ADJ / (int)number_to_move == (int)YY_MORE_ADJ /; 23 # Fix flex 2.5.4 namespace omission 24 $line =~ s/^class istream;/\#include <iostream>\nusing namespace std;\n/; 25 # Fix flex 2.5.31 redefinition 26 $line =~ s!(\#define\s+yyFlexLexer\s+yyFlexLexer)!//flexfix: $1!g; 27 # Fix flex 2.5.1 yytext_ptr undef 28 $line =~ s!(\#undef\s+yytext_ptr)!//flexfix: $1!g; 29 # Fix flex 2.5.4 and GCC 4.1.0 warn_unused_result 30 $line =~ s!\(void\) *fwrite\((.*)\)!if (fwrite($1)) {}!g; 31 # Fix flex 2.5.33 and GCC 4.1.2 "warning: comparison between signed and unsigned integer expressions" in YY_INPUT 32 $line =~ s!for \( n = 0; n < max_size && !for ( n = 0; ((size_t)n < (size_t)max_size) && !g; 33 # Fix flex 2.5.4 and GCC 4.0.2 under FLEX_DEBUG 34 $line =~ s!--accepting rule at line %d !--accepting rule at line %ld !g; 35 # Fix compiler warning filenames 36 $line =~ s!(#line \d+ ".*)_pretmp!$1!; 37 38 print "$line"; 39} 40