diff options
author | Karl Williamson <public@khwilliamson.com> | 2012-03-16 13:12:49 -0600 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2012-03-19 16:51:25 -0600 |
commit | 6901521e3ffe762ff8e3f268762b0d2f667771a7 (patch) | |
tree | 79cc44f29d9748013e814867ce1ddd82c5debf53 | |
parent | 6342d44542ab62d41255e7655319b5f5ce0975a3 (diff) | |
download | perl-6901521e3ffe762ff8e3f268762b0d2f667771a7.tar.gz |
mktables: Don't duplicate entries
The Name table can have multiple names for each code point. The highest
priority ones are first in the file. Prior to this patch, adding a
high priority name to a code point which already had the same name, the
old name could be retained, leaving two identical names for the code
point. This patch causes the lower-priority one to be deleted.
-rw-r--r-- | lib/unicore/mktables | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/lib/unicore/mktables b/lib/unicore/mktables index 8d38d0e506..f0813cf97c 100644 --- a/lib/unicore/mktables +++ b/lib/unicore/mktables @@ -3394,9 +3394,17 @@ sub trace { return main::trace(@_); } # multiple times. They are stored LIFO, so # that the final one inserted is the first one # returned in an ordered search of the table. + # If this is an exact duplicate, including the + # value, the original will be moved to be + # first, before any other duplicate ranges + # with different values. # => $MULTIPLE_AFTER is like $MULTIPLE_BEFORE, but is stored # FIFO, so that this one is inserted after all - # others that currently exist. + # others that currently exist. If this is an + # exact duplicate, including value, of an + # existing range, this one is discarded + # (leaving the existing one in its original, + # higher priority position # => anything else is the same as => $IF_NOT_EQUIVALENT # # "same value" means identical for non-type-0 ranges, and it means @@ -3678,7 +3686,10 @@ sub trace { return main::trace(@_); } # If to place this new record after, move to beyond all existing # ones; but don't add this one if identical to any of them, as it - # isn't really a multiple + # isn't really a multiple. This leaves the original order, so + # that the current request is ignored. The reasoning is that the + # previous request that wanted this record to have high priority + # should have precedence. if ($replace == $MULTIPLE_AFTER) { while ($i < @$r && $r->[$i]->start == $start) { return if $value eq $r->[$i]->value @@ -3686,6 +3697,22 @@ sub trace { return main::trace(@_); } $i++; } } + else { + # If instead we are to place this new record before any + # existing ones, remove any identical ones that come after it. + # This changes the existing order so that the new one is + # first, as is being requested. + for (my $j = $i + 1; + $j < @$r && $r->[$j]->start == $start; + $j++) + { + if ($value eq $r->[$j]->value && $type eq $r->[$j]->type) { + splice @$r, $j, 1; + last; # There should only be one instance, so no + # need to keep looking + } + } + } trace "Adding multiple record at $i with $start..$end, $value" if main::DEBUG && $to_trace; my @return = splice @$r, |