2020-01-10 01:01:12 +00:00
|
|
|
#!/usr/bin/env perl
|
2006-08-26 11:35:28 +00:00
|
|
|
######################################################################
|
|
|
|
#
|
2020-03-21 15:24:24 +00:00
|
|
|
# Copyright 2002-2020 by Wilson Snyder. This program is free software; you
|
2009-05-04 21:07:57 +00:00
|
|
|
# can redistribute it and/or modify it under the terms of either the GNU
|
|
|
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
|
|
|
# Version 2.0.
|
2020-03-21 15:24:24 +00:00
|
|
|
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2008-06-10 01:25:10 +00:00
|
|
|
#
|
2006-08-26 11:35:28 +00:00
|
|
|
######################################################################
|
2007-05-12 15:31:04 +00:00
|
|
|
# DESCRIPTION: Edits flex output to get around various broken flex issues.
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2020-01-10 01:01:12 +00:00
|
|
|
use warnings;
|
|
|
|
|
2010-02-27 00:50:44 +00:00
|
|
|
my $Opt_Prefix = $ARGV[0] or die "%Error: No prefix specified,";
|
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
foreach my $line (<STDIN>) {
|
2018-02-07 23:58:21 +00:00
|
|
|
# Fix flex 2.6.1 warning
|
2018-02-28 11:34:03 +00:00
|
|
|
$line =~ s/for \( i = 0; i < _yybytes_len; \+\+i \)/for ( i = 0; (yy_size_t)(i) < (yy_size_t)(_yybytes_len); ++i )/g;
|
2016-02-03 00:32:17 +00:00
|
|
|
# Fix flex 2.6.0 warning
|
2016-11-19 00:40:39 +00:00
|
|
|
$line =~ s/\(\(int\) \(\(yy_n_chars\) \+ number_to_move\) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size\)/((int) ((yy_n_chars) + number_to_move) > (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size)/g;
|
2016-02-03 00:32:17 +00:00
|
|
|
$line =~ s/ number_to_move == YY_MORE_ADJ / (int)number_to_move == (int)YY_MORE_ADJ /;
|
2006-08-26 11:35:28 +00:00
|
|
|
# Fix flex 2.5.4 namespace omission
|
|
|
|
$line =~ s/^class istream;/\#include <iostream>\nusing namespace std;\n/;
|
|
|
|
# Fix flex 2.5.31 redefinition
|
|
|
|
$line =~ s!(\#define\s+yyFlexLexer\s+yyFlexLexer)!//flexfix: $1!g;
|
|
|
|
# Fix flex 2.5.1 yytext_ptr undef
|
|
|
|
$line =~ s!(\#undef\s+yytext_ptr)!//flexfix: $1!g;
|
2007-05-12 15:31:04 +00:00
|
|
|
# Fix flex 2.5.4 and GCC 4.1.0 warn_unused_result
|
|
|
|
$line =~ s!\(void\) *fwrite\((.*)\)!if (fwrite($1)) {}!g;
|
|
|
|
# Fix flex 2.5.33 and GCC 4.1.2 "warning: comparison between signed and unsigned integer expressions" in YY_INPUT
|
|
|
|
$line =~ s!for \( n = 0; n < max_size && !for ( n = 0; ((size_t)n < (size_t)max_size) && !g;
|
2009-10-31 03:17:56 +00:00
|
|
|
# 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;
|
2010-02-27 00:50:44 +00:00
|
|
|
# Fix compiler warning filenames
|
|
|
|
$line =~ s!(#line \d+ ".*)_pretmp!$1!;
|
2020-08-18 12:02:50 +00:00
|
|
|
# Fix 'register' storage class specifier is deprecated and incompatible with C++17
|
|
|
|
$line =~ s!register !!g;
|
2009-10-31 03:17:56 +00:00
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
print "$line";
|
|
|
|
}
|