1
0
mirror of https://git.code.sf.net/p/zint/code synced 2025-12-20 11:27:09 +00:00

ERROR_* renamed to ZERROR*

This commit is contained in:
tgotic
2011-01-17 19:32:47 +01:00
parent d89876d85b
commit 0c2742262d

View File

@@ -101,7 +101,7 @@ int is_sane(char test_string[], unsigned char source[], int length)
} }
} }
if (!(latch)) { if (!(latch)) {
return ERROR_INVALID_DATA; return ZERROR_INVALID_DATA;
} }
} }
@@ -127,7 +127,7 @@ void lookup(char set_string[], char *table[], char data, char dest[])
int module_is_set(struct zint_symbol *symbol, int y_coord, int x_coord) int module_is_set(struct zint_symbol *symbol, int y_coord, int x_coord)
{ {
return (symbol->encoded_data[y_coord][x_coord / 7] & (1 << (x_coord % 7))) ? 1 : 0; return (symbol->encoded_data[y_coord][x_coord / 7] >> (x_coord % 7)) & 1;
#if 0 #if 0
switch(x_sub) { switch(x_sub) {
case 0: if((symbol->encoded_data[y_coord][x_char] & 0x01) != 0) { result = 1; } break; case 0: if((symbol->encoded_data[y_coord][x_char] & 0x01) != 0) { result = 1; } break;
@@ -145,8 +145,7 @@ int module_is_set(struct zint_symbol *symbol, int y_coord, int x_coord)
void set_module(struct zint_symbol *symbol, int y_coord, int x_coord) void set_module(struct zint_symbol *symbol, int y_coord, int x_coord)
{ {
if(module_is_set(symbol, y_coord, x_coord)) { return; } symbol->encoded_data[y_coord][x_coord / 7] |= 1 << (x_coord % 7);
symbol->encoded_data[y_coord][x_coord / 7] += 1 << (x_coord % 7);
#if 0 #if 0
int x_char, x_sub; int x_char, x_sub;
@@ -168,8 +167,7 @@ void set_module(struct zint_symbol *symbol, int y_coord, int x_coord)
void unset_module(struct zint_symbol *symbol, int y_coord, int x_coord) void unset_module(struct zint_symbol *symbol, int y_coord, int x_coord)
{ {
if(!(module_is_set(symbol, y_coord, x_coord))) { return; } symbol->encoded_data[y_coord][x_coord / 7] &= ~(1 << (x_coord % 7));
symbol->encoded_data[y_coord][x_coord / 7] -= 1 << (x_coord % 7);
#if 0 #if 0
int x_char, x_sub; int x_char, x_sub;
@@ -203,11 +201,8 @@ void expand(struct zint_symbol *symbol, char data[])
if(latch == '1') { set_module(symbol, symbol->rows, writer); } if(latch == '1') { set_module(symbol, symbol->rows, writer); }
writer++; writer++;
} }
if(latch == '1') {
latch = '0'; latch = (latch == '1' ? '0' : '1');
} else {
latch = '1';
}
} }
if(symbol->symbology != BARCODE_PHARMA) { if(symbol->symbology != BARCODE_PHARMA) {
@@ -315,7 +310,7 @@ int latin1_process(struct zint_symbol *symbol, unsigned char source[], unsigned
} }
if(next == -1) { if(next == -1) {
strcpy(symbol->errtxt, "error: Invalid character in input string (only Latin-1 characters supported)"); strcpy(symbol->errtxt, "error: Invalid character in input string (only Latin-1 characters supported)");
return ERROR_INVALID_DATA; return ZERROR_INVALID_DATA;
} }
i = next; i = next;
} while(i < *length); } while(i < *length);
@@ -327,7 +322,7 @@ int latin1_process(struct zint_symbol *symbol, unsigned char source[], unsigned
int utf8toutf16(struct zint_symbol *symbol, unsigned char source[], int vals[], int *length) int utf8toutf16(struct zint_symbol *symbol, unsigned char source[], int vals[], int *length)
{ {
int bpos, jpos, error_number, done; int bpos, jpos, error_number;
int next; int next;
bpos = 0; bpos = 0;
@@ -336,54 +331,36 @@ int utf8toutf16(struct zint_symbol *symbol, unsigned char source[], int vals[],
next = 0; next = 0;
do { do {
done = 0;
if(source[bpos] <= 0x7f) { if(source[bpos] <= 0x7f) {
/* 1 byte mode (7-bit ASCII) */ /* 1 byte mode (7-bit ASCII) */
vals[jpos] = source[bpos]; vals[jpos] = source[bpos];
next = bpos + 1; next = bpos + 1;
jpos++; jpos++;
done = 1; } else {
}
if(done == 0) {
if((source[bpos] >= 0x80) && (source[bpos] <= 0xbf)) { if((source[bpos] >= 0x80) && (source[bpos] <= 0xbf)) {
strcpy(symbol->errtxt, "Corrupt Unicode data"); strcpy(symbol->errtxt, "Corrupt Unicode data");
return ERROR_INVALID_DATA; return ZERROR_INVALID_DATA;
} }
}
if(done == 0) {
if((source[bpos] >= 0xc0) && (source[bpos] <= 0xc1)) { if((source[bpos] >= 0xc0) && (source[bpos] <= 0xc1)) {
strcpy(symbol->errtxt, "Overlong encoding not supported"); strcpy(symbol->errtxt, "Overlong encoding not supported");
return ERROR_INVALID_DATA; return ZERROR_INVALID_DATA;
}
} }
if(done == 0) {
if((source[bpos] >= 0xc2) && (source[bpos] <= 0xdf)) { if((source[bpos] >= 0xc2) && (source[bpos] <= 0xdf)) {
/* 2 byte mode */ /* 2 byte mode */
vals[jpos] = ((source[bpos] & 0x1f) << 6) + (source[bpos + 1] & 0x3f); vals[jpos] = ((source[bpos] & 0x1f) << 6) + (source[bpos + 1] & 0x3f);
next = bpos + 2; next = bpos + 2;
jpos++; jpos++;
done = 1; } else
}
}
if(done == 0) {
if((source[bpos] >= 0xe0) && (source[bpos] <= 0xef)) { if((source[bpos] >= 0xe0) && (source[bpos] <= 0xef)) {
/* 3 byte mode */ /* 3 byte mode */
vals[jpos] = ((source[bpos] & 0x0f) << 12) + ((source[bpos + 1] & 0x3f) << 6) + (source[bpos + 2] & 0x3f); vals[jpos] = ((source[bpos] & 0x0f) << 12) + ((source[bpos + 1] & 0x3f) << 6) + (source[bpos + 2] & 0x3f);
next = bpos + 3; next = bpos + 3;
jpos ++; jpos ++;
done = 1; } else
}
}
if(done == 0) {
if(source[bpos] >= 0xf0) { if(source[bpos] >= 0xf0) {
strcpy(symbol->errtxt, "Unicode sequences of more than 3 bytes not supported"); strcpy(symbol->errtxt, "Unicode sequences of more than 3 bytes not supported");
return ERROR_INVALID_DATA; return ZERROR_INVALID_DATA;
} }
} }