mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Fix "most" compilation issues MSVC has
test_library is still broken
This commit is contained in:
parent
88bbeb862b
commit
2221cb1e83
@ -47,11 +47,11 @@ static void test_utf8_to_unicode(int index, int debug) {
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { "", -1, 1, 0, 0, {}, "" },
|
||||
/* 0*/ { "", -1, 1, 0, 0, {0}, "" },
|
||||
/* 1*/ { "\000a\302\200\340\240\200", 7, 1, 0, 4, { 0, 'a', 0x80, 0x800 }, "NUL a C280 E0A080" },
|
||||
/* 2*/ { "\357\277\277", -1, 1, 0, 1, { 0xFFFF }, "EFBFBF" },
|
||||
/* 3*/ { "\360\220\200\200", -1, 1, ZINT_ERROR_INVALID_DATA, -1, {}, "Four-byte F0908080" },
|
||||
/* 4*/ { "a\200b", -1, 1, ZINT_ERROR_INVALID_DATA, -1, {}, "Orphan continuation 0x80" },
|
||||
/* 3*/ { "\360\220\200\200", -1, 1, ZINT_ERROR_INVALID_DATA, -1, {0}, "Four-byte F0908080" },
|
||||
/* 4*/ { "a\200b", -1, 1, ZINT_ERROR_INVALID_DATA, -1, {0}, "Orphan continuation 0x80" },
|
||||
};
|
||||
int data_size = sizeof(data) / sizeof(struct item);
|
||||
|
||||
|
@ -780,7 +780,7 @@ static void test_utf8_to_eci_ucs2be(void) {
|
||||
int length = data[i].length != -1 ? data[i].length : (int) strlen(data[i].data);
|
||||
int out_length = length;
|
||||
int eci_length = get_eci_length(data[i].eci, (const unsigned char *) data[i].data, length);
|
||||
char dest[eci_length + 1];
|
||||
char *dest = alloca(eci_length + 1);
|
||||
|
||||
ret = utf8_to_eci(data[i].eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d utf8_to_eci ret %d != %d\n", i, ret, data[i].ret);
|
||||
|
@ -232,8 +232,8 @@ static void test_gb18030_utf8_to_eci(int index) {
|
||||
struct item data[] = {
|
||||
/* 0*/ { 3, 0, "é", -1, 0, 1, { 0xE9 }, "Not full multibyte" },
|
||||
/* 1*/ { 3, 1, "é", -1, 0, 1, { 0xE9 }, "First byte in range but only one byte" },
|
||||
/* 2*/ { 3, 0, "β", -1, ZINT_ERROR_INVALID_DATA, -1, {}, "Not full multibyte" },
|
||||
/* 3*/ { 3, 1, "β", -1, ZINT_ERROR_INVALID_DATA, -1, {}, "Not in ECI 3 (ISO 8859-1)" },
|
||||
/* 2*/ { 3, 0, "β", -1, ZINT_ERROR_INVALID_DATA, -1, {0}, "Not full multibyte" },
|
||||
/* 3*/ { 3, 1, "β", -1, ZINT_ERROR_INVALID_DATA, -1, {0}, "Not in ECI 3 (ISO 8859-1)" },
|
||||
/* 4*/ { 9, 0, "β", -1, 0, 1, { 0xE2 }, "Not full multibyte" },
|
||||
/* 5*/ { 9, 1, "β", -1, 0, 1, { 0xE2 }, "In ECI 9 (ISO 8859-7)" },
|
||||
/* 6*/ { 3, 0, "¥", -1, 0, 1, { 0xA5 }, "Not full multibyte" },
|
||||
@ -277,7 +277,7 @@ static void test_gb18030_utf8_to_eci(int index) {
|
||||
/* 44*/ { 29, 1, "崂", -1, 0, 1, { 0xE1C0 }, "GB 2312" },
|
||||
/* 45*/ { 29, 0, "・", -1, 0, 2, { 0xA1, 0xA4 }, "GB 2312 U+30FB" },
|
||||
/* 46*/ { 29, 1, "・", -1, 0, 1, { 0xA1A4 }, "GB 2312" },
|
||||
/* 47*/ { 29, 0, "釦", -1, ZINT_ERROR_INVALID_DATA, -1, {}, "GB 18030 U+91E6 not in GB 2312" },
|
||||
/* 47*/ { 29, 0, "釦", -1, ZINT_ERROR_INVALID_DATA, -1, {0}, "GB 18030 U+91E6 not in GB 2312" },
|
||||
/* 48*/ { 30, 0, "¡¡", -1, 0, 4, { 0x22 + 0x80, 0x2E + 0x80, 0x22 + 0x80, 0x2E + 0x80 }, "EUC-KR U+00A1 (0xA2AE)" },
|
||||
/* 49*/ { 30, 1, "¡¡", -1, 0, 2, { 0x222E + 0x8080, 0x222E + 0x8080 }, "All EUC-KR in GB 18030 Hanzi mode range" },
|
||||
/* 50*/ { 30, 0, "詰", -1, 0, 2, { 0x7D + 0x80, 0x7E + 0x80 }, "EUC-KR U+8A70 (0xFDFE)" },
|
||||
|
@ -114,7 +114,7 @@ static void test_gb2312_utf8(int index) {
|
||||
/* 0*/ { "é", -1, 0, 1, { 0xA8A6 }, "" },
|
||||
/* 1*/ { "β", -1, 0, 1, { 0xA6C2 }, "" },
|
||||
/* 2*/ { "¤", -1, 0, 1, { 0xA1E8 }, "" },
|
||||
/* 3*/ { "¥", -1, ZINT_ERROR_INVALID_DATA, -1, {}, "" },
|
||||
/* 3*/ { "¥", -1, ZINT_ERROR_INVALID_DATA, -1, {0}, "" },
|
||||
/* 4*/ { "・", -1, 0, 1, { 0xA1A4 }, "GB2312.TXT mapping" },
|
||||
/* 5*/ { "·", -1, 0, 1, { 0xA1A4 }, "GB 18030 subset mapping" },
|
||||
/* 6*/ { "―", -1, 0, 1, { 0xA1AA }, "GB2312.TXT mapping" },
|
||||
@ -178,8 +178,8 @@ static void test_gb2312_utf8_to_eci(int index) {
|
||||
struct item data[] = {
|
||||
/* 0*/ { 3, 0, "é", -1, 0, 1, { 0xE9 }, "Not full multibyte" },
|
||||
/* 1*/ { 3, 1, "é", -1, 0, 1, { 0xE9 }, "First byte in range but only one byte" },
|
||||
/* 2*/ { 3, 0, "β", -1, ZINT_ERROR_INVALID_DATA, -1, {}, "Not in ECI 3 (ISO 8859-1)" },
|
||||
/* 3*/ { 3, 1, "β", -1, ZINT_ERROR_INVALID_DATA, -1, {}, "Not in ECI 3 (ISO 8859-1)" },
|
||||
/* 2*/ { 3, 0, "β", -1, ZINT_ERROR_INVALID_DATA, -1, {0}, "Not in ECI 3 (ISO 8859-1)" },
|
||||
/* 3*/ { 3, 1, "β", -1, ZINT_ERROR_INVALID_DATA, -1, {0}, "Not in ECI 3 (ISO 8859-1)" },
|
||||
/* 4*/ { 9, 0, "β", -1, 0, 1, { 0xE2 }, "In ECI 9 (ISO 8859-7)" },
|
||||
/* 5*/ { 9, 1, "β", -1, 0, 1, { 0xE2 }, "In ECI 9 (ISO 8859-7)" },
|
||||
/* 6*/ { 3, 0, "¥", -1, 0, 1, { 0xA5 }, "Not full multibyte" },
|
||||
@ -215,7 +215,7 @@ static void test_gb2312_utf8_to_eci(int index) {
|
||||
/* 36*/ { 29, 1, "崂", -1, 0, 1, { 0xE1C0 }, "GB 2312" },
|
||||
/* 37*/ { 29, 0, "・", -1, 0, 2, { 0xA1, 0xA4 }, "GB 2312 U+30FB" },
|
||||
/* 38*/ { 29, 1, "・", -1, 0, 1, { 0xA1A4 }, "GB 2312" },
|
||||
/* 39*/ { 29, 0, "釦", -1, ZINT_ERROR_INVALID_DATA, -1, {}, "GB 18030 U+91E6 not in GB 2312" },
|
||||
/* 39*/ { 29, 0, "釦", -1, ZINT_ERROR_INVALID_DATA, -1, {0}, "GB 18030 U+91E6 not in GB 2312" },
|
||||
/* 40*/ { 30, 0, "¡¡", -1, 0, 4, { 0x22 + 0x80, 0x2E + 0x80, 0x22 + 0x80, 0x2E + 0x80 }, "EUC-KR U+00A1 (0xA2AE)" },
|
||||
/* 41*/ { 30, 1, "¡¡", -1, 0, 2, { 0x222E + 0x8080, 0x222E + 0x8080 }, "EUC-KR 0xA2AE in GB 2312 Hanzi mode range" },
|
||||
/* 42*/ { 30, 0, "詰", -1, 0, 2, { 0x7D + 0x80, 0x7E + 0x80 }, "EUC-KR U+8A70 (0xFDFE)" },
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void test_checks(int index, int debug) {
|
||||
|
||||
|
@ -134,8 +134,8 @@ static void test_sjis_utf8(int index) {
|
||||
// テ U+30C6 katakana, in Shift JIS 0x8365 (\203\145), UTF-8 E38386
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { "é", -1, ZINT_ERROR_INVALID_DATA, -1, {}, "" },
|
||||
/* 1*/ { "~", -1, ZINT_ERROR_INVALID_DATA, -1, {}, "" },
|
||||
/* 0*/ { "é", -1, ZINT_ERROR_INVALID_DATA, -1, {0}, "" },
|
||||
/* 1*/ { "~", -1, ZINT_ERROR_INVALID_DATA, -1, {0}, "" },
|
||||
/* 2*/ { "β", -1, 0, 1, { 0x83C0 }, "" },
|
||||
/* 3*/ { "¥", -1, 0, 1, { 0x5C }, "" },
|
||||
/* 4*/ { "aβcЖ¥・ソ‾\\\点茗テ", -1, 0, 13, { 'a', 0x83C0, 'c', 0x8447, 0x5C, 0xA5, 0xBF, 0x7E, 0x815F, 0x815F, 0x935F, 0xE4AA, 0x8365 }, "" },
|
||||
@ -194,8 +194,8 @@ static void test_sjis_utf8_to_eci(int index) {
|
||||
struct item data[] = {
|
||||
/* 0*/ { 3, 0, "é", -1, 0, 1, { 0xE9 }, "" },
|
||||
/* 1*/ { 3, 1, "é", -1, 0, 1, { 0xE9 }, "" },
|
||||
/* 2*/ { 3, 0, "β", -1, ZINT_ERROR_INVALID_DATA, -1, {}, "" },
|
||||
/* 3*/ { 3, 1, "β", -1, ZINT_ERROR_INVALID_DATA, -1, {}, "" },
|
||||
/* 2*/ { 3, 0, "β", -1, ZINT_ERROR_INVALID_DATA, -1, {0}, "" },
|
||||
/* 3*/ { 3, 1, "β", -1, ZINT_ERROR_INVALID_DATA, -1, {0}, "" },
|
||||
/* 4*/ { 9, 0, "β", -1, 0, 1, { 0xE2 }, "" },
|
||||
/* 5*/ { 9, 1, "β", -1, 0, 1, { 0xE2 }, "" },
|
||||
/* 6*/ { 3, 0, "¥", -1, 0, 1, { 0xA5 }, "" },
|
||||
@ -210,7 +210,7 @@ static void test_sjis_utf8_to_eci(int index) {
|
||||
/* 15*/ { 20, 1, "\\\\", -1, 0, 2, { 0x815F, 0x815F }, "Shift JIS reverse solidus (backslash) mapping from ASCII to double byte" },
|
||||
/* 16*/ { 20, 0, "爍", -1, 0, 2, { 0xE0, 0xA1 }, "Shift JIS U+720D" },
|
||||
/* 17*/ { 20, 1, "爍", -1, 0, 1, { 0xE0A1 }, "Shift JIS" },
|
||||
/* 18*/ { 20, 0, "~", -1, ZINT_ERROR_INVALID_DATA, -1, {}, "ASCII tilde not in Shift JIS" },
|
||||
/* 18*/ { 20, 0, "~", -1, ZINT_ERROR_INVALID_DATA, -1, {0}, "ASCII tilde not in Shift JIS" },
|
||||
/* 19*/ { 25, 0, "12", -1, 0, 4, { 0x00, 0x31, 0x00, 0x32 }, "UCS-2BE ASCII" },
|
||||
/* 20*/ { 25, 0, "", -1, 0, 4, { 0x00, 0x81, 0x00, 0x81 }, "UCS-2BE U+0081" },
|
||||
/* 21*/ { 25, 1, "", -1, 0, 4, { 0x00, 0x81, 0x00, 0x81 }, "UCS-2BE outside QR Kanji mode range" },
|
||||
@ -223,7 +223,7 @@ static void test_sjis_utf8_to_eci(int index) {
|
||||
/* 28*/ { 29, 0, "¨¨", -1, 0, 4, { 0xA1, 0xA7, 0xA1, 0xA7 }, "GB 2312 U+00A8" },
|
||||
/* 29*/ { 29, 1, "¨¨", -1, 0, 4, { 0xA1, 0xA7, 0xA1, 0xA7 }, "GB 2312 outside QR Kanji mode range" },
|
||||
/* 30*/ { 29, 0, "崂", -1, 0, 2, { 0xE1, 0xC0 }, "GB 2312 U+5D02" },
|
||||
/* 31*/ { 29, 0, "釦", -1, ZINT_ERROR_INVALID_DATA, -1, {}, "GB 18030 U+91E6 not in GB 2312" },
|
||||
/* 31*/ { 29, 0, "釦", -1, ZINT_ERROR_INVALID_DATA, -1, {0}, "GB 18030 U+91E6 not in GB 2312" },
|
||||
/* 32*/ { 29, 1, "崂", -1, 0, 1, { 0xE1C0 }, "GB 2312 in QR Kanji mode range" },
|
||||
/* 33*/ { 30, 0, "¡¡", -1, 0, 4, { 0x22 + 0x80, 0x2E + 0x80, 0x22 + 0x80, 0x2E + 0x80 }, "EUC-KR U+00A1 (0xA2AE)" },
|
||||
/* 34*/ { 30, 1, "¡¡", -1, 0, 4, { 0x22 + 0x80, 0x2E + 0x80, 0x22 + 0x80, 0x2E + 0x80 }, "EUC-KR 0xA2AE outside QR Kanji mode range" },
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include <assert.h>
|
||||
#include <getopt.h>
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
static int tests = 0;
|
||||
@ -2098,13 +2097,13 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
|
||||
int max_data_len = 4 + primary_len + 1 + 1 + data_len * 4 + 64; /* 4 AI prefix + primary + '|' + leading zero + escaped data + fudge */
|
||||
|
||||
int eci_length = get_eci_length(symbol->eci, (const unsigned char *) data, data_len);
|
||||
char converted[eci_length + 1];
|
||||
char cmd[max_data_len + 1024];
|
||||
char *converted = alloca(eci_length + 1);
|
||||
char *cmd = alloca(max_data_len + 1024);
|
||||
const char *bwipp_barcode = NULL;
|
||||
char *bwipp_opts = NULL;
|
||||
char bwipp_data[max_data_len + 1];
|
||||
char *bwipp_data = alloca(max_data_len + 1);
|
||||
char bwipp_opts_buf[512];
|
||||
int bwipp_row_height[symbol->rows];
|
||||
int *bwipp_row_height = alloca(sizeof(int) * symbol->rows);
|
||||
int linear_row_height;
|
||||
int gs1_cvt;
|
||||
int user_mask;
|
||||
|
@ -42,6 +42,14 @@
|
||||
#define ZINT_DEBUG_TEST_BWIPP 128
|
||||
#define ZINT_DEBUG_TEST_PERFORMANCE 256
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <malloc.h>
|
||||
#define alloca(nmemb) _malloca(nmemb)
|
||||
#define popen(command, mode) _popen(command, mode)
|
||||
#define pclose(stream) _pclose(stream)
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include "../common.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user