From 49f65386827c09dfe0d9991be714e0cf3001774b Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Fri, 18 Aug 2017 00:39:30 +0000 Subject: [PATCH] Updated a comment in getAlignmentPatternPositions() in most language versions (except JavaScript). --- c/qrcodegen.c | 7 ++++--- cpp/QrCode.cpp | 7 ++++--- java/io/nayuki/qrcodegen/QrCode.java | 7 ++++--- python/qrcodegen.py | 3 ++- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/c/qrcodegen.c b/c/qrcodegen.c index e86a1de..081b29a 100644 --- a/c/qrcodegen.c +++ b/c/qrcodegen.c @@ -630,9 +630,10 @@ testable int getAlignmentPatternPositions(int version, uint8_t result[7]) { int qrsize = version * 4 + 17; int numAlign = version / 7 + 2; int step; - if (version != 32) - step = (version * 4 + numAlign * 2 + 1) / (2 * numAlign - 2) * 2; // ceil((qrsize - 13) / (2*numAlign - 2)) * 2 - else // C-C-C-Combo breaker! + if (version != 32) { + // ceil((qrsize - 13) / (2*numAlign - 2)) * 2 + step = (version * 4 + numAlign * 2 + 1) / (2 * numAlign - 2) * 2; + } else // C-C-C-Combo breaker! step = 26; for (int i = numAlign - 1, pos = qrsize - 7; i >= 1; i--, pos -= step) result[i] = pos; diff --git a/cpp/QrCode.cpp b/cpp/QrCode.cpp index d9bbc9e..5180789 100644 --- a/cpp/QrCode.cpp +++ b/cpp/QrCode.cpp @@ -507,9 +507,10 @@ vector QrCode::getAlignmentPatternPositions(int ver) { else { int numAlign = ver / 7 + 2; int step; - if (ver != 32) - step = (ver * 4 + numAlign * 2 + 1) / (2 * numAlign - 2) * 2; // ceil((size - 13) / (2*numAlign - 2)) * 2 - else // C-C-C-Combo breaker! + if (ver != 32) { + // ceil((size - 13) / (2*numAlign - 2)) * 2 + step = (ver * 4 + numAlign * 2 + 1) / (2 * numAlign - 2) * 2; + } else // C-C-C-Combo breaker! step = 26; vector result; diff --git a/java/io/nayuki/qrcodegen/QrCode.java b/java/io/nayuki/qrcodegen/QrCode.java index 3a189aa..c20324d 100644 --- a/java/io/nayuki/qrcodegen/QrCode.java +++ b/java/io/nayuki/qrcodegen/QrCode.java @@ -668,9 +668,10 @@ public final class QrCode { else { int numAlign = ver / 7 + 2; int step; - if (ver != 32) - step = (ver * 4 + numAlign * 2 + 1) / (2 * numAlign - 2) * 2; // ceil((size - 13) / (2*numAlign - 2)) * 2 - else // C-C-C-Combo breaker! + if (ver != 32) { + // ceil((size - 13) / (2*numAlign - 2)) * 2 + step = (ver * 4 + numAlign * 2 + 1) / (2 * numAlign - 2) * 2; + } else // C-C-C-Combo breaker! step = 26; int[] result = new int[numAlign]; diff --git a/python/qrcodegen.py b/python/qrcodegen.py index 7001588..97b8f5f 100644 --- a/python/qrcodegen.py +++ b/python/qrcodegen.py @@ -506,7 +506,8 @@ class QrCode(object): else: numalign = ver // 7 + 2 if ver != 32: - step = (ver * 4 + numalign * 2 + 1) // (2 * numalign - 2) * 2 # ceil((size - 13) / (2*numalign - 2)) * 2 + # ceil((size - 13) / (2*numalign - 2)) * 2 + step = (ver * 4 + numalign * 2 + 1) // (2 * numalign - 2) * 2 else: # C-C-C-Combo breaker! step = 26 result = [6]