From 9eedce2b89b546aea44595bad1bf0bb6ad5061ad Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Mon, 3 Jun 2002 07:13:09 +0000 Subject: [PATCH] Cleanup script for re2c output that removes unreferenced labels (significantly reducing C compiler warnings). svn path=/trunk/yasm/; revision=647 --- tools/re2c/Makefile.am | 3 ++- tools/re2c/Makefile.inc | 3 ++- tools/re2c/cleanup.pl | 10 ++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100755 tools/re2c/cleanup.pl diff --git a/tools/re2c/Makefile.am b/tools/re2c/Makefile.am index 75d56488..6c8c5ae1 100644 --- a/tools/re2c/Makefile.am +++ b/tools/re2c/Makefile.am @@ -52,4 +52,5 @@ EXTRA_DIST = \ examples/simple.re \ examples/rexx/README \ examples/rexx/rexx.l \ - examples/rexx/scanio.c + examples/rexx/scanio.c \ + cleanup.pl diff --git a/tools/re2c/Makefile.inc b/tools/re2c/Makefile.inc index 75d56488..6c8c5ae1 100644 --- a/tools/re2c/Makefile.inc +++ b/tools/re2c/Makefile.inc @@ -52,4 +52,5 @@ EXTRA_DIST = \ examples/simple.re \ examples/rexx/README \ examples/rexx/rexx.l \ - examples/rexx/scanio.c + examples/rexx/scanio.c \ + cleanup.pl diff --git a/tools/re2c/cleanup.pl b/tools/re2c/cleanup.pl new file mode 100755 index 00000000..7034a468 --- /dev/null +++ b/tools/re2c/cleanup.pl @@ -0,0 +1,10 @@ +#!/usr/bin/perl +my @sourcelines = <>; +my %usedlabel; +for (@sourcelines) { + $usedlabel{"$1:"} = "$1:" if m/goto\s+(yy[0-9]*)\s*;/ +} +for (@sourcelines) { + s/^(yy[0-9]*:)/$usedlabel{$1}/; + print; +}