mirror of
https://git.code.sf.net/p/zint/code
synced 2026-09-14 00:08:53 +00:00
CODABAR: fix position of invalid internal char in error message;
allow for checksum being wide char
This commit is contained in:
+3
-4
@@ -85,7 +85,7 @@ INTERNAL int zint_codabar(struct zint_symbol *symbol, unsigned char source[], in
|
||||
/* And must not use A, B, C or D otherwise (BS EN 798:1995 4.3.2) */
|
||||
if ((i = z_not_sane(CALCIUM_INNER_F, source + 1, length - 2))) {
|
||||
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 363,
|
||||
"Invalid character at position %d in input (cannot contain \"A\", \"B\", \"C\" or \"D\")", i);
|
||||
"Invalid character at position %d in input (cannot contain \"A\", \"B\", \"C\" or \"D\")", i + 1);
|
||||
}
|
||||
|
||||
/* Add check character: 1 don't show to HRT, 2 do show to HRT
|
||||
@@ -107,12 +107,11 @@ INTERNAL int zint_codabar(struct zint_symbol *symbol, unsigned char source[], in
|
||||
}
|
||||
memcpy(d, CodaTable[checksum], 8);
|
||||
d += 8;
|
||||
d_chars += checksum >= 12; /* Wide data char */
|
||||
}
|
||||
}
|
||||
memcpy(d, CodaTable[posns[i]], 8);
|
||||
if (source[i] == '/' || source[i] == ':' || source[i] == '.' || source[i] == '+') { /* Wide data characters */
|
||||
d_chars++;
|
||||
}
|
||||
d_chars += posns[i] >= 12 && posns[i] <= 15; /* Wide data chars ":/.+" */
|
||||
}
|
||||
|
||||
z_expand(symbol, dest, (int) (d - dest));
|
||||
|
||||
@@ -182,7 +182,7 @@ static void test_input(const testCtx *const p_ctx) {
|
||||
/* 4*/ { BARCODE_CODABAR, "C123.D", 0, 1, 63, "", 1, "" },
|
||||
/* 5*/ { BARCODE_CODABAR, "C123,D", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 357: Invalid character at position 5 in input (\"0123456789-$:/.+ABCD\" only)", 1, "" },
|
||||
/* 6*/ { BARCODE_CODABAR, "D:C", 0, 1, 33, "", 1, "" },
|
||||
/* 7*/ { BARCODE_CODABAR, "DCC", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 363: Invalid character at position 1 in input (cannot contain \"A\", \"B\", \"C\" or \"D\")", 1, "" },
|
||||
/* 7*/ { BARCODE_CODABAR, "DCC", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 363: Invalid character at position 2 in input (cannot contain \"A\", \"B\", \"C\" or \"D\")", 1, "" },
|
||||
/* 8*/ { BARCODE_CODABAR, "A234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123B", ZINT_ERROR_TOO_LONG, -1, -1, "Error 356: Input length 104 too long (maximum 103)", 1, "" },
|
||||
/* 9*/ { BARCODE_CODABAR, "AB", ZINT_ERROR_TOO_LONG, -1, -1, "Error 362: Input length 2 too short (minimum 3)", 1, "" },
|
||||
};
|
||||
|
||||
+595
-592
File diff suppressed because it is too large
Load Diff
+596
-592
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user