changeset 24:888b08634e8f

fix merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 19 Feb 2023 08:46:59 +0900
parents 2748cd7ccfca
children 98d017d452c6
files Calcon.pm
diffstat 1 files changed, 29 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Calcon.pm	Fri Feb 07 11:34:38 2014 +0900
+++ b/Calcon.pm	Sun Feb 19 08:46:59 2023 +0900
@@ -210,20 +210,43 @@
 sub equal {
     my ($self,$record) = @_;
 
+# $self->show;
+# $record->show;
     foreach my $key (keys %{$self}) {
 	if (!defined $self->{$key} && !defined $record->{$key}) {
              # print "!!!!! $key not defiend \n";
              next;
         }
 	if(ref $self->{$key} && ref $record->{$key}) {
-	    return 0 if (! $self->{$key}->equal($record->{$key}));
+            if (! $self->{$key}->equal($record->{$key})) {
+# print "not equal $key\n";
+                return 0 
+            }
 	} else {
             if ($self->{$key} ne $record->{$key}) {
-               # print "!!!!! $key not equal $self->{$key} <!!!!!> $record->{$key}\n";
+               if ($key eq 'summary') {
+                    my $a = $record->{summary};
+                    my $b = $self->{summary};
+                    $a =~ s/[\s\W]*//mg;
+                    $b =~ s/[\s\W]*//mg;
+                    next if ( $a =~ /$b/ || $b =~ /$a/ ) ;
+               } elsif ( $key eq 'memo') {
+                    my $a = $record->{memo};
+                    my $b = $self->{memo};
+                    $a =~ s/[\s\W]*//mg;
+                    $b =~ s/[\s\W]*//mg;
+                    next if ( $a =~ /$b/ || $b =~ /$a/ ) ;
+               }
+               next if ( $key eq 'end-date');
+               next if ( $key eq 'extra');
+               next if ( $key eq 'modify-date');
+               next if ( $key eq 'sequence');
+               # print STDERR "not equal $key $self->{summary} \n != $record->{summary}\n";
                return 0;
             }
 	}
     }
+# print "equal\n";
     return 1;
 }
 
@@ -1292,17 +1315,19 @@
 
 sub same_record_in_list {
     my ($self,$list,$record) = @_;
+    my $r;
     return -1 if ( ! $list );
 # print "\nCampare: ";$record->value;
     record: 
     for (my $i = 0; $i<=$#{$list}; $i++) {
-	my $r = $list->[$i];
+	$r = $list->[$i];
 # print "\nList: ";$r->value;
 	next if (! $record->equal($r));
 # print "\nResult: $i\n";
 	return $i;
     }
 # print "\nResult: -1\n";
+# print "not equal\n";$record->show;$r->show;
     return -1;
 }
 
@@ -1352,6 +1377,7 @@
 
 # Pool にないレコードだったら、そのレコードを付け加える。
 # 中身を見て、必要な情報のみを付け加える方が良い。
+# 情報が追加されると duplicate してしまう。新しい方を残すほうが良いのだが。
 
 use strict;
 # use warnings;