diff options
Diffstat (limited to 'pidl/lib/Parse/Pidl/Samba4/NDR')
-rw-r--r-- | pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm | 2 | ||||
-rw-r--r-- | pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 12 |
2 files changed, 12 insertions, 2 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm index f8209be654..f2a96a3037 100644 --- a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm +++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm @@ -131,7 +131,9 @@ sub Parse($$$$) if (is_intree()) { $res .= "#include \"includes.h\"\n"; } else { + $res .= "#ifndef _GNU_SOURCE\n"; $res .= "#define _GNU_SOURCE\n"; + $res .= "#endif\n"; $res .= "#include <stdio.h>\n"; $res .= "#include <stdbool.h>\n"; $res .= "#include <stdlib.h>\n"; diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index af6885f67a..34aebc7f0f 100644 --- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -586,9 +586,15 @@ sub ParseElementPushLevel my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL}); my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}"; + my $array_pointless = ($length eq "0"); + + if ($array_pointless) { + warning($e->{ORIGINAL}, "pointless array `$e->{NAME}' will always have size 0"); + } + $var_name = get_array_element($var_name, $counter); - if (($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) { + if ((($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) and not $array_pointless) { $self->pidl("for ($counter = 0; $counter < $length; $counter++) {"); $self->indent; $self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 1, 0); @@ -596,7 +602,7 @@ sub ParseElementPushLevel $self->pidl("}"); } - if ($deferred and ContainsDeferred($e, $l)) { + if ($deferred and ContainsDeferred($e, $l) and not $array_pointless) { $self->pidl("for ($counter = 0; $counter < $length; $counter++) {"); $self->indent; $self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 0, 1); @@ -2548,7 +2554,9 @@ sub GenerateIncludes($) if (is_intree()) { $self->pidl("#include \"includes.h\""); } else { + $self->pidl("#ifndef _GNU_SOURCE"); $self->pidl("#define _GNU_SOURCE"); + $self->pidl("#endif"); $self->pidl("#include <stdint.h>"); $self->pidl("#include <stdlib.h>"); $self->pidl("#include <stdio.h>"); |