Skip to content

Commit

Permalink
Improve hashing of verb and verbatim text (patch modfied from issue #36)
Browse files Browse the repository at this point in the history
  • Loading branch information
ftilmann committed Dec 11, 2015
1 parent ac107dd commit 2219f49
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions latexdiff
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
# - patch mhchem: allow ce in equations
# - flatten now also expands \input etc. in the preamble (but not \usepackage!)
# - Better support for Japanese ( contributed by github user kshramt )
# - prevent duplicated verbatim hashes (patch contributed by github user therussianjig, issue #36)
#
# Version 1.1.0
# - treat diacritics (\",\', etc) as safe commands
Expand Down Expand Up @@ -2088,17 +2089,18 @@ sub tohash {

@arr=unpack('c*',$string);

foreach $val (@arr) {
$sum += $i*$val;
$i++;
}
$hstr= "$sum";
if (defined($hash->{$hstr}) && $string ne $hash->{$hstr}) {
warn "Repeated hash value for verbatim mode in spite of different content.";
$hstr="-$hstr";
while (1) {
foreach $val (@arr) {
$sum += $i*$val;
$i++;
}
$hstr= "$sum";
### $hstr="-$hstr";
last unless (defined($hash->{$hstr}) && $string ne $hash->{$hstr});
# else found a duplicate HASH need to repeat for a higher hash value
}
$hash->{$hstr}=$string;
### print STDERR "Hash:$hstr: Content:$string:\n";
### print STDERR "Hash:$hstr: Content:$string:\n";
return($hstr);
}

Expand Down

0 comments on commit 2219f49

Please sign in to comment.