From f2ea49b7d480e2383271288af9a1e9e4bbe210d2 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Sat, 13 Oct 2018 19:54:30 +0000 Subject: [PATCH] Tweaked QrCode.drawFormatBits() to use end-exclusive range in second copy for clarity, in most languages. --- c/qrcodegen.c | 2 +- cpp/QrCode.cpp | 2 +- java/io/nayuki/qrcodegen/QrCode.java | 2 +- javascript/qrcodegen.js | 2 +- typescript/qrcodegen.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/c/qrcodegen.c b/c/qrcodegen.c index 8f6de55..79bf810 100644 --- a/c/qrcodegen.c +++ b/c/qrcodegen.c @@ -528,7 +528,7 @@ static void drawFormatBits(enum qrcodegen_Ecc ecl, enum qrcodegen_Mask mask, uin // Draw second copy int qrsize = qrcodegen_getSize(qrcode); - for (int i = 0; i <= 7; i++) + for (int i = 0; i < 8; i++) setModule(qrcode, qrsize - 1 - i, 8, getBit(bits, i)); for (int i = 8; i < 15; i++) setModule(qrcode, 8, qrsize - 15 + i, getBit(bits, i)); diff --git a/cpp/QrCode.cpp b/cpp/QrCode.cpp index 0a8b12f..5005949 100644 --- a/cpp/QrCode.cpp +++ b/cpp/QrCode.cpp @@ -243,7 +243,7 @@ void QrCode::drawFormatBits(int mask) { setFunctionModule(14 - i, 8, getBit(bits, i)); // Draw second copy - for (int i = 0; i <= 7; i++) + for (int i = 0; i < 8; i++) setFunctionModule(size - 1 - i, 8, getBit(bits, i)); for (int i = 8; i < 15; i++) setFunctionModule(8, size - 15 + i, getBit(bits, i)); diff --git a/java/io/nayuki/qrcodegen/QrCode.java b/java/io/nayuki/qrcodegen/QrCode.java index eba69ec..e689955 100644 --- a/java/io/nayuki/qrcodegen/QrCode.java +++ b/java/io/nayuki/qrcodegen/QrCode.java @@ -396,7 +396,7 @@ public final class QrCode { setFunctionModule(14 - i, 8, getBit(bits, i)); // Draw second copy - for (int i = 0; i <= 7; i++) + for (int i = 0; i < 8; i++) setFunctionModule(size - 1 - i, 8, getBit(bits, i)); for (int i = 8; i < 15; i++) setFunctionModule(8, size - 15 + i, getBit(bits, i)); diff --git a/javascript/qrcodegen.js b/javascript/qrcodegen.js index 520daad..16531a5 100644 --- a/javascript/qrcodegen.js +++ b/javascript/qrcodegen.js @@ -257,7 +257,7 @@ var qrcodegen = new function() { setFunctionModule(14 - i, 8, getBit(bits, i)); // Draw second copy - for (var i = 0; i <= 7; i++) + for (var i = 0; i < 8; i++) setFunctionModule(size - 1 - i, 8, getBit(bits, i)); for (var i = 8; i < 15; i++) setFunctionModule(8, size - 15 + i, getBit(bits, i)); diff --git a/typescript/qrcodegen.ts b/typescript/qrcodegen.ts index e2c1964..fe17bcd 100644 --- a/typescript/qrcodegen.ts +++ b/typescript/qrcodegen.ts @@ -337,7 +337,7 @@ namespace qrcodegen { this.setFunctionModule(14 - i, 8, getBit(bits, i)); // Draw second copy - for (let i = 0; i <= 7; i++) + for (let i = 0; i < 8; i++) this.setFunctionModule(this.size - 1 - i, 8, getBit(bits, i)); for (let i = 8; i < 15; i++) this.setFunctionModule(8, this.size - 15 + i, getBit(bits, i));