1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-08-07 05:48:54 +00:00

DATAMATRIX: add manual FNC1 support

CODE128: error on unrecognized extra escape sequences instead of
  just passing them thru;
  fix possible shifting before manual FNC1 in 2nd position
  after single alpha (otherwise won't be recognized as AIM)
  fix not removing manual FNC1 in 1st/2nd position from content
  segs (as implied by symbology identifier)
CLI: warn if both "--dmre" and "--square" given (as "--square"
  overwrites "--dmre")
common: new routines `z_isalpha()`, `z_extra_escapes()` and
  `z_ct_set_seg_extra_escapes_eci()`
library: new helper `supports_extra_escape_mode()`;
  fix some error_number dups
BWIPP: update to latest, and allow for removal of DBAR_LTD_CC RHS
  quiet zones & extra row when have add-on in EAN/UPC composites
test suite: fix BWIPP escaping
manual/man/tcl: update for DATAMATRIX manual FNC1 support
Windows: resource scripts: make more consistent (libzint, CLI, GUI)
win32/README: update with MSVC 2026
This commit is contained in:
gitlost
2026-04-18 22:55:52 +01:00
parent f9a493522f
commit 7b076717f2
30 changed files with 1650 additions and 869 deletions
+120 -83
View File
@@ -204,83 +204,113 @@ static void test_hrt(const testCtx *const p_ctx) {
int expected_length;
const char *expected_content;
int expected_content_length;
int bwipp_cmp;
int zxingcpp_cmp;
const char *comment;
};
/*
é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII
*/
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "1234567890", -1, "1234567890", -1, "", -1, 1 },
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "1234567890", -1, "1234567890", -1, "1234567890", -1, 1 },
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "\000ABC\000DEF\000", 9, " ABC DEF ", -1, "", -1, 1 },
/* 3*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "\000ABC\000DEF\000", 9, " ABC DEF ", -1, "\000ABC\000DEF\000", 9, 1 }, /* No replacements */
/* 4*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, -1, "12345\00067890", 11, "12345 67890", -1, "", -1, 1 },
/* 5*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "12345\00067890", 11, "12345 67890", -1, "12345\00067890", 11, 1 },
/* 6*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "12345\01167890\037\177", -1, "12345 67890 ", -1, "", -1, 1 },
/* 7*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "12345\01167890\037\177", -1, "12345 67890 ", -1, "12345\01167890\037\177", -1, 1 },
/* 8*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "abcdé", -1, "abcdé", -1, "", -1, 1 },
/* 9*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "abcdé", -1, "abcdé", -1, "abcdé", -1, 1 }, /* Now UTF-8, not converted */
/* 10*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "abcdé\302\240", -1, "abcdé\302\240", -1, "", -1, 1 }, /* \302\240 (U+A0) NBSP */
/* 11*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "abcdé\302\240", -1, "abcdé\302\240", -1, "abcdé\302\240", -1, 1 },
/* 12*/ { BARCODE_CODE128, DATA_MODE, -1, -1, "abcd\351", -1, "abcdé", -1, "", -1, 899 },
/* 13*/ { BARCODE_CODE128, DATA_MODE, -1, BARCODE_CONTENT_SEGS, "abcd\351", -1, "abcdé", -1, "abcd\351", -1, 899 },
/* 14*/ { BARCODE_CODE128, DATA_MODE, -1, -1, "ab\240cd\351", -1, "ab\302\240cdé", -1, "", -1, 899 }, /* \240 (U+A0) NBSP */
/* 15*/ { BARCODE_CODE128, DATA_MODE, -1, BARCODE_CONTENT_SEGS, "ab\240cd\351", -1, "ab\302\240cdé", -1, "ab\240cd\351", -1, 899 },
/* 16*/ { BARCODE_CODE128, DATA_MODE, -1, -1, "ab\200cd\351", -1, "ab cdé", -1, "", -1, 899 }, /* \200 (U+80) non-ISO/IEC 8859-1 */
/* 17*/ { BARCODE_CODE128, DATA_MODE, -1, BARCODE_CONTENT_SEGS, "ab\200cd\351", -1, "ab cdé", -1, "ab\200cd\351", -1, 899 },
/* 18*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, "", -1, 1 }, /* Max length 198 + 19 special escapes = 99 + 19*3 = 255 */
/* 19*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, 1 },
/* 20*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, -1, "abcdé", -1, "abcdé", -1, "", -1, 1 },
/* 21*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "abcdé", -1, "abcdé", -1, "abcdé", -1, 1 },
/* 22*/ { BARCODE_CODE128AB, DATA_MODE, -1, -1, "abcd\351", -1, "abcdé", -1, "", -1, 899 },
/* 23*/ { BARCODE_CODE128AB, DATA_MODE, -1, BARCODE_CONTENT_SEGS, "abcd\351", -1, "abcdé", -1, "abcd\351", -1, 899 },
/* 24*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, -1, "1234567890", -1, "*+12345678900*", -1, "", -1, 1 },
/* 25*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "1234567890", -1, "*+12345678900*", -1, "+12345678900", -1, 1 },
/* 26*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, -1, "a99912345", -1, "*+A999123457*", -1, "", -1, 1 }, /* Converts to upper */
/* 27*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "a99912345", -1, "*+A999123457*", -1, "+A999123457", -1, 1 },
/* 28*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "000393206219912345678101040", -1, "0003 932 0621 9912 3456 78 101 040 9", -1, "", -1, 1 }, /* DPDAPPD 4.0.2 - Illustration 7 */
/* 29*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "000393206219912345678101040", -1, "0003 932 0621 9912 3456 78 101 040 9", -1, "%000393206219912345678101040", -1, 1 }, /* Includes '%', no spaces, no check digit */
/* 30*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007110601782532948375101276", -1, "0071 106 0178 2532 9483 75 101 276 X", -1, "", -1, 1 }, /* DPDAPPD 4.0.2 - Illustration 6, figure's HRT seems incorrect */
/* 31*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "007110601782532948375101276", -1, "0071 106 0178 2532 9483 75 101 276 X", -1, "%007110601782532948375101276", -1, 1 },
/* 32*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020028101276", -1, "0081 827 0998 0000 0200 28 101 276 B", -1, "", -1, 1 }, /* DPDPLS Section 4 */
/* 33*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "008182709980000020028101276", -1, "0081 827 0998 0000 0200 28 101 276 B", -1, "%008182709980000020028101276", -1, 1 },
/* 34*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007110601632532948375179276", -1, "0071 106 0163 2532 9483 75 179 276 A", -1, "", -1, 1 }, /* DPDPLS Section 4.6 */
/* 35*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "007110601632532948375179276", -1, "0071 106 0163 2532 9483 75 179 276 A", -1, "%007110601632532948375179276", -1, 1 },
/* 36*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "001990009980000020084109203", -1, "0019 900 0998 0000 0200 84 109 203 1", -1, "", -1, 1 }, /* DPDPLS Section 5.1 */
/* 37*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "001990009980000020084109203", -1, "0019 900 0998 0000 0200 84 109 203 1", -1, "%001990009980000020084109203", -1, 1 },
/* 38*/ { BARCODE_DPD, UNICODE_MODE, 1, -1, "007110601632532948375101276", -1, "0071 106 0163 2532 9483 75 101 276 O", -1, "", -1, 1 }, /* DPDPLS Section 6.1.2 relabel, figure is actually 8.7.2 with mislabelled HRT */
/* 39*/ { BARCODE_DPD, UNICODE_MODE, 1, BARCODE_CONTENT_SEGS, "007110601632532948375101276", -1, "0071 106 0163 2532 9483 75 101 276 O", -1, "007110601632532948375101276", -1, 1 }, /* No '%' */
/* 40*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020029136276", -1, "0081 827 0998 0000 0200 29 136 276 3", -1, "", -1, 1 }, /* DPDPLS Section 8.1 */
/* 41*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "001234509980000020031105276", -1, "0012 345 0998 0000 0200 31 105 276 L", -1, "", -1, 1 }, /* DPDPLS Section 8.2 */
/* 42*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020032154276", -1, "0081 827 0998 0000 0200 32 154 276 J", -1, "", -1, 1 }, /* DPDPLS Section 8.3 */
/* 43*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020030109276", -1, "0081 827 0998 0000 0200 30 109 276 W", -1, "", -1, 1 }, /* DPDPLS Section 8.4 */
/* 44*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020033350276", -1, "0081 827 0998 0000 0200 33 350 276 C", -1, "", -1, 1 }, /* DPDPLS Section 8.5.1 */
/* 45*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020034179276", -1, "0081 827 0998 0000 0200 34 179 276 I", -1, "", -1, 1 }, /* DPDPLS Section 8.5.2 */
/* 46*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020035225276", -1, "0081 827 0998 0000 0200 35 225 276 H", -1, "", -1, 1 }, /* DPDPLS Section 8.5.3 */
/* 47*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020036155276", -1, "0081 827 0998 0000 0200 36 155 276 5", -1, "", -1, 1 }, /* DPDPLS Section 8.5.4 */
/* 48*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "000280009980000020037155056", -1, "0002 800 0998 0000 0200 37 155 056 6", -1, "", -1, 1 }, /* DPDPLS Section 8.5.5 */
/* 49*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007855009980000020041302840", -1, "0078 550 0998 0000 0200 41 302 840 U", -1, "", -1, 1 }, /* DPDPLS Section 8.5.6 */
/* 50*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020042102276", -1, "0081 827 0998 0000 0200 42 102 276 R", -1, "", -1, 1 }, /* DPDPLS Section 8.6.1 */
/* 51*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020043113276", -1, "0081 827 0998 0000 0200 43 113 276 Y", -1, "", -1, 1 }, /* DPDPLS Section 8.7.1 */
/* 52*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "008182709980000020043113276", -1, "0081 827 0998 0000 0200 43 113 276 Y", -1, "%008182709980000020043113276", -1, 1 },
/* 53*/ { BARCODE_DPD, UNICODE_MODE, 1, -1, "006376209980000020044118276", -1, "0063 762 0998 0000 0200 44 118 276 I", -1, "", -1, 1 }, /* DPDPLS Section 8.7.2 relabel */
/* 54*/ { BARCODE_DPD, UNICODE_MODE, 1, BARCODE_CONTENT_SEGS, "006376209980000020044118276", -1, "0063 762 0998 0000 0200 44 118 276 I", -1, "006376209980000020044118276", -1, 1 },
/* 55*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007160009980000020050294276", -1, "0071 600 0998 0000 0200 50 294 276 C", -1, "", -1, 1 }, /* DPDPLS Section 8.8 */
/* 56*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020045327276", -1, "0081 827 0998 0000 0200 45 327 276 N", -1, "", -1, 1 }, /* DPDPLS Section 8.9.1 */
/* 57*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "006374309980000020047337276", -1, "0063 743 0998 0000 0200 47 337 276 O", -1, "", -1, 1 }, /* DPDPLS Section 8.9.2 */
/* 58*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "006374309980000020047337276", -1, "0063 743 0998 0000 0200 47 337 276 O", -1, "%006374309980000020047337276", -1, 1 },
/* 59*/ { BARCODE_DPD, UNICODE_MODE, 1, -1, "006374109980978004757332276", -1, "0063 741 0998 0978 0047 57 332 276 M", -1, "", -1, 1 }, /* DPDPLS Section 8.9.3 relabel, figure's HRT seems incorrect */
/* 60*/ { BARCODE_DPD, UNICODE_MODE, 1, BARCODE_CONTENT_SEGS, "006374109980978004757332276", -1, "0063 741 0998 0978 0047 57 332 276 M", -1, "006374109980978004757332276", -1, 1 },
/* 61*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020051106276", -1, "0081 827 0998 0000 0200 51 106 276 M", -1, "", -1, 1 }, /* DPDPLS Section 9.1 */
/* 62*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020052110276", -1, "0081 827 0998 0000 0200 52 110 276 W", -1, "", -1, 1 }, /* DPDPLS Section 9.2 */
/* 63*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020053161276", -1, "0081 827 0998 0000 0200 53 161 276 O", -1, "", -1, 1 }, /* DPDPLS Section 9.3 */
/* 64*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020054352276", -1, "0081 827 0998 0000 0200 54 352 276 B", -1, "", -1, 1 }, /* DPDPLS Section 9.4 */
/* 65*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020055191276", -1, "0081 827 0998 0000 0200 55 191 276 A", -1, "", -1, 1 }, /* DPDPLS Section 9.5 */
/* 66*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020056237276", -1, "0081 827 0998 0000 0200 56 237 276 K", -1, "", -1, 1 }, /* DPDPLS Section 9.6 */
/* 67*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "008182709980000020056237276", -1, "0081 827 0998 0000 0200 56 237 276 K", -1, "%008182709980000020056237276", -1, 1 },
/* 68*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, -1, "EE876543216CA", -1, "EE 876 543 216 CA", -1, "", -1, 1 }, /* UPU S10 Annex A */
/* 69*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "EE876543216CA", -1, "EE 876 543 216 CA", -1, "EE876543216CA", -1, 1 }, /* No spaces */
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "1234567890", -1, "1234567890", -1, "", -1, 1, 1, "" },
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "1234567890", -1, "1234567890", -1, "1234567890", -1, 1, 1, "" },
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "\000ABC\000DEF\000", 9, " ABC DEF ", -1, "", -1, 1, 1, "" },
/* 3*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "\000ABC\000DEF\000", 9, " ABC DEF ", -1, "\000ABC\000DEF\000", 9, 1, 1, "No replacements" },
/* 4*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, -1, "12345\00067890", 11, "12345 67890", -1, "", -1, 1, 1, "" },
/* 5*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "12345\00067890", 11, "12345 67890", -1, "12345\00067890", 11, 1, 1, "" },
/* 6*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "12345\01167890\037\177", -1, "12345 67890 ", -1, "", -1, 1, 1, "" },
/* 7*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "12345\01167890\037\177", -1, "12345 67890 ", -1, "12345\01167890\037\177", -1, 1, 1, "" },
/* 8*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "abcdé", -1, "abcdé", -1, "", -1, 1, 1, "" },
/* 9*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "abcdé", -1, "abcdé", -1, "abcdé", -1, 1, 1, "Now UTF-8, not converted" },
/* 10*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "abcdé\302\240", -1, "abcdé\302\240", -1, "", -1, 1, 1, "\302\240 (U+A0) NBSP" },
/* 11*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "abcdé\302\240", -1, "abcdé\302\240", -1, "abcdé\302\240", -1, 1, 1, "" },
/* 12*/ { BARCODE_CODE128, DATA_MODE, -1, -1, "abcd\351", -1, "abcdé", -1, "", -1, 1, 899, "" },
/* 13*/ { BARCODE_CODE128, DATA_MODE, -1, BARCODE_CONTENT_SEGS, "abcd\351", -1, "abcdé", -1, "abcd\351", -1, 1, 899, "" },
/* 14*/ { BARCODE_CODE128, DATA_MODE, -1, -1, "ab\240cd\351", -1, "ab\302\240cdé", -1, "", -1, 1, 899, "\240 (U+A0) NBSP" },
/* 15*/ { BARCODE_CODE128, DATA_MODE, -1, BARCODE_CONTENT_SEGS, "ab\240cd\351", -1, "ab\302\240cdé", -1, "ab\240cd\351", -1, 1, 899, "" },
/* 16*/ { BARCODE_CODE128, DATA_MODE, -1, -1, "ab\200cd\351", -1, "ab cdé", -1, "", -1, 1, 899, "\200 (U+80) non-ISO/IEC 8859-1" },
/* 17*/ { BARCODE_CODE128, DATA_MODE, -1, BARCODE_CONTENT_SEGS, "ab\200cd\351", -1, "ab cdé", -1, "ab\200cd\351", -1, 1, 899, "" },
/* 18*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, "", -1, 1, 1, "Max length 198 + 19 special escapes = 99 + 19*3 = 255" },
/* 19*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, 1, 1, "" },
/* 20*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^10412345", -1, "0412345", -1, "", -1, 1, 1, "" },
/* 21*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^10412345", -1, "0412345", -1, "0412345", -1, 1, 1, "" },
/* 22*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^1\\^1041234\\^15", -1, "0412345", -1, "", -1, 0, 1, "BWIPP: different encodation (same no. of codewords) - see below (forced mode)" },
/* 23*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^1\\^1041234\\^15", -1, "0412345", -1, "\035041234\0355", -1, 0, 1, "BWIPP - see below (forced mode)" },
/* 24*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^1\\^1041234\\^B\\^15", -1, "0412345", -1, "", -1, 1, 1, "" },
/* 25*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^1\\^1041234\\^B\\^15", -1, "0412345", -1, "\035041234\0355", -1, 1, 1, "" },
/* 26*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "A\\^1123456", -1, "A123456", -1, "", -1, 1, 1, "" },
/* 27*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "A\\^1123456", -1, "A123456", -1, "A123456", -1, 1, 1, "" },
/* 28*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "A\\^1123456\\^1", -1, "A123456", -1, "", -1, 1, 1, "" },
/* 29*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "A\\^1123456\\^1", -1, "A123456", -1, "A123456\035", -1, 1, 1, "" },
/* 30*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "?\\^1123456\\^1", -1, "?123456", -1, "", -1, 0, 1, "BWIPP: different encodation (same no. of codewords) - see below (forced mode)" },
/* 31*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "?\\^1123456\\^1", -1, "?123456", -1, "?\035123456\035", -1, 0, 1, "BWIPP - see below (forced mode)" },
/* 32*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "?\\^B\\^1\\^@123456\\^1", -1, "?123456", -1, "", -1, 1, 1, "" },
/* 33*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "?\\^B\\^1\\^@123456\\^1", -1, "?123456", -1, "?\035123456\035", -1, 1, 1, "" },
/* 34*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "12\\^1123456", -1, "12123456", -1, "", -1, 1, 1, "" },
/* 35*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "12\\^1123456", -1, "12123456", -1, "12123456", -1, 1, 1, "" },
/* 36*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "12\\^1\\^1123456", -1, "12123456", -1, "", -1, 1, 1, "" },
/* 37*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "12\\^1\\^1123456", -1, "12123456", -1, "12\035123456", -1, 1, 1, "" },
/* 38*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^C12\\^1\\^1123456", -1, "12123456", -1, "", -1, 1, 1, "" },
/* 39*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^C12\\^1\\^1123456", -1, "12123456", -1, "12\035123456", -1, 1, 1, "" },
/* 40*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "1A\\^1123456", -1, "1A123456", -1, "", -1, 0, 1, "BWIPP: different encodation (same no. of codewords)" },
/* 41*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "1A\\^1123456", -1, "1A123456", -1, "1A\035123456", -1, 0, 1, "BWIPP: as above" },
/* 42*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^1\\^1", -1, "", -1, "", -1, 0, 1, "BWIPP: different encodation (same no. of codewords) - see below (forced mode)" },
/* 43*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^1\\^1", -1, "", -1, "\035", -1, 0, 1, "BWIPP - see below (forced mode)" },
/* 44*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^B\\^1\\^1", -1, "", -1, "", -1, 1, 1, "" },
/* 45*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^B\\^1\\^1", -1, "", -1, "\035", -1, 1, 1, "" },
/* 46*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^1\\^1\\^1", -1, "", -1, "", -1, 0, 1, "BWIPP: different encodation (same no. of codewords)" },
/* 47*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^1\\^1\\^1", -1, "", -1, "\035\035", -1, 0, 1, "BWIPP: as above" },
/* 48*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, -1, "abcdé", -1, "abcdé", -1, "", -1, 1, 1, "" },
/* 49*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "abcdé", -1, "abcdé", -1, "abcdé", -1, 1, 1, "" },
/* 50*/ { BARCODE_CODE128AB, DATA_MODE, -1, -1, "abcd\351", -1, "abcdé", -1, "", -1, 1, 899, "" },
/* 51*/ { BARCODE_CODE128AB, DATA_MODE, -1, BARCODE_CONTENT_SEGS, "abcd\351", -1, "abcdé", -1, "abcd\351", -1, 1, 899, "" },
/* 52*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, -1, "1234567890", -1, "*+12345678900*", -1, "", -1, 1, 1, "" },
/* 53*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "1234567890", -1, "*+12345678900*", -1, "+12345678900", -1, 1, 1, "" },
/* 54*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, -1, "a99912345", -1, "*+A999123457*", -1, "", -1, 1, 1, "Converts to upper" },
/* 55*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "a99912345", -1, "*+A999123457*", -1, "+A999123457", -1, 1, 1, "" },
/* 56*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "000393206219912345678101040", -1, "0003 932 0621 9912 3456 78 101 040 9", -1, "", -1, 1, 1, "DPDAPPD 4.0.2 - Illustration 7" },
/* 57*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "000393206219912345678101040", -1, "0003 932 0621 9912 3456 78 101 040 9", -1, "%000393206219912345678101040", -1, 1, 1, "Includes '%', no spaces, no check digit" },
/* 58*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007110601782532948375101276", -1, "0071 106 0178 2532 9483 75 101 276 X", -1, "", -1, 1, 1, "DPDAPPD 4.0.2 - Illustration 6, figure's HRT seems incorrect" },
/* 59*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "007110601782532948375101276", -1, "0071 106 0178 2532 9483 75 101 276 X", -1, "%007110601782532948375101276", -1, 1, 1, "" },
/* 60*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020028101276", -1, "0081 827 0998 0000 0200 28 101 276 B", -1, "", -1, 1, 1, "DPDPLS Section 4" },
/* 61*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "008182709980000020028101276", -1, "0081 827 0998 0000 0200 28 101 276 B", -1, "%008182709980000020028101276", -1, 1, 1, "" },
/* 62*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007110601632532948375179276", -1, "0071 106 0163 2532 9483 75 179 276 A", -1, "", -1, 1, 1, "DPDPLS Section 4.6" },
/* 63*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "007110601632532948375179276", -1, "0071 106 0163 2532 9483 75 179 276 A", -1, "%007110601632532948375179276", -1, 1, 1, "" },
/* 64*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "001990009980000020084109203", -1, "0019 900 0998 0000 0200 84 109 203 1", -1, "", -1, 1, 1, "DPDPLS Section 5.1" },
/* 65*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "001990009980000020084109203", -1, "0019 900 0998 0000 0200 84 109 203 1", -1, "%001990009980000020084109203", -1, 1, 1, "" },
/* 66*/ { BARCODE_DPD, UNICODE_MODE, 1, -1, "007110601632532948375101276", -1, "0071 106 0163 2532 9483 75 101 276 O", -1, "", -1, 1, 1, "DPDPLS Section 6.1.2 relabel, figure is actually 8.7.2 with mislabelled HRT" },
/* 67*/ { BARCODE_DPD, UNICODE_MODE, 1, BARCODE_CONTENT_SEGS, "007110601632532948375101276", -1, "0071 106 0163 2532 9483 75 101 276 O", -1, "007110601632532948375101276", -1, 1, 1, "No '%'" },
/* 68*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020029136276", -1, "0081 827 0998 0000 0200 29 136 276 3", -1, "", -1, 1, 1, "DPDPLS Section 8.1" },
/* 69*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "001234509980000020031105276", -1, "0012 345 0998 0000 0200 31 105 276 L", -1, "", -1, 1, 1, "DPDPLS Section 8.2" },
/* 70*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020032154276", -1, "0081 827 0998 0000 0200 32 154 276 J", -1, "", -1, 1, 1, "DPDPLS Section 8.3" },
/* 71*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020030109276", -1, "0081 827 0998 0000 0200 30 109 276 W", -1, "", -1, 1, 1, "DPDPLS Section 8.4" },
/* 72*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020033350276", -1, "0081 827 0998 0000 0200 33 350 276 C", -1, "", -1, 1, 1, "DPDPLS Section 8.5.1" },
/* 73*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020034179276", -1, "0081 827 0998 0000 0200 34 179 276 I", -1, "", -1, 1, 1, "DPDPLS Section 8.5.2" },
/* 74*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020035225276", -1, "0081 827 0998 0000 0200 35 225 276 H", -1, "", -1, 1, 1, "DPDPLS Section 8.5.3" },
/* 75*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020036155276", -1, "0081 827 0998 0000 0200 36 155 276 5", -1, "", -1, 1, 1, "DPDPLS Section 8.5.4" },
/* 76*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "000280009980000020037155056", -1, "0002 800 0998 0000 0200 37 155 056 6", -1, "", -1, 1, 1, "DPDPLS Section 8.5.5" },
/* 77*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007855009980000020041302840", -1, "0078 550 0998 0000 0200 41 302 840 U", -1, "", -1, 1, 1, "DPDPLS Section 8.5.6" },
/* 78*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020042102276", -1, "0081 827 0998 0000 0200 42 102 276 R", -1, "", -1, 1, 1, "DPDPLS Section 8.6.1" },
/* 79*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020043113276", -1, "0081 827 0998 0000 0200 43 113 276 Y", -1, "", -1, 1, 1, "DPDPLS Section 8.7.1" },
/* 80*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "008182709980000020043113276", -1, "0081 827 0998 0000 0200 43 113 276 Y", -1, "%008182709980000020043113276", -1, 1, 1, "" },
/* 81*/ { BARCODE_DPD, UNICODE_MODE, 1, -1, "006376209980000020044118276", -1, "0063 762 0998 0000 0200 44 118 276 I", -1, "", -1, 1, 1, "DPDPLS Section 8.7.2 relabel" },
/* 82*/ { BARCODE_DPD, UNICODE_MODE, 1, BARCODE_CONTENT_SEGS, "006376209980000020044118276", -1, "0063 762 0998 0000 0200 44 118 276 I", -1, "006376209980000020044118276", -1, 1, 1, "" },
/* 83*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007160009980000020050294276", -1, "0071 600 0998 0000 0200 50 294 276 C", -1, "", -1, 1, 1, "DPDPLS Section 8.8" },
/* 84*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020045327276", -1, "0081 827 0998 0000 0200 45 327 276 N", -1, "", -1, 1, 1, "DPDPLS Section 8.9.1" },
/* 85*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "006374309980000020047337276", -1, "0063 743 0998 0000 0200 47 337 276 O", -1, "", -1, 1, 1, "DPDPLS Section 8.9.2" },
/* 86*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "006374309980000020047337276", -1, "0063 743 0998 0000 0200 47 337 276 O", -1, "%006374309980000020047337276", -1, 1, 1, "" },
/* 87*/ { BARCODE_DPD, UNICODE_MODE, 1, -1, "006374109980978004757332276", -1, "0063 741 0998 0978 0047 57 332 276 M", -1, "", -1, 1, 1, "DPDPLS Section 8.9.3 relabel, figure's HRT seems incorrect" },
/* 88*/ { BARCODE_DPD, UNICODE_MODE, 1, BARCODE_CONTENT_SEGS, "006374109980978004757332276", -1, "0063 741 0998 0978 0047 57 332 276 M", -1, "006374109980978004757332276", -1, 1, 1, "" },
/* 89*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020051106276", -1, "0081 827 0998 0000 0200 51 106 276 M", -1, "", -1, 1, 1, "DPDPLS Section 9.1" },
/* 90*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020052110276", -1, "0081 827 0998 0000 0200 52 110 276 W", -1, "", -1, 1, 1, "DPDPLS Section 9.2" },
/* 91*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020053161276", -1, "0081 827 0998 0000 0200 53 161 276 O", -1, "", -1, 1, 1, "DPDPLS Section 9.3" },
/* 92*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020054352276", -1, "0081 827 0998 0000 0200 54 352 276 B", -1, "", -1, 1, 1, "DPDPLS Section 9.4" },
/* 93*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020055191276", -1, "0081 827 0998 0000 0200 55 191 276 A", -1, "", -1, 1, 1, "DPDPLS Section 9.5" },
/* 94*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020056237276", -1, "0081 827 0998 0000 0200 56 237 276 K", -1, "", -1, 1, 1, "DPDPLS Section 9.6" },
/* 95*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "008182709980000020056237276", -1, "0081 827 0998 0000 0200 56 237 276 K", -1, "%008182709980000020056237276", -1, 1, 1, "" },
/* 96*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, -1, "EE876543216CA", -1, "EE 876 543 216 CA", -1, "", -1, 1, 1, "UPU S10 Annex A" },
/* 97*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "EE876543216CA", -1, "EE 876 543 216 CA", -1, "EE876543216CA", -1, 1, 1, "No spaces" },
/* BARCODE_GS1_128, BARCODE_EAN14, BARCODE_NVE18 hrt tested in test_gs1.c */
};
const int data_size = ARRAY_SIZE(data);
@@ -319,9 +349,9 @@ static void test_hrt(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
i, symbol->text_length, expected_length);
assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n",
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d (%s, %s)\n",
i, symbol->text_length, expected_length, symbol->text, data[i].expected);
assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d text memcmp(%s, %s, %d) != 0\n",
i, symbol->text, data[i].expected, expected_length);
if (ret < ZINT_ERROR) {
@@ -329,10 +359,11 @@ static void test_hrt(const testCtx *const p_ctx) {
assert_nonnull(symbol->content_segs, "i:%d content_segs NULL\n", i);
assert_nonnull(symbol->content_segs[0].source, "i:%d content_segs[0].source NULL\n", i);
assert_equal(symbol->content_segs[0].length, expected_content_length,
"i:%d content_segs[0].length %d != expected_content_length %d\n",
i, symbol->content_segs[0].length, expected_content_length);
"i:%d content_segs[0].length %d != expected_content_length %d (%.*s, %s)\n",
i, symbol->content_segs[0].length, expected_content_length,
symbol->content_segs[0].length, symbol->content_segs[0].source, data[i].expected_content);
assert_zero(memcmp(symbol->content_segs[0].source, data[i].expected_content, expected_content_length),
"i:%d memcmp(%.*s, %s, %d) != 0\n",
"i:%d content_segs memcmp(%.*s, %s, %d) != 0\n",
i, symbol->content_segs[0].length, symbol->content_segs[0].source,
data[i].expected_content, expected_content_length);
} else {
@@ -340,7 +371,12 @@ static void test_hrt(const testCtx *const p_ctx) {
}
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) {
if (data[i].symbology == BARCODE_HIBC_128
if (!data[i].bwipp_cmp) {
if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s not BWIPP compatible (%s)\n",
i, testUtilBarcodeName(symbol->symbology), data[i].comment);
}
} else if (data[i].symbology == BARCODE_HIBC_128
&& z_not_sane(IS_NUM_F | IS_UPR_F | IS_SPC_F | IS_PLS_F | IS_MNS_F | IS_SIL_F, ZCUCP(data[i].data), length)) {
if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s not BWIPP compatible (%s)\n",
@@ -363,6 +399,7 @@ static void test_hrt(const testCtx *const p_ctx) {
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
int cmp_len, ret_len;
char modules_dump[4096];
assert_nonzero(data[i].zxingcpp_cmp, "i:%d data[i].zxingcpp_cmp == 0", i);
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
"i:%d testUtilModulesDump == -1\n", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, data[i].zxingcpp_cmp, cmp_buf,
@@ -512,8 +549,8 @@ static void test_input(const testCtx *const p_ctx) {
/* 2*/ { UNICODE_MODE, "AIM1234", -1, 0, 101, 1, 1, "(9) 104 33 41 45 99 12 34 87 106", "Example from Annex A.1, check char value 87" },
/* 3*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "123456789", -1, 0, 101, 1, 1, "(9) 105 12 34 56 78 100 25 79 106", "Ticket #204 ZPL example" },
/* 4*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^C6789", -1, 0, 123, 0, 1, "(11) 104 17 18 19 20 21 99 67 89 11 106", "Ticket #204 ZPL example; BWIPP as above" },
/* 5*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^D6789", -1, 0, 167, 0, 1, "(15) 104 17 18 19 20 21 60 62 36 22 23 24 25 1 106", "Unrecognized extra escape passed thru; BWIPP different encodation" },
/* 6*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^D6789", -1, 0, 167, 0, 1, "(15) 104 17 18 19 20 21 60 62 36 22 23 24 25 1 106", "Unrecognized extra escape passed thru; BWIPP different encodation" },
/* 5*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^D6789", -1, ZINT_ERROR_INVALID_DATA, 0, 1, 1, "Error 348: Unrecognized extra escape \"\\^D\"", "" },
/* 6*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^\0016789", -1, ZINT_ERROR_INVALID_DATA, 0, 1, 1, "Error 348: Unrecognized extra escape \"\\^?\"", "" },
/* 7*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^B\\^C", -1, ZINT_ERROR_INVALID_DATA, 0, 1, 1, "Error 842: No input data", "" },
/* 8*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^^B\\^C", -1, 0, 68, 0, 1, "(6) 103 60 62 34 80 106", "BWIPP different encodation" },
/* 9*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^B\\^^C", -1, 0, 68, 1, 1, "(6) 104 60 62 35 84 106", "" },
@@ -649,10 +686,10 @@ static void test_input(const testCtx *const p_ctx) {
/*139*/ { UNICODE_MODE, "12é12é", -1, 0, 123, 0, 1, "(11) 105 12 100 100 73 17 18 100 73 17 106", "StartC 12 CodeB FNC4 é 1 2 FNC4 é; BWIPP different encodation (StartB)" },
/*140*/ { UNICODE_MODE, "1234é123456é", -1, 0, 167, 1, 1, "(15) 105 12 34 100 100 73 99 12 34 56 100 100 73 15 106", "StartC 12 34 CodeB FNC4 é CodeC 12 34 56 CodeB FNC4 é" },
/*141*/ { DATA_MODE, "\256^a\357\033\270\017,\274u$B\305\311\006\011]\273\025u\315\2638\263\333", -1, 0, 453, 1, 899, "(41) 104 100 14 62 65 100 79 101 91 101 24 79 12 101 28 98 85 4 34 101 37 101 41 70 73 61", "" },
/*142*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^C\\^1", -1, 0, 46, 0, 0, "(4) 105 102 1 106", "StartC FNC1; From fuzz 2026-01-12; BWIPP see below; zxing-cpp empty text" },
/*143*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^1", -1, 0, 46, 0, 0, "(4) 103 102 102 106", "StartA FNC1; From fuzz 2026-01-12; BWIPP see below; zxing-cpp empty text" },
/*144*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^1", -1, 0, 46, 1, 0, "(4) 104 102 0 106", "StartB FNC1; From fuzz 2026-01-12; zxing-cpp empty text" },
/*145*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^1", -1, 0, 46, 0, 0, "(4) 105 102 1 106", "StartC FNC1; BWIPP see above; zxing-cpp empty text" },
/*142*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^C\\^1", -1, 0, 46, 0, 1, "(4) 105 102 1 106", "StartC FNC1; From fuzz 2026-01-12; BWIPP see below" },
/*143*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^1", -1, 0, 46, 0, 1, "(4) 103 102 102 106", "StartA FNC1; From fuzz 2026-01-12; BWIPP see below" },
/*144*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^1", -1, 0, 46, 1, 1, "(4) 104 102 0 106", "StartB FNC1; From fuzz 2026-01-12" },
/*145*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^1", -1, 0, 46, 0, 1, "(4) 105 102 1 106", "StartC FNC1; BWIPP see above" },
/*146*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^C\\^1A", -1, 0, 68, 0, 3, "(6) 105 102 100 33 94 106", "StartC CodeB FNC1 A; BWIPP see below" },
/*147*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^1A", -1, 0, 57, 0, 3, "(5) 103 102 33 65 106", "StartA FNC1 A; BWIPP see below" },
/*148*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^1A", -1, 0, 57, 1, 3, "(5) 104 102 33 66 106", "StartB FNC1 A" },
+147 -7
View File
@@ -155,8 +155,7 @@ static void test_to_upper(const testCtx *const p_ctx) {
buf[length] = '\0';
z_to_upper(buf, length);
assert_zero(strcmp((const char *) buf, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, buf, data[i].expected);
assert_zero(strcmp(ZCCP(buf), data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, buf, data[i].expected);
}
testFinish();
@@ -764,6 +763,70 @@ static void test_utf8_to_unicode(const testCtx *const p_ctx) {
testFinish();
}
static void test_extra_escapes(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int eci;
const char *data;
int length;
int ret;
const char *expected;
const char expected_fncs[32];
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { 0, "", -1, 0, "", {0}, "" },
/* 1*/ { 3, "ABC", -1, 0, "ABC", {0}, "" },
/* 2*/ { 4, "\\^1ABC", -1, 0, "\035ABC", {1}, "" },
/* 3*/ { 26, "\\^1\\^1A\\^1BC\\^1", -1, 0, "\035\035A\035BC\035", {1,1,0,1,0,0,1}, "" },
/* 4*/ { 27, "\\^^\\^1A\\^1BC\\^^1", -1, 0, "\\^\035A\035BC\\^1", {0,0,1,0,1}, "" },
/* 5*/ { 20, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, "" },
/* 6*/ { 25, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, "" },
/* 7*/ { 28, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, "" },
/* 8*/ { 29, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, "" },
/* 9*/ { 899, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, "" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol;
int expected_length;
testStart(p_ctx->func_name);
symbol->debug = debug;
for (i = 0; i < data_size; i++) {
int len = 0;
unsigned char dest[32] = {0};
char fncs[32] = {0};
if (testContinue(p_ctx, i)) continue;
memset(symbol, 0, sizeof(*symbol));
length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
expected_length = (int) strlen(data[i].expected);
assert_nonzero(expected_length < (int) sizeof(dest), "i:%d expected_length %d >= sizeof(dest) %d\n",
i, expected_length, (int) sizeof(dest));
ret = z_extra_escapes(symbol, ZCUCP(data[i].data), length, data[i].eci, dest, fncs, &len);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
if (ret < ZINT_ERROR) {
assert_equal(len, expected_length, "i:%d len %d != expected_length %d (%s)\n",
i, len, expected_length, dest);
assert_zero(strcmp(ZCCP(dest), data[i].expected), "i:%d dest (%s) != expected (%s)\n",
i, dest, data[i].expected);
assert_zero(memcmp(fncs, data[i].expected_fncs, expected_length), "i:%d fncs != expected_fncs\n", i);
}
}
testFinish();
}
/* Note transferred from "test_code128.c" */
static void test_hrt_cpy_iso8859_1(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
@@ -1033,7 +1096,7 @@ static void test_hrt_printf_nochk(const testCtx *const p_ctx) {
assert_zero(1, "i:%d, bad num_args\n", i);
}
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(\"%s\", \"%s\") != 0\n",
assert_zero(strcmp(ZCCP(symbol->text), data[i].expected), "i:%d strcmp(\"%s\", \"%s\") != 0\n",
i, symbol->text, data[i].expected);
}
@@ -1084,7 +1147,7 @@ static void test_hrt_conv_gs1_brackets_nochk(const testCtx *const p_ctx) {
z_hrt_conv_gs1_brackets_nochk(symbol, TCU(data[i].data), length);
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(\"%s\", \"%s\") != 0\n",
assert_zero(strcmp(ZCCP(symbol->text), data[i].expected), "i:%d strcmp(\"%s\", \"%s\") != 0\n",
i, symbol->text, data[i].expected);
}
@@ -1223,7 +1286,7 @@ static void test_ct_cpy(const testCtx *const p_ctx) {
i, symbol->content_segs[0].length, expected_length);
assert_zero(memcmp(symbol->content_segs[0].source, data[i].expected, expected_length),
"i:%d content_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
testUtilEscape((const char *) symbol->content_segs[0].source, symbol->content_segs[0].length,
testUtilEscape(ZCCP(symbol->content_segs[0].source), symbol->content_segs[0].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
@@ -1237,6 +1300,81 @@ static void test_ct_cpy(const testCtx *const p_ctx) {
testFinish();
}
static void test_ct_set_seg_extra_escapes_eci(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int seg_idx;
int seg_count;
int eci;
struct zint_seg segs[3];
struct zint_seg expected_content_segs[3];
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { 0, 1, 3, { { TU("\\^1A"), 0, 0 } }, { { TU("\035A"), 2, 3 } } },
/* 1*/ { 0, 1, 0, { { TU("\\^1A"), 0, 0 } }, { { TU("A"), 1, 3 } } },
/* 2*/ { 0, 1, 4, { { TU("A\\^1"), 0, 0 } }, { { TU("A\035"), 2, 4 } } },
/* 3*/ { 0, 1, 0, { { TU("A\\^1"), 0, 0 } }, { { TU("A"), 1, 3 } } },
/* 4*/ { 0, 1, 0, { { TU("a\\^1"), 0, 0 } }, { { TU("a"), 1, 3 } } },
/* 5*/ { 0, 1, 0, { { TU("12\\^1"), 0, 0 } }, { { TU("12"), 2, 3 } } },
/* 6*/ { 0, 1, 0, { { TU("?\\^1"), 0, 0 } }, { { TU("?\035"), 2, 3 } } },
/* 7*/ { 0, 1, 0, { { TU("1A\\^1"), 0, 0 } }, { { TU("1A\035"), 3, 3 } } },
/* 8*/ { 0, 1, 0, { { TU("\\^1\\^^1A\\^1"), 0, 0 } }, { { TU("\\^1A\035"), 5, 3 } } },
/* 9*/ { 0, 1, 5, { { TU("\\^1\\^^1A\\^1"), 0, 0 } }, { { TU("\035\\^1A\035"), 6, 5 } } },
/* 10*/ { 1, 2, 27, { { TU("\\^^A"), 0, 0 }, { TU("\\^1A\\^^1\\^1B\\^"), 0, 0 } }, { { TU("\\^^A"), 0, 0 }, { TU("\035A\\^1\035B\\^"), 9, 27 } } },
/* 11*/ { 1, 2, 0, { { TU("\\^^A"), 0, 0 }, { TU("\\^1A\\^^1\\^1B\\^"), 0, 0 } }, { { TU("\\^^A"), 0, 0 }, { TU("\035A\\^1\035B\\^"), 9, 3 } } },
};
const int data_size = ARRAY_SIZE(data);
int i, ret;
struct zint_symbol s_symbol = {0};
struct zint_symbol *symbol = &s_symbol;
char escaped[4096];
char escaped2[4096];
testStart(p_ctx->func_name);
symbol->debug = debug;
for (i = 0; i < data_size; i++) {
int expected_length;
unsigned char *expected_source;
int expected_eci = data[i].eci ? data[i].eci : 3;
int seg_idx = data[i].seg_idx;
if (testContinue(p_ctx, i)) continue;
ret = z_ct_cpy_segs(symbol, data[i].segs, data[i].seg_count);
assert_zero(ret, "i:%d z_ct_cpy_segs %d != 0\n", i, ret);
assert_nonnull(symbol->content_segs, "i:%d content_segs NULL\n", i);
z_ct_set_seg_extra_escapes_eci(symbol, seg_idx, data[i].eci);
assert_nonnull(symbol->content_segs[seg_idx].source, "i:%d content_segs[%d].source NULL\n", i, seg_idx);
expected_length = data[i].expected_content_segs[seg_idx].length;
expected_source = data[i].expected_content_segs[seg_idx].source;
assert_equal(symbol->content_segs[seg_idx].length, expected_length,
"i:%d content_segs[%d].length %d != expected_length %d\n",
i, seg_idx, symbol->content_segs[seg_idx].length, expected_length);
assert_zero(memcmp(symbol->content_segs[seg_idx].source, expected_source, expected_length),
"i:%d content_segs[%d].source memcmp(%s, %s, %d) != 0\n", i, seg_idx,
testUtilEscape(ZCCP(symbol->content_segs[seg_idx].source), symbol->content_segs[seg_idx].length,
escaped, sizeof(escaped)),
testUtilEscape(ZCCP(expected_source), expected_length, escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->content_segs[seg_idx].eci, expected_eci, "i:%d content_segs[%d].eci %d != expected_eci %d\n",
i, seg_idx, symbol->content_segs[seg_idx].eci, expected_eci);
ZBarcode_Clear(symbol);
}
testFinish();
}
static void test_ct_cpy_iso8859_1(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
@@ -1287,7 +1425,7 @@ static void test_ct_cpy_iso8859_1(const testCtx *const p_ctx) {
i, symbol->content_segs[0].length, expected_length);
assert_zero(memcmp(symbol->content_segs[0].source, data[i].expected, expected_length),
"i:%d content_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
testUtilEscape((const char *) symbol->content_segs[0].source, symbol->content_segs[0].length,
testUtilEscape(ZCCP(symbol->content_segs[0].source), symbol->content_segs[0].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
@@ -1355,7 +1493,7 @@ static void test_ct_printf_256(const testCtx *const p_ctx) {
i, symbol->content_segs[0].length, expected_length);
assert_zero(memcmp(symbol->content_segs[0].source, data[i].expected, expected_length),
"i:%d content_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
testUtilEscape((const char *) symbol->content_segs[0].source, symbol->content_segs[0].length,
testUtilEscape(ZCCP(symbol->content_segs[0].source), symbol->content_segs[0].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
@@ -1489,12 +1627,14 @@ int main(int argc, char *argv[]) {
{ "test_cnt_digits", test_cnt_digits },
{ "test_is_valid_utf8", test_is_valid_utf8 },
{ "test_utf8_to_unicode", test_utf8_to_unicode },
{ "test_extra_escapes", test_extra_escapes },
{ "test_hrt_cpy_iso8859_1", test_hrt_cpy_iso8859_1 },
{ "test_hrt_cpy_nochk", test_hrt_cpy_nochk },
{ "test_hrt_cpy_cat_nochk", test_hrt_cpy_cat_nochk },
{ "test_hrt_printf_nochk", test_hrt_printf_nochk },
{ "test_hrt_conv_gs1_brackets_nochk", test_hrt_conv_gs1_brackets_nochk },
{ "test_ct_cpy_segs", test_ct_cpy_segs },
{ "test_ct_set_seg_extra_escapes_eci", test_ct_set_seg_extra_escapes_eci },
{ "test_ct_cpy", test_ct_cpy },
{ "test_ct_cpy_iso8859_1", test_ct_cpy_iso8859_1 },
{ "test_ct_printf_256", test_ct_printf_256 },
File diff suppressed because it is too large Load Diff
+30 -15
View File
@@ -191,10 +191,10 @@ static void test_checks(const testCtx *const p_ctx) {
/*127*/ { 150, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 },
/*128*/ { BARCODE_LAST + 1, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 },
/*129*/ { BARCODE_LAST + 1, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 },
/*130*/ { BARCODE_CODE128, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 },
/*131*/ { BARCODE_CODE128, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 },
/*132*/ { BARCODE_MAXICODE, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 },
/*133*/ { BARCODE_MAXICODE, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 },
/*130*/ { BARCODE_CODE128, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input", -1 },
/*131*/ { BARCODE_CODE128, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input", -1 },
/*132*/ { BARCODE_MAXICODE, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input", -1 },
/*133*/ { BARCODE_MAXICODE, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input", -1 },
/*134*/ { BARCODE_GS1_128, -1, "[01]12345678901234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'", -1 },
/*135*/ { BARCODE_GS1_128, -1, "[01]12345678901234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_NONCOMPLIANT, "Error 261: AI (01) data position 14: Bad checksum '4', expected '1'", -1 },
/*136*/ { BARCODE_QRCODE, -1, "", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 },
@@ -306,10 +306,10 @@ static void test_checks_segs(const testCtx *const p_ctx) {
/* 8*/ { BARCODE_CODE128, -1, { { TU("A"), 0, 3 }, { NULL, 0, 0 } }, 1, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching" },
/* 9*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 1 } }, 2, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 218: ECI code '1' out of range (0 to 999999, excluding 1, 2, 14 and 19)" },
/* 10*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 4 } }, 2, GS1_MODE, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 776: GS1 mode not supported for multiple segments" },
/* 11*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("\200"), 0, 4 } }, 2, UNICODE_MODE, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input" },
/* 11*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("\200"), 0, 4 } }, 2, UNICODE_MODE, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input" },
/* 12*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 4 } }, 2, -1, -1, -1, 0, "" },
/* 13*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 0 }, { TU("B"), 0, 4 } }, 2, -1, 3, -1, 0, "" },
/* 14*/ { BARCODE_AZTEC, -1, { { TU("A"), ZINT_MAX_DATA_LEN, 3 }, { TU("B"), 1, 4 } }, 2, -1, -1, -1, ZINT_ERROR_TOO_LONG, "Error 243: Input too long" },
/* 14*/ { BARCODE_AZTEC, -1, { { TU("A"), ZINT_MAX_DATA_LEN, 3 }, { TU("B"), 1, 4 } }, 2, -1, -1, -1, ZINT_ERROR_TOO_LONG, "Error 214: Input too long" },
};
const int data_size = ARRAY_SIZE(data);
int i, ret;
@@ -731,9 +731,9 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
/* 44*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\uFG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" },
/* 45*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u00F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" },
/* 46*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u00FG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 211: Invalid character for '\\u' escape sequence in input (hexadecimal only)", 0, "" },
/* 47*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\ufffe", "", ZINT_ERROR_INVALID_DATA, 0, "Error 246: Value of escape sequence '\\ufffe' in input out of range", 0, "Reversed BOM" },
/* 48*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\ud800", "", ZINT_ERROR_INVALID_DATA, 0, "Error 246: Value of escape sequence '\\ud800' in input out of range", 0, "Surrogate" },
/* 49*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\udfff", "", ZINT_ERROR_INVALID_DATA, 0, "Error 246: Value of escape sequence '\\udfff' in input out of range", 0, "Surrogate" },
/* 47*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\ufffe", "", ZINT_ERROR_INVALID_DATA, 0, "Error 216: Value of escape sequence '\\ufffe' in input out of range", 0, "Reversed BOM" },
/* 48*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\ud800", "", ZINT_ERROR_INVALID_DATA, 0, "Error 216: Value of escape sequence '\\ud800' in input out of range", 0, "Surrogate" },
/* 49*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\udfff", "", ZINT_ERROR_INVALID_DATA, 0, "Error 216: Value of escape sequence '\\udfff' in input out of range", 0, "Surrogate" },
/* 50*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\uffff", "", 0, 12, "E7 2C B0 16 AB A1 1F 85 EB 50 A1 4C", 0, "" },
/* 51*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 17, "\\xE2\\x82\\xAC", "", 0, 12, "F1 12 EB 25 81 4A 0A 8C 31 AC E3 2E", 0, "Zint manual 4.10 Ex1" },
/* 52*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 17, "\\u20AC", "", 0, 12, "F1 12 EB 25 81 4A 0A 8C 31 AC E3 2E", 1, "" },
@@ -755,7 +755,7 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
/* 68*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Udfff", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "Surrogate" },
/* 69*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U000F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" },
/* 70*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U0000F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" },
/* 71*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U110000", "", ZINT_ERROR_INVALID_DATA, 0, "Error 246: Value of escape sequence '\\U110000' in input out of range", 0, "" },
/* 71*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U110000", "", ZINT_ERROR_INVALID_DATA, 0, "Error 216: Value of escape sequence '\\U110000' in input out of range", 0, "" },
/* 72*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 25, "\\U10FFFF", "", 0, 14, "F1 1A E7 57 C7 81 F7 AC 09 06 28 51 F3 00 E1 8C 2A 1C", 0, "" },
/* 73*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 26, "\\U10FFFF", "", 0, 14, "F1 1B E7 57 E0 11 D7 6C 4F 45 E2 B3 FF F1 72 AB 54 9F", 0, "" },
/* 74*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 32, "\\U10FFFF", "", 0, 14, "F1 21 EB 64 33 EB 1B 36 1D F7 B1 6D 8C A6 34 64 19 3A", 0, "" },
@@ -764,11 +764,25 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
/* 77*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 35, "\\U10FFFF", "", 0, 14, "F1 24 EB 80 EB 80 11 01 17 BA C6 05 9F 4C EA E5 18 31", 0, "" },
/* 78*/ { BARCODE_GS1_128_CC, GS1_MODE, -1, "[20]10", "[10]A", 0, 99, "(7) 105 102 20 10 100 59 106", 0, "" },
/* 79*/ { BARCODE_GS1_128_CC, GS1_MODE, -1, "[2\\x30]1\\d048", "[\\x310]\\x41", 0, 99, "(7) 105 102 20 10 100 59 106", 1, "" },
/* 80*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid for Code 128 in extra escape mode", 0, "" },
/* 81*/ { BARCODE_CODE128, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", 0, 46, "(4) 103 17 17 106", 0, "" },
/* 82*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^", "", 0, 57, "(5) 104 60 62 82 106", 0, "Partial special escape '\\^' at end allowed" },
/* 83*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^D1", "", 0, 79, "(7) 104 60 62 36 17 52 106", 0, "Unknown special escapes passed straight thu" },
/* 84*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\w", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\w' in input", 0, "" },
/* 80*/ { BARCODE_AZTEC, DATA_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in extra escape mode", 0, "" },
/* 81*/ { BARCODE_AZTEC, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 213: Extra escape '\\^' not valid for this symbology and/or input mode", 0, "" },
/* 82*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in extra escape mode", 0, "" },
/* 83*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in extra escape mode", 0, "" },
/* 84*/ { BARCODE_DATAMATRIX, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", 0, 10, "E8 32 81 98 94 7B 7F 6D", 0, "" },
/* 85*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^A\"", 0, "" },
/* 86*/ { BARCODE_DATAMATRIX, GS1_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 213: Extra escape '\\^' not valid for this symbology and/or input mode", 0, "Not allowed of DATAMATRIX in GS1_MODE" },
/* 87*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 18, "A\\^1B", "", 0, 12, "F1 13 42 E8 43 C3 1B 02 5A 6B 37 CC", 0, "" },
/* 88*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 20, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, "" },
/* 89*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 20, "\\^1ーコ\\^1ード\\^1東京\\^1都", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, "" },
/* 90*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 25, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, "" },
/* 91*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 33, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, "" },
/* 92*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 170, "A\\^1B", "", ZINT_ERROR_INVALID_DATA, 0, "Error 244: Invalid character in input for ECI '170'", 0, "" },
/* 93*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 899, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, "" },
/* 94*/ { BARCODE_CODE128, DATA_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in extra escape mode", 0, "" },
/* 95*/ { BARCODE_CODE128, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", 0, 46, "(4) 103 17 17 106", 0, "" },
/* 96*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^", "", 0, 57, "(5) 104 60 62 82 106", 0, "Partial special escape '\\^' at end allowed" },
/* 97*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^D1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 348: Unrecognized extra escape \"\\^D\"", 0, "" },
/* 98*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\w", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\w' in input", 0, "" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
@@ -891,6 +905,7 @@ static void test_escape_char_process_test(const testCtx *const p_ctx) {
/* 2*/ { 0, 0, "\\U010283", 0, "\360\220\212\203", 4 },
/* 3*/ { 0, 0, "\\u007F\\u0080\\u011E\\u13C9\\U010283", 0, "\177\302\200\304\236\341\217\211\360\220\212\203", 12 },
/* 4*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, "\\^A\\^^\\^B", 0, "\\^A\\^^\\^B", 9 },
/* 5*/ { BARCODE_DATAMATRIX, EXTRA_ESCAPE_MODE, "\\^1\\^^\\^1", 0, "\\^1\\^^\\^1", 9 },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
+106 -54
View File
@@ -2665,29 +2665,77 @@ static char *testUtilBwippCvtGS1Data(char *bwipp_data, const int bwipp_data_size
return bwipp_data;
}
/* Copied from "library.c" */
/* Returns 1 if `symbol` can process EXTRA_ESCAPE_MODE */
static int supports_extra_escape_mode(const struct zint_symbol *const symbol) {
return symbol->symbology == BARCODE_CODE128
|| (symbol->symbology == BARCODE_DATAMATRIX && (symbol->input_mode & 0x07) != GS1_MODE);
}
#define z_isxdigit(c) (z_isdigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
#define z_isodigit(c) ((c) <= '7' && (c) >= '0')
/* Convert data to Ghostscript format for passing to bwipp_dump.ps */
static char *testUtilBwippEscape(char *bwipp_data, const int bwipp_data_size, const char *data, const int length,
const int zint_escape_mode, const int eci, int *parse, int *parsefnc) {
static char *testUtilBwippEscape(const struct zint_symbol *const symbol, char *bwipp_data, const int bwipp_data_size,
const char *data, const int length, const int eci, int *parse, int *parsefnc) {
const int is_extra_escaped = (symbol->input_mode & EXTRA_ESCAPE_MODE) && supports_extra_escape_mode(symbol);
const int is_escaped = (symbol->input_mode & ESCAPE_MODE) || is_extra_escaped;
const int is_c128 = symbol->symbology == BARCODE_CODE128;
char *b = bwipp_data;
char *be = b + bwipp_data_size;
unsigned char *d = (unsigned char *) data;
unsigned char *de = (unsigned char *) data + length;
int have_done_single_caret = 0; /* Flag to help debug escaping of carets */
if (eci && !*parsefnc) {
if (eci) {
sprintf(bwipp_data, "^ECI%06d", eci);
*parsefnc = 1;
b = bwipp_data + 10;
}
while (b < be && d < de) {
/* Deal with extra escape sequences first */
if (is_extra_escaped && *d == '\\' && d + 1 < de && d[1] == '^'
&& (d + 2 == de || ((d[2] == '1' || d[2] == '^' || (is_c128 && d[2] >= '@' && d[2] <= 'C'))))) {
if (d + 2 == de || d[2] == '^') {
/* Literal "\^^" */
if (*parsefnc) {
if (b + 6 >= be) {
fprintf(stderr, "testUtilBwippEscape: extra escape double caret bwipp_data buffer full (%d)\n",
bwipp_data_size);
return NULL;
}
strcpy(b, "^092^^");
b += 6;
*parse = 1;
} else {
if (b + 8 >= be) {
fprintf(stderr, "testUtilBwippEscape: extra escape 094 caret bwipp_data buffer full (%d)\n",
bwipp_data_size);
return NULL;
}
strcpy(b, "^092^094");
b += 8;
*parse = 1;
}
} else if (d[2] == '1') {
if (b + 5 >= be) {
fprintf(stderr, "testUtilBwippEscape: extra escape FNC1 bwipp_data buffer full (%d)\n",
bwipp_data_size);
return NULL;
}
strcpy(b, "^FNC1");
b += 5;
*parsefnc = 1;
} else {
assert(d + 2 < de && is_c128 && d[2] >= '@' && d[2] <= 'C');
}
d += 2 + (d + 2 != de);
/* Have to escape double quote otherwise Ghostscript gives "Unterminated quote in @-file" for some reason */
/* Escape single quote also to avoid having to do proper shell escaping TODO: proper shell escaping */
if (*d < 0x20 || *d >= 0x7F || (*d == '^' && !*parsefnc) || *d == '"' || *d == '\''
|| *d == '(' || (*d == '\\' && !zint_escape_mode)) {
} else if (*d < 0x20 || *d >= 0x7F || (*d == '^' && !*parsefnc) || *d == '"' || *d == '\''
|| *d == '(' || (*d == '\\' && !is_escaped)) {
if (b + 4 >= be) {
fprintf(stderr, "testUtilBwippEscape: double quote bwipp_data buffer full (%d)\n", bwipp_data_size);
return NULL;
@@ -2710,7 +2758,7 @@ static char *testUtilBwippEscape(char *bwipp_data, const int bwipp_data_size, co
/* `parsefnc` changed while escaping (see FNC1 processing below) - may cause test to fail */
fprintf(stderr, "testUtilBwippEscape: WARNING: already escaped caret singularly\n");
}
} else if (zint_escape_mode && *d == '\\' && d + 1 < de) {
} else if (is_escaped && *d == '\\' && d + 1 < de) {
int val;
switch (*++d) {
case '0': val = 0x00; /* Null */ break;
@@ -2883,6 +2931,7 @@ static char *testUtilBwippUtf8Convert(const int index, const int symbology, cons
/* Create bwipp_dump.ps command and run */
int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3,
const char *data, int length, const char *primary, char *buffer, int buffer_size, int *p_parsefnc) {
static const char fn[] = "testUtilBwipp";
static const char cmd_fmt[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%s'"
" backend/tests/tools/bwipp_dump.ps";
static const char cmd_opts_fmt[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%s' -so='%s'"
@@ -2924,10 +2973,11 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
FILE *fp = NULL;
int cnt;
int exit_status;
char *b = buffer;
char *be = buffer + buffer_size;
int r, h;
int r;
int parse = 0, parsefnc = p_parsefnc ? *p_parsefnc : 0;
const int upcean = (ZBarcode_Cap(symbology, ZINT_CAP_EANUPC) & ZINT_CAP_EANUPC) == ZINT_CAP_EANUPC;
@@ -2944,8 +2994,8 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
bwipp_barcode = testUtilBwippName(index, symbol, option_1, option_2, option_3, 0, &linear_row_height, &gs1_cvt);
if (!bwipp_barcode) {
fprintf(stderr, "i:%d testUtilBwipp: no mapping for %s, option_1 %d, option_2 %d, option_3 %d\n",
index, testUtilBarcodeName(symbology), option_1, option_2, option_3);
fprintf(stderr, "i:%d %s:%d no mapping for %s, option_1 %d, option_2 %d, option_3 %d\n",
index, fn, __LINE__, testUtilBarcodeName(symbology), option_1, option_2, option_3);
return -1;
}
@@ -2956,8 +3006,8 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
bwipp_row_height[r] = symbol->row_height[r] ? symbol->row_height[r] : linear_row_height;
}
if ((symbol->debug & ZINT_DEBUG_TEST_PRINT) && !(symbol->debug & ZINT_DEBUG_TEST_LESS_NOISY)) {
fprintf(stderr, "bwipp_row_height[%d] %d, symbol->row_height[%d] %g\n",
r, bwipp_row_height[r], r, symbol->row_height[r]);
fprintf(stderr, "i:%d %s:%d bwipp_row_height[%d] %d, symbol->row_height[%d] %g\n",
index, fn, __LINE__, r, bwipp_row_height[r], r, symbol->row_height[r]);
}
}
@@ -2966,14 +3016,15 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
if ((symbol->input_mode & 0x07) == UNICODE_MODE && zint_is_eci_convertible(eci)
&& (data = testUtilBwippUtf8Convert(index, symbology, 1 /*try_sjis*/, &eci, (const unsigned char *) data,
&data_len, (unsigned char *) converted)) == NULL) {
fprintf(stderr, "i:%d testUtilBwipp: failed to convert UTF-8 data for %s\n",
index, testUtilBarcodeName(symbology));
fprintf(stderr, "i:%d %s:%d failed to convert UTF-8 data for %s\n",
index, fn, __LINE__, testUtilBarcodeName(symbology));
return -1;
}
if (z_is_composite(symbology)) {
if (!primary) {
fprintf(stderr, "i:%d testUtilBwipp: no primary data given %s\n", index, testUtilBarcodeName(symbology));
fprintf(stderr, "i:%d %s:%d no primary data given %s\n",
index, fn, __LINE__, testUtilBarcodeName(symbology));
return -1;
}
if (*primary != obracket && !upcean) {
@@ -3072,10 +3123,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
}
#endif
} else {
const int is_extra_escaped = (symbol->input_mode & EXTRA_ESCAPE_MODE)
&& symbol->symbology == BARCODE_CODE128;
const int is_escaped = (symbol->input_mode & ESCAPE_MODE) || is_extra_escaped;
if (testUtilBwippEscape(bwipp_data, bwipp_data_size, data, data_len, is_escaped, eci, &parse, &parsefnc)
if (testUtilBwippEscape(symbol, bwipp_data, bwipp_data_size, data, data_len, eci, &parse, &parsefnc)
== NULL) {
return -1;
}
@@ -3560,9 +3608,8 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
}
if ((option_1 != -1 || option_2 != -1 || option_3 != -1) && !bwipp_opts) {
fprintf(stderr,
"i:%d testUtilBwipp: no BWIPP options set option_1 %d, option_2 %d, option_3 %d for symbology %s\n",
index, option_1, option_2, option_3, testUtilBarcodeName(symbology));
fprintf(stderr, "i:%d %s:%d no BWIPP options set option_1 %d, option_2 %d, option_3 %d for symbology %s\n",
index, fn, __LINE__, option_1, option_2, option_3, testUtilBarcodeName(symbology));
return -1;
}
@@ -3607,7 +3654,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
memcpy(cmd + GS_INITIAL_LEN, adj, sizeof(adj) - 1);
}
if (symbology == BARCODE_CODE11 || symbology == BARCODE_CODE39 || symbology == BARCODE_EXCODE39
|| symbology == BARCODE_CODABAR || symbology == BARCODE_PHARMA || symbology == BARCODE_PZN
|| symbology == BARCODE_CODABAR || symbology == BARCODE_PZN
|| symbology == BARCODE_CODE32 || symbology == BARCODE_VIN) {
/* Ratio 3 width bar/space -> 2 width */
char adj[] = " -sr=0.6";
@@ -3664,12 +3711,12 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
}
if (symbol->debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d testUtilBwipp: cmd %s\n", index, cmd);
printf("i:%d %s cmd %s\n", index, fn, cmd);
}
fp = testutil_popen(cmd, "r");
if (!fp) {
fprintf(stderr, "i:%d testUtilBwipp: failed to run '%s'\n", index, cmd);
fprintf(stderr, "i:%d %s:%d failed to run '%s'\n", index, fn, __LINE__, cmd);
return -1;
}
@@ -3679,45 +3726,38 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
} else {
for (r = 0; r < symbol->rows; r++) {
if (b + symbol->width > be) {
fprintf(stderr, "i:%d testUtilBwipp: row %d, width %d, row width iteration overrun (%s)\n",
index, r, symbol->width, cmd);
testutil_pclose(fp);
fprintf(stderr, "i:%d %s:%d row %d, width %d, row width iteration overrun (%s)\n",
index, fn, __LINE__, r, symbol->width, cmd);
(void) testutil_pclose(fp);
return -1;
}
cnt = (int) fread(b, 1, symbol->width, fp);
if (cnt != symbol->width) {
fprintf(stderr,
"i:%d testUtilBwipp: failed to read row %d of %d, symbol->width %d bytes, cnt %d (%s)\n",
index, r + 1, symbol->rows, symbol->width, cnt, cmd);
testutil_pclose(fp);
fprintf(stderr, "i:%d %s:%d failed to read row %d of %d, symbol->width %d bytes, cnt %d (%s)\n",
index, fn, __LINE__, r + 1, symbol->rows, symbol->width, cnt, cmd);
(void) testutil_pclose(fp);
return -1;
}
b += cnt;
for (h = bwipp_row_height[r]; h > 1; h--) { /* Ignore row copies if any */
cnt = (int) fread(b, 1, symbol->width, fp);
if (cnt != symbol->width) {
fprintf(stderr,
"i:%d testUtilBwipp: failed to read/ignore symbol->width %d bytes, cnt %d, h %d"
", bwipp_row_height[%d] %d, symbol->row_height[%d] %g (%s)\n",
index, symbol->width, cnt, h, r, bwipp_row_height[r], r, symbol->row_height[r], cmd);
testutil_pclose(fp);
return -1;
}
if (h * 2 == bwipp_row_height[r]) { /* Hack to use middle row (avoids add-on text offsets) */
memcpy(b - cnt, b, cnt);
}
}
}
}
*b = '\0';
if (fgetc(fp) != EOF) {
fprintf(stderr, "i:%d testUtilBwipp: failed to read full stream (%s)\n", index, cmd);
testutil_pclose(fp);
fprintf(stderr, "i:%d %s:%d failed to read full stream (%s)\n", index, fn, __LINE__, cmd);
(void) testutil_pclose(fp);
return -1;
}
testutil_pclose(fp);
if ((exit_status = testutil_pclose(fp))) {
#ifndef _WIN32
if (WIFEXITED(exit_status)) {
exit_status = WEXITSTATUS(exit_status);
}
#endif
fprintf(stderr, "i:%d %s:%d pclose returned exit status %d (%s)\n", index, fn, __LINE__, exit_status, cmd);
return -1;
}
return 0;
}
@@ -3797,7 +3837,7 @@ int testUtilBwippSegs(int index, struct zint_symbol *symbol, int option_1, int o
total_len = (int) (d - data);
if (unicode_mode) {
symbol->input_mode = DATA_MODE;
symbol->input_mode = DATA_MODE | (symbol->input_mode & ~0x07);
}
symbol->eci = 0;
@@ -4147,6 +4187,7 @@ int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source,
FILE *fp = NULL;
int cnt;
int exit_status;
buffer[0] = '\0';
@@ -4192,17 +4233,25 @@ int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source,
if (cnt == buffer_size) {
fprintf(stderr, "i:%d testUtilZXingCPP: buffer too small, %d bytes, cnt %d (%s)\n",
index, buffer_size, cnt, cmd);
testutil_pclose(fp);
(void) testutil_pclose(fp);
return -1;
}
if (fgetc(fp) != EOF) {
fprintf(stderr, "i:%d testUtilZXingCPP: failed to read full stream (%s)\n", index, cmd);
testutil_pclose(fp);
(void) testutil_pclose(fp);
return -1;
}
testutil_pclose(fp);
if ((exit_status = testutil_pclose(fp))) {
#ifndef _WIN32
if (WIFEXITED(exit_status)) {
exit_status = WEXITSTATUS(exit_status);
}
#endif
fprintf(stderr, "i:%d testUtilZXingCPP: pclose returned exit status %d (%s)\n", index, exit_status, cmd);
return -1;
}
if ((data_mode && zxingcpp_cmp > 1 && (zxingcpp_cmp == 899 || zint_is_eci_convertible(zxingcpp_cmp)))
|| symbol->eci >= 899) {
@@ -4311,7 +4360,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
const int is_dbar_nonexp = symbology == BARCODE_DBAR_OMN || symbology == BARCODE_DBAR_LTD
|| symbology == BARCODE_DBAR_OMNSTK || symbology == BARCODE_DBAR_STK;
const int gs1 = (symbol->input_mode & 0x07) == GS1_MODE || is_gs1_128_dbar_exp;
const int is_extra_escaped = (symbol->input_mode & EXTRA_ESCAPE_MODE) && symbol->symbology == BARCODE_CODE128;
const int is_extra_escaped = (symbol->input_mode & EXTRA_ESCAPE_MODE) && supports_extra_escape_mode(symbol);
const int is_escaped = (symbol->input_mode & ESCAPE_MODE) || is_extra_escaped;
const int is_hibc = symbology >= BARCODE_HIBC_128 && symbology <= BARCODE_HIBC_AZTEC;
const int have_ccheckdigit = symbol->option_2 == 1 || symbol->option_2 == 2; /* Good for C25, CODE39, CODABAR */
@@ -4360,6 +4409,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
/* Remove any Code 128 special escapes */
int j = 0;
int have_manual_ab = 0;
int have_position_fnc1 = 0;
for (i = 0; i < expected_len; i++) {
if (escaped[i] == '\\' && i + 2 < expected_len && escaped[i + 1] == '^'
&& ((escaped[i + 2] >= '@' && escaped[i + 2] <= 'C') || escaped[i + 2] == '1'
@@ -4372,11 +4422,13 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
/* FNC1 in 1st position treated as GS1 and in 2nd position AIM, neither transmitted -
need to skip AIM (single alphabetic or Code Set C double digit)
TODO: guessing about whether in Code Set C for double digit */
if (j > 2 || (j == 1 && !(z_isupper(escaped[0]) || z_islower(escaped[0])))
if (symbol->eci || have_position_fnc1 || j > 2 || (j == 1 && !z_isalpha(escaped[0]))
|| (j == 2 && !(z_isdigit(escaped[0]) && z_isdigit(escaped[1])
&& !have_manual_ab))) {
/* Probably not AIM */
escaped[j++] = 29; /* GS */
} else {
have_position_fnc1 = 1;
}
}
} else {
@@ -98,6 +98,32 @@ ret /pixs known {
pixs 0 tmppixs 0 j getinterval putinterval
} if
b (databarlimitedcomposite) eq {
% Add RHS 5-space quiet zone
/cpypixs pixs length array def
cpypixs 0 pixs 0 pixs length getinterval putinterval
/pixw pixs length pixx idiv def
/pixs [
0 pixx cpypixs length 1 sub {
/i exch def
cpypixs i pixx getinterval aload pop 0 0 0 0 0
} for
] def
/pixx pixx 5 add def
} if
b (ean13composite) eq b (ean8composite) eq or b (upcacomposite) eq or b (upcecomposite) eq or {
d (|) search {
/linear exch def
pop pop
linear ( ) search { % Have add-on?
pop pop pop
% Remove last row from pixs array which just contains add-on overhang
/pixs [ pixs 0 pixs length pixx sub getinterval aload pop ] def
} { pop } ifelse
} { pop } ifelse
} if
/xs systemdict /xs known { systemdict /xs get cvi } { 0 } ifelse def
/xe systemdict /xe known { systemdict /xe get cvi } { 0 } ifelse def
Binary file not shown.