Subject: | Gedcom gets confused when adding a NOTE record -- thinks its an xref when it isn't |
When I call $record->add("NOTE", "some random text") on an individual
record, Gedcom decides that I'm adding an xref rather than a textual
note. Then it won't let me add a "CONT" to the note because xref note
records aren't allowed to have continuation lines.
I'm not sure what the "right" fix to this is, but the attached patch
works.
Subject: | Gedcom-1.15-xref-grammar.patch |
--- Gedcom.pm~ 2009-04-23 21:10:50.000000000 -0400
+++ Gedcom.pm 2009-04-24 09:43:22.000000000 -0400
@@ -360,7 +360,7 @@
$s = $self->add_submitter;
$s->add("NAME", $me);
}
- $l0->add("SUBM", $s->xref);
+ $l0->add("SUBM", $s);
}
$self->add_trailer unless $r->get_record("trlr");
--- Gedcom/Record.pm.orig 2009-04-24 10:20:35.000000000 -0400
+++ Gedcom/Record.pm 2009-04-24 10:21:11.000000000 -0400
@@ -143,6 +143,10 @@
}
elsif (my @g = $self->{grammar}->item($args{tag}))
{
+ if (@g > 1 and defined($args{value_is_xref})) {
+ my(@g2) = grep((!$args{value_is_xref} == !($_->value =~ /^<XREF:/)), @g);
+ @g = @g2 if (@g2);
+ }
$self->parse($record, $g[0]);
}
else
@@ -163,7 +167,11 @@
my @funcs = map { ref() ? $_ : split } @_;
$funcs[-1] = [$funcs[-1], 0] unless ref $funcs[-1];
- my $r = $self->get_and_create(@funcs);
+ my %options;
+ if ($val) {
+ $options{value_is_xref} = UNIVERSAL::isa($val, "Gedcom::Record");
+ }
+ my $r = $self->get_and_create(\%options, @funcs);
if (defined $val)
{
@@ -205,6 +213,10 @@
sub get_and_create
{
my $self = shift;
+ my($options) = {};
+ if (ref $_[0] eq "HASH") {
+ $options = shift;
+ }
my @funcs = @_;
my $rec = $self;
@@ -235,12 +247,12 @@
if ($count < 0)
{
- $rec = $rec->add_record(tag => $record);
+ $rec = $rec->add_record(tag => $record, %{$options});
}
elsif ($#records < $count)
{
my $new;
- $new = $rec->add_record(tag => $record) for (0 .. @records - $count);
+ $new = $rec->add_record(tag => $record, %{$options}) for (0 .. @records - $count);
$rec = $new;
}
else