Skip to content

Commit ce35f21

Browse files
committed
Merge branch 'hotfix' into develop
2 parents 9ea13e3 + 50b3e57 commit ce35f21

File tree

8 files changed

+83
-7
lines changed

8 files changed

+83
-7
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.1.0)
22

3-
project(QRencode VERSION 4.1.0 LANGUAGES C)
3+
project(QRencode VERSION 4.1.1 LANGUAGES C)
44

55
option(WITH_TOOLS "Build utility tools" YES )
66
option(WITH_TESTS "Build tests" NO )

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
2020.09.28 Kentaro Fukuchi <[email protected]>
2+
[hotfix]
3+
* qrinput.c, tests/test_estimatebit.c:
4+
- Fixed a bug in the estimation of the Micro QR Code's data length
5+
in QRinput_estimateBitStreamSizeOfEntry() has been fixed.
6+
- Fixed a bug in the calculation of the Micro QR Code's data capacity in
7+
QRinput_encodeBitStream().
8+
- A test case to test the bugs above has been added.
9+
* Bumped version to 4.1.1.
210
[develop]
311
* tests/release_check.sh:
412
- Release checker script has been added. Currently it checks only the

NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ Version x.x.x (2020.xx.xx)
99
* Some minor bug fixes. (Thanks to Darsey Litzenberger and Edward E.)
1010
* Some performance improvements.
1111

