From: Tobias Leich Date: Wed, 11 Nov 2009 19:38:41 +0000 (+0100) Subject: regex for decimal and hex X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c0233ac4c6a2d4579f8c26c28d655bef92a5dd4d;p=sdlgit%2FSDL_perl.git regex for decimal and hex --- diff --git a/scripts/auto_constants.pl b/scripts/auto_constants.pl index ce3418c..280ed69 100644 --- a/scripts/auto_constants.pl +++ b/scripts/auto_constants.pl @@ -16,15 +16,11 @@ foreach (@header) open FH, $_; while() { - if($_ =~ /#define SDL_/) - { - my $line = $_; - my @cop = (split ' ', $line); - print 'sub '.$cop[1].' {return '.$cop[2].'}'."\n" ; - } + # pattern: "#define SDL_RELEASED 0" (decimal) + printf("sub %s{ return %s; }\n", $1, $2) if($_ =~ /^#define\s+(\w+)\s+(\d+)\s*$/); - # pattern: "#define SDL_RELEASED 0" - printf("sub %s{ return %s; }\n", $1, $2) if($_ =~ /^#define\s+(\w+)\s+(\w+)\s*$/); + # pattern: "#define SDL_RELEASED 0x1234" (hex) + printf("sub %s{ return %s; }\n", $1, $2) if($_ =~ /^#define\s+(\w+)\s+(0x\d+)\s*$/); } close FH; }