aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-07-14 02:25:12 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-07-14 02:25:12 +0200
commit1c3910befbe8d6679979ac43b00796ea58329dff (patch)
treec7c51535744b13e236bc1374b8e83bb4abae8a12
parentb7202cc09b67f5a1e58576b9c0feac7baae387c2 (diff)
downloadrefcat-1c3910befbe8d6679979ac43b00796ea58329dff.tar.gz
refcat-1c3910befbe8d6679979ac43b00796ea58329dff.zip
reduce: fix off-by-one error
duplication detection required a +1 on the index in the ref document
-rw-r--r--skate/reduce.go2
-rw-r--r--skate/reduce_test.go2
2 files changed, 2 insertions, 2 deletions
diff --git a/skate/reduce.go b/skate/reduce.go
index eac2e83..01df50f 100644
--- a/skate/reduce.go
+++ b/skate/reduce.go
@@ -501,7 +501,7 @@ func matchedRefsExtend(matched []*BiblioRef, refs []*Ref, stats *statsAugment) [
seen.Add(s)
}
for _, r := range refs {
- s := r.Key + fmt.Sprintf("%d", r.Index)
+ s := r.Key + fmt.Sprintf("%d", r.Index+1)
if seen.Contains(s) {
stats.skipMatchedRef++
log.Printf("skip-matched-ref [%d]: from %d matches; ident=%v, title=%s, key=%v, index=%d",
diff --git a/skate/reduce_test.go b/skate/reduce_test.go
index 99c0ed7..da4e21e 100644
--- a/skate/reduce_test.go
+++ b/skate/reduce_test.go
@@ -215,7 +215,7 @@ func TestMatchedRefsExtend(t *testing.T) {
Biblio: Biblio{
Title: "Title",
},
- Index: 2,
+ Index: 1,
Key: "K2",
},
},