X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=regcomp.pl;h=7fdbd1303fb46028a27e524ab532ef568a23cace;hb=115454352a978d4e8b08f627af1ad772bab2816b;hp=17472cc8110f1494430a4e8d35afe7dd65a416a5;hpb=f7819f85d6af0dcf9114284a4fe5ef21855e4e5a;p=p5sagit%2Fp5-mst-13.2.git diff --git a/regcomp.pl b/regcomp.pl index 17472cc..7fdbd13 100644 --- a/regcomp.pl +++ b/regcomp.pl @@ -1,3 +1,18 @@ +#!/usr/bin/perl +# +# Regenerate (overwriting only if changed): +# +# regnodes.h +# +# from information stored in +# +# regcomp.sym +# regexp.h +# +# Accepts the standard regen_lib -q and -v args. +# +# This script is normally invoked from regen.pl. + BEGIN { # Get function prototypes require 'regen_lib.pl'; @@ -64,15 +79,13 @@ close DESC; die "Too many regexp/state opcodes! Maximum is 256, but there are $lastregop in file!" if $lastregop>256; -my $tmp_h = 'tmp_reg.h'; +my $tmp_h = 'regnodes.h-new'; unlink $tmp_h if -f $tmp_h; -open OUT, ">$tmp_h"; -#*OUT=\*STDOUT; -binmode OUT; +my $out = safer_open($tmp_h); -printf OUT <) { if (/#define\s+(RXf_\w+)\s+(0x[A-F\d]+)/i) { - $rxfv{$1}= eval $2; - $val|=$rxfv{$1}; + my $newval = eval $2; + if($val & $newval) { + die sprintf "Both $1 and $reverse{$newval} use %08X", $newval; + } + $val|=$newval; + $rxfv{$1}= $newval; + $reverse{$newval} = $1; } } my %vrxf=reverse %rxfv; -printf OUT "\t/* Bits in extflags defined: %032b */\n",$val; +printf $out "\t/* Bits in extflags defined: %032b */\n",$val; for (0..31) { my $n=$vrxf{2**$_}||"UNUSED_BIT_$_"; $n=~s/^RXf_(PMf_)?//; - printf OUT qq(\t%-20s/* 0x%08x */\n), + printf $out qq(\t%-20s/* 0x%08x */\n), qq("$n",),2**$_; } -print OUT <