summaryrefslogtreecommitdiff
path: root/gtk2_ardour/session_metadata_dialog.cc
diff options
context:
space:
mode:
authorColin Fletcher <colin.m.fletcher@googlemail.com>2016-04-01 15:18:53 +0100
committerColin Fletcher <colin.m.fletcher@googlemail.com>2016-04-01 15:18:53 +0100
commit91c7845d409665e54d78c9325c36aa8926b82669 (patch)
treee18a4765afeb5e2e8cc1c22046e2e22b06b2c9df /gtk2_ardour/session_metadata_dialog.cc
parent9a8a5f4f20d6e6f8495e264880f123ca4b9a1a1b (diff)
Fix EAN check digit calculation
Fix two mistakes in in the EAN check digit calculation.
Diffstat (limited to 'gtk2_ardour/session_metadata_dialog.cc')
-rw-r--r--gtk2_ardour/session_metadata_dialog.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/gtk2_ardour/session_metadata_dialog.cc b/gtk2_ardour/session_metadata_dialog.cc
index 7973d035bb..88720edc74 100644
--- a/gtk2_ardour/session_metadata_dialog.cc
+++ b/gtk2_ardour/session_metadata_dialog.cc
@@ -270,15 +270,18 @@ EAN13MetadataField::update_status ()
// calculate EAN-13 modulo 10 check digit
int sum = 0;
const char *p = _value.c_str();
- for (int i =0; i < 12; i++) {
+ for (int i = 0; i < 12; i++) {
char c = p[i] - '0';
if (i % 2) {
- sum += c;
- } else {
sum += c * 3;
+ } else {
+ sum += c;
}
}
sum %= 10;
+ if (sum)
+ sum = 10 - sum;
+
if (sum == p[12] - '0') {
status_label->set_markup (string_compose(
"<span color=\"green\">%1: %2</span>",