1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-01-27 13:55:57 +00:00

general: prefix all INTERNAL funcs/tables with zint_, except

those in "backend/common.h", which are prefixed by `z_` - makes
  symbol clashes more unlikely when zint is statically linked
  (ticket #337, props Ulrich Becker)
DOTCODE: fix padding allowance (10 -> 52 - probable max 35) to
  cover cases with large no. of columns requested and little data,
  to prevent `codeword_array` buffer overflow
AZTEC/CODEONE: some code fiddling
general_field: prefix defines with `GF_`, shorten static funcs
  prefix `general_field_` -> `gf_`
This commit is contained in:
gitlost
2025-08-26 23:48:00 +01:00
parent e18b047a45
commit 39380d6767
106 changed files with 4477 additions and 4360 deletions

View File

@@ -40,7 +40,7 @@
#include "../just_say_gno/gb2312_gnu.c"
#endif
INTERNAL int u_gb2312_int_test(const unsigned int u, unsigned int *d);
INTERNAL int zint_test_u_gb2312_int(const unsigned int u, unsigned int *d);
/* As control convert to GB 2312 using simple table generated from unicode.org GB2312.TXT plus simple processing */
/* GB2312.TXT no longer on unicode.org site but available from https://haible.de/bruno/charsets/conversion-tables/GB2312.html */
@@ -106,9 +106,10 @@ static void test_u_gb2312_int(const testCtx *const p_ctx) {
}
if (testContinue(p_ctx, i)) continue;
val = val2 = 0;
ret = u_gb2312_int_test(i, &val);
ret = zint_test_u_gb2312_int(i, &val);
ret2 = u_gb2312_int2(i, &val2);
assert_equal(ret, ret2, "i:%d 0x%04X ret %d != ret2 %d, val 0x%04X, val2 0x%04X\n", (int) i, i, ret, ret2, val, val2);
assert_equal(ret, ret2, "i:%d 0x%04X ret %d != ret2 %d, val 0x%04X, val2 0x%04X\n",
(int) i, i, ret, ret2, val, val2);
if (ret2) {
assert_equal(val, val2, "i:%d 0x%04X val 0x%04X != val2 0x%04X\n", (int) i, i, val, val2);
}
@@ -123,7 +124,7 @@ static void test_u_gb2312_int(const testCtx *const p_ctx) {
val = val2 = 0;
start = clock();
ret = u_gb2312_int_test(i, &val);
ret = zint_test_u_gb2312_int(i, &val);
total += clock() - start;
start = clock();
@@ -132,7 +133,8 @@ static void test_u_gb2312_int(const testCtx *const p_ctx) {
}
}
assert_equal(ret, ret2, "i:%d 0x%04X ret %d != ret2 %d, val 0x%04X, val2 0x%04X\n", (int) i, i, ret, ret2, val, val2);
assert_equal(ret, ret2, "i:%d 0x%04X ret %d != ret2 %d, val 0x%04X, val2 0x%04X\n",
(int) i, i, ret, ret2, val, val2);
if (ret2) {
assert_equal(val, val2, "i:%d 0x%04X val 0x%04X != val2 0x%04X\n", (int) i, i, val, val2);
}
@@ -200,13 +202,15 @@ static void test_gb2312_utf8(const testCtx *const p_ctx) {
length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
ret_length = length;
ret = gb2312_utf8(&symbol, (unsigned char *) data[i].data, &ret_length, gbdata);
ret = zint_gb2312_utf8(&symbol, (unsigned char *) data[i].data, &ret_length, gbdata);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol.errtxt);
if (ret == 0) {
int j;
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %d != %d\n", i, ret_length, data[i].ret_length);
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %d != %d\n",
i, ret_length, data[i].ret_length);
for (j = 0; j < (int) ret_length; j++) {
assert_equal(gbdata[j], data[i].expected_gbdata[j], "i:%d gbdata[%d] %04X != %04X\n", i, j, gbdata[j], data[i].expected_gbdata[j]);
assert_equal(gbdata[j], data[i].expected_gbdata[j], "i:%d gbdata[%d] %04X != %04X\n",
i, j, gbdata[j], data[i].expected_gbdata[j]);
}
}
}
@@ -302,13 +306,16 @@ static void test_gb2312_utf8_to_eci(const testCtx *const p_ctx) {
length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
ret_length = length;
ret = gb2312_utf8_to_eci(data[i].eci, (unsigned char *) data[i].data, &ret_length, gbdata, data[i].full_multibyte);
ret = zint_gb2312_utf8_to_eci(data[i].eci, (unsigned char *) data[i].data, &ret_length, gbdata,
data[i].full_multibyte);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
if (ret == 0) {
int j;
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %d != %d\n", i, ret_length, data[i].ret_length);
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %d != %d\n",
i, ret_length, data[i].ret_length);
for (j = 0; j < (int) ret_length; j++) {
assert_equal(gbdata[j], data[i].expected_gbdata[j], "i:%d gbdata[%d] 0x%04X != 0x%04X\n", i, j, gbdata[j], data[i].expected_gbdata[j]);
assert_equal(gbdata[j], data[i].expected_gbdata[j], "i:%d gbdata[%d] 0x%04X != 0x%04X\n",
i, j, gbdata[j], data[i].expected_gbdata[j]);
}
}
}
@@ -316,7 +323,7 @@ static void test_gb2312_utf8_to_eci(const testCtx *const p_ctx) {
testFinish();
}
INTERNAL void gb2312_cpy_test(const unsigned char source[], int *p_length, unsigned int *ddata,
INTERNAL void zint_test_gb2312_cpy(const unsigned char source[], int *p_length, unsigned int *ddata,
const int full_multibyte);
static void test_gb2312_cpy(const testCtx *const p_ctx) {
@@ -359,10 +366,11 @@ static void test_gb2312_cpy(const testCtx *const p_ctx) {
length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
ret_length = length;
gb2312_cpy_test((unsigned char *) data[i].data, &ret_length, gbdata, data[i].full_multibyte);
zint_test_gb2312_cpy((unsigned char *) data[i].data, &ret_length, gbdata, data[i].full_multibyte);
assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %d != %d\n", i, ret_length, data[i].ret_length);
for (j = 0; j < (int) ret_length; j++) {
assert_equal(gbdata[j], data[i].expected_gbdata[j], "i:%d gbdata[%d] %04X != %04X\n", i, j, gbdata[j], data[i].expected_gbdata[j]);
assert_equal(gbdata[j], data[i].expected_gbdata[j], "i:%d gbdata[%d] %04X != %04X\n",
i, j, gbdata[j], data[i].expected_gbdata[j]);
}
}
@@ -413,7 +421,9 @@ static void test_perf(const testCtx *const p_ctx) {
return;
}
for (i = 0; i < data_size; i++) if ((int) strlen(data[i].comment) > comment_max) comment_max = (int) strlen(data[i].comment);
for (i = 0; i < data_size; i++) {
if ((int) strlen(data[i].comment) > comment_max) comment_max = (int) strlen(data[i].comment);
}
printf("Iterations %d\n", TEST_PERF_ITERATIONS);
@@ -430,7 +440,7 @@ static void test_perf(const testCtx *const p_ctx) {
ret_length = length;
start = clock();
ret = gb2312_utf8(&symbol, (unsigned char *) data[i].data, &ret_length, ddata);
ret = zint_gb2312_utf8(&symbol, (unsigned char *) data[i].data, &ret_length, ddata);
diff += clock() - start;
#ifdef TEST_JUST_SAY_GNO
@@ -443,19 +453,20 @@ static void test_perf(const testCtx *const p_ctx) {
ret_length = length;
start = clock();
(void)utf8_to_eci(29, (unsigned char *) data[i].data, dest, &ret_length);
(void)zint_utf8_to_eci(29, (unsigned char *) data[i].data, dest, &ret_length);
diff_eci += clock() - start;
#ifdef TEST_JUST_SAY_GNO
ret_length2 = length;
start = clock();
(void)utf8_to_eci_wctomb(29, (unsigned char *) data[i].data, dest2, &ret_length2);
(void)zint_utf8_to_eci_wctomb(29, (unsigned char *) data[i].data, dest2, &ret_length2);
diff_eci_gno += clock() - start;
#endif
}
assert_equal(ret, ret2, "i:%d ret %d != ret2 %d\n", (int) i, ret, ret2);
printf("%*s: new % 8gms, gno % 8gms ratio % 9g | eci % 8gms, gno % 8gms ratio %g\n", comment_max, data[i].comment,
printf("%*s: new % 8gms, gno % 8gms ratio % 9g | eci % 8gms, gno % 8gms ratio %g\n",
comment_max, data[i].comment,
TEST_PERF_TIME(diff), TEST_PERF_TIME(diff_gno), TEST_PERF_RATIO(diff, diff_gno),
TEST_PERF_TIME(diff_eci), TEST_PERF_TIME(diff_eci_gno), TEST_PERF_RATIO(diff_eci, diff_eci_gno));