mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
UPCE/UPCE_CC: allow check digit (same as UPCA/UPCA_CC) so selecting composite doesn't give error
composite.c: warning wasn't been passed back zint.h/library.c: add const to char pointer args; move func defs around a bit
This commit is contained in:
parent
58420f3dde
commit
7cc2095d3c
@ -1266,6 +1266,8 @@ static int linear_dummy_run(int input_mode, unsigned char *source, const int len
|
|||||||
return linear_width;
|
return linear_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char in_linear_comp[] = " in linear component";
|
||||||
|
|
||||||
INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int length) {
|
INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||||
int error_number, warn_number = 0, cc_mode, cc_width = 0, ecc_level = 0;
|
int error_number, warn_number = 0, cc_mode, cc_width = 0, ecc_level = 0;
|
||||||
int j, i, k;
|
int j, i, k;
|
||||||
@ -1305,7 +1307,9 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
|
|||||||
linear_width = linear_dummy_run(symbol->input_mode, (unsigned char *) symbol->primary, pri_len,
|
linear_width = linear_dummy_run(symbol->input_mode, (unsigned char *) symbol->primary, pri_len,
|
||||||
symbol->errtxt);
|
symbol->errtxt);
|
||||||
if (linear_width == 0) {
|
if (linear_width == 0) {
|
||||||
strcat(symbol->errtxt, " in linear component");
|
if (strlen(symbol->errtxt) + strlen(in_linear_comp) < sizeof(symbol->errtxt)) {
|
||||||
|
strcat(symbol->errtxt, in_linear_comp);
|
||||||
|
}
|
||||||
return ZINT_ERROR_INVALID_DATA;
|
return ZINT_ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||||
@ -1464,12 +1468,16 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error_number >= ZINT_ERROR) {
|
if (error_number) {
|
||||||
strcpy(symbol->errtxt, linear->errtxt);
|
strcpy(symbol->errtxt, linear->errtxt);
|
||||||
strcat(symbol->errtxt, " in linear component");
|
if (strlen(symbol->errtxt) + strlen(in_linear_comp) < sizeof(symbol->errtxt)) {
|
||||||
|
strcat(symbol->errtxt, in_linear_comp);
|
||||||
|
}
|
||||||
|
if (error_number >= ZINT_ERROR) {
|
||||||
ZBarcode_Delete(linear);
|
ZBarcode_Delete(linear);
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Merge the linear component with the 2D component */
|
/* Merge the linear component with the 2D component */
|
||||||
|
|
||||||
|
@ -537,111 +537,6 @@ static int has_hrt(const int symbology) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the capability flags for symbology `symbol_id` that match `cap_flag` */
|
|
||||||
unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag) {
|
|
||||||
unsigned int result = 0;
|
|
||||||
|
|
||||||
if (!ZBarcode_ValidID(symbol_id)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((cap_flag & ZINT_CAP_HRT) && has_hrt(symbol_id)) {
|
|
||||||
result |= ZINT_CAP_HRT;
|
|
||||||
}
|
|
||||||
if ((cap_flag & ZINT_CAP_STACKABLE) && is_stackable(symbol_id)) {
|
|
||||||
result |= ZINT_CAP_STACKABLE;
|
|
||||||
}
|
|
||||||
if ((cap_flag & ZINT_CAP_EXTENDABLE) && is_extendable(symbol_id)) {
|
|
||||||
result |= ZINT_CAP_EXTENDABLE;
|
|
||||||
}
|
|
||||||
if ((cap_flag & ZINT_CAP_COMPOSITE) && is_composite(symbol_id)) {
|
|
||||||
result |= ZINT_CAP_COMPOSITE;
|
|
||||||
}
|
|
||||||
if ((cap_flag & ZINT_CAP_ECI) && supports_eci(symbol_id)) {
|
|
||||||
result |= ZINT_CAP_ECI;
|
|
||||||
}
|
|
||||||
if ((cap_flag & ZINT_CAP_GS1) && gs1_compliant(symbol_id)) {
|
|
||||||
result |= ZINT_CAP_GS1;
|
|
||||||
}
|
|
||||||
if ((cap_flag & ZINT_CAP_DOTTY) && is_dotty(symbol_id)) {
|
|
||||||
result |= ZINT_CAP_DOTTY;
|
|
||||||
}
|
|
||||||
if ((cap_flag & ZINT_CAP_FIXED_RATIO) && is_fixed_ratio(symbol_id)) {
|
|
||||||
result |= ZINT_CAP_FIXED_RATIO;
|
|
||||||
}
|
|
||||||
if (cap_flag & ZINT_CAP_READER_INIT) {
|
|
||||||
/* Note does not include HIBC versions */
|
|
||||||
switch (symbol_id) {
|
|
||||||
case BARCODE_CODE128: /* Note does not include GS1_128 or NVE18 */
|
|
||||||
case BARCODE_CODE128B:
|
|
||||||
case BARCODE_CODE16K:
|
|
||||||
case BARCODE_CODABLOCKF:
|
|
||||||
case BARCODE_PDF417:
|
|
||||||
case BARCODE_PDF417COMP:
|
|
||||||
case BARCODE_DATAMATRIX:
|
|
||||||
case BARCODE_MICROPDF417:
|
|
||||||
case BARCODE_AZTEC:
|
|
||||||
case BARCODE_DOTCODE:
|
|
||||||
case BARCODE_GRIDMATRIX:
|
|
||||||
case BARCODE_ULTRA:
|
|
||||||
result |= ZINT_CAP_READER_INIT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (cap_flag & ZINT_CAP_FULL_MULTIBYTE) {
|
|
||||||
switch (symbol_id) {
|
|
||||||
case BARCODE_QRCODE:
|
|
||||||
case BARCODE_MICROQR:
|
|
||||||
//case BARCODE_HIBC_QR: Note character set restricted to ASCII subset
|
|
||||||
//case BARCODE_UPNQR: Note does not use Kanji mode
|
|
||||||
case BARCODE_RMQR:
|
|
||||||
case BARCODE_HANXIN:
|
|
||||||
case BARCODE_GRIDMATRIX:
|
|
||||||
result |= ZINT_CAP_FULL_MULTIBYTE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (cap_flag & ZINT_CAP_MASK) {
|
|
||||||
switch (symbol_id) {
|
|
||||||
case BARCODE_QRCODE:
|
|
||||||
case BARCODE_MICROQR:
|
|
||||||
case BARCODE_HANXIN:
|
|
||||||
case BARCODE_DOTCODE:
|
|
||||||
result |= ZINT_CAP_MASK;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ZBarcode_ValidID(int symbol_id) {
|
|
||||||
/* Checks whether a symbology is supported */
|
|
||||||
static const unsigned char ids[146] = {
|
|
||||||
0, 1, 2, 3, 4, 0, 6, 7, 8, 9,
|
|
||||||
0, 0, 0, 13, 14, 0, 16, 0, 18, 0,
|
|
||||||
20, 21, 22, 23, 24, 25, 0, 0, 28, 29,
|
|
||||||
30, 31, 32, 0, 34, 35, 0, 37, 38, 0,
|
|
||||||
40, 0, 0, 0, 0, 0, 0, 47, 0, 49,
|
|
||||||
50, 51, 52, 53, 0, 55, 56, 57, 58, 0,
|
|
||||||
60, 0, 0, 63, 0, 0, 66, 67, 68, 69,
|
|
||||||
70, 71, 72, 73, 74, 75, 76, 77, 0, 79,
|
|
||||||
80, 81, 82, 0, 84, 85, 86, 87, 0, 89,
|
|
||||||
90, 0, 92, 93, 0, 0, 96, 97, 98, 99,
|
|
||||||
0, 0, 102, 0, 104, 0, 106, 0, 108, 0,
|
|
||||||
110, 0, 112, 0, 0, 115, 116, 0, 0, 0,
|
|
||||||
0, 121, 0, 0, 0, 0, 0, 0, 128, 129,
|
|
||||||
130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
|
|
||||||
140, 141, 142, 143, 144, 145,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (symbol_id <= 0 || symbol_id > 145) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ids[symbol_id] != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, int length);
|
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, int length);
|
||||||
|
|
||||||
static int extended_or_reduced_charset(struct zint_symbol *symbol, unsigned char *source, const int length) {
|
static int extended_or_reduced_charset(struct zint_symbol *symbol, unsigned char *source, const int length) {
|
||||||
@ -1198,8 +1093,9 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
|
|||||||
#endif
|
#endif
|
||||||
error_number = gs1_verify(symbol, local_source, length, reduced);
|
error_number = gs1_verify(symbol, local_source, length, reduced);
|
||||||
if (error_number) {
|
if (error_number) {
|
||||||
const char in_2d_comp[] = " in 2D component";
|
static const char in_2d_comp[] = " in 2D component";
|
||||||
if (is_composite(symbol->symbology) && strlen(symbol->errtxt) < 100 - strlen(in_2d_comp)) {
|
if (is_composite(symbol->symbology)
|
||||||
|
&& strlen(symbol->errtxt) + strlen(in_2d_comp) < sizeof(symbol->errtxt)) {
|
||||||
strcat(symbol->errtxt, in_2d_comp);
|
strcat(symbol->errtxt, in_2d_comp);
|
||||||
}
|
}
|
||||||
error_number = error_tag(symbol, error_number, NULL);
|
error_number = error_tag(symbol, error_number, NULL);
|
||||||
@ -1320,6 +1216,7 @@ int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle) {
|
|||||||
return error_tag(symbol, error_number, NULL);
|
return error_tag(symbol, error_number, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Output a previously encoded symbol to memory as raster (`symbol->bitmap`) */
|
||||||
int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle) {
|
int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle) {
|
||||||
int error_number;
|
int error_number;
|
||||||
|
|
||||||
@ -1346,6 +1243,7 @@ int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle) {
|
|||||||
return error_tag(symbol, error_number, NULL);
|
return error_tag(symbol, error_number, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Output a previously encoded symbol to memory as vector (`symbol->vector`) */
|
||||||
int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle) {
|
int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle) {
|
||||||
int error_number;
|
int error_number;
|
||||||
|
|
||||||
@ -1373,7 +1271,7 @@ int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Encode and output a symbol to file `symbol->outfile` */
|
/* Encode and output a symbol to file `symbol->outfile` */
|
||||||
int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *source, int length, int rotate_angle) {
|
int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, const unsigned char *source, int length, int rotate_angle) {
|
||||||
int error_number;
|
int error_number;
|
||||||
int first_err;
|
int first_err;
|
||||||
|
|
||||||
@ -1390,7 +1288,9 @@ int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *source,
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *source, int length, int rotate_angle) {
|
/* Encode and output a symbol to memory as raster (`symbol->bitmap`) */
|
||||||
|
int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, const unsigned char *source, int length,
|
||||||
|
int rotate_angle) {
|
||||||
int error_number;
|
int error_number;
|
||||||
int first_err;
|
int first_err;
|
||||||
|
|
||||||
@ -1408,7 +1308,8 @@ int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *source
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol, unsigned char *source, int length,
|
/* Encode and output a symbol to memory as vector (`symbol->vector`) */
|
||||||
|
int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol, const unsigned char *source, int length,
|
||||||
int rotate_angle) {
|
int rotate_angle) {
|
||||||
int error_number;
|
int error_number;
|
||||||
int first_err;
|
int first_err;
|
||||||
@ -1428,7 +1329,7 @@ int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol, unsigned char
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Encode a barcode using input data from file `filename` */
|
/* Encode a barcode using input data from file `filename` */
|
||||||
int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename) {
|
int ZBarcode_Encode_File(struct zint_symbol *symbol, const char *filename) {
|
||||||
FILE *file;
|
FILE *file;
|
||||||
int file_opened = 0;
|
int file_opened = 0;
|
||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
@ -1503,7 +1404,7 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Encode a symbol using input data from file `filename` and output to file `symbol->outfile` */
|
/* Encode a symbol using input data from file `filename` and output to file `symbol->outfile` */
|
||||||
int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename, int rotate_angle) {
|
int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, const char *filename, int rotate_angle) {
|
||||||
int error_number;
|
int error_number;
|
||||||
int first_err;
|
int first_err;
|
||||||
|
|
||||||
@ -1522,7 +1423,7 @@ int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Encode a symbol using input data from file `filename` and output to memory as raster (`symbol->bitmap`) */
|
/* Encode a symbol using input data from file `filename` and output to memory as raster (`symbol->bitmap`) */
|
||||||
int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char *filename, int rotate_angle) {
|
int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char const *filename, int rotate_angle) {
|
||||||
int error_number;
|
int error_number;
|
||||||
int first_err;
|
int first_err;
|
||||||
|
|
||||||
@ -1541,7 +1442,7 @@ int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char *filename,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Encode a symbol using input data from file `filename` and output to memory as vector (`symbol->vector`) */
|
/* Encode a symbol using input data from file `filename` and output to memory as vector (`symbol->vector`) */
|
||||||
int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol, char *filename, int rotate_angle) {
|
int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol, const char *filename, int rotate_angle) {
|
||||||
int error_number;
|
int error_number;
|
||||||
int first_err;
|
int first_err;
|
||||||
|
|
||||||
@ -1559,6 +1460,111 @@ int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol, char *fil
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ZBarcode_ValidID(int symbol_id) {
|
||||||
|
/* Checks whether a symbology is supported */
|
||||||
|
static const unsigned char ids[146] = {
|
||||||
|
0, 1, 2, 3, 4, 0, 6, 7, 8, 9,
|
||||||
|
0, 0, 0, 13, 14, 0, 16, 0, 18, 0,
|
||||||
|
20, 21, 22, 23, 24, 25, 0, 0, 28, 29,
|
||||||
|
30, 31, 32, 0, 34, 35, 0, 37, 38, 0,
|
||||||
|
40, 0, 0, 0, 0, 0, 0, 47, 0, 49,
|
||||||
|
50, 51, 52, 53, 0, 55, 56, 57, 58, 0,
|
||||||
|
60, 0, 0, 63, 0, 0, 66, 67, 68, 69,
|
||||||
|
70, 71, 72, 73, 74, 75, 76, 77, 0, 79,
|
||||||
|
80, 81, 82, 0, 84, 85, 86, 87, 0, 89,
|
||||||
|
90, 0, 92, 93, 0, 0, 96, 97, 98, 99,
|
||||||
|
0, 0, 102, 0, 104, 0, 106, 0, 108, 0,
|
||||||
|
110, 0, 112, 0, 0, 115, 116, 0, 0, 0,
|
||||||
|
0, 121, 0, 0, 0, 0, 0, 0, 128, 129,
|
||||||
|
130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
|
||||||
|
140, 141, 142, 143, 144, 145,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (symbol_id <= 0 || symbol_id > 145) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ids[symbol_id] != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the capability flags for symbology `symbol_id` that match `cap_flag` */
|
||||||
|
unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag) {
|
||||||
|
unsigned int result = 0;
|
||||||
|
|
||||||
|
if (!ZBarcode_ValidID(symbol_id)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((cap_flag & ZINT_CAP_HRT) && has_hrt(symbol_id)) {
|
||||||
|
result |= ZINT_CAP_HRT;
|
||||||
|
}
|
||||||
|
if ((cap_flag & ZINT_CAP_STACKABLE) && is_stackable(symbol_id)) {
|
||||||
|
result |= ZINT_CAP_STACKABLE;
|
||||||
|
}
|
||||||
|
if ((cap_flag & ZINT_CAP_EXTENDABLE) && is_extendable(symbol_id)) {
|
||||||
|
result |= ZINT_CAP_EXTENDABLE;
|
||||||
|
}
|
||||||
|
if ((cap_flag & ZINT_CAP_COMPOSITE) && is_composite(symbol_id)) {
|
||||||
|
result |= ZINT_CAP_COMPOSITE;
|
||||||
|
}
|
||||||
|
if ((cap_flag & ZINT_CAP_ECI) && supports_eci(symbol_id)) {
|
||||||
|
result |= ZINT_CAP_ECI;
|
||||||
|
}
|
||||||
|
if ((cap_flag & ZINT_CAP_GS1) && gs1_compliant(symbol_id)) {
|
||||||
|
result |= ZINT_CAP_GS1;
|
||||||
|
}
|
||||||
|
if ((cap_flag & ZINT_CAP_DOTTY) && is_dotty(symbol_id)) {
|
||||||
|
result |= ZINT_CAP_DOTTY;
|
||||||
|
}
|
||||||
|
if ((cap_flag & ZINT_CAP_FIXED_RATIO) && is_fixed_ratio(symbol_id)) {
|
||||||
|
result |= ZINT_CAP_FIXED_RATIO;
|
||||||
|
}
|
||||||
|
if (cap_flag & ZINT_CAP_READER_INIT) {
|
||||||
|
/* Note does not include HIBC versions */
|
||||||
|
switch (symbol_id) {
|
||||||
|
case BARCODE_CODE128: /* Note does not include GS1_128 or NVE18 */
|
||||||
|
case BARCODE_CODE128B:
|
||||||
|
case BARCODE_CODE16K:
|
||||||
|
case BARCODE_CODABLOCKF:
|
||||||
|
case BARCODE_PDF417:
|
||||||
|
case BARCODE_PDF417COMP:
|
||||||
|
case BARCODE_DATAMATRIX:
|
||||||
|
case BARCODE_MICROPDF417:
|
||||||
|
case BARCODE_AZTEC:
|
||||||
|
case BARCODE_DOTCODE:
|
||||||
|
case BARCODE_GRIDMATRIX:
|
||||||
|
case BARCODE_ULTRA:
|
||||||
|
result |= ZINT_CAP_READER_INIT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cap_flag & ZINT_CAP_FULL_MULTIBYTE) {
|
||||||
|
switch (symbol_id) {
|
||||||
|
case BARCODE_QRCODE:
|
||||||
|
case BARCODE_MICROQR:
|
||||||
|
//case BARCODE_HIBC_QR: Note character set restricted to ASCII subset
|
||||||
|
//case BARCODE_UPNQR: Note does not use Kanji mode
|
||||||
|
case BARCODE_RMQR:
|
||||||
|
case BARCODE_HANXIN:
|
||||||
|
case BARCODE_GRIDMATRIX:
|
||||||
|
result |= ZINT_CAP_FULL_MULTIBYTE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cap_flag & ZINT_CAP_MASK) {
|
||||||
|
switch (symbol_id) {
|
||||||
|
case BARCODE_QRCODE:
|
||||||
|
case BARCODE_MICROQR:
|
||||||
|
case BARCODE_HANXIN:
|
||||||
|
case BARCODE_DOTCODE:
|
||||||
|
result |= ZINT_CAP_MASK;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/* Return the version of Zint linked to */
|
/* Return the version of Zint linked to */
|
||||||
int ZBarcode_Version() {
|
int ZBarcode_Version() {
|
||||||
if (ZINT_VERSION_BUILD) {
|
if (ZINT_VERSION_BUILD) {
|
||||||
|
@ -2859,6 +2859,155 @@ static void test_gs1parens(int index, int debug) {
|
|||||||
testFinish();
|
testFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_hrt(int index, int debug) {
|
||||||
|
|
||||||
|
struct item {
|
||||||
|
int symbology;
|
||||||
|
int input_mode;
|
||||||
|
char *data;
|
||||||
|
char *composite;
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
char *expected;
|
||||||
|
};
|
||||||
|
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||||
|
struct item data[] = {
|
||||||
|
/* 0*/ { BARCODE_EANX_CC, -1, "1234567", "[20]12", 0, "12345670" }, // EAN-8
|
||||||
|
/* 1*/ { BARCODE_EANX_CC, -1, "123456789012", "[20]12", 0, "1234567890128" }, // EAN-13
|
||||||
|
/* 2*/ { BARCODE_EANX_CC, -1, "1234567890128", "[20]12", 0, "1234567890128" },
|
||||||
|
/* 3*/ { BARCODE_EANX_CC, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "" },
|
||||||
|
/* 4*/ { BARCODE_EANX_CC, -1, "1234567890128", "[20]1A", ZINT_WARN_NONCOMPLIANT, "1234567890128" }, // AI (20) should be 2 nos.
|
||||||
|
/* 5*/ { BARCODE_DBAR_OMN_CC, -1, "1234567890123", "[20]12", 0, "(01)12345678901231" },
|
||||||
|
/* 6*/ { BARCODE_DBAR_OMN_CC, -1, "12345678901231", "[20]12", 0, "(01)12345678901231" },
|
||||||
|
/* 7*/ { BARCODE_DBAR_OMN_CC, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "" },
|
||||||
|
/* 8*/ { BARCODE_DBAR_OMN_CC, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231" }, // AI (20) should be 2 nos.
|
||||||
|
/* 9*/ { BARCODE_DBAR_LTD_CC, -1, "1234567890123", "[20]12", 0, "(01)12345678901231" },
|
||||||
|
/* 10*/ { BARCODE_DBAR_LTD_CC, -1, "12345678901231", "[20]12", 0, "(01)12345678901231" },
|
||||||
|
/* 11*/ { BARCODE_DBAR_LTD_CC, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "" },
|
||||||
|
/* 12*/ { BARCODE_DBAR_LTD_CC, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231" }, // AI (20) should be 2 nos.
|
||||||
|
/* 13*/ { BARCODE_UPCA_CC, -1, "12345678901", "[20]12", 0, "123456789012" },
|
||||||
|
/* 14*/ { BARCODE_UPCA_CC, -1, "123456789012", "[20]12", 0, "123456789012" },
|
||||||
|
/* 15*/ { BARCODE_UPCA_CC, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, "" },
|
||||||
|
/* 16*/ { BARCODE_UPCA_CC, -1, "123456789012", "[20]1A", ZINT_WARN_NONCOMPLIANT, "123456789012" }, // AI (20) should be 2 nos.
|
||||||
|
/* 17*/ { BARCODE_UPCE_CC, -1, "123456", "[20]12", 0, "01234565" },
|
||||||
|
/* 18*/ { BARCODE_UPCE_CC, -1, "1234567", "[20]12", 0, "12345670" },
|
||||||
|
/* 19*/ { BARCODE_UPCE_CC, -1, "12345670", "[20]12", 0, "12345670" }, // Check digit can now be given for UPCE_CC, like UPCA_CC
|
||||||
|
/* 20*/ { BARCODE_UPCE_CC, -1, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, "12345670" }, // AI (20) should be 2 nos.
|
||||||
|
/* 21*/ { BARCODE_DBAR_STK_CC, -1, "12345678901231", "[20]12", 0, "" }, // No HRT for stacked symbologies
|
||||||
|
/* 22*/ { BARCODE_DBAR_OMNSTK_CC, -1, "12345678901231", "[20]12", 0, "" },
|
||||||
|
};
|
||||||
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
int i, length, composite_length, ret;
|
||||||
|
struct zint_symbol *symbol;
|
||||||
|
|
||||||
|
testStart("test_hrt");
|
||||||
|
|
||||||
|
for (i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
|
if (index != -1 && i != index) continue;
|
||||||
|
|
||||||
|
symbol = ZBarcode_Create();
|
||||||
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
|
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
|
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||||
|
strcpy(symbol->primary, data[i].data);
|
||||||
|
|
||||||
|
composite_length = (int) strlen(data[i].composite);
|
||||||
|
|
||||||
|
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
|
||||||
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt);
|
||||||
|
|
||||||
|
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||||
|
|
||||||
|
ZBarcode_Delete(symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
testFinish();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_input(int index, int debug) {
|
||||||
|
|
||||||
|
struct item {
|
||||||
|
int symbology;
|
||||||
|
int input_mode;
|
||||||
|
char *data;
|
||||||
|
char *composite;
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
char *expected_errtxt;
|
||||||
|
};
|
||||||
|
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||||
|
struct item data[] = {
|
||||||
|
/* 0*/ { BARCODE_EANX_CC, -1, "1234567", "[20]12", 0, "" }, // EAN-8
|
||||||
|
/* 1*/ { BARCODE_EANX_CC, -1, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" },
|
||||||
|
/* 2*/ { BARCODE_EANX_CC, -1, "123456789012", "[20]12", 0, "" }, // EAN-13
|
||||||
|
/* 3*/ { BARCODE_EANX_CC, -1, "1234567890128", "[20]12", 0, "" }, // EAN-13
|
||||||
|
/* 4*/ { BARCODE_EANX_CC, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '3', expecting '8' in linear component" },
|
||||||
|
/* 5*/ { BARCODE_EANX_CC, -1, "1234567890128", "[20]1A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" }, // AI (20) should be 2 nos.
|
||||||
|
/* 6*/ { BARCODE_EANX_CC, -1, "1234567890128", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' in 2D component" },
|
||||||
|
/* 7*/ { BARCODE_DBAR_OMN_CC, -1, "1234567890123", "[20]12", 0, "" },
|
||||||
|
/* 8*/ { BARCODE_DBAR_OMN_CC, -1, "12345678901231", "[20]12", 0, "" },
|
||||||
|
/* 9*/ { BARCODE_DBAR_OMN_CC, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "Error 388: Invalid check digit '2', expecting '1' in linear component" },
|
||||||
|
/* 10*/ { BARCODE_DBAR_OMN_CC, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" }, // AI (20) should be 2 nos.
|
||||||
|
/* 11*/ { BARCODE_DBAR_OMN_CC, -1, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' in 2D component" },
|
||||||
|
/* 12*/ { BARCODE_DBAR_LTD_CC, -1, "1234567890123", "[20]12", 0, "" },
|
||||||
|
/* 13*/ { BARCODE_DBAR_LTD_CC, -1, "12345678901231", "[20]12", 0, "" },
|
||||||
|
/* 14*/ { BARCODE_DBAR_LTD_CC, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "Error 389: Invalid check digit '2', expecting '1' in linear component" },
|
||||||
|
/* 15*/ { BARCODE_DBAR_LTD_CC, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" }, // AI (20) should be 2 nos.
|
||||||
|
/* 16*/ { BARCODE_DBAR_LTD_CC, -1, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' in 2D component" },
|
||||||
|
/* 17*/ { BARCODE_UPCA_CC, -1, "12345678901", "[20]12", 0, "" },
|
||||||
|
/* 18*/ { BARCODE_UPCA_CC, -1, "123456789012", "[20]12", 0, "" },
|
||||||
|
/* 19*/ { BARCODE_UPCA_CC, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '3', expecting '2' in linear component" },
|
||||||
|
/* 20*/ { BARCODE_UPCA_CC, -1, "123456789012", "[20]1A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" }, // AI (20) should be 2 nos.
|
||||||
|
/* 21*/ { BARCODE_UPCA_CC, -1, "123456789012", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' in 2D component" },
|
||||||
|
/* 22*/ { BARCODE_UPCE_CC, -1, "123456", "[20]12", 0, "" },
|
||||||
|
/* 23*/ { BARCODE_UPCE_CC, -1, "123456", "[20]1A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" }, // AI (20) should be 2 nos.
|
||||||
|
/* 24*/ { BARCODE_UPCE_CC, -1, "1234567", "[20]12", 0, "" },
|
||||||
|
/* 25*/ { BARCODE_UPCE_CC, -1, "12345670", "[20]12", 0, "" }, // Check digit can now be given for UPCE_CC, like UPCA_CC
|
||||||
|
/* 26*/ { BARCODE_UPCE_CC, -1, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" }, // AI (20) should be 2 nos.
|
||||||
|
/* 27*/ { BARCODE_UPCE_CC, -1, "1234567", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' in 2D component" },
|
||||||
|
/* 28*/ { BARCODE_DBAR_STK_CC, -1, "1234567890123", "[20]12", 0, "" },
|
||||||
|
/* 29*/ { BARCODE_DBAR_STK_CC, -1, "12345678901231", "[20]12", 0, "" },
|
||||||
|
/* 30*/ { BARCODE_DBAR_STK_CC, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "Error 388: Invalid check digit '2', expecting '1' in linear component" },
|
||||||
|
/* 31*/ { BARCODE_DBAR_STK_CC, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" }, // AI (20) should be 2 nos.
|
||||||
|
/* 32*/ { BARCODE_DBAR_STK_CC, -1, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' in 2D component" },
|
||||||
|
/* 33*/ { BARCODE_DBAR_OMNSTK_CC, -1, "1234567890123", "[20]12", 0, "" },
|
||||||
|
/* 34*/ { BARCODE_DBAR_OMNSTK_CC, -1, "12345678901231", "[20]12", 0, "" },
|
||||||
|
/* 35*/ { BARCODE_DBAR_OMNSTK_CC, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "Error 388: Invalid check digit '2', expecting '1' in linear component" },
|
||||||
|
/* 36*/ { BARCODE_DBAR_OMNSTK_CC, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" }, // AI (20) should be 2 nos.
|
||||||
|
/* 37*/ { BARCODE_DBAR_OMNSTK_CC, -1, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' in 2D component" },
|
||||||
|
};
|
||||||
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
int i, length, composite_length, ret;
|
||||||
|
struct zint_symbol *symbol;
|
||||||
|
|
||||||
|
testStart("test_input");
|
||||||
|
|
||||||
|
for (i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
|
if (index != -1 && i != index) continue;
|
||||||
|
|
||||||
|
symbol = ZBarcode_Create();
|
||||||
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
|
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
|
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||||
|
strcpy(symbol->primary, data[i].data);
|
||||||
|
|
||||||
|
composite_length = (int) strlen(data[i].composite);
|
||||||
|
|
||||||
|
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
|
||||||
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt);
|
||||||
|
|
||||||
|
assert_zero(strcmp((const char *) symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
|
||||||
|
|
||||||
|
ZBarcode_Delete(symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
testFinish();
|
||||||
|
}
|
||||||
|
|
||||||
// #181 Christian Hartlage OSS-Fuzz
|
// #181 Christian Hartlage OSS-Fuzz
|
||||||
static void test_fuzz(int index, int debug) {
|
static void test_fuzz(int index, int debug) {
|
||||||
|
|
||||||
@ -3007,6 +3156,8 @@ int main(int argc, char *argv[]) {
|
|||||||
{ "test_encodation_11", test_encodation_11, 1, 1, 1 },
|
{ "test_encodation_11", test_encodation_11, 1, 1, 1 },
|
||||||
{ "test_addongap", test_addongap, 1, 1, 1 },
|
{ "test_addongap", test_addongap, 1, 1, 1 },
|
||||||
{ "test_gs1parens", test_gs1parens, 1, 0, 1 },
|
{ "test_gs1parens", test_gs1parens, 1, 0, 1 },
|
||||||
|
{ "test_hrt", test_hrt, 1, 0, 1 },
|
||||||
|
{ "test_input", test_input, 1, 0, 1 },
|
||||||
{ "test_fuzz", test_fuzz, 1, 0, 1 },
|
{ "test_fuzz", test_fuzz, 1, 0, 1 },
|
||||||
{ "test_perf", test_perf, 1, 0, 1 },
|
{ "test_perf", test_perf, 1, 0, 1 },
|
||||||
};
|
};
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -49,40 +49,47 @@ static void test_upce_input(int index, int debug) {
|
|||||||
/* 6*/ { BARCODE_UPCE, "1234567", 0 }, // equivalent: 12345600007, hrt: 12345670, Check digit: 0
|
/* 6*/ { BARCODE_UPCE, "1234567", 0 }, // equivalent: 12345600007, hrt: 12345670, Check digit: 0
|
||||||
/* 7*/ { BARCODE_UPCE_CHK, "1234567", ZINT_ERROR_INVALID_CHECK },
|
/* 7*/ { BARCODE_UPCE_CHK, "1234567", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 8*/ { BARCODE_UPCE_CHK, "1234565", 0 }, // equivalent: 01234500006, hrt: 01234565, Check digit: 5
|
/* 8*/ { BARCODE_UPCE_CHK, "1234565", 0 }, // equivalent: 01234500006, hrt: 01234565, Check digit: 5
|
||||||
/* 9*/ { BARCODE_UPCE, "12345678", ZINT_ERROR_TOO_LONG },
|
/* 9*/ { BARCODE_UPCE, "12345678", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 10*/ { BARCODE_UPCE_CHK, "12345678", ZINT_ERROR_INVALID_CHECK },
|
/* 10*/ { BARCODE_UPCE, "12345670", 0 }, // equivalent: 12345600007, hrt: 12345670, Check digit: 0
|
||||||
/* 11*/ { BARCODE_UPCE_CHK, "12345670", 0 }, // equivalent: 12345600007, hrt: 12345670, Check digit: 0
|
/* 11*/ { BARCODE_UPCE_CHK, "12345678", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 12*/ { BARCODE_UPCE, "123456789", ZINT_ERROR_TOO_LONG },
|
/* 12*/ { BARCODE_UPCE_CHK, "12345670", 0 }, // equivalent: 12345600007, hrt: 12345670, Check digit: 0
|
||||||
/* 13*/ { BARCODE_UPCE_CHK, "123456789", ZINT_ERROR_TOO_LONG },
|
/* 13*/ { BARCODE_UPCE, "123456789", ZINT_ERROR_TOO_LONG },
|
||||||
/* 14*/ { BARCODE_UPCE, "2345678", 0 }, // 2 ignored, equivalent: 03456700008, hrt: 03456781, Check digit: 1
|
/* 14*/ { BARCODE_UPCE_CHK, "123456789", ZINT_ERROR_TOO_LONG },
|
||||||
/* 15*/ { BARCODE_UPCE_CHK, "23456781", 0 }, // 2 ignored, equivalent: 03456700008, hrt: 03456781, Check digit: 1
|
/* 15*/ { BARCODE_UPCE, "123456A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 16*/ { BARCODE_UPCE, "123455", 0 }, // equivalent: 01234500005, hrt: 01234558, Check digit: 8 (BS 797 Rule 3 (a))
|
/* 16*/ { BARCODE_UPCE, "1234567A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 17*/ { BARCODE_UPCE_CHK, "1234558", 0 }, // equivalent: 01234500005, hrt: 01234558, Check digit: 8 (BS 797 Rule 3 (a))
|
/* 17*/ { BARCODE_UPCE, "12345678A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 18*/ { BARCODE_UPCE, "456784", 0 }, // equivalent: 04567000008, hrt: 04567840, Check digit: 0 (BS 797 Rule 3 (b))
|
/* 18*/ { BARCODE_UPCE_CHK, "123456A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 19*/ { BARCODE_UPCE_CHK, "4567840", 0 }, // equivalent: 04567000008, hrt: 04567840, Check digit: 0 (BS 797 Rule 3 (b))
|
/* 19*/ { BARCODE_UPCE_CHK, "1234567A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 20*/ { BARCODE_UPCE, "345670", 0 }, // equivalent: 03400000567, hrt: 03456703, Check digit: 3 (BS 797 Rule 3 (c))
|
/* 20*/ { BARCODE_UPCE_CHK, "12345678A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 21*/ { BARCODE_UPCE_CHK, "3456703", 0 }, // equivalent: 03400000567, hrt: 03456703, Check digit: 3 (BS 797 Rule 3 (c))
|
/* 21*/ { BARCODE_UPCE, "2345678", 0 }, // 2 ignored, equivalent: 03456700008, hrt: 03456781, Check digit: 1
|
||||||
/* 22*/ { BARCODE_UPCE, "984753", 0 }, // equivalent: 09840000075, hrt: 09847531, Check digit: 1 (BS 797 Rule 3 (d))
|
/* 22*/ { BARCODE_UPCE_CHK, "23456781", 0 }, // 2 ignored, equivalent: 03456700008, hrt: 03456781, Check digit: 1
|
||||||
/* 23*/ { BARCODE_UPCE_CHK, "9847531", 0 }, // equivalent: 09840000075, hrt: 09847531, Check digit: 1 (BS 797 Rule 3 (d))
|
/* 23*/ { BARCODE_UPCE, "123455", 0 }, // equivalent: 01234500005, hrt: 01234558, Check digit: 8 (BS 797 Rule 3 (a))
|
||||||
/* 24*/ { BARCODE_UPCE, "120453", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 3, 3rd can't be 0, 1 or 2 (BS 787 Table 5 NOTE 1)
|
/* 24*/ { BARCODE_UPCE_CHK, "1234558", 0 }, // equivalent: 01234500005, hrt: 01234558, Check digit: 8 (BS 797 Rule 3 (a))
|
||||||
/* 25*/ { BARCODE_UPCE, "121453", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 3, 3rd can't be 0, 1 or 2 (BS 787 Table 5 NOTE 1)
|
/* 25*/ { BARCODE_UPCE, "456784", 0 }, // equivalent: 04567000008, hrt: 04567840, Check digit: 0 (BS 797 Rule 3 (b))
|
||||||
/* 26*/ { BARCODE_UPCE, "122453", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 3, 3rd can't be 0, 1 or 2 (BS 787 Table 5 NOTE 1)
|
/* 26*/ { BARCODE_UPCE_CHK, "4567840", 0 }, // equivalent: 04567000008, hrt: 04567840, Check digit: 0 (BS 797 Rule 3 (b))
|
||||||
/* 27*/ { BARCODE_UPCE, "123453", 0 },
|
/* 27*/ { BARCODE_UPCE, "345670", 0 }, // equivalent: 03400000567, hrt: 03456703, Check digit: 3 (BS 797 Rule 3 (c))
|
||||||
/* 28*/ { BARCODE_UPCE, "123054", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 4, 4th can't be 0 (BS 787 Table 5 NOTE 2)
|
/* 28*/ { BARCODE_UPCE_CHK, "3456703", 0 }, // equivalent: 03400000567, hrt: 03456703, Check digit: 3 (BS 797 Rule 3 (c))
|
||||||
/* 29*/ { BARCODE_UPCE, "123154", 0 },
|
/* 29*/ { BARCODE_UPCE, "984753", 0 }, // equivalent: 09840000075, hrt: 09847531, Check digit: 1 (BS 797 Rule 3 (d))
|
||||||
/* 30*/ { BARCODE_UPCE, "123405", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 5, 5th can't be 0 (BS 787 Table 5 NOTE 3)
|
/* 30*/ { BARCODE_UPCE_CHK, "9847531", 0 }, // equivalent: 09840000075, hrt: 09847531, Check digit: 1 (BS 797 Rule 3 (d))
|
||||||
/* 31*/ { BARCODE_UPCE, "123455", 0 },
|
/* 31*/ { BARCODE_UPCE, "120453", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 3, 3rd can't be 0, 1 or 2 (BS 787 Table 5 NOTE 1)
|
||||||
/* 32*/ { BARCODE_UPCE, "123406", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 6, 5th can't be 0 (BS 787 Table 5 NOTE 3)
|
/* 32*/ { BARCODE_UPCE, "121453", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 3, 3rd can't be 0, 1 or 2 (BS 787 Table 5 NOTE 1)
|
||||||
/* 33*/ { BARCODE_UPCE, "123456", 0 },
|
/* 33*/ { BARCODE_UPCE, "122453", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 3, 3rd can't be 0, 1 or 2 (BS 787 Table 5 NOTE 1)
|
||||||
/* 34*/ { BARCODE_UPCE, "123407", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 7, 5th can't be 0 (BS 787 Table 5 NOTE 3)
|
/* 34*/ { BARCODE_UPCE, "123453", 0 },
|
||||||
/* 35*/ { BARCODE_UPCE, "123457", 0 },
|
/* 35*/ { BARCODE_UPCE, "123054", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 4, 4th can't be 0 (BS 787 Table 5 NOTE 2)
|
||||||
/* 36*/ { BARCODE_UPCE, "123408", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 8, 5th can't be 0 (BS 787 Table 5 NOTE 3)
|
/* 36*/ { BARCODE_UPCE, "123154", 0 },
|
||||||
/* 37*/ { BARCODE_UPCE, "123458", 0 },
|
/* 37*/ { BARCODE_UPCE, "123405", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 5, 5th can't be 0 (BS 787 Table 5 NOTE 3)
|
||||||
/* 38*/ { BARCODE_UPCE, "123409", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 9, 5th can't be 0 (BS 787 Table 5 NOTE 3)
|
/* 38*/ { BARCODE_UPCE, "123455", 0 },
|
||||||
/* 39*/ { BARCODE_UPCE, "123459", 0 },
|
/* 39*/ { BARCODE_UPCE, "123406", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 6, 5th can't be 0 (BS 787 Table 5 NOTE 3)
|
||||||
/* 40*/ { BARCODE_UPCE, "000000", 0 },
|
/* 40*/ { BARCODE_UPCE, "123456", 0 },
|
||||||
/* 41*/ { BARCODE_UPCE, "000001", 0 },
|
/* 41*/ { BARCODE_UPCE, "123407", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 7, 5th can't be 0 (BS 787 Table 5 NOTE 3)
|
||||||
/* 42*/ { BARCODE_UPCE, "000002", 0 },
|
/* 42*/ { BARCODE_UPCE, "123457", 0 },
|
||||||
|
/* 43*/ { BARCODE_UPCE, "123408", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 8, 5th can't be 0 (BS 787 Table 5 NOTE 3)
|
||||||
|
/* 44*/ { BARCODE_UPCE, "123458", 0 },
|
||||||
|
/* 45*/ { BARCODE_UPCE, "123409", ZINT_ERROR_INVALID_DATA }, // If last digit (emode) 9, 5th can't be 0 (BS 787 Table 5 NOTE 3)
|
||||||
|
/* 46*/ { BARCODE_UPCE, "123459", 0 },
|
||||||
|
/* 47*/ { BARCODE_UPCE, "000000", 0 },
|
||||||
|
/* 48*/ { BARCODE_UPCE, "000001", 0 },
|
||||||
|
/* 49*/ { BARCODE_UPCE, "000002", 0 },
|
||||||
};
|
};
|
||||||
int data_size = ARRAY_SIZE(data);
|
int data_size = ARRAY_SIZE(data);
|
||||||
int i, length, ret;
|
int i, length, ret;
|
||||||
@ -163,67 +170,77 @@ static void test_upca_input(int index, int debug) {
|
|||||||
/* 1*/ { BARCODE_UPCA, "1234567890", 0 },
|
/* 1*/ { BARCODE_UPCA, "1234567890", 0 },
|
||||||
/* 2*/ { BARCODE_UPCA, "123456789012", 0 }, // UPC-A accepts CHK
|
/* 2*/ { BARCODE_UPCA, "123456789012", 0 }, // UPC-A accepts CHK
|
||||||
/* 3*/ { BARCODE_UPCA, "123456789011", ZINT_ERROR_INVALID_CHECK },
|
/* 3*/ { BARCODE_UPCA, "123456789011", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 4*/ { BARCODE_UPCA, "12345678901+1", 0 },
|
/* 4*/ { BARCODE_UPCA, "1234567890123", ZINT_ERROR_TOO_LONG },
|
||||||
/* 5*/ { BARCODE_UPCA, "123456789012+1", 0 },
|
/* 5*/ { BARCODE_UPCA, "123456789012A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 6*/ { BARCODE_UPCA, "123456789013+1", ZINT_ERROR_INVALID_CHECK },
|
/* 6*/ { BARCODE_UPCA, "12345678901A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 7*/ { BARCODE_UPCA, "12345678901+12", 0 },
|
/* 7*/ { BARCODE_UPCA, "12345678901+1", 0 },
|
||||||
/* 8*/ { BARCODE_UPCA, "123456789012+12", 0 },
|
/* 8*/ { BARCODE_UPCA, "123456789012+1", 0 },
|
||||||
/* 9*/ { BARCODE_UPCA, "123456789014+12", ZINT_ERROR_INVALID_CHECK },
|
/* 9*/ { BARCODE_UPCA, "123456789013+1", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 10*/ { BARCODE_UPCA, "12345678901+123", 0 },
|
/* 10*/ { BARCODE_UPCA, "12345678901+12", 0 },
|
||||||
/* 11*/ { BARCODE_UPCA, "123456789012+123", 0 },
|
/* 11*/ { BARCODE_UPCA, "123456789012+12", 0 },
|
||||||
/* 12*/ { BARCODE_UPCA, "123456789015+123", ZINT_ERROR_INVALID_CHECK },
|
/* 12*/ { BARCODE_UPCA, "123456789014+12", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 13*/ { BARCODE_UPCA, "123456789012+1234", 0 },
|
/* 13*/ { BARCODE_UPCA, "12345678901+123", 0 },
|
||||||
/* 14*/ { BARCODE_UPCA, "123456789016+1234", ZINT_ERROR_INVALID_CHECK },
|
/* 14*/ { BARCODE_UPCA, "123456789012+123", 0 },
|
||||||
/* 15*/ { BARCODE_UPCA, "123456789012+12345", 0 },
|
/* 15*/ { BARCODE_UPCA, "123456789015+123", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 16*/ { BARCODE_UPCA, "123456789017+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 16*/ { BARCODE_UPCA, "123456789012+1234", 0 },
|
||||||
/* 17*/ { BARCODE_UPCA, "123456789012+123456", ZINT_ERROR_TOO_LONG },
|
/* 17*/ { BARCODE_UPCA, "123456789016+1234", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 18*/ { BARCODE_UPCA, "123456789017+123456", ZINT_ERROR_TOO_LONG },
|
/* 18*/ { BARCODE_UPCA, "123456789012+12345", 0 },
|
||||||
/* 19*/ { BARCODE_UPCA_CHK, "123456789012", 0 },
|
/* 19*/ { BARCODE_UPCA, "123456789017+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 20*/ { BARCODE_UPCA_CHK, "123456789011", ZINT_ERROR_INVALID_CHECK },
|
/* 20*/ { BARCODE_UPCA, "123456789012+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 21*/ { BARCODE_UPCA_CHK, "12345678901", ZINT_ERROR_INVALID_CHECK },
|
/* 21*/ { BARCODE_UPCA, "123456789017+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 22*/ { BARCODE_UPCA_CHK, "12345678905", 0 },
|
/* 22*/ { BARCODE_UPCA, "123456789017+12345A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 23*/ { BARCODE_UPCA_CHK, "1234567890", ZINT_ERROR_INVALID_CHECK },
|
/* 23*/ { BARCODE_UPCA_CHK, "123456789012", 0 },
|
||||||
/* 24*/ { BARCODE_UPCA_CHK, "1234567895", 0 },
|
/* 24*/ { BARCODE_UPCA_CHK, "123456789011", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 25*/ { BARCODE_UPCA_CHK, "123456789", ZINT_ERROR_INVALID_CHECK },
|
/* 25*/ { BARCODE_UPCA_CHK, "1234567890123", ZINT_ERROR_TOO_LONG },
|
||||||
/* 26*/ { BARCODE_UPCA_CHK, "123456784", 0 },
|
/* 26*/ { BARCODE_UPCA_CHK, "123456789012A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 27*/ { BARCODE_UPCA_CHK, "12345678", ZINT_ERROR_INVALID_CHECK },
|
/* 27*/ { BARCODE_UPCA_CHK, "12345678901A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 28*/ { BARCODE_UPCA_CHK, "12345670", 0 },
|
/* 28*/ { BARCODE_UPCA_CHK, "12345678901", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 29*/ { BARCODE_UPCA_CHK, "1234567", ZINT_ERROR_INVALID_CHECK },
|
/* 29*/ { BARCODE_UPCA_CHK, "12345678905", 0 },
|
||||||
/* 30*/ { BARCODE_UPCA_CHK, "1234565", 0 },
|
/* 30*/ { BARCODE_UPCA_CHK, "1234567890", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 31*/ { BARCODE_UPCA_CHK, "123456", ZINT_ERROR_INVALID_CHECK },
|
/* 31*/ { BARCODE_UPCA_CHK, "1234567895", 0 },
|
||||||
/* 32*/ { BARCODE_UPCA_CHK, "123457", 0 },
|
/* 32*/ { BARCODE_UPCA_CHK, "123456789", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 33*/ { BARCODE_UPCA_CHK, "12345", ZINT_ERROR_INVALID_CHECK },
|
/* 33*/ { BARCODE_UPCA_CHK, "123456784", 0 },
|
||||||
/* 34*/ { BARCODE_UPCA_CHK, "12348", 0 },
|
/* 34*/ { BARCODE_UPCA_CHK, "12345678", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 35*/ { BARCODE_UPCA_CHK, "1234", ZINT_ERROR_INVALID_CHECK },
|
/* 35*/ { BARCODE_UPCA_CHK, "12345670", 0 },
|
||||||
/* 36*/ { BARCODE_UPCA_CHK, "1236", 0 },
|
/* 36*/ { BARCODE_UPCA_CHK, "1234567", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 37*/ { BARCODE_UPCA_CHK, "123", 0 }, // Happens to be correct check digit
|
/* 37*/ { BARCODE_UPCA_CHK, "1234565", 0 },
|
||||||
/* 38*/ { BARCODE_UPCA_CHK, "124", ZINT_ERROR_INVALID_CHECK },
|
/* 38*/ { BARCODE_UPCA_CHK, "123456", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 39*/ { BARCODE_UPCA_CHK, "12", ZINT_ERROR_INVALID_CHECK },
|
/* 39*/ { BARCODE_UPCA_CHK, "123457", 0 },
|
||||||
/* 40*/ { BARCODE_UPCA_CHK, "17", 0 },
|
/* 40*/ { BARCODE_UPCA_CHK, "12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 41*/ { BARCODE_UPCA_CHK, "1", ZINT_ERROR_INVALID_CHECK },
|
/* 41*/ { BARCODE_UPCA_CHK, "12348", 0 },
|
||||||
/* 42*/ { BARCODE_UPCA_CHK, "0", 0 },
|
/* 42*/ { BARCODE_UPCA_CHK, "1234", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 43*/ { BARCODE_UPCA_CHK, "12345678905+12", 0 },
|
/* 43*/ { BARCODE_UPCA_CHK, "1236", 0 },
|
||||||
/* 44*/ { BARCODE_UPCA_CHK, "12345678905+12345", 0 },
|
/* 44*/ { BARCODE_UPCA_CHK, "123", 0 }, // Happens to be correct check digit
|
||||||
/* 45*/ { BARCODE_UPCA_CHK, "1234567895+12345", 0 },
|
/* 45*/ { BARCODE_UPCA_CHK, "124", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 46*/ { BARCODE_UPCA_CHK, "1234567891+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 46*/ { BARCODE_UPCA_CHK, "12", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 47*/ { BARCODE_UPCA_CHK, "123456784+12345", 0 },
|
/* 47*/ { BARCODE_UPCA_CHK, "17", 0 },
|
||||||
/* 48*/ { BARCODE_UPCA_CHK, "123456782+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 48*/ { BARCODE_UPCA_CHK, "1", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 49*/ { BARCODE_UPCA_CHK, "12345670+12345", 0 },
|
/* 49*/ { BARCODE_UPCA_CHK, "0", 0 },
|
||||||
/* 50*/ { BARCODE_UPCA_CHK, "12345673+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 50*/ { BARCODE_UPCA_CHK, "12345678905+12", 0 },
|
||||||
/* 51*/ { BARCODE_UPCA_CHK, "1234565+12345", 0 },
|
/* 51*/ { BARCODE_UPCA_CHK, "12345678905+12345", 0 },
|
||||||
/* 52*/ { BARCODE_UPCA_CHK, "1234564+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 52*/ { BARCODE_UPCA_CHK, "12345678905+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 53*/ { BARCODE_UPCA_CHK, "123457+12345", 0 },
|
/* 53*/ { BARCODE_UPCA_CHK, "12345678905+12345A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 54*/ { BARCODE_UPCA_CHK, "123455+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 54*/ { BARCODE_UPCA_CHK, "12345678905+1234A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 55*/ { BARCODE_UPCA_CHK, "12348+12345", 0 },
|
/* 55*/ { BARCODE_UPCA_CHK, "1234567895+12345", 0 },
|
||||||
/* 56*/ { BARCODE_UPCA_CHK, "12346+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 56*/ { BARCODE_UPCA_CHK, "1234567891+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 57*/ { BARCODE_UPCA_CHK, "1236+12345", 0 },
|
/* 57*/ { BARCODE_UPCA_CHK, "123456784+12345", 0 },
|
||||||
/* 58*/ { BARCODE_UPCA_CHK, "1237+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 58*/ { BARCODE_UPCA_CHK, "123456782+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 59*/ { BARCODE_UPCA_CHK, "123+12345", 0 },
|
/* 59*/ { BARCODE_UPCA_CHK, "12345670+12345", 0 },
|
||||||
/* 60*/ { BARCODE_UPCA_CHK, "128+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 60*/ { BARCODE_UPCA_CHK, "12345673+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 61*/ { BARCODE_UPCA_CHK, "17+12345", 0 },
|
/* 61*/ { BARCODE_UPCA_CHK, "1234565+12345", 0 },
|
||||||
/* 62*/ { BARCODE_UPCA_CHK, "19+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 62*/ { BARCODE_UPCA_CHK, "1234564+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 63*/ { BARCODE_UPCA_CHK, "1+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 63*/ { BARCODE_UPCA_CHK, "123457+12345", 0 },
|
||||||
/* 64*/ { BARCODE_UPCA_CHK, "0+12345", 0 },
|
/* 64*/ { BARCODE_UPCA_CHK, "123455+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
|
/* 65*/ { BARCODE_UPCA_CHK, "12348+12345", 0 },
|
||||||
|
/* 66*/ { BARCODE_UPCA_CHK, "12346+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
|
/* 67*/ { BARCODE_UPCA_CHK, "1236+12345", 0 },
|
||||||
|
/* 68*/ { BARCODE_UPCA_CHK, "1237+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
|
/* 69*/ { BARCODE_UPCA_CHK, "123+12345", 0 },
|
||||||
|
/* 70*/ { BARCODE_UPCA_CHK, "128+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
|
/* 71*/ { BARCODE_UPCA_CHK, "17+12345", 0 },
|
||||||
|
/* 72*/ { BARCODE_UPCA_CHK, "19+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
|
/* 73*/ { BARCODE_UPCA_CHK, "1+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
|
/* 74*/ { BARCODE_UPCA_CHK, "0+12345", 0 },
|
||||||
};
|
};
|
||||||
int data_size = ARRAY_SIZE(data);
|
int data_size = ARRAY_SIZE(data);
|
||||||
int i, length, ret;
|
int i, length, ret;
|
||||||
@ -259,127 +276,135 @@ static void test_eanx_input(int index, int debug) {
|
|||||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||||
struct item data[] = {
|
struct item data[] = {
|
||||||
/* 0*/ { BARCODE_EANX, "123456789012", 0 },
|
/* 0*/ { BARCODE_EANX, "123456789012", 0 },
|
||||||
/* 1*/ { BARCODE_EANX, "12345678901", 0 },
|
/* 1*/ { BARCODE_EANX, "12345678901A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 2*/ { BARCODE_EANX, "1234567890128", 0 }, // EANX accepts CHK (treated as such if no leading zeroes required)
|
/* 2*/ { BARCODE_EANX, "12345678901", 0 },
|
||||||
/* 3*/ { BARCODE_EANX, "1234567890120", ZINT_ERROR_INVALID_CHECK },
|
/* 3*/ { BARCODE_EANX, "1234567890128", 0 }, // EANX accepts CHK (treated as such if no leading zeroes required)
|
||||||
/* 4*/ { BARCODE_EANX, "123456789012+1", 0 },
|
/* 4*/ { BARCODE_EANX, "1234567890120", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 5*/ { BARCODE_EANX, "1234567890128+1", 0 },
|
/* 5*/ { BARCODE_EANX, "123456789012+1", 0 },
|
||||||
/* 6*/ { BARCODE_EANX, "1234567890121+1", ZINT_ERROR_INVALID_CHECK },
|
/* 6*/ { BARCODE_EANX, "1234567890128+1", 0 },
|
||||||
/* 7*/ { BARCODE_EANX, "123456789012+12", 0 },
|
/* 7*/ { BARCODE_EANX, "1234567890121+1", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 8*/ { BARCODE_EANX, "1234567890128+12", 0 },
|
/* 8*/ { BARCODE_EANX, "123456789012+12", 0 },
|
||||||
/* 9*/ { BARCODE_EANX, "1234567890122+12", ZINT_ERROR_INVALID_CHECK },
|
/* 9*/ { BARCODE_EANX, "1234567890128+12", 0 },
|
||||||
/* 10*/ { BARCODE_EANX, "12345678901234+12", ZINT_ERROR_TOO_LONG },
|
/* 10*/ { BARCODE_EANX, "1234567890122+12", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 11*/ { BARCODE_EANX, "123456789012345+12", ZINT_ERROR_TOO_LONG },
|
/* 11*/ { BARCODE_EANX, "12345678901234+12", ZINT_ERROR_TOO_LONG },
|
||||||
/* 12*/ { BARCODE_EANX, "1234567890123456+12", ZINT_ERROR_TOO_LONG },
|
/* 12*/ { BARCODE_EANX, "123456789012345+12", ZINT_ERROR_TOO_LONG },
|
||||||
/* 13*/ { BARCODE_EANX, "123456789012+123", 0 },
|
/* 13*/ { BARCODE_EANX, "1234567890123456+12", ZINT_ERROR_TOO_LONG },
|
||||||
/* 14*/ { BARCODE_EANX, "1234567890128+123", 0 },
|
/* 14*/ { BARCODE_EANX, "123456789012+123", 0 },
|
||||||
/* 15*/ { BARCODE_EANX, "1234567890123+123", ZINT_ERROR_INVALID_CHECK },
|
/* 15*/ { BARCODE_EANX, "1234567890128+123", 0 },
|
||||||
/* 16*/ { BARCODE_EANX, "12345678901234+123", ZINT_ERROR_TOO_LONG },
|
/* 16*/ { BARCODE_EANX, "1234567890123+123", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 17*/ { BARCODE_EANX, "123456789012345+123", ZINT_ERROR_TOO_LONG },
|
/* 17*/ { BARCODE_EANX, "12345678901234+123", ZINT_ERROR_TOO_LONG },
|
||||||
/* 18*/ { BARCODE_EANX, "123456789012+1234", 0 },
|
/* 18*/ { BARCODE_EANX, "123456789012345+123", ZINT_ERROR_TOO_LONG },
|
||||||
/* 19*/ { BARCODE_EANX, "1234567890128+1234", 0 },
|
/* 19*/ { BARCODE_EANX, "123456789012+1234", 0 },
|
||||||
/* 20*/ { BARCODE_EANX, "1234567890124+1234", ZINT_ERROR_INVALID_CHECK },
|
/* 20*/ { BARCODE_EANX, "1234567890128+1234", 0 },
|
||||||
/* 21*/ { BARCODE_EANX, "12345678901234+1234", ZINT_ERROR_TOO_LONG },
|
/* 21*/ { BARCODE_EANX, "1234567890124+1234", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 22*/ { BARCODE_EANX, "123456789012+12345", 0 },
|
/* 22*/ { BARCODE_EANX, "12345678901234+1234", ZINT_ERROR_TOO_LONG },
|
||||||
/* 23*/ { BARCODE_EANX, "1234567890128+12345", 0 },
|
/* 23*/ { BARCODE_EANX, "123456789012+12345", 0 },
|
||||||
/* 24*/ { BARCODE_EANX, "12345678901234+12345", ZINT_ERROR_TOO_LONG },
|
/* 24*/ { BARCODE_EANX, "1234567890128+12345", 0 },
|
||||||
/* 25*/ { BARCODE_EANX, "1234567890125+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 25*/ { BARCODE_EANX, "12345678901234+12345", ZINT_ERROR_TOO_LONG },
|
||||||
/* 26*/ { BARCODE_EANX, "123456789012+123456", ZINT_ERROR_TOO_LONG },
|
/* 26*/ { BARCODE_EANX, "1234567890125+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 27*/ { BARCODE_EANX, "1234567890128+123456", ZINT_ERROR_TOO_LONG },
|
/* 27*/ { BARCODE_EANX, "123456789012+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 28*/ { BARCODE_EANX, "12345678901+123456", ZINT_ERROR_TOO_LONG },
|
/* 28*/ { BARCODE_EANX, "1234567890128+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 29*/ { BARCODE_EANX, "12345678901+1234567", ZINT_ERROR_TOO_LONG },
|
/* 29*/ { BARCODE_EANX, "12345678901+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 30*/ { BARCODE_EANX, "1234567890+123456", ZINT_ERROR_TOO_LONG },
|
/* 30*/ { BARCODE_EANX, "12345678901+1234567", ZINT_ERROR_TOO_LONG },
|
||||||
/* 31*/ { BARCODE_EANX, "1234567890+1234567", ZINT_ERROR_TOO_LONG },
|
/* 31*/ { BARCODE_EANX, "1234567890+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 32*/ { BARCODE_EANX, "123456789+123456", ZINT_ERROR_TOO_LONG },
|
/* 32*/ { BARCODE_EANX, "1234567890+1234567", ZINT_ERROR_TOO_LONG },
|
||||||
/* 33*/ { BARCODE_EANX, "123456789+1234567", ZINT_ERROR_TOO_LONG },
|
/* 33*/ { BARCODE_EANX, "123456789+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 34*/ { BARCODE_EANX, "12345678+123456", ZINT_ERROR_TOO_LONG },
|
/* 34*/ { BARCODE_EANX, "123456789+1234567", ZINT_ERROR_TOO_LONG },
|
||||||
/* 35*/ { BARCODE_EANX, "1234567+123456", ZINT_ERROR_TOO_LONG }, // EAN-8
|
/* 35*/ { BARCODE_EANX, "12345678+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 36*/ { BARCODE_EANX, "123456+123456", ZINT_ERROR_TOO_LONG },
|
/* 36*/ { BARCODE_EANX, "1234567+123456", ZINT_ERROR_TOO_LONG }, // EAN-8
|
||||||
/* 37*/ { BARCODE_EANX, "12345+123456", ZINT_ERROR_TOO_LONG },
|
/* 37*/ { BARCODE_EANX, "123456+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 38*/ { BARCODE_EANX, "1234+123456", ZINT_ERROR_TOO_LONG },
|
/* 38*/ { BARCODE_EANX, "12345+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 39*/ { BARCODE_EANX, "123+123456", ZINT_ERROR_TOO_LONG },
|
/* 39*/ { BARCODE_EANX, "1234+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 40*/ { BARCODE_EANX, "12+123456", ZINT_ERROR_TOO_LONG },
|
/* 40*/ { BARCODE_EANX, "123+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 41*/ { BARCODE_EANX, "1+123456", ZINT_ERROR_TOO_LONG },
|
/* 41*/ { BARCODE_EANX, "12+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 42*/ { BARCODE_EANX, "1+12345678901234", ZINT_ERROR_TOO_LONG },
|
/* 42*/ { BARCODE_EANX, "1+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 43*/ { BARCODE_EANX, "1+12345", 0 },
|
/* 43*/ { BARCODE_EANX, "1+12345678901234", ZINT_ERROR_TOO_LONG },
|
||||||
/* 44*/ { BARCODE_EANX, "1+", 0 }, // EAN-2
|
/* 44*/ { BARCODE_EANX, "1+12345", 0 },
|
||||||
/* 45*/ { BARCODE_EANX, "+1", 0 }, // EAN-8
|
/* 45*/ { BARCODE_EANX, "1+", 0 }, // EAN-2
|
||||||
/* 46*/ { BARCODE_EANX, "+", 0 }, // EAN-2
|
/* 46*/ { BARCODE_EANX, "+1", 0 }, // EAN-8
|
||||||
/* 47*/ { BARCODE_EANX, "1", 0 }, // EAN-2
|
/* 47*/ { BARCODE_EANX, "+", 0 }, // EAN-2
|
||||||
/* 48*/ { BARCODE_EANX, "12", 0 }, // EAN-2
|
/* 48*/ { BARCODE_EANX, "1", 0 }, // EAN-2
|
||||||
/* 49*/ { BARCODE_EANX, "123", 0 }, // EAN-5
|
/* 49*/ { BARCODE_EANX, "12", 0 }, // EAN-2
|
||||||
/* 50*/ { BARCODE_EANX, "12345678901234", ZINT_ERROR_TOO_LONG },
|
/* 50*/ { BARCODE_EANX, "123", 0 }, // EAN-5
|
||||||
/* 51*/ { BARCODE_EANX, "123456789012345", ZINT_ERROR_TOO_LONG },
|
/* 51*/ { BARCODE_EANX, "12345678901234", ZINT_ERROR_TOO_LONG },
|
||||||
/* 52*/ { BARCODE_EANX, "1234567890123456", ZINT_ERROR_TOO_LONG },
|
/* 52*/ { BARCODE_EANX, "1234567890123A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 53*/ { BARCODE_EANX, "12345678901234567", ZINT_ERROR_TOO_LONG },
|
/* 53*/ { BARCODE_EANX, "123456789012345", ZINT_ERROR_TOO_LONG },
|
||||||
/* 54*/ { BARCODE_EANX, "123456789012345678", ZINT_ERROR_TOO_LONG },
|
/* 54*/ { BARCODE_EANX, "12345678901234A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 55*/ { BARCODE_EANX, "1234567890123456789", ZINT_ERROR_TOO_LONG },
|
/* 55*/ { BARCODE_EANX, "1234567890123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 56*/ { BARCODE_EANX_CHK, "123456789012", 0 }, // EANX_CHK accepts no CHK
|
/* 56*/ { BARCODE_EANX, "12345678901234567", ZINT_ERROR_TOO_LONG },
|
||||||
/* 57*/ { BARCODE_EANX_CHK, "12345678901", ZINT_ERROR_INVALID_CHECK }, // But only if no leading zeroes required
|
/* 57*/ { BARCODE_EANX, "123456789012345678", ZINT_ERROR_TOO_LONG },
|
||||||
/* 58*/ { BARCODE_EANX_CHK, "12345678905", 0 },
|
/* 58*/ { BARCODE_EANX, "1234567890123456789", ZINT_ERROR_TOO_LONG },
|
||||||
/* 59*/ { BARCODE_EANX_CHK, "1234567890", ZINT_ERROR_INVALID_CHECK },
|
/* 59*/ { BARCODE_EANX_CHK, "1234567890128", 0 },
|
||||||
/* 60*/ { BARCODE_EANX_CHK, "123456789", ZINT_ERROR_INVALID_CHECK },
|
/* 60*/ { BARCODE_EANX_CHK, "1234567890126", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 61*/ { BARCODE_EANX_CHK, "12345678", ZINT_ERROR_INVALID_CHECK }, // EAN-8
|
/* 61*/ { BARCODE_EANX_CHK, "123456789012A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 62*/ { BARCODE_EANX_CHK, "1234567", ZINT_ERROR_INVALID_CHECK },
|
/* 62*/ { BARCODE_EANX_CHK, "123456789012", 0 }, // Note: this is "0123456789012" with '2' happening to be the correct check digit
|
||||||
/* 63*/ { BARCODE_EANX_CHK, "123456", ZINT_ERROR_INVALID_CHECK },
|
/* 63*/ { BARCODE_EANX_CHK, "123456789013", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 64*/ { BARCODE_EANX_CHK, "12345", 0 }, // EAN-5
|
/* 64*/ { BARCODE_EANX_CHK, "12345678901", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 65*/ { BARCODE_EANX_CHK, "1234", 0 },
|
/* 65*/ { BARCODE_EANX_CHK, "12345678905", 0 },
|
||||||
/* 66*/ { BARCODE_EANX_CHK, "123", 0 },
|
/* 66*/ { BARCODE_EANX_CHK, "1234567890", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 67*/ { BARCODE_EANX_CHK, "12", 0 }, // EAN-2
|
/* 67*/ { BARCODE_EANX_CHK, "123456789", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 68*/ { BARCODE_EANX_CHK, "1", 0 },
|
/* 68*/ { BARCODE_EANX_CHK, "12345678", ZINT_ERROR_INVALID_CHECK }, // EAN-8
|
||||||
/* 69*/ { BARCODE_EANX_CHK, "1234567890128", 0 },
|
/* 69*/ { BARCODE_EANX_CHK, "1234567", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 70*/ { BARCODE_EANX_CHK, "1234567890126", ZINT_ERROR_INVALID_CHECK },
|
/* 70*/ { BARCODE_EANX_CHK, "123456", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 71*/ { BARCODE_EANX_CHK, "123456789012+1", 0 },
|
/* 71*/ { BARCODE_EANX_CHK, "12345", 0 }, // EAN-5
|
||||||
/* 72*/ { BARCODE_EANX_CHK, "1234567890128+1", 0 },
|
/* 72*/ { BARCODE_EANX_CHK, "1234", 0 },
|
||||||
/* 73*/ { BARCODE_EANX_CHK, "1234567890127+1", ZINT_ERROR_INVALID_CHECK },
|
/* 73*/ { BARCODE_EANX_CHK, "123", 0 },
|
||||||
/* 74*/ { BARCODE_EANX_CHK, "123456789012+12", 0 },
|
/* 74*/ { BARCODE_EANX_CHK, "12", 0 }, // EAN-2
|
||||||
/* 75*/ { BARCODE_EANX_CHK, "1234567890128+12", 0 },
|
/* 75*/ { BARCODE_EANX_CHK, "1", 0 },
|
||||||
/* 76*/ { BARCODE_EANX_CHK, "1234567890129+12", ZINT_ERROR_INVALID_CHECK },
|
/* 76*/ { BARCODE_EANX_CHK, "123456789012+1", 0 },
|
||||||
/* 77*/ { BARCODE_EANX_CHK, "123456789012+123", 0 },
|
/* 77*/ { BARCODE_EANX_CHK, "1234567890128+1", 0 },
|
||||||
/* 78*/ { BARCODE_EANX_CHK, "1234567890128+123", 0 },
|
/* 78*/ { BARCODE_EANX_CHK, "1234567890127+1", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 79*/ { BARCODE_EANX_CHK, "1234567890120+1234", ZINT_ERROR_INVALID_CHECK },
|
/* 79*/ { BARCODE_EANX_CHK, "123456789012+12", 0 },
|
||||||
/* 80*/ { BARCODE_EANX_CHK, "123456789012+1234", 0 },
|
/* 80*/ { BARCODE_EANX_CHK, "1234567890128+12", 0 },
|
||||||
/* 81*/ { BARCODE_EANX_CHK, "1234567890128+1234", 0 },
|
/* 81*/ { BARCODE_EANX_CHK, "1234567890129+12", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 82*/ { BARCODE_EANX_CHK, "1234567890121+1234", ZINT_ERROR_INVALID_CHECK },
|
/* 82*/ { BARCODE_EANX_CHK, "123456789012+123", 0 },
|
||||||
/* 83*/ { BARCODE_EANX_CHK, "123456789012+12345", 0 },
|
/* 83*/ { BARCODE_EANX_CHK, "1234567890128+123", 0 },
|
||||||
/* 84*/ { BARCODE_EANX_CHK, "1234567890128+12345", 0 },
|
/* 84*/ { BARCODE_EANX_CHK, "1234567890120+1234", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 85*/ { BARCODE_EANX_CHK, "1234567890122+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 85*/ { BARCODE_EANX_CHK, "123456789012+1234", 0 },
|
||||||
/* 86*/ { BARCODE_EANX_CHK, "123456789012+123456", ZINT_ERROR_TOO_LONG },
|
/* 86*/ { BARCODE_EANX_CHK, "1234567890128+1234", 0 },
|
||||||
/* 87*/ { BARCODE_EANX_CHK, "1234567890128+123456", ZINT_ERROR_TOO_LONG },
|
/* 87*/ { BARCODE_EANX_CHK, "1234567890121+1234", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 88*/ { BARCODE_EANX_CHK, "12345678901+123456", ZINT_ERROR_TOO_LONG },
|
/* 88*/ { BARCODE_EANX_CHK, "123456789012+12345", 0 },
|
||||||
/* 89*/ { BARCODE_EANX_CHK, "12345678901+1234567", ZINT_ERROR_TOO_LONG },
|
/* 89*/ { BARCODE_EANX_CHK, "1234567890128+12345", 0 },
|
||||||
/* 90*/ { BARCODE_EANX_CHK, "12345678901+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 90*/ { BARCODE_EANX_CHK, "1234567890122+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 91*/ { BARCODE_EANX_CHK, "1234567890+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 91*/ { BARCODE_EANX_CHK, "1234567890122+1234A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 92*/ { BARCODE_EANX_CHK, "1234567890+123456", ZINT_ERROR_TOO_LONG },
|
/* 92*/ { BARCODE_EANX_CHK, "123456789012+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 93*/ { BARCODE_EANX_CHK, "123456789+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 93*/ { BARCODE_EANX_CHK, "123456789012+12345A", ZINT_ERROR_INVALID_DATA },
|
||||||
/* 94*/ { BARCODE_EANX_CHK, "12345678+12345", ZINT_ERROR_INVALID_CHECK }, // EAN-8
|
/* 94*/ { BARCODE_EANX_CHK, "1234567890128+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 95*/ { BARCODE_EANX_CHK, "12345670+12345", 0 },
|
/* 95*/ { BARCODE_EANX_CHK, "12345678901+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/* 96*/ { BARCODE_EANX_CHK, "1234567+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 96*/ { BARCODE_EANX_CHK, "12345678901+1234567", ZINT_ERROR_TOO_LONG },
|
||||||
/* 97*/ { BARCODE_EANX_CHK, "1234565+12345", 0 },
|
/* 97*/ { BARCODE_EANX_CHK, "12345678901+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 98*/ { BARCODE_EANX_CHK, "123456+12345", ZINT_ERROR_INVALID_CHECK },
|
/* 98*/ { BARCODE_EANX_CHK, "1234567890+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/* 99*/ { BARCODE_EANX_CHK, "123457+12345", 0 },
|
/* 99*/ { BARCODE_EANX_CHK, "1234567890+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/*100*/ { BARCODE_EANX_CHK, "12345+12345", ZINT_ERROR_INVALID_CHECK },
|
/*100*/ { BARCODE_EANX_CHK, "123456789+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/*101*/ { BARCODE_EANX_CHK, "12348+12345", 0 },
|
/*101*/ { BARCODE_EANX_CHK, "12345678+12345", ZINT_ERROR_INVALID_CHECK }, // EAN-8
|
||||||
/*102*/ { BARCODE_EANX_CHK, "1234+12345", ZINT_ERROR_INVALID_CHECK },
|
/*102*/ { BARCODE_EANX_CHK, "12345670+12345", 0 },
|
||||||
/*103*/ { BARCODE_EANX_CHK, "1236+12345", 0 },
|
/*103*/ { BARCODE_EANX_CHK, "1234567+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/*104*/ { BARCODE_EANX_CHK, "123+12345", 0 }, // 3 happens to be correct check digit
|
/*104*/ { BARCODE_EANX_CHK, "1234565+12345", 0 },
|
||||||
/*105*/ { BARCODE_EANX_CHK, "124+12345", ZINT_ERROR_INVALID_CHECK },
|
/*105*/ { BARCODE_EANX_CHK, "123456+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/*106*/ { BARCODE_EANX_CHK, "12+12345", ZINT_ERROR_INVALID_CHECK },
|
/*106*/ { BARCODE_EANX_CHK, "123457+12345", 0 },
|
||||||
/*107*/ { BARCODE_EANX_CHK, "17+12345", 0 },
|
/*107*/ { BARCODE_EANX_CHK, "12345+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/*108*/ { BARCODE_EANX_CHK, "1+12345", ZINT_ERROR_INVALID_CHECK },
|
/*108*/ { BARCODE_EANX_CHK, "12348+12345", 0 },
|
||||||
/*109*/ { BARCODE_EANX_CHK, "0+12345", 0 },
|
/*109*/ { BARCODE_EANX_CHK, "1234+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/*110*/ { BARCODE_EANX_CHK, "0+123456", ZINT_ERROR_TOO_LONG },
|
/*110*/ { BARCODE_EANX_CHK, "1236+12345", 0 },
|
||||||
/*111*/ { BARCODE_EANX_CHK, "1+12345678901234", ZINT_ERROR_TOO_LONG },
|
/*111*/ { BARCODE_EANX_CHK, "123+12345", 0 }, // 3 happens to be correct check digit
|
||||||
/*112*/ { BARCODE_EANX_CHK, "0+12345678901234", ZINT_ERROR_TOO_LONG },
|
/*112*/ { BARCODE_EANX_CHK, "124+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/*113*/ { BARCODE_EANX_CHK, "1+", 0 }, // EAN-2
|
/*113*/ { BARCODE_EANX_CHK, "12+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/*114*/ { BARCODE_EANX_CHK, "+1", 0 }, // EAN-8
|
/*114*/ { BARCODE_EANX_CHK, "17+12345", 0 },
|
||||||
/*115*/ { BARCODE_EANX_CHK, "+", 0 }, // EAN-2
|
/*115*/ { BARCODE_EANX_CHK, "1+12345", ZINT_ERROR_INVALID_CHECK },
|
||||||
/*116*/ { BARCODE_EANX_CHK, "12345678901234", ZINT_ERROR_TOO_LONG },
|
/*116*/ { BARCODE_EANX_CHK, "0+12345", 0 },
|
||||||
/*117*/ { BARCODE_EANX_CHK, "123456789012345", ZINT_ERROR_TOO_LONG },
|
/*117*/ { BARCODE_EANX_CHK, "0+123456", ZINT_ERROR_TOO_LONG },
|
||||||
/*118*/ { BARCODE_EANX_CHK, "1234567890123456", ZINT_ERROR_TOO_LONG },
|
/*118*/ { BARCODE_EANX_CHK, "1+12345678901234", ZINT_ERROR_TOO_LONG },
|
||||||
/*119*/ { BARCODE_EANX_CHK, "12345678901234567", ZINT_ERROR_TOO_LONG },
|
/*119*/ { BARCODE_EANX_CHK, "0+12345678901234", ZINT_ERROR_TOO_LONG },
|
||||||
/*120*/ { BARCODE_EANX_CHK, "123456789012345678", ZINT_ERROR_TOO_LONG },
|
/*120*/ { BARCODE_EANX_CHK, "1+", 0 }, // EAN-2
|
||||||
/*121*/ { BARCODE_EANX_CHK, "1234567890123456789", ZINT_ERROR_TOO_LONG },
|
/*121*/ { BARCODE_EANX_CHK, "+1", 0 }, // EAN-8
|
||||||
|
/*122*/ { BARCODE_EANX_CHK, "+", 0 }, // EAN-2
|
||||||
|
/*123*/ { BARCODE_EANX_CHK, "12345678901234", ZINT_ERROR_TOO_LONG },
|
||||||
|
/*124*/ { BARCODE_EANX_CHK, "1234567890123A", ZINT_ERROR_INVALID_DATA },
|
||||||
|
/*125*/ { BARCODE_EANX_CHK, "123456789012345", ZINT_ERROR_TOO_LONG },
|
||||||
|
/*126*/ { BARCODE_EANX_CHK, "1234567890123456", ZINT_ERROR_TOO_LONG },
|
||||||
|
/*127*/ { BARCODE_EANX_CHK, "12345678901234567", ZINT_ERROR_TOO_LONG },
|
||||||
|
/*128*/ { BARCODE_EANX_CHK, "123456789012345678", ZINT_ERROR_TOO_LONG },
|
||||||
|
/*129*/ { BARCODE_EANX_CHK, "1234567890123456789", ZINT_ERROR_TOO_LONG },
|
||||||
};
|
};
|
||||||
int data_size = ARRAY_SIZE(data);
|
int data_size = ARRAY_SIZE(data);
|
||||||
int i, length, ret;
|
int i, length, ret;
|
||||||
@ -455,67 +480,70 @@ static void test_isbn_input(int index, int debug) {
|
|||||||
/* 38*/ { "0571086187", 0, 0 }, // 7 is correct check digit
|
/* 38*/ { "0571086187", 0, 0 }, // 7 is correct check digit
|
||||||
/* 39*/ { "0486600882", 0, 0 }, // 2 is correct check digit
|
/* 39*/ { "0486600882", 0, 0 }, // 2 is correct check digit
|
||||||
/* 40*/ { "04866008X2", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 40*/ { "04866008X2", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 41*/ { "12345678901", ZINT_ERROR_TOO_LONG, -1 },
|
/* 41*/ { "123456789A", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 42*/ { "123456789012", ZINT_ERROR_TOO_LONG, -1 },
|
/* 42*/ { "12345678901", ZINT_ERROR_TOO_LONG, -1 },
|
||||||
/* 43*/ { "12345678901", ZINT_ERROR_TOO_LONG, -1 },
|
/* 43*/ { "1234567890A", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 44*/ { "123456789012", ZINT_ERROR_TOO_LONG, -1 },
|
/* 44*/ { "123456789012", ZINT_ERROR_TOO_LONG, -1 },
|
||||||
/* 45*/ { "1234567890123", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 45*/ { "12345678901", ZINT_ERROR_TOO_LONG, -1 },
|
||||||
/* 46*/ { "9784567890123", ZINT_ERROR_INVALID_CHECK, -1 },
|
/* 46*/ { "123456789012", ZINT_ERROR_TOO_LONG, -1 },
|
||||||
/* 47*/ { "9784567890120", 0, 0 }, // 0 is correct check digit
|
/* 47*/ { "1234567890123", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 48*/ { "9783161484100", 0, 0 }, // 0 is correct check digit
|
/* 48*/ { "9784567890123", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||||
/* 49*/ { "9781846688225", 0, 0 }, // 5 is correct check digit
|
/* 49*/ { "9784567890120", 0, 0 }, // 0 is correct check digit
|
||||||
/* 50*/ { "9781847657954", 0, 0 }, // 4 is correct check digit
|
/* 50*/ { "9783161484100", 0, 0 }, // 0 is correct check digit
|
||||||
/* 51*/ { "9781846688188", 0, 0 }, // 8 is correct check digit
|
/* 51*/ { "9781846688225", 0, 0 }, // 5 is correct check digit
|
||||||
/* 52*/ { "9781847659293", 0, 0 }, // 3 is correct check digit
|
/* 52*/ { "9781847657954", 0, 0 }, // 4 is correct check digit
|
||||||
/* 53*/ { "97845678901201", ZINT_ERROR_TOO_LONG, -1 },
|
/* 53*/ { "9781846688188", 0, 0 }, // 8 is correct check digit
|
||||||
/* 54*/ { "978456789012012", ZINT_ERROR_TOO_LONG, -1 },
|
/* 54*/ { "9781847659293", 0, 0 }, // 3 is correct check digit
|
||||||
/* 55*/ { "3954994+12", 0, 0 },
|
/* 55*/ { "97845678901201", ZINT_ERROR_TOO_LONG, -1 },
|
||||||
/* 56*/ { "3954994+1X", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 56*/ { "978456789012012", ZINT_ERROR_TOO_LONG, -1 },
|
||||||
/* 57*/ { "39549X4+12", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 57*/ { "3954994+12", 0, 0 },
|
||||||
/* 58*/ { "3954994+12345", 0, 0 },
|
/* 58*/ { "3954994+1X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 59*/ { "3954994+1234X", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 59*/ { "39549X4+12", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 60*/ { "39549X4+12345", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 60*/ { "3954994+12345", 0, 0 },
|
||||||
/* 61*/ { "3954994+123456", ZINT_ERROR_TOO_LONG, -1 },
|
/* 61*/ { "3954994+1234X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 62*/ { "3954994+", 0, 0 },
|
/* 62*/ { "39549X4+12345", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 63*/ { "3954X94+", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 63*/ { "3954994+123456", ZINT_ERROR_TOO_LONG, -1 },
|
||||||
/* 64*/ { "61954993+1", 0, 0 },
|
/* 64*/ { "3954994+", 0, 0 },
|
||||||
/* 65*/ { "61954993+X", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 65*/ { "3954X94+", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 66*/ { "619549X3+1", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 66*/ { "61954993+1", 0, 0 },
|
||||||
/* 67*/ { "61954992+123", ZINT_ERROR_INVALID_CHECK, -1 },
|
/* 67*/ { "61954993+X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 68*/ { "61954993+123", 0, 0 },
|
/* 68*/ { "619549X3+1", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 69*/ { "61954993+12X", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 69*/ { "61954992+123", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||||
/* 70*/ { "619549X3+123", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 70*/ { "61954993+123", 0, 0 },
|
||||||
/* 71*/ { "361954990+12", ZINT_ERROR_INVALID_CHECK, -1 },
|
/* 71*/ { "61954993+12X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 72*/ { "361954999+12", 0, 0 },
|
/* 72*/ { "619549X3+123", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 73*/ { "361954999+1X", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 73*/ { "361954990+12", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||||
/* 74*/ { "3619549X9+12", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 74*/ { "361954999+12", 0, 0 },
|
||||||
/* 75*/ { "361954999+1234", 0, 0 },
|
/* 75*/ { "361954999+1X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 76*/ { "361954999+123X", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 76*/ { "3619549X9+12", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 77*/ { "3619549X9+1234", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 77*/ { "361954999+1234", 0, 0 },
|
||||||
/* 78*/ { "1999000030+12", ZINT_ERROR_INVALID_CHECK, -1 },
|
/* 78*/ { "361954999+123X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 79*/ { "199900003X+12", 0, 0 },
|
/* 79*/ { "3619549X9+1234", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 80*/ { "199900003x+12", 0, 0 },
|
/* 80*/ { "1999000030+12", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||||
/* 81*/ { "19990000XX+12", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 81*/ { "199900003X+12", 0, 0 },
|
||||||
/* 82*/ { "199900003X+1X", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 82*/ { "199900003x+12", 0, 0 },
|
||||||
/* 83*/ { "1999000031+12345", ZINT_ERROR_INVALID_CHECK, -1 },
|
/* 83*/ { "19990000XX+12", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 84*/ { "199900003X+12345", 0, 0 },
|
/* 84*/ { "199900003X+1X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 85*/ { "199900003x+12345", 0, 0 },
|
/* 85*/ { "1999000031+12345", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||||
/* 86*/ { "199900003X+1234X", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 86*/ { "199900003X+12345", 0, 0 },
|
||||||
/* 87*/ { "19990000XX+12345", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 87*/ { "199900003x+12345", 0, 0 },
|
||||||
/* 88*/ { "9791234567895+12", ZINT_ERROR_INVALID_CHECK, -1 },
|
/* 88*/ { "199900003X+1234X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 89*/ { "9791234567896+12", 0, 0 },
|
/* 89*/ { "19990000XX+12345", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 90*/ { "9791234567896+1X", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 90*/ { "199900003X+1234A", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 91*/ { "97912345678X6+12", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 91*/ { "9791234567895+12", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||||
/* 92*/ { "9791234567897+12345", ZINT_ERROR_INVALID_CHECK, -1 },
|
/* 92*/ { "9791234567896+12", 0, 0 },
|
||||||
/* 93*/ { "9791234567896+12345", 0, 0 },
|
/* 93*/ { "9791234567896+1X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 94*/ { "9791234567896+1234X", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 94*/ { "97912345678X6+12", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 95*/ { "979123456X896+12345", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 95*/ { "9791234567897+12345", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||||
/* 96*/ { "9791234567892+", ZINT_ERROR_INVALID_CHECK, -1 },
|
/* 96*/ { "9791234567896+12345", 0, 0 },
|
||||||
/* 97*/ { "9791234567896+", 0, 0 },
|
/* 97*/ { "9791234567896+1234X", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 98*/ { "97912345678X6+", ZINT_ERROR_INVALID_DATA, -1 },
|
/* 98*/ { "979123456X896+12345", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
/* 99*/ { "97912345678961+", ZINT_ERROR_TOO_LONG, -1 },
|
/* 99*/ { "9791234567892+", ZINT_ERROR_INVALID_CHECK, -1 },
|
||||||
/*100*/ { "97912345678961+12345", ZINT_ERROR_TOO_LONG, -1 },
|
/*100*/ { "9791234567896+", 0, 0 },
|
||||||
/*101*/ { "9791234567896+123456", ZINT_ERROR_TOO_LONG, -1 },
|
/*101*/ { "97912345678X6+", ZINT_ERROR_INVALID_DATA, -1 },
|
||||||
|
/*102*/ { "97912345678961+", ZINT_ERROR_TOO_LONG, -1 },
|
||||||
|
/*103*/ { "97912345678961+12345", ZINT_ERROR_TOO_LONG, -1 },
|
||||||
|
/*104*/ { "9791234567896+123456", ZINT_ERROR_TOO_LONG, -1 },
|
||||||
};
|
};
|
||||||
int data_size = ARRAY_SIZE(data);
|
int data_size = ARRAY_SIZE(data);
|
||||||
int i, length, ret;
|
int i, length, ret;
|
||||||
@ -547,6 +575,100 @@ static void test_isbn_input(int index, int debug) {
|
|||||||
testFinish();
|
testFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_hrt(int index, int debug) {
|
||||||
|
|
||||||
|
struct item {
|
||||||
|
int symbology;
|
||||||
|
char *data;
|
||||||
|
int ret;
|
||||||
|
char *expected;
|
||||||
|
};
|
||||||
|
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||||
|
struct item data[] = {
|
||||||
|
/* 0*/ { BARCODE_EANX, "12345678901", 0, "0123456789012" },
|
||||||
|
/* 1*/ { BARCODE_EANX, "123456789012", 0, "1234567890128" },
|
||||||
|
/* 2*/ { BARCODE_EANX, "1234567890128", 0, "1234567890128" }, // EANX accepts CHK (treated as such if no leading zeroes required)
|
||||||
|
/* 3*/ { BARCODE_EANX_CHK, "1234567890128", 0, "1234567890128" },
|
||||||
|
/* 4*/ { BARCODE_EANX_CHK, "123456789012", 0, "0123456789012" }, // '2' happens to be correct check digit for "012345678901"
|
||||||
|
/* 5*/ { BARCODE_EANX, "1234567890128+1", 0, "1234567890128+01" },
|
||||||
|
/* 6*/ { BARCODE_EANX_CHK, "1234567890128+1", 0, "1234567890128+01" },
|
||||||
|
/* 7*/ { BARCODE_EANX, "12345678", 0, "0000123456784" },
|
||||||
|
/* 8*/ { BARCODE_EANX, "1234567", 0, "12345670" }, // EAN-8
|
||||||
|
/* 9*/ { BARCODE_EANX_CHK, "12345670", 0, "12345670" }, // EAN-8
|
||||||
|
/* 10*/ { BARCODE_EANX, "123456", 0, "01234565" }, // EAN-8
|
||||||
|
/* 11*/ { BARCODE_EANX_CHK, "123457", 0, "00123457" }, // EAN-8
|
||||||
|
/* 12*/ { BARCODE_EANX, "12345", 0, "12345" }, // EAN-5
|
||||||
|
/* 13*/ { BARCODE_EANX, "123", 0, "00123" }, // EAN-5
|
||||||
|
/* 14*/ { BARCODE_EANX, "12", 0, "12" }, // EAN-2
|
||||||
|
/* 15*/ { BARCODE_EANX, "1", 0, "01" }, // EAN-2
|
||||||
|
/* 16*/ { BARCODE_EANX, "0", 0, "00" }, // EAN-2
|
||||||
|
/* 17*/ { BARCODE_ISBNX, "0", 0, "9780000000002" },
|
||||||
|
/* 18*/ { BARCODE_ISBNX, "123456789X", 0, "9781234567897" },
|
||||||
|
/* 19*/ { BARCODE_ISBNX, "9781234567897", 0, "9781234567897" },
|
||||||
|
/* 20*/ { BARCODE_ISBNX, "9791234567896+12", 0, "9791234567896+12" },
|
||||||
|
/* 21*/ { BARCODE_UPCA, "12345678901", 0, "123456789012" },
|
||||||
|
/* 22*/ { BARCODE_UPCA, "123456789012", 0, "123456789012" },
|
||||||
|
/* 23*/ { BARCODE_UPCA_CHK, "123456789012", 0, "123456789012" },
|
||||||
|
/* 24*/ { BARCODE_UPCA, "12345678905+1", 0, "123456789050+01" },
|
||||||
|
/* 25*/ { BARCODE_UPCA_CHK, "123456789050+1", 0, "123456789050+01" },
|
||||||
|
/* 26*/ { BARCODE_UPCA, "123456789050+123", 0, "123456789050+00123" },
|
||||||
|
/* 27*/ { BARCODE_UPCA_CHK, "123456789050+123", 0, "123456789050+00123" },
|
||||||
|
/* 28*/ { BARCODE_UPCE, "12345", 0, "00123457" }, // equivalent: 00123400005, hrt: 00123457, Check digit: 7
|
||||||
|
/* 29*/ { BARCODE_UPCE_CHK, "12344", 0, "00012344" }, // equivalent: 00012000003, hrt: 00012344, Check digit: 4
|
||||||
|
/* 30*/ { BARCODE_UPCE, "123456", 0, "01234565" }, // equivalent: 01234500006, hrt: 01234565, Check digit: 5
|
||||||
|
/* 31*/ { BARCODE_UPCE_CHK, "123457", 0, "00123457" }, // equivalent: 00123400005, hrt: 00123457, Check digit: 7
|
||||||
|
/* 32*/ { BARCODE_UPCE, "1234567", 0, "12345670" }, // equivalent: 12345600007, hrt: 12345670, Check digit: 0
|
||||||
|
/* 33*/ { BARCODE_UPCE_CHK, "1234565", 0, "01234565" }, // equivalent: 01234500006, hrt: 01234565, Check digit: 5
|
||||||
|
/* 34*/ { BARCODE_UPCE_CHK, "12345670", 0, "12345670" }, // equivalent: 12345600007, hrt: 12345670, Check digit: 0
|
||||||
|
/* 35*/ { BARCODE_UPCE, "2345678", 0, "03456781" }, // 2 ignored, equivalent: 03456700008, hrt: 03456781, Check digit: 1
|
||||||
|
/* 36*/ { BARCODE_UPCE_CHK, "23456781", 0, "03456781" }, // 2 ignored, equivalent: 03456700008, hrt: 03456781, Check digit: 1
|
||||||
|
/* 37*/ { BARCODE_UPCE, "123455", 0, "01234558" }, // equivalent: 01234500005, hrt: 01234558, Check digit: 8 (BS 797 Rule 3 (a))
|
||||||
|
/* 38*/ { BARCODE_UPCE_CHK, "1234558", 0, "01234558" }, // equivalent: 01234500005, hrt: 01234558, Check digit: 8 (BS 797 Rule 3 (a))
|
||||||
|
/* 39*/ { BARCODE_UPCE, "456784", 0, "04567840" }, // equivalent: 04567000008, hrt: 04567840, Check digit: 0 (BS 797 Rule 3 (b))
|
||||||
|
/* 40*/ { BARCODE_UPCE_CHK, "4567840", 0, "04567840" }, // equivalent: 04567000008, hrt: 04567840, Check digit: 0 (BS 797 Rule 3 (b))
|
||||||
|
/* 41*/ { BARCODE_UPCE, "345670", 0, "03456703" }, // equivalent: 03400000567, hrt: 03456703, Check digit: 3 (BS 797 Rule 3 (c))
|
||||||
|
/* 42*/ { BARCODE_UPCE_CHK, "3456703", 0, "03456703" }, // equivalent: 03400000567, hrt: 03456703, Check digit: 3 (BS 797 Rule 3 (c))
|
||||||
|
/* 43*/ { BARCODE_UPCE, "984753", 0, "09847531" }, // equivalent: 09840000075, hrt: 09847531, Check digit: 1 (BS 797 Rule 3 (d))
|
||||||
|
/* 44*/ { BARCODE_UPCE_CHK, "9847531", 0, "09847531" }, // equivalent: 09840000075, hrt: 09847531, Check digit: 1 (BS 797 Rule 3 (d))
|
||||||
|
/* 45*/ { BARCODE_UPCE, "123453", 0, "01234531" },
|
||||||
|
/* 46*/ { BARCODE_UPCE, "000000", 0, "00000000" },
|
||||||
|
/* 47*/ { BARCODE_UPCE, "0000000", 0, "00000000" },
|
||||||
|
/* 48*/ { BARCODE_UPCE, "1000000", 0, "10000007" },
|
||||||
|
/* 49*/ { BARCODE_UPCE, "2000000", 0, "00000000" }, // First char 2-9 ignored, replaced with 0
|
||||||
|
/* 50*/ { BARCODE_UPCE, "3000000", 0, "00000000" },
|
||||||
|
/* 51*/ { BARCODE_UPCE, "8000000", 0, "00000000" },
|
||||||
|
/* 52*/ { BARCODE_UPCE, "9000000", 0, "00000000" },
|
||||||
|
/* 53*/ { BARCODE_UPCE, "1234567+1", 0, "12345670+01" },
|
||||||
|
/* 54*/ { BARCODE_UPCE, "12345670+1", 0, "12345670+01" },
|
||||||
|
/* 55*/ { BARCODE_UPCE_CHK, "12345670+1", 0, "12345670+01" },
|
||||||
|
/* 56*/ { BARCODE_UPCE_CHK, "1234565+1", 0, "01234565+01" },
|
||||||
|
};
|
||||||
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
int i, length, ret;
|
||||||
|
struct zint_symbol *symbol;
|
||||||
|
|
||||||
|
testStart("test_hrt");
|
||||||
|
|
||||||
|
for (i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
|
if (index != -1 && i != index) continue;
|
||||||
|
|
||||||
|
symbol = ZBarcode_Create();
|
||||||
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
|
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||||
|
|
||||||
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||||
|
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
|
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||||
|
|
||||||
|
ZBarcode_Delete(symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
testFinish();
|
||||||
|
}
|
||||||
|
|
||||||
static void test_vector_same(int index, int debug) {
|
static void test_vector_same(int index, int debug) {
|
||||||
|
|
||||||
struct item {
|
struct item {
|
||||||
@ -841,6 +963,7 @@ int main(int argc, char *argv[]) {
|
|||||||
{ "test_upca_input", test_upca_input, 1, 0, 1 },
|
{ "test_upca_input", test_upca_input, 1, 0, 1 },
|
||||||
{ "test_eanx_input", test_eanx_input, 1, 0, 1 },
|
{ "test_eanx_input", test_eanx_input, 1, 0, 1 },
|
||||||
{ "test_isbn_input", test_isbn_input, 1, 0, 1 },
|
{ "test_isbn_input", test_isbn_input, 1, 0, 1 },
|
||||||
|
{ "test_hrt", test_hrt, 1, 0, 1 },
|
||||||
{ "test_vector_same", test_vector_same, 1, 0, 1 },
|
{ "test_vector_same", test_vector_same, 1, 0, 1 },
|
||||||
{ "test_encode", test_encode, 1, 1, 1 },
|
{ "test_encode", test_encode, 1, 1, 1 },
|
||||||
{ "test_fuzz", test_fuzz, 1, 0, 1 },
|
{ "test_fuzz", test_fuzz, 1, 0, 1 },
|
||||||
|
@ -161,29 +161,39 @@ static int upca(struct zint_symbol *symbol, const unsigned char source[], int le
|
|||||||
static int upce_cc(struct zint_symbol *symbol, unsigned char source[], int length, char dest[], int cc_rows) {
|
static int upce_cc(struct zint_symbol *symbol, unsigned char source[], int length, char dest[], int cc_rows) {
|
||||||
int i, num_system;
|
int i, num_system;
|
||||||
char emode, check_digit, parity[8];
|
char emode, check_digit, parity[8];
|
||||||
|
char src_check_digit = '\0';
|
||||||
unsigned char equivalent[12];
|
unsigned char equivalent[12];
|
||||||
char hrt[9];
|
char hrt[9];
|
||||||
float height;
|
float height;
|
||||||
int error_number = 0;
|
int error_number = 0;
|
||||||
|
|
||||||
|
if (length == 8 || symbol->symbology == BARCODE_UPCE_CHK) {
|
||||||
|
/* Will validate later */
|
||||||
|
src_check_digit = source[--length];
|
||||||
|
}
|
||||||
|
|
||||||
/* Two number systems can be used - system 0 and system 1 */
|
/* Two number systems can be used - system 0 and system 1 */
|
||||||
if ((symbol->symbology != BARCODE_UPCE_CHK && length == 7) || length == 8) {
|
hrt[0] = '\0';
|
||||||
|
if (length == 7) {
|
||||||
switch (source[0]) {
|
switch (source[0]) {
|
||||||
case '0': num_system = 0;
|
case '0': num_system = 0;
|
||||||
|
ustrncat(hrt, source, length);
|
||||||
break;
|
break;
|
||||||
case '1': num_system = 1;
|
case '1': num_system = 1;
|
||||||
|
ustrncat(hrt, source, length);
|
||||||
break;
|
break;
|
||||||
default: num_system = 0;
|
default: num_system = 0;
|
||||||
/* First source char ignored */
|
/* First source char ignored */
|
||||||
|
ustrncat(hrt, source, length);
|
||||||
|
hrt[0] = '0'; /* Overwrite HRT first char with '0' to correct TODO: error/warn in future */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ustrcpy(hrt, source);
|
|
||||||
for (i = 1; i <= length; i++) {
|
for (i = 1; i <= length; i++) {
|
||||||
source[i - 1] = hrt[i];
|
source[i - 1] = hrt[i];
|
||||||
}
|
}
|
||||||
length--;
|
length--;
|
||||||
} else {
|
} else {
|
||||||
/* Length 6 with no check digit, or length 7 with check digit, system 0, insert leading zero */
|
/* Length 6, insert leading zero */
|
||||||
num_system = 0;
|
num_system = 0;
|
||||||
hrt[0] = '0';
|
hrt[0] = '0';
|
||||||
hrt[1] = '\0';
|
hrt[1] = '\0';
|
||||||
@ -252,6 +262,11 @@ static int upce_cc(struct zint_symbol *symbol, unsigned char source[], int lengt
|
|||||||
|
|
||||||
check_digit = gs1_check_digit(equivalent, 11);
|
check_digit = gs1_check_digit(equivalent, 11);
|
||||||
|
|
||||||
|
if (src_check_digit && src_check_digit != check_digit) {
|
||||||
|
sprintf(symbol->errtxt, "274: Invalid check digit '%c', expecting '%c'", src_check_digit, check_digit);
|
||||||
|
return ZINT_ERROR_INVALID_CHECK;
|
||||||
|
}
|
||||||
|
|
||||||
/* Use the number system and check digit information to choose a parity scheme */
|
/* Use the number system and check digit information to choose a parity scheme */
|
||||||
if (num_system == 1) {
|
if (num_system == 1) {
|
||||||
strcpy(parity, UPCParity1[ctoi(check_digit)]);
|
strcpy(parity, UPCParity1[ctoi(check_digit)]);
|
||||||
@ -276,15 +291,9 @@ static int upce_cc(struct zint_symbol *symbol, unsigned char source[], int lengt
|
|||||||
/* stop character */
|
/* stop character */
|
||||||
strcat(dest, "111111");
|
strcat(dest, "111111");
|
||||||
|
|
||||||
if (symbol->symbology != BARCODE_UPCE_CHK) {
|
|
||||||
hrt[7] = check_digit;
|
hrt[7] = check_digit;
|
||||||
hrt[8] = '\0';
|
hrt[8] = '\0';
|
||||||
} else {
|
|
||||||
if (hrt[7] != check_digit) {
|
|
||||||
sprintf(symbol->errtxt, "274: Invalid check digit '%c', expecting '%c'", hrt[7], check_digit);
|
|
||||||
return ZINT_ERROR_INVALID_CHECK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||||
printf("UPC-E: %s, equivalent: %s, hrt: %s, Check digit: %c\n", source, equivalent, hrt, check_digit);
|
printf("UPC-E: %s, equivalent: %s, hrt: %s, Check digit: %c\n", source, equivalent, hrt, check_digit);
|
||||||
}
|
}
|
||||||
@ -898,7 +907,7 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
|
|||||||
symbol->rows += 3;
|
symbol->rows += 3;
|
||||||
error_number = ean13_cc(symbol, first_part, first_part_len, dest, cc_rows);
|
error_number = ean13_cc(symbol, first_part, first_part_len, dest, cc_rows);
|
||||||
break;
|
break;
|
||||||
default: strcpy(symbol->errtxt, "287: Input wrong length (6, 12 or 13 characters only)");
|
default: strcpy(symbol->errtxt, "287: Input wrong length (7, 12 or 13 characters only)");
|
||||||
return ZINT_ERROR_TOO_LONG;
|
return ZINT_ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -907,7 +916,7 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
|
|||||||
if ((first_part_len == 11) || (first_part_len == 12)) {
|
if ((first_part_len == 11) || (first_part_len == 12)) {
|
||||||
error_number = upca(symbol, first_part, first_part_len, dest);
|
error_number = upca(symbol, first_part, first_part_len, dest);
|
||||||
} else {
|
} else {
|
||||||
strcpy(symbol->errtxt, "288: Input wrong length (11 or 12 characters only)");
|
strcpy(symbol->errtxt, "288: Input wrong length (12 character maximum)");
|
||||||
return ZINT_ERROR_TOO_LONG;
|
return ZINT_ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -925,21 +934,21 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
|
|||||||
symbol->rows += 3;
|
symbol->rows += 3;
|
||||||
error_number = upca_cc(symbol, first_part, first_part_len, dest, cc_rows);
|
error_number = upca_cc(symbol, first_part, first_part_len, dest, cc_rows);
|
||||||
} else {
|
} else {
|
||||||
strcpy(symbol->errtxt, "289: Input wrong length (11 or 12 characters only)");
|
strcpy(symbol->errtxt, "289: Input wrong length (12 character maximum)");
|
||||||
return ZINT_ERROR_TOO_LONG;
|
return ZINT_ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_UPCE:
|
case BARCODE_UPCE:
|
||||||
case BARCODE_UPCE_CHK:
|
case BARCODE_UPCE_CHK:
|
||||||
if ((first_part_len >= 6) && (first_part_len <= (symbol->symbology == BARCODE_UPCE ? 7 : 8))) {
|
if ((first_part_len >= 6) && (first_part_len <= 8)) {
|
||||||
error_number = upce(symbol, first_part, first_part_len, dest);
|
error_number = upce(symbol, first_part, first_part_len, dest);
|
||||||
} else {
|
} else {
|
||||||
strcpy(symbol->errtxt, "290: Input wrong length (7 or 8 characters only)");
|
strcpy(symbol->errtxt, "290: Input wrong length (8 character maximum)");
|
||||||
return ZINT_ERROR_TOO_LONG;
|
return ZINT_ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_UPCE_CC:
|
case BARCODE_UPCE_CC:
|
||||||
if ((first_part_len >= 6) && (first_part_len <= 7)) {
|
if ((first_part_len >= 6) && (first_part_len <= 8)) {
|
||||||
set_module(symbol, symbol->rows, 1);
|
set_module(symbol, symbol->rows, 1);
|
||||||
set_module(symbol, symbol->rows, 51);
|
set_module(symbol, symbol->rows, 51);
|
||||||
set_module(symbol, symbol->rows + 1, 0);
|
set_module(symbol, symbol->rows + 1, 0);
|
||||||
@ -952,7 +961,7 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
|
|||||||
symbol->rows += 3;
|
symbol->rows += 3;
|
||||||
error_number = upce_cc(symbol, first_part, first_part_len, dest, cc_rows);
|
error_number = upce_cc(symbol, first_part, first_part_len, dest, cc_rows);
|
||||||
} else {
|
} else {
|
||||||
strcpy(symbol->errtxt, "291: Input wrong length (7 or 8 characters only)");
|
strcpy(symbol->errtxt, "291: Input wrong length (8 character maximum)");
|
||||||
return ZINT_ERROR_TOO_LONG;
|
return ZINT_ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -328,44 +328,63 @@ extern "C" {
|
|||||||
|
|
||||||
/* Create and initialize a symbol structure */
|
/* Create and initialize a symbol structure */
|
||||||
ZINT_EXTERN struct zint_symbol *ZBarcode_Create(void);
|
ZINT_EXTERN struct zint_symbol *ZBarcode_Create(void);
|
||||||
|
|
||||||
/* Free any output buffers that may have been created and initialize output fields */
|
/* Free any output buffers that may have been created and initialize output fields */
|
||||||
ZINT_EXTERN void ZBarcode_Clear(struct zint_symbol *symbol);
|
ZINT_EXTERN void ZBarcode_Clear(struct zint_symbol *symbol);
|
||||||
|
|
||||||
/* Free a symbol structure, including any output buffers */
|
/* Free a symbol structure, including any output buffers */
|
||||||
ZINT_EXTERN void ZBarcode_Delete(struct zint_symbol *symbol);
|
ZINT_EXTERN void ZBarcode_Delete(struct zint_symbol *symbol);
|
||||||
|
|
||||||
|
|
||||||
/* Encode a barcode. If `length` is 0, `source` must be NUL-terminated. */
|
/* Encode a barcode. If `length` is 0, `source` must be NUL-terminated. */
|
||||||
ZINT_EXTERN int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int length);
|
ZINT_EXTERN int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int length);
|
||||||
|
|
||||||
/* Encode a barcode using input data from file `filename` */
|
/* Encode a barcode using input data from file `filename` */
|
||||||
ZINT_EXTERN int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename);
|
ZINT_EXTERN int ZBarcode_Encode_File(struct zint_symbol *symbol, const char *filename);
|
||||||
|
|
||||||
/* Output a previously encoded symbol to file `symbol->outfile` */
|
/* Output a previously encoded symbol to file `symbol->outfile` */
|
||||||
ZINT_EXTERN int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle);
|
ZINT_EXTERN int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle);
|
||||||
|
|
||||||
|
|
||||||
/* Encode and output a symbol to file `symbol->outfile` */
|
/* Encode and output a symbol to file `symbol->outfile` */
|
||||||
ZINT_EXTERN int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *source, int length,
|
ZINT_EXTERN int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, const unsigned char *source, int length,
|
||||||
int rotate_angle);
|
int rotate_angle);
|
||||||
|
|
||||||
/* Encode a symbol using input data from file `filename` and output to file `symbol->outfile` */
|
/* Encode a symbol using input data from file `filename` and output to file `symbol->outfile` */
|
||||||
ZINT_EXTERN int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename, int rotate_angle);
|
ZINT_EXTERN int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, const char *filename,
|
||||||
|
int rotate_angle);
|
||||||
|
|
||||||
|
|
||||||
/* Output a previously encoded symbol to memory as raster (`symbol->bitmap`) */
|
/* Output a previously encoded symbol to memory as raster (`symbol->bitmap`) */
|
||||||
ZINT_EXTERN int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle);
|
ZINT_EXTERN int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle);
|
||||||
|
|
||||||
|
/* Encode and output a symbol to memory as raster (`symbol->bitmap`) */
|
||||||
|
ZINT_EXTERN int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, const unsigned char *source, int length,
|
||||||
|
int rotate_angle);
|
||||||
|
|
||||||
|
/* Encode a symbol using input data from file `filename` and output to memory as raster (`symbol->bitmap`) */
|
||||||
|
ZINT_EXTERN int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, const char *filename,
|
||||||
|
int rotate_angle);
|
||||||
|
|
||||||
|
|
||||||
/* Output a previously encoded symbol to memory as vector (`symbol->vector`) */
|
/* Output a previously encoded symbol to memory as vector (`symbol->vector`) */
|
||||||
ZINT_EXTERN int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle);
|
ZINT_EXTERN int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle);
|
||||||
/* Encode and output a symbol to memory as raster (`symbol->bitmap`) */
|
|
||||||
ZINT_EXTERN int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *source, int length,
|
|
||||||
int rotate_angle);
|
|
||||||
/* Encode and output a symbol to memory as vector (`symbol->vector`) */
|
/* Encode and output a symbol to memory as vector (`symbol->vector`) */
|
||||||
ZINT_EXTERN int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol, unsigned char *source, int length,
|
ZINT_EXTERN int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol, const unsigned char *source,
|
||||||
int rotate_angle);
|
int length, int rotate_angle);
|
||||||
/* Encode a symbol using input data from file `filename` and output to memory as raster (`symbol->bitmap`) */
|
|
||||||
ZINT_EXTERN int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char *filename, int rotate_angle);
|
|
||||||
/* Encode a symbol using input data from file `filename` and output to memory as vector (`symbol->vector`) */
|
/* Encode a symbol using input data from file `filename` and output to memory as vector (`symbol->vector`) */
|
||||||
ZINT_EXTERN int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol, char *filename,
|
ZINT_EXTERN int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol, const char *filename,
|
||||||
int rotate_angle);
|
int rotate_angle);
|
||||||
|
|
||||||
|
|
||||||
/* Is `symbol_id` a recognized symbology? */
|
/* Is `symbol_id` a recognized symbology? */
|
||||||
ZINT_EXTERN int ZBarcode_ValidID(int symbol_id);
|
ZINT_EXTERN int ZBarcode_ValidID(int symbol_id);
|
||||||
|
|
||||||
/* Return the capability flags for symbology `symbol_id` that match `cap_flag` */
|
/* Return the capability flags for symbology `symbol_id` that match `cap_flag` */
|
||||||
ZINT_EXTERN unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag);
|
ZINT_EXTERN unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag);
|
||||||
|
|
||||||
/* Return the version of Zint linked to */
|
/* Return the version of Zint linked to */
|
||||||
ZINT_EXTERN int ZBarcode_Version();
|
ZINT_EXTERN int ZBarcode_Version();
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ file formats. Vector is a high level command- or data-based representation of an
|
|||||||
image. EMF, EPS and SVG are vector file formats. They require renderers to turn
|
image. EMF, EPS and SVG are vector file formats. They require renderers to turn
|
||||||
them into bitmaps.
|
them into bitmaps.
|
||||||
|
|
||||||
|
|
||||||
2. Installing Zint
|
2. Installing Zint
|
||||||
==================
|
==================
|
||||||
|
|
||||||
@ -96,8 +97,12 @@ utilities. You will need to install CMake and libpng first. Note that you will
|
|||||||
need both libpng and libpng-devel packages. If you want to take advantage of
|
need both libpng and libpng-devel packages. If you want to take advantage of
|
||||||
Zint Barcode Studio you will also need the Qt libraries pre-installed.
|
Zint Barcode Studio you will also need the Qt libraries pre-installed.
|
||||||
|
|
||||||
Once you have fulfilled these requirements unzip the source code tarball and
|
Once you have fulfilled these requirements unzip the source code tarball or
|
||||||
follow these steps in the top directory:
|
clone the latest source
|
||||||
|
|
||||||
|
git clone https://git.code.sf.net/p/zint/code zint
|
||||||
|
|
||||||
|
and follow these steps in the top directory:
|
||||||
|
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
@ -136,6 +141,8 @@ a free and open-source software project with no advertising and hence no
|
|||||||
income, meaning we are not able to afford the $664 per year to have the
|
income, meaning we are not able to afford the $664 per year to have the
|
||||||
application digitally signed by Microsoft.
|
application digitally signed by Microsoft.
|
||||||
|
|
||||||
|
To build Zint on Windows from source, see "win32/README".
|
||||||
|
|
||||||
2.3 Apple macOS
|
2.3 Apple macOS
|
||||||
---------------
|
---------------
|
||||||
Zint can be installed using Homebrew. To install homebrew input the following
|
Zint can be installed using Homebrew. To install homebrew input the following
|
||||||
|
Loading…
Reference in New Issue
Block a user