Rev 11453: Fix bug in pidl that prevented value(0) from working. Bug reported by metze. in file:///home/jelmer/bzr.samba/SAMBA_4_0/

Jelmer Vernooij jelmer at samba.org
Wed Feb 14 12:39:48 GMT 2007


At file:///home/jelmer/bzr.samba/SAMBA_4_0/

------------------------------------------------------------
revno: 11453
revision-id: jelmer at samba.org-20070214123932-nmsy6lnin8gtzxrn
parent: svn-v2:21331 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: SAMBA_4_0
timestamp: Wed 2007-02-14 13:39:32 +0100
message:
  Fix bug in pidl that prevented value(0) from working. Bug reported by metze.
modified:
  source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm svn-v2:12463 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2flib%2fParse%2fPidl%2fSamba4%2fNDR%2fParser.pm
  source/pidl/tests/samba-ndr.pl svn-v2:20637 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2ftests%2fsamba%2dndr.pl
=== modified file 'source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm'
--- a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm	2007-02-08 23:54:31 +0000
+++ b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm	2007-02-14 12:39:32 +0000
@@ -10,7 +10,8 @@
 require Exporter;
 @ISA = qw(Exporter);
 @EXPORT = qw(is_charset_array);
- at EXPORT_OK = qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv);
+ at EXPORT_OK = qw(check_null_pointer GenerateFunctionInEnv 
+   GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv);
 
 use strict;
 use Parse::Pidl::Typelist qw(hasType getType mapType);
@@ -234,7 +235,7 @@
 
 	# Substitute the value() values in the env
 	foreach my $e (@{$s->{ELEMENTS}}) {
-		next unless (my $v = has_property($e, "value"));
+		next unless (defined(my $v = has_property($e, "value")));
 		
 		$env->{$e->{NAME}} = ParseExpr($v, $env, $e);
 	}
@@ -714,7 +715,7 @@
 
 	start_flags($e);
 
-	if (my $value = has_property($e, "value")) {
+	if (defined(my $value = has_property($e, "value"))) {
 		$var_name = ParseExpr($value, $env, $e->{ORIGINAL});
 	}
 
@@ -765,7 +766,7 @@
 
 	$var_name = append_prefix($e, $var_name);
 
-	if (my $value = has_property($e, "value")) {
+	if (defined(my $value = has_property($e, "value"))) {
 		$var_name = "(ndr->flags & LIBNDR_PRINT_SET_VALUES)?" . ParseExpr($value,$env, $e->{ORIGINAL}) . ":$var_name";
 	}
 

=== modified file 'source/pidl/tests/samba-ndr.pl'
--- a/source/pidl/tests/samba-ndr.pl	2007-02-08 23:54:31 +0000
+++ b/source/pidl/tests/samba-ndr.pl	2007-02-14 12:39:32 +0000
@@ -4,12 +4,12 @@
 use strict;
 use warnings;
 
-use Test::More tests => 16;
+use Test::More tests => 20;
 use FindBin qw($RealBin);
 use lib "$RealBin";
 use Util;
 use Parse::Pidl::Util qw(MyDumper);
-use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv);
+use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv EnvSubstituteValue); 
 
 my $output;
 sub print_fn($) { my $x = shift; $output.=$x; }
@@ -152,3 +152,23 @@
 
 $fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] };
 is_deeply({ }, GenerateFunctionInEnv($fn));
+
+$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] };
+is_deeply({ foo => "r->foo", bar => "r->bar", this => "r" }, GenerateStructEnv($fn));
+
+$fn = { ELEMENTS => [ { NAME => "foo", PROPERTIES => { value => 3 }} ] };
+
+my $env = GenerateStructEnv($fn);
+EnvSubstituteValue($env, $fn);
+is_deeply($env, { foo => 3, this => "r" });
+
+$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] };
+$env = GenerateStructEnv($fn);
+EnvSubstituteValue($env, $fn);
+is_deeply($env, { foo => 'r->foo', bar => 'r->bar', this => "r" });
+
+$fn = { ELEMENTS => [ { NAME => "foo", PROPERTIES => { value => 0 }} ] };
+
+$env = GenerateStructEnv($fn);
+EnvSubstituteValue($env, $fn);
+is_deeply($env, { foo => 0, this => "r" });



More information about the samba-cvs mailing list