Subject: | ep3_defines does not mark the variable as defined |
Distribution: Text-EP3-1.00
Test case details:
----template file: foo.tmpl----
@ifdef FOO
foo defined
@else
foo NOT defined
@endif
--------------------------------
Show quoted text
----perl program----
use Text::EP3;
my $object = new Text::EP3;
$object->ep3_defines("FOO=1");
$object->ep3_process("foo.tmpl");
--------------------------------
When this is run, it currently prints "foo NOT defined". After the patch it works as expected.
The problem seems to be that
$Text::EP3::line;
$Text::EP3::filename;
are not set when defines are passed programmatically via ep3_defines.
Attaching a diff that fixes this problem.
--- /tmp/EP3.pm Fri Aug 13 15:54:40 2004
+++ EP3.pm Fri Aug 13 15:56:21 2004
@@ -1080,6 +1080,15 @@
$self->{Keyline}{$key} = $Text::EP3::line;
$self->{Keyfile}{$key} = $Text::EP3::filename;
+ # line and filename will be empty when ep3_defines is used so set them
+ # appropriately
+ if (!length($self->{Keyline}{$key})) {
+ $self->{Keyline}{$key} = "$directive $key $inline";
+ }
+ if (!length($self->{Keyfile}{$key})) {
+ $self->{Keyfile}{$key} = "[Programmatic]";
+ }
+
# place it in the key list and bump the keycount
$self->{Keylist}[$self->{Keycount}] = $key;
$self->{Keycount}++;