12+
Version 4.1.1 (2020.9.28)
13+
-------------------------
14+
* Some minor bugs in Micro QR Code generation have been fixed.
15+
* The data capacity calculations are now correct. These bugs probably did not
16+
affect the Micro QR Code generation.
17+
1218
Version 4.1.0 (2020.8.29)
1319
-------------------------
1420
* Command line tool "qrencode" has been improved:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# libqrencode - a fast and compact QR Code encoding library
22
[![build](https://github.com/fukuchi/libqrencode/workflows/build/badge.svg)](https://github.com/fukuchi/libqrencode/actions)
33

4-
**Attention:** This repository contains the development version of libqrencode. See <https://fukuchi.org/works/qrencode/> for the official stable releases. At this moment, the latest stable release is version 4.1.0.
4+
**Attention:** This repository contains the development version of libqrencode. See <https://fukuchi.org/works/qrencode/> for the official stable releases. At this moment, the latest stable release is version 4.1.1.
55

66
GENERAL INFORMATION
77
===================

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
m4_define([__MAJOR_VERSION], [4])dnl
22
m4_define([__MINOR_VERSION], [1])dnl
3-
m4_define([__MICRO_VERSION], [0])dnl
3+
m4_define([__MICRO_VERSION], [1])dnl
44
m4_define([__VERSION], [__MAJOR_VERSION.__MINOR_VERSION.__MICRO_VERSION])dnl
55
AC_INIT(QRencode, __VERSION)
66

qrinput.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version
890890
}
891891

892892
if(mqr) {
893-
l = QRspec_lengthIndicator(entry->mode, version);
893+
l = MQRspec_lengthIndicator(entry->mode, version);
894894
m = version - 1;
895895
bits += l + m;
896896
} else {
@@ -1018,7 +1018,11 @@ static int QRinput_encodeBitStream(QRinput_List *entry, BitStream *bstream, int
10181018

10191019
prevsize = (int)BitStream_size(bstream);
10201020

1021-
words = QRspec_maximumWords(entry->mode, version);
1021+
if(mqr) {
1022+
words = MQRspec_maximumWords(entry->mode, version);
1023+
} else {
1024+
words = QRspec_maximumWords(entry->mode, version);
1025+
}
10221026
if(words != 0 && entry->size > words) {
10231027
st1 = QRinput_List_newEntry(entry->mode, words, entry->data);
10241028
if(st1 == NULL) goto ABORT;

tests/test_estimatebit.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,34 @@ static void test_mix(void)
139139
QRinput_free(gstream);
140140
}
141141

142+
/* Taken from JISX 0510:2018, p.23 */
143+
static void test_numbit1_mqr(void)
144+
{
145+
QRinput *stream;
146+
char *str = "0123456789012345";
147+
int bits;
148+
149+
testStart("Estimation of Numeric stream for Micro QR Code (16 digits)");
150+
stream = QRinput_newMQR(3, QR_ECLEVEL_M);
151+
QRinput_append(stream, QR_MODE_NUM, 16, (const unsigned char *)str);
152+
bits = QRinput_estimateBitStreamSize(stream, QRinput_getVersion(stream));
153+
assert_equal(bits, 61, "Estimated bit length is wrong: %d, expected: %d.\n", bits, 61);
154+
QRinput_free(stream);
155+
156+
stream = QRinput_newMQR(4, QR_ECLEVEL_M);
157+
QRinput_append(stream, QR_MODE_NUM, 16, (const unsigned char *)str);
158+
bits = QRinput_estimateBitStreamSize(stream, QRinput_getVersion(stream));
159+
assert_equal(bits, 63, "Estimated bit length is wrong: %d, expected: %d.\n", bits, 63);
160+
QRinput_free(stream);
161+
162+
testFinish();
163+
}
164+
142165
int main()
143166
{
144167
gstream = QRinput_new();
145168

146-
int tests = 8;
169+
int tests = 9;
147170
testInit(tests);
148171
test_numbit();
149172
test_numbit2();
@@ -153,6 +176,7 @@ int main()
153176
test_kanji();
154177
test_structure();
155178
test_mix();
179+
test_numbit1_mqr();
156180
testReport(tests);
157181

158182
return 0;

tests/test_qrinput.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,38 @@ static void test_estimateVersionBoundaryCheck(void)
889889
testFinish();
890890
}
891891

892+
static void test_QRinput_new_invalid(void)
893+
{
894+
testStart("Invalid input to QRinput_new2()");
895+
QRinput *input;
896+
897+
input = QRinput_new2(-1, QR_ECLEVEL_H);
898+
assert_null(input, "QRinput_new2() returns non-null for invalid version (-1).\n");
899+
assert_equal(errno, EINVAL, "Error code is not EINVAL.\n");
900+
input = QRinput_new2(41, QR_ECLEVEL_H);
901+
assert_null(input, "QRinput_new2() returns non-null for invalid version (41).\n");
902+
assert_equal(errno, EINVAL, "Error code is not EINVAL.\n");
903+
input = QRinput_new2(1, -1);
904+
assert_null(input, "QRinput_new2() returns non-null for invalid level (-1).\n");
905+
assert_equal(errno, EINVAL, "Error code is not EINVAL.\n");
906+
input = QRinput_new2(1, 5);
907+
assert_null(input, "QRinput_new2() returns non-null for invalid level (5).\n");
908+
assert_equal(errno, EINVAL, "Error code is not EINVAL.\n");
909+
testFinish();
910+
}
911+
912+
static void test_QRinput_getErrorCorrectionLevel(void)
913+
{
914+
testStart("Invalid input to QRinput_getErrorCorrectionLevel()");
915+
QRinput *input;
916+
QRecLevel level;
917+
918+
input = QRinput_new2(1, QR_ECLEVEL_H);
919+
level = QRinput_getErrorCorrectionLevel(input);
920+
assert_equal(level, QR_ECLEVEL_H, "QRinput_getErrorCorrectionLevel() fails to return expected level.\n");
921+
testFinish();
922+
}
923+
892924
static void test_mqr_new(void)
893925
{
894926
QRinput *input;
@@ -1044,7 +1076,7 @@ static void test_encodeECI(void)
10441076

10451077
int main()
10461078
{
1047-
int tests = 40;
1079+
int tests = 42;
10481080
testInit(tests);
10491081

10501082
test_encodeNumeric();
@@ -1078,6 +1110,8 @@ int main()
10781110
test_parity2();
10791111
test_null_free();
10801112
test_estimateVersionBoundaryCheck();
1113+
test_QRinput_new_invalid();
1114+
test_QRinput_getErrorCorrectionLevel();
10811115

10821116
test_mqr_new();
10831117
test_mqr_setversion();

0 commit comments

Comments
 (0)