Author: jelmer Date: 2006-05-21 15:35:33 +0000 (Sun, 21 May 2006) New Revision: 15780
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15780 Log: Fix indentation of deferred code (fixed #3739) Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm Changeset: Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm =================================================================== --- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm 2006-05-21 15:02:01 UTC (rev 15779) +++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm 2006-05-21 15:35:33 UTC (rev 15780) @@ -103,7 +103,7 @@ } my $res; -my $deferred = ""; +my $deferred = []; my $tabs = ""; #################################### @@ -128,14 +128,16 @@ # output buffer at the end of the structure/union/function # This is needed to cope with code that must be pushed back # to the end of a block of elements +my $defer_tabs = ""; +sub defer_indent() { $defer_tabs.="\t"; } +sub defer_deindent() { $defer_tabs=substr($defer_tabs, 0, -1); } + sub defer($) { my $d = shift; if ($d) { - $deferred .= $tabs; - $deferred .= $d; + push(@$deferred, $defer_tabs.$d); } - $deferred .="\n"; } ######################################## @@ -143,8 +145,9 @@ # output sub add_deferred() { - $res .= $deferred; - $deferred = ""; + pidl $_ foreach (@$deferred); + $deferred = []; + $defer_tabs = ""; } sub indent() @@ -370,16 +373,20 @@ if ($l->{IS_CONFORMANT} and not $l->{IS_ZERO_TERMINATED}) { my $size = ParseExpr($l->{SIZE_IS}, $env); defer "if ($var_name) {"; + defer_indent; check_null_pointer_deferred($size); defer "NDR_CHECK(ndr_check_array_size(ndr, (void*)" . get_pointer_to($var_name) . ", $size));"; + defer_deindent; defer "}"; } if ($l->{IS_VARYING} and not $l->{IS_ZERO_TERMINATED}) { my $length = ParseExpr($l->{LENGTH_IS}, $env); defer "if ($var_name) {"; + defer_indent; check_null_pointer_deferred($length); defer "NDR_CHECK(ndr_check_array_length(ndr, (void*)" . get_pointer_to($var_name) . ", $length));"; + defer_deindent; defer "}" }