1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-05-14 18:13:53 +00:00

general: raw_segs -> content_segs, BARCODE_RAW_TEXT ->

`BARCODE_CONTENT_SEGS`, `z_rt_XXX()` -> `z_ct_XXX()`;
  move `encoded_data`/`row_height` to end of `zint_symbol`
  (see ZXing-C++ issue #883)
manual: update re `content_segs`; `my_symbol` -> `symbol`;
  improve MicroPDF417 description
This commit is contained in:
gitlost
2025-11-04 23:02:10 +00:00
parent 543696cb06
commit f0c7248b62
82 changed files with 2203 additions and 2187 deletions

View File

@@ -113,91 +113,91 @@ static void test_hrt(const testCtx *const p_ctx) {
const char *data;
const char *expected;
const char *expected_raw;
const char *expected_content;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { BARCODE_MSI_PLESSEY, -1, -1, "1234567", "1234567", "" },
/* 1*/ { BARCODE_MSI_PLESSEY, -1, BARCODE_RAW_TEXT, "1234567", "1234567", "1234567" },
/* 1*/ { BARCODE_MSI_PLESSEY, -1, BARCODE_CONTENT_SEGS, "1234567", "1234567", "1234567" },
/* 2*/ { BARCODE_MSI_PLESSEY, 0, -1, "1234567", "1234567", "" },
/* 3*/ { BARCODE_MSI_PLESSEY, 0, BARCODE_RAW_TEXT, "1234567", "1234567", "1234567" },
/* 3*/ { BARCODE_MSI_PLESSEY, 0, BARCODE_CONTENT_SEGS, "1234567", "1234567", "1234567" },
/* 4*/ { BARCODE_MSI_PLESSEY, 1, -1, "1234567", "12345674", "" },
/* 5*/ { BARCODE_MSI_PLESSEY, 1, BARCODE_RAW_TEXT, "1234567", "12345674", "12345674" },
/* 5*/ { BARCODE_MSI_PLESSEY, 1, BARCODE_CONTENT_SEGS, "1234567", "12345674", "12345674" },
/* 6*/ { BARCODE_MSI_PLESSEY, 1 + 10, -1, "1234567", "1234567", "" },
/* 7*/ { BARCODE_MSI_PLESSEY, 1 + 10, BARCODE_RAW_TEXT, "1234567", "1234567", "12345674" },
/* 7*/ { BARCODE_MSI_PLESSEY, 1 + 10, BARCODE_CONTENT_SEGS, "1234567", "1234567", "12345674" },
/* 8*/ { BARCODE_MSI_PLESSEY, 1, -1, "9999999999", "99999999990", "" },
/* 9*/ { BARCODE_MSI_PLESSEY, 1, BARCODE_RAW_TEXT, "9999999999", "99999999990", "99999999990" },
/* 9*/ { BARCODE_MSI_PLESSEY, 1, BARCODE_CONTENT_SEGS, "9999999999", "99999999990", "99999999990" },
/* 10*/ { BARCODE_MSI_PLESSEY, 2, -1, "1234567", "123456741", "" },
/* 11*/ { BARCODE_MSI_PLESSEY, 2, BARCODE_RAW_TEXT, "1234567", "123456741", "123456741" },
/* 11*/ { BARCODE_MSI_PLESSEY, 2, BARCODE_CONTENT_SEGS, "1234567", "123456741", "123456741" },
/* 12*/ { BARCODE_MSI_PLESSEY, 2 + 10, -1, "1234567", "1234567", "" },
/* 13*/ { BARCODE_MSI_PLESSEY, 2 + 10, BARCODE_RAW_TEXT, "1234567", "1234567", "123456741" },
/* 13*/ { BARCODE_MSI_PLESSEY, 2 + 10, BARCODE_CONTENT_SEGS, "1234567", "1234567", "123456741" },
/* 14*/ { BARCODE_MSI_PLESSEY, 2, -1, "9999999999", "999999999900", "" },
/* 15*/ { BARCODE_MSI_PLESSEY, 2, BARCODE_RAW_TEXT, "9999999999", "999999999900", "999999999900" },
/* 15*/ { BARCODE_MSI_PLESSEY, 2, BARCODE_CONTENT_SEGS, "9999999999", "999999999900", "999999999900" },
/* 16*/ { BARCODE_MSI_PLESSEY, 3, -1, "1234567", "12345674", "" },
/* 17*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_RAW_TEXT, "1234567", "12345674", "12345674" },
/* 17*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_CONTENT_SEGS, "1234567", "12345674", "12345674" },
/* 18*/ { BARCODE_MSI_PLESSEY, 3 + 10, -1, "1234567", "1234567", "" },
/* 19*/ { BARCODE_MSI_PLESSEY, 3 + 10, BARCODE_RAW_TEXT, "1234567", "1234567", "12345674" },
/* 19*/ { BARCODE_MSI_PLESSEY, 3 + 10, BARCODE_CONTENT_SEGS, "1234567", "1234567", "12345674" },
/* 20*/ { BARCODE_MSI_PLESSEY, 3, -1, "9999999999", "99999999995", "" },
/* 21*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_RAW_TEXT, "9999999999", "99999999995", "99999999995" },
/* 21*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_CONTENT_SEGS, "9999999999", "99999999995", "99999999995" },
/* 22*/ { BARCODE_MSI_PLESSEY, 4, -1, "1234567", "123456741", "" },
/* 23*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_RAW_TEXT, "1234567", "123456741", "123456741" },
/* 23*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_CONTENT_SEGS, "1234567", "123456741", "123456741" },
/* 24*/ { BARCODE_MSI_PLESSEY, 4 + 10, -1, "1234567", "1234567", "" },
/* 25*/ { BARCODE_MSI_PLESSEY, 4 + 10, BARCODE_RAW_TEXT, "1234567", "1234567", "123456741" },
/* 25*/ { BARCODE_MSI_PLESSEY, 4 + 10, BARCODE_CONTENT_SEGS, "1234567", "1234567", "123456741" },
/* 26*/ { BARCODE_MSI_PLESSEY, 4, -1, "9999999999", "999999999959", "" },
/* 27*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_RAW_TEXT, "9999999999", "999999999959", "999999999959" },
/* 27*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_CONTENT_SEGS, "9999999999", "999999999959", "999999999959" },
/* 28*/ { BARCODE_MSI_PLESSEY, 5, -1, "1234567", "12345679", "" },
/* 29*/ { BARCODE_MSI_PLESSEY, 5, BARCODE_RAW_TEXT, "1234567", "12345679", "12345679" },
/* 29*/ { BARCODE_MSI_PLESSEY, 5, BARCODE_CONTENT_SEGS, "1234567", "12345679", "12345679" },
/* 30*/ { BARCODE_MSI_PLESSEY, 5 + 10, -1, "1234567", "1234567", "" },
/* 31*/ { BARCODE_MSI_PLESSEY, 5 + 10, BARCODE_RAW_TEXT, "1234567", "1234567", "12345679" },
/* 31*/ { BARCODE_MSI_PLESSEY, 5 + 10, BARCODE_CONTENT_SEGS, "1234567", "1234567", "12345679" },
/* 32*/ { BARCODE_MSI_PLESSEY, 5, -1, "9999999999", "999999999910", "" },
/* 33*/ { BARCODE_MSI_PLESSEY, 5, BARCODE_RAW_TEXT, "9999999999", "999999999910", "999999999910" },
/* 33*/ { BARCODE_MSI_PLESSEY, 5, BARCODE_CONTENT_SEGS, "9999999999", "999999999910", "999999999910" },
/* 34*/ { BARCODE_MSI_PLESSEY, 6, -1, "1234567", "123456790", "" },
/* 35*/ { BARCODE_MSI_PLESSEY, 6, BARCODE_RAW_TEXT, "1234567", "123456790", "123456790" },
/* 35*/ { BARCODE_MSI_PLESSEY, 6, BARCODE_CONTENT_SEGS, "1234567", "123456790", "123456790" },
/* 36*/ { BARCODE_MSI_PLESSEY, 6 + 10, -1, "1234567", "1234567", "" },
/* 37*/ { BARCODE_MSI_PLESSEY, 6 + 10, BARCODE_RAW_TEXT, "1234567", "1234567", "123456790" },
/* 37*/ { BARCODE_MSI_PLESSEY, 6 + 10, BARCODE_CONTENT_SEGS, "1234567", "1234567", "123456790" },
/* 38*/ { BARCODE_MSI_PLESSEY, 6, -1, "9999999999", "9999999999109", "" },
/* 39*/ { BARCODE_MSI_PLESSEY, 6, BARCODE_RAW_TEXT, "9999999999", "9999999999109", "9999999999109" },
/* 39*/ { BARCODE_MSI_PLESSEY, 6, BARCODE_CONTENT_SEGS, "9999999999", "9999999999109", "9999999999109" },
/* 40*/ { BARCODE_MSI_PLESSEY, 1, -1, "123456", "1234566", "" },
/* 41*/ { BARCODE_MSI_PLESSEY, 1, BARCODE_RAW_TEXT, "123456", "1234566", "1234566" },
/* 41*/ { BARCODE_MSI_PLESSEY, 1, BARCODE_CONTENT_SEGS, "123456", "1234566", "1234566" },
/* 42*/ { BARCODE_MSI_PLESSEY, 2, -1, "123456", "12345666", "" },
/* 43*/ { BARCODE_MSI_PLESSEY, 2, BARCODE_RAW_TEXT, "123456", "12345666", "12345666" },
/* 43*/ { BARCODE_MSI_PLESSEY, 2, BARCODE_CONTENT_SEGS, "123456", "12345666", "12345666" },
/* 44*/ { BARCODE_MSI_PLESSEY, 3, -1, "123456", "1234560", "" },
/* 45*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_RAW_TEXT, "123456", "1234560", "1234560" },
/* 45*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_CONTENT_SEGS, "123456", "1234560", "1234560" },
/* 46*/ { BARCODE_MSI_PLESSEY, 4, -1, "123456", "12345609", "" },
/* 47*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_RAW_TEXT, "123456", "12345609", "12345609" },
/* 47*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_CONTENT_SEGS, "123456", "12345609", "12345609" },
/* 48*/ { BARCODE_MSI_PLESSEY, 3, -1, "2211", "221110", "" }, /* Mod-11 check digit '10' */
/* 49*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_RAW_TEXT, "2211", "221110", "221110" },
/* 49*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_CONTENT_SEGS, "2211", "221110", "221110" },
/* 50*/ { BARCODE_MSI_PLESSEY, 3 + 10, -1, "2211", "2211", "" }, /* Mod-11 check digit '10' */
/* 51*/ { BARCODE_MSI_PLESSEY, 3 + 10, BARCODE_RAW_TEXT, "2211", "2211", "221110" },
/* 51*/ { BARCODE_MSI_PLESSEY, 3 + 10, BARCODE_CONTENT_SEGS, "2211", "2211", "221110" },
/* 52*/ { BARCODE_MSI_PLESSEY, 4, -1, "2211", "2211100", "" },
/* 53*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_RAW_TEXT, "2211", "2211100", "2211100" },
/* 53*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_CONTENT_SEGS, "2211", "2211100", "2211100" },
/* 54*/ { BARCODE_MSI_PLESSEY, 4 + 10, -1, "2211", "2211", "" },
/* 55*/ { BARCODE_MSI_PLESSEY, 4 + 10, BARCODE_RAW_TEXT, "2211", "2211", "2211100" },
/* 55*/ { BARCODE_MSI_PLESSEY, 4 + 10, BARCODE_CONTENT_SEGS, "2211", "2211", "2211100" },
/* 56*/ { BARCODE_PLESSEY, -1, -1, "0123456789ABCDEF", "0123456789ABCDEF", "" },
/* 57*/ { BARCODE_PLESSEY, -1, BARCODE_RAW_TEXT, "0123456789ABCDEF", "0123456789ABCDEF", "0123456789ABCDEF90" },
/* 57*/ { BARCODE_PLESSEY, -1, BARCODE_CONTENT_SEGS, "0123456789ABCDEF", "0123456789ABCDEF", "0123456789ABCDEF90" },
/* 58*/ { BARCODE_PLESSEY, 1, -1, "0123456789ABCDEF", "0123456789ABCDEF90", "" },
/* 59*/ { BARCODE_PLESSEY, 1, BARCODE_RAW_TEXT, "0123456789ABCDEF", "0123456789ABCDEF90", "0123456789ABCDEF90" },
/* 59*/ { BARCODE_PLESSEY, 1, BARCODE_CONTENT_SEGS, "0123456789ABCDEF", "0123456789ABCDEF90", "0123456789ABCDEF90" },
/* 60*/ { BARCODE_PLESSEY, -1, -1, "1", "1", "" },
/* 61*/ { BARCODE_PLESSEY, -1, BARCODE_RAW_TEXT, "1", "1", "173" },
/* 61*/ { BARCODE_PLESSEY, -1, BARCODE_CONTENT_SEGS, "1", "1", "173" },
/* 62*/ { BARCODE_PLESSEY, 1, -1, "1", "173", "" },
/* 63*/ { BARCODE_PLESSEY, 1, BARCODE_RAW_TEXT, "1", "173", "173" },
/* 63*/ { BARCODE_PLESSEY, 1, BARCODE_CONTENT_SEGS, "1", "173", "173" },
/* 64*/ { BARCODE_PLESSEY, -1, -1, "7", "7", "" },
/* 65*/ { BARCODE_PLESSEY, -1, BARCODE_RAW_TEXT, "7", "7", "758" },
/* 65*/ { BARCODE_PLESSEY, -1, BARCODE_CONTENT_SEGS, "7", "7", "758" },
/* 66*/ { BARCODE_PLESSEY, 1, -1, "7", "758", "" },
/* 67*/ { BARCODE_PLESSEY, 1, BARCODE_RAW_TEXT, "7", "758", "758" },
/* 67*/ { BARCODE_PLESSEY, 1, BARCODE_CONTENT_SEGS, "7", "758", "758" },
/* 68*/ { BARCODE_PLESSEY, -1, -1, "75", "75", "" },
/* 69*/ { BARCODE_PLESSEY, -1, BARCODE_RAW_TEXT, "75", "75", "7580" },
/* 69*/ { BARCODE_PLESSEY, -1, BARCODE_CONTENT_SEGS, "75", "75", "7580" },
/* 70*/ { BARCODE_PLESSEY, 1, -1, "75", "7580", "" },
/* 71*/ { BARCODE_PLESSEY, 1, BARCODE_RAW_TEXT, "75", "7580", "7580" },
/* 71*/ { BARCODE_PLESSEY, 1, BARCODE_CONTENT_SEGS, "75", "7580", "7580" },
/* 72*/ { BARCODE_PLESSEY, -1, -1, "993", "993", "" },
/* 73*/ { BARCODE_PLESSEY, -1, BARCODE_RAW_TEXT, "993", "993", "993AA" },
/* 73*/ { BARCODE_PLESSEY, -1, BARCODE_CONTENT_SEGS, "993", "993", "993AA" },
/* 74*/ { BARCODE_PLESSEY, 1, -1, "993", "993AA", "" },
/* 75*/ { BARCODE_PLESSEY, 1, BARCODE_RAW_TEXT, "993", "993AA", "993AA" },
/* 75*/ { BARCODE_PLESSEY, 1, BARCODE_CONTENT_SEGS, "993", "993AA", "993AA" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int expected_length, expected_raw_length;
int expected_length, expected_content_length;
testStartSymbol(p_ctx->func_name, &symbol);
@@ -212,7 +212,7 @@ static void test_hrt(const testCtx *const p_ctx) {
-1 /*option_1*/, data[i].option_2, -1, data[i].output_options,
data[i].data, -1, debug);
expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
expected_content_length = (int) strlen(data[i].expected_content);
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
@@ -221,18 +221,18 @@ static void test_hrt(const testCtx *const p_ctx) {
i, symbol->text_length, expected_length);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
if (symbol->output_options & BARCODE_CONTENT_SEGS) {
assert_nonnull(symbol->content_segs, "i:%d content_segs NULL\n", i);
assert_nonnull(symbol->content_segs[0].source, "i:%d content_segs[0].source NULL\n", i);
assert_equal(symbol->content_segs[0].length, expected_content_length,
"i:%d content_segs[0].length %d != expected_content_length %d\n",
i, symbol->content_segs[0].length, expected_content_length);
assert_zero(memcmp(symbol->content_segs[0].source, data[i].expected_content, expected_content_length),
"i:%d memcmp(%.*s, %s, %d) != 0\n",
i, symbol->raw_segs[0].length, symbol->raw_segs[0].source, data[i].expected_raw,
expected_raw_length);
i, symbol->content_segs[0].length, symbol->content_segs[0].source, data[i].expected_content,
expected_content_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
assert_null(symbol->content_segs, "i:%d content_segs not NULL\n", i);
}
ZBarcode_Delete(symbol);