diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-01-05 20:18:33 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:36:58 -0500 |
commit | 74239c2e944fdbe1ff137e91d80576b87c59d478 (patch) | |
tree | 06eb2349c699893cc243abedecb12ac652068bce /source4/pidl/lib/Parse/Pidl/Util.pm | |
parent | 5a162488a1018d44b28475538bffeeef56b453b6 (diff) | |
download | samba-74239c2e944fdbe1ff137e91d80576b87c59d478.tar.gz samba-74239c2e944fdbe1ff137e91d80576b87c59d478.tar.bz2 samba-74239c2e944fdbe1ff137e91d80576b87c59d478.zip |
r20563: Start using the new parser in ParseExpr(). It's now trivial to use this
to check for NULL pointers when pointers are being dereferenced (#4218).
There are exactly 500 tests for pidl now :-)
(This used to be commit d3146f3bcd4541f890d6c1b072ff34853e9239d2)
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl/Util.pm')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Util.pm | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Util.pm b/source4/pidl/lib/Parse/Pidl/Util.pm index 064862b7c5..2f3547bbb5 100644 --- a/source4/pidl/lib/Parse/Pidl/Util.pm +++ b/source4/pidl/lib/Parse/Pidl/Util.pm @@ -12,6 +12,8 @@ $VERSION = '0.01'; use strict; +use Parse::Pidl::Expr; + ##################################################################### # a dumper wrapper to prevent dependence on the Data::Dumper module # unless we actually need it @@ -97,22 +99,19 @@ sub useUintEnums() sub ParseExpr($$) { - my($expr,$varlist) = @_; + my($expr, $varlist) = @_; die("Undefined value in ParseExpr") if not defined($expr); - my @tokens = split /((?:[A-Za-z_])(?:(?:(?:[A-Za-z0-9_.])|(?:->))+)?)/, $expr; - my $ret = ""; - - foreach my $t (@tokens) { - if (defined($varlist->{$t})) { - $ret .= $varlist->{$t}; - } else { - $ret .= $t; - } - } - - return $ret; + my $x = new Parse::Pidl::Expr(); + + return $x->Run($expr, sub { my $x = shift; die(MyDumper($x)); }, + # Lookup fn + sub { my $x = shift; + return($varlist->{$x}) if (defined($varlist->{$x})); + return $x; + }, + undef); } 1; |