summaryrefslogtreecommitdiff
path: root/source4/build/pidl/idl.yp
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-07-10 01:16:02 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:19:29 -0500
commit514ce32a894585b66d7dc276d10fe6f4b525e02b (patch)
treec8d5f194aba2ba1ca2738ca9d6d14dfbe51c2433 /source4/build/pidl/idl.yp
parent76ecf81428c161a98a5621b55a64cb8515f80585 (diff)
downloadsamba-514ce32a894585b66d7dc276d10fe6f4b525e02b.tar.gz
samba-514ce32a894585b66d7dc276d10fe6f4b525e02b.tar.bz2
samba-514ce32a894585b66d7dc276d10fe6f4b525e02b.zip
r8274: Export some more symbols.
(This used to be commit d1f754a0a34c5938579a605b4f113100e14bac3d)
Diffstat (limited to 'source4/build/pidl/idl.yp')
-rw-r--r--source4/build/pidl/idl.yp29
1 files changed, 28 insertions, 1 deletions
diff --git a/source4/build/pidl/idl.yp b/source4/build/pidl/idl.yp
index acf926dd40..0e505b81fb 100644
--- a/source4/build/pidl/idl.yp
+++ b/source4/build/pidl/idl.yp
@@ -306,6 +306,33 @@ optional_semicolon:
use Parse::Pidl::Util;
+#####################################################################
+# traverse a perl data structure removing any empty arrays or
+# hashes and any hash elements that map to undef
+sub CleanData($)
+{
+ sub CleanData($);
+ my($v) = shift;
+ if (ref($v) eq "ARRAY") {
+ foreach my $i (0 .. $#{$v}) {
+ CleanData($v->[$i]);
+ if (ref($v->[$i]) eq "ARRAY" && $#{$v->[$i]}==-1) {
+ $v->[$i] = undef;
+ next;
+ }
+ }
+ # this removes any undefined elements from the array
+ @{$v} = grep { defined $_ } @{$v};
+ } elsif (ref($v) eq "HASH") {
+ foreach my $x (keys %{$v}) {
+ CleanData($v->{$x});
+ if (!defined $v->{$x}) { delete($v->{$x}); next; }
+ if (ref($v->{$x}) eq "ARRAY" && $#{$v->{$x}}==-1) { delete($v->{$x}); next; }
+ }
+ }
+ return $v;
+}
+
sub _Error {
if (exists $_[0]->YYData->{ERRMSG}) {
print $_[0]->YYData->{ERRMSG};
@@ -393,5 +420,5 @@ sub parse_idl($$)
my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
- return Parse::Pidl::Util::CleanData($idl);
+ return CleanData($idl);
}