lazbarcodes: Refactor avoiding trivial usage of function IsTrue(boolean) (not complete).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8239 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-03-28 17:13:07 +00:00
parent f75afb789d
commit 7e371e08cd
2 changed files with 335 additions and 359 deletions

View File

@ -94,12 +94,12 @@ matrixrsblock: array [0..29] of integer = (
procedure ecc200placementbit(parray: PInteger; NR: Integer; NC: Integer; r: Integer; c: Integer; p: Integer; b: BYTE); procedure ecc200placementbit(parray: PInteger; NR: Integer; NC: Integer; r: Integer; c: Integer; p: Integer; b: BYTE);
begin begin
if IsTrue(r < 0) then if (r < 0) then
begin begin
r := r + NR; r := r + NR;
c := c + (4 - ((NR + 4) mod 8)); c := c + (4 - ((NR + 4) mod 8));
end; end;
if IsTrue(c < 0) then if (c < 0) then
begin begin
c := c + NC; c := c + NC;
r := r + (4 - ((NC + 4) mod 8)); r := r + (4 - ((NC + 4) mod 8));
@ -188,51 +188,51 @@ begin
r := 4; r := 4;
c := 0; c := 0;
repeat repeat
if IsTrue(IsTrue(r = NR) AND IsTrue(BooleanNot (c))) then if IsTrue((r = NR) and IsTrue(BooleanNot (c))) then
begin begin
ecc200placementcornerA (parray, NR, NC, PostInc (p)); ecc200placementcornerA (parray, NR, NC, PostInc (p));
end; end;
if IsTrue(IsTrue(IsTrue(r = NR - 2) AND IsTrue(BooleanNot (c))) AND IsTrue(NC mod 4)) then if IsTrue(IsTrue((r = NR - 2) AND IsTrue(BooleanNot (c))) AND IsTrue(NC mod 4)) then
begin begin
ecc200placementcornerB (parray, NR, NC, PostInc (p)); ecc200placementcornerB (parray, NR, NC, PostInc (p));
end; end;
if IsTrue(IsTrue(IsTrue(r = NR - 2) AND IsTrue(BooleanNot (c))) AND IsTrue((NC mod 8) = 4)) then if IsTrue(IsTrue((r = NR - 2) AND IsTrue(BooleanNot (c))) AND IsTrue((NC mod 8) = 4)) then
begin begin
ecc200placementcornerC (parray, NR, NC, PostInc (p)); ecc200placementcornerC (parray, NR, NC, PostInc (p));
end; end;
if IsTrue(IsTrue(IsTrue(r = NR + 4) AND IsTrue(c = 2)) AND IsTrue(BooleanNot ((NC mod 8)))) then if IsTrue(IsTrue((r = NR + 4) AND IsTrue(c = 2)) AND IsTrue(BooleanNot ((NC mod 8)))) then
begin begin
ecc200placementcornerD (parray, NR, NC, PostInc (p)); ecc200placementcornerD (parray, NR, NC, PostInc (p));
end; end;
repeat repeat
if IsTrue(IsTrue(IsTrue(r < NR) AND IsTrue(c >= 0)) AND IsTrue(BooleanNot (parray[r * NC + c]))) then if IsTrue((r < NR) and (c >= 0) AND IsTrue(BooleanNot (parray[r * NC + c]))) then
begin begin
ecc200placementblock (parray, NR, NC, r, c, PostInc (p)); ecc200placementblock (parray, NR, NC, r, c, PostInc (p));
end; end;
r := r - 2; r := r - 2;
c := c + 2; c := c + 2;
until not (IsTrue(r >= 0) AND IsTrue(c < NC)); until not ((r >= 0) and (c < NC));
Inc (r); Inc (r);
c := c + 3; c := c + 3;
repeat repeat
if IsTrue(IsTrue(IsTrue(r >= 0) AND IsTrue(c < NC)) AND IsTrue(BooleanNot (parray[r * NC + c]))) then if IsTrue(IsTrue((r >= 0) and (c < NC)) AND IsTrue(BooleanNot (parray[r * NC + c]))) then
begin begin
ecc200placementblock (parray, NR, NC, r, c, PostInc (p)); ecc200placementblock (parray, NR, NC, r, c, PostInc (p));
end; end;
r := r + 2; r := r + 2;
c := c - 2; c := c - 2;
until not (IsTrue(r < NR) AND IsTrue(c >= 0)); until not ((r < NR) and (c >= 0));
r := r + 3; r := r + 3;
Inc (c); Inc (c);
until not (IsTrue(r < NR) OR IsTrue(c < NC)); until not ((r < NR) or (c < NC));
if IsTrue(BooleanNot (parray[NR * NC - 1])) then if BooleanNot(parray[NR * NC - 1]) then
begin begin
parray[NR * NC - NC - 2] := 1; parray[NR * NC - NC - 2] := 1;
parray[NR * NC - 1] := 1; parray[NR * NC - 1] := 1;
end; end;
end; end;
procedure ecc200(binary: PBYTE; bytes: Integer; datablock: Integer; rsblock: Integer; skew: Integer); procedure ecc200(binary: PByte; bytes, datablock, rsblock, skew: Integer);
var var
b: Integer; b: Integer;
blocks: Integer; blocks: Integer;
@ -259,9 +259,9 @@ begin
n := b; n := b;
while n < rsblock * blocks do while n < rsblock * blocks do
begin begin
if IsTrue(skew) then if skew <> 0 then
begin begin
if IsTrue(b < 8) then if b < 8 then
begin begin
binary[bytes + n + 2] := ecc[PostDec (p)]; binary[bytes + n + 2] := ecc[PostDec (p)];
end else begin end else begin
@ -277,33 +277,9 @@ begin
rs_free; rs_free;
end; end;
function isx12(source: BYTE): Integer; function isx12(source: Byte): Boolean;
begin begin
if IsTrue(source = 13) then Result := source in [13, 42, 62, 32, byte('0')..byte('9'), byte('A')..byte('Z')];
begin
exit (1);
end;
if IsTrue(source = 42) then
begin
exit (1);
end;
if IsTrue(source = 62) then
begin
exit (1);
end;
if IsTrue(source = 32) then
begin
exit (1);
end;
if IsTrue(IsTrue((source >= BYTE('0'))) AND IsTrue((source <= BYTE('9')))) then
begin
exit (1);
end;
if IsTrue(IsTrue((source >= BYTE('A'))) AND IsTrue((source <= BYTE('Z')))) then
begin
exit (1);
end;
exit (0);
end; end;
procedure dminsert(binary_string: PChar; posn: Integer; newbit: Char); procedure dminsert(binary_string: PChar; posn: Integer; newbit: Char);
@ -348,7 +324,7 @@ var
sp: Integer; sp: Integer;
reduced_char: Char; reduced_char: Char;
begin begin
if IsTrue(current_mode = DM_ASCII) then if current_mode = DM_ASCII then
begin begin
ascii_count := 0.0; ascii_count := 0.0;
c40_count := 1.0; c40_count := 1.0;
@ -372,94 +348,94 @@ begin
DM_BASE256: b256_count := 0.0; DM_BASE256: b256_count := 0.0;
end; end;
sp := position; sp := position;
while IsTrue((sp < sourcelen)) AND IsTrue((sp <= (position + 8))) do while (sp < sourcelen) and (sp <= position + 8) do
begin begin
if IsTrue(source[sp] <= 127) then if source[sp] <= 127 then
begin begin
reduced_char := char(source[sp]); reduced_char := char(source[sp]);
end else begin end else begin
reduced_char := char(source[sp] - 127); reduced_char := char(source[sp] - 127);
end; end;
if IsTrue(IsTrue((source[sp] >= BYTE('0'))) AND IsTrue((source[sp] <= BYTE('9')))) then if (source[sp] in [byte('0')..byte('9')]) then
begin begin
ascii_count := ascii_count + 0.5; ascii_count := ascii_count + 0.5;
end else begin end else begin
ascii_count := ascii_count + 1.0; ascii_count := ascii_count + 1.0;
end; end;
if IsTrue(source[sp] > 127) then if source[sp] > 127 then
begin begin
ascii_count := ascii_count + 1.0; ascii_count := ascii_count + 1.0;
end; end;
done := 0; done := 0;
if IsTrue(reduced_char = ' ') then if reduced_char = ' ' then
begin begin
c40_count := c40_count + ((2.0 / 3.0)); c40_count := c40_count + ((2.0 / 3.0));
done := 1; done := 1;
end; end;
if IsTrue(IsTrue((reduced_char >= '0')) AND IsTrue((reduced_char <= '9'))) then if (reduced_char in ['0'..'9']) then
begin begin
c40_count := c40_count + ((2.0 / 3.0)); c40_count := c40_count + ((2.0 / 3.0));
done := 1; done := 1;
end; end;
if IsTrue(IsTrue((reduced_char >= 'A')) AND IsTrue((reduced_char <= 'Z'))) then if (reduced_char in ['A'..'Z']) then
begin begin
c40_count := c40_count + ((2.0 / 3.0)); c40_count := c40_count + ((2.0 / 3.0));
done := 1; done := 1;
end; end;
if IsTrue(source[sp] > 127) then if source[sp] > 127 then
begin begin
c40_count := c40_count + ((4.0 / 3.0)); c40_count := c40_count + ((4.0 / 3.0));
end; end;
if IsTrue(done = 0) then if done = 0 then
begin begin
c40_count := c40_count + ((4.0 / 3.0)); c40_count := c40_count + ((4.0 / 3.0));
end; end;
done := 0; done := 0;
if IsTrue(reduced_char = ' ') then if reduced_char = ' ' then
begin begin
text_count := text_count + ((2.0 / 3.0)); text_count := text_count + ((2.0 / 3.0));
done := 1; done := 1;
end; end;
if IsTrue(IsTrue((reduced_char >= '0')) AND IsTrue((reduced_char <= '9'))) then if (reduced_char in ['0'..'9']) then
begin begin
text_count := text_count + ((2.0 / 3.0)); text_count := text_count + ((2.0 / 3.0));
done := 1; done := 1;
end; end;
if IsTrue(IsTrue((reduced_char >= 'a')) AND IsTrue((reduced_char <= 'z'))) then if (reduced_char in ['a'..'z']) then
begin begin
text_count := text_count + ((2.0 / 3.0)); text_count := text_count + ((2.0 / 3.0));
done := 1; done := 1;
end; end;
if IsTrue(source[sp] > 127) then if source[sp] > 127 then
begin begin
text_count := text_count + ((4.0 / 3.0)); text_count := text_count + ((4.0 / 3.0));
end; end;
if IsTrue(done = 0) then if done = 0 then
begin begin
text_count := text_count + ((4.0 / 3.0)); text_count := text_count + ((4.0 / 3.0));
end; end;
if IsTrue(isx12 (source[sp])) then if isx12(source[sp]) then
begin begin
x12_count := x12_count + ((2.0 / 3.0)); x12_count := x12_count + ((2.0 / 3.0));
end else begin end else begin
x12_count := x12_count + 4.0; x12_count := x12_count + 4.0;
end; end;
done := 0; done := 0;
if IsTrue(IsTrue((source[sp] >= BYTE(' '))) AND IsTrue((source[sp] <= BYTE('^')))) then if (source[sp] in [Byte(' ')..Byte('^')]) then
begin begin
edf_count := edf_count + ((3.0 / 4.0)); edf_count := edf_count + ((3.0 / 4.0));
end else begin end else begin
edf_count := edf_count + 6.0; edf_count := edf_count + 6.0;
end; end;
if IsTrue(IsTrue(gs1) AND IsTrue((source[sp] = BYTE('[')))) then if IsTrue(gs1) and (source[sp] = Byte('[')) then
begin begin
edf_count := edf_count + 6.0; edf_count := edf_count + 6.0;
end; end;
if IsTrue(sp >= (sourcelen - 5)) then if sp >= (sourcelen - 5) then
begin begin
edf_count := edf_count + 6.0; edf_count := edf_count + 6.0;
end; end;
if IsTrue(IsTrue(gs1) AND IsTrue((source[sp] = BYTE('[')))) then if IsTrue(gs1) and (source[sp] = BYTE('[')) then
begin begin
b256_count := b256_count + 4.0; b256_count := b256_count + 4.0;
end else begin end else begin
@ -469,27 +445,27 @@ begin
end; end;
best_count := ascii_count; best_count := ascii_count;
best_scheme := DM_ASCII; best_scheme := DM_ASCII;
if IsTrue(b256_count <= best_count) then if b256_count <= best_count then
begin begin
best_count := b256_count; best_count := b256_count;
best_scheme := DM_BASE256; best_scheme := DM_BASE256;
end; end;
if IsTrue(edf_count <= best_count) then if edf_count <= best_count then
begin begin
best_count := edf_count; best_count := edf_count;
best_scheme := DM_EDIFACT; best_scheme := DM_EDIFACT;
end; end;
if IsTrue(text_count <= best_count) then if text_count <= best_count then
begin begin
best_count := text_count; best_count := text_count;
best_scheme := DM_TEXT; best_scheme := DM_TEXT;
end; end;
if IsTrue(x12_count <= best_count) then if x12_count <= best_count then
begin begin
best_count := x12_count; best_count := x12_count;
best_scheme := DM_X12; best_scheme := DM_X12;
end; end;
if IsTrue(c40_count <= best_count) then if c40_count <= best_count then
begin begin
best_count := c40_count; best_count := c40_count;
best_scheme := DM_C40; best_scheme := DM_C40;
@ -539,7 +515,7 @@ begin
strcpy (binary, ''); strcpy (binary, '');
current_mode := DM_ASCII; current_mode := DM_ASCII;
next_mode := DM_ASCII; next_mode := DM_ASCII;
if IsTrue(symbol^.input_mode = GS1_MODE) then if symbol^.input_mode = GS1_MODE then
begin begin
gs1 := 1; gs1 := 1;
end else begin end else begin
@ -555,7 +531,7 @@ begin
write( format ('FN1 ',[]) ); write( format ('FN1 ',[]) );
end; end;
end; end;
if IsTrue(symbol^.output_options and READER_INIT) then if (symbol^.output_options and READER_INIT <> 0) then
begin begin
if IsTrue(gs1) then if IsTrue(gs1) then
begin begin
@ -574,7 +550,7 @@ begin
while sp < inputlen do while sp < inputlen do
begin begin
current_mode := next_mode; current_mode := next_mode;
if IsTrue(current_mode = DM_ASCII) then if (current_mode = DM_ASCII) then
begin begin
next_mode := DM_ASCII; next_mode := DM_ASCII;
if IsTrue(IsTrue(istwodigits (source, sp)) AND IsTrue(((sp + 1) <> inputlen))) then if IsTrue(IsTrue(istwodigits (source, sp)) AND IsTrue(((sp + 1) <> inputlen))) then
@ -589,7 +565,7 @@ begin
sp := sp + 2; sp := sp + 2;
end else begin end else begin
next_mode := look_ahead_test (source, inputlen, sp, current_mode, gs1); next_mode := look_ahead_test (source, inputlen, sp, current_mode, gs1);
if IsTrue(next_mode <> DM_ASCII) then if (next_mode <> DM_ASCII) then
begin begin
case next_mode of case next_mode of
DM_C40: DM_C40:
@ -644,7 +620,7 @@ begin
end; end;
end; end;
end else begin end else begin
if IsTrue(source[sp] > 127) then if (source[sp] > 127) then
begin begin
target[tp] := 235; target[tp] := 235;
if IsTrue(debug) then if IsTrue(debug) then
@ -660,7 +636,7 @@ begin
Inc (tp); Inc (tp);
concat (binary, ' '); concat (binary, ' ');
end else begin end else begin
if IsTrue(IsTrue(gs1) AND IsTrue((source[sp] = BYTE('[')))) then if IsTrue(gs1) and (source[sp] = Byte('[')) then
begin begin
target[tp] := 232; target[tp] := 232;
if IsTrue(debug) then if IsTrue(debug) then
@ -681,14 +657,14 @@ begin
end; end;
end; end;
end; end;
if IsTrue(current_mode = DM_C40) then if (current_mode = DM_C40) then
begin begin
next_mode := DM_C40; next_mode := DM_C40;
if IsTrue(c40_p = 0) then if (c40_p = 0) then
begin begin
next_mode := look_ahead_test (source, inputlen, sp, current_mode, gs1); next_mode := look_ahead_test (source, inputlen, sp, current_mode, gs1);
end; end;
if IsTrue(next_mode <> DM_C40) then if (next_mode <> DM_C40) then
begin begin
target[tp] := 254; target[tp] := 254;
Inc (tp); Inc (tp);
@ -699,7 +675,7 @@ begin
write( format ('ASC ',[]) ); write( format ('ASC ',[]) );
end; end;
end else begin end else begin
if IsTrue(source[sp] > 127) then if (source[sp] > 127) then
begin begin
c40_buffer[c40_p] := 1; c40_buffer[c40_p] := 1;
Inc (c40_p); Inc (c40_p);
@ -711,19 +687,19 @@ begin
shift_set := c40_shift[source[sp]]; shift_set := c40_shift[source[sp]];
value := c40_value[source[sp]]; value := c40_value[source[sp]];
end; end;
if IsTrue(IsTrue(gs1) AND IsTrue((source[sp] = BYTE('[')))) then if IsTrue(gs1) and (source[sp] = Byte('[')) then
begin begin
shift_set := 2; shift_set := 2;
value := 27; value := 27;
end; end;
if IsTrue(shift_set <> 0) then if (shift_set <> 0) then
begin begin
c40_buffer[c40_p] := shift_set - 1; c40_buffer[c40_p] := shift_set - 1;
Inc (c40_p); Inc (c40_p);
end; end;
c40_buffer[c40_p] := value; c40_buffer[c40_p] := value;
Inc (c40_p); Inc (c40_p);
if IsTrue(c40_p >= 3) then if (c40_p >= 3) then
begin begin
iv := (1600 * c40_buffer[0]) + (40 * c40_buffer[1]) + (c40_buffer[2]) + 1; iv := (1600 * c40_buffer[0]) + (40 * c40_buffer[1]) + (c40_buffer[2]) + 1;
target[tp] := iv div 256; target[tp] := iv div 256;
@ -746,14 +722,14 @@ begin
Inc (sp); Inc (sp);
end; end;
end; end;
if IsTrue(current_mode = DM_TEXT) then if (current_mode = DM_TEXT) then
begin begin
next_mode := DM_TEXT; next_mode := DM_TEXT;
if IsTrue(text_p = 0) then if (text_p = 0) then
begin begin
next_mode := look_ahead_test (source, inputlen, sp, current_mode, gs1); next_mode := look_ahead_test (source, inputlen, sp, current_mode, gs1);
end; end;
if IsTrue(next_mode <> DM_TEXT) then if (next_mode <> DM_TEXT) then
begin begin
target[tp] := 254; target[tp] := 254;
Inc (tp); Inc (tp);
@ -764,7 +740,7 @@ begin
write( format ('ASC ',[]) ); write( format ('ASC ',[]) );
end; end;
end else begin end else begin
if IsTrue(source[sp] > 127) then if (source[sp] > 127) then
begin begin
text_buffer[text_p] := 1; text_buffer[text_p] := 1;
Inc (text_p); Inc (text_p);
@ -776,19 +752,19 @@ begin
shift_set := text_shift[source[sp]]; shift_set := text_shift[source[sp]];
value := text_value[source[sp]]; value := text_value[source[sp]];
end; end;
if IsTrue(IsTrue(gs1) AND IsTrue((source[sp] = BYTE('[')))) then if IsTrue(gs1) and (source[sp] = Byte('[')) then
begin begin
shift_set := 2; shift_set := 2;
value := 27; value := 27;
end; end;
if IsTrue(shift_set <> 0) then if (shift_set <> 0) then
begin begin
text_buffer[text_p] := shift_set - 1; text_buffer[text_p] := shift_set - 1;
Inc (text_p); Inc (text_p);
end; end;
text_buffer[text_p] := value; text_buffer[text_p] := value;
Inc (text_p); Inc (text_p);
if IsTrue(text_p >= 3) then if (text_p >= 3) then
begin begin
iv := (1600 * text_buffer[0]) + (40 * text_buffer[1]) + (text_buffer[2]) + 1; iv := (1600 * text_buffer[0]) + (40 * text_buffer[1]) + (text_buffer[2]) + 1;
target[tp] := iv div 256; target[tp] := iv div 256;
@ -811,15 +787,15 @@ begin
Inc (sp); Inc (sp);
end; end;
end; end;
if IsTrue(current_mode = DM_X12) then if (current_mode = DM_X12) then
begin begin
{INITCODE} value := 0; {INITCODE} value := 0;
next_mode := DM_X12; next_mode := DM_X12;
if IsTrue(text_p = 0) then if (text_p = 0) then
begin begin
next_mode := look_ahead_test (source, inputlen, sp, current_mode, gs1); next_mode := look_ahead_test (source, inputlen, sp, current_mode, gs1);
end; end;
if IsTrue(next_mode <> DM_X12) then if (next_mode <> DM_X12) then
begin begin
target[tp] := 254; target[tp] := 254;
Inc (tp); Inc (tp);
@ -830,33 +806,33 @@ begin
write( format ('ASC ',[]) ); write( format ('ASC ',[]) );
end; end;
end else begin end else begin
if IsTrue(source[sp] = 13) then if (source[sp] = 13) then
begin begin
value := 0; value := 0;
end; end;
if IsTrue(source[sp] = BYTE('*')) then if (source[sp] = Byte('*')) then
begin begin
value := 1; value := 1;
end; end;
if IsTrue(source[sp] = BYTE('>')) then if (source[sp] = Byte('>')) then
begin begin
value := 2; value := 2;
end; end;
if IsTrue(source[sp] = BYTE(' ')) then if (source[sp] = Byte(' ')) then
begin begin
value := 3; value := 3;
end; end;
if IsTrue(IsTrue((source[sp] >= BYTE('0'))) AND IsTrue((source[sp] <= BYTE('9')))) then if source[sp] in [Byte('0')..Byte('9')] then
begin begin
value := (source[sp] - BYTE('0')) + 4; value := (source[sp] - BYTE('0')) + 4;
end; end;
if IsTrue(IsTrue((source[sp] >= BYTE('A'))) AND IsTrue((source[sp] <= BYTE('Z')))) then if source[sp] in [Byte('A')..Byte('Z')] then
begin begin
value := (source[sp] - BYTE('A')) + 14; value := (source[sp] - Byte('A')) + 14;
end; end;
x12_buffer[x12_p] := value; x12_buffer[x12_p] := value;
Inc (x12_p); Inc(x12_p);
if IsTrue(x12_p >= 3) then if (x12_p >= 3) then
begin begin
iv := (1600 * x12_buffer[0]) + (40 * x12_buffer[1]) + (x12_buffer[2]) + 1; iv := (1600 * x12_buffer[0]) + (40 * x12_buffer[1]) + (x12_buffer[2]) + 1;
target[tp] := iv div 256; target[tp] := iv div 256;
@ -879,25 +855,25 @@ begin
Inc (sp); Inc (sp);
end; end;
end; end;
if IsTrue(current_mode = DM_EDIFACT) then if (current_mode = DM_EDIFACT) then
begin begin
{INITCODE} value := 0; {INITCODE} value := 0;
next_mode := DM_EDIFACT; next_mode := DM_EDIFACT;
if IsTrue(edifact_p = 3) then if (edifact_p = 3) then
begin begin
next_mode := look_ahead_test (source, inputlen, sp, current_mode, gs1); next_mode := look_ahead_test (source, inputlen, sp, current_mode, gs1);
end; end;
if IsTrue(next_mode <> DM_EDIFACT) then if (next_mode <> DM_EDIFACT) then
begin begin
edifact_buffer[edifact_p] := 31; edifact_buffer[edifact_p] := 31;
Inc (edifact_p); Inc (edifact_p);
next_mode := DM_ASCII; next_mode := DM_ASCII;
end else begin end else begin
if IsTrue(IsTrue((source[sp] >= BYTE('@'))) AND IsTrue((source[sp] <= BYTE('^')))) then if source[sp] in [Byte('@')..Byte('^')] then
begin begin
value := source[sp] - BYTE('@'); value := source[sp] - BYTE('@');
end; end;
if IsTrue(IsTrue((source[sp] >= BYTE(' '))) AND IsTrue((source[sp] <= BYTE('?')))) then if source[sp] in [Byte(' ')..Byte('?')] then
begin begin
value := source[sp]; value := source[sp];
end; end;
@ -905,7 +881,7 @@ begin
Inc (edifact_p); Inc (edifact_p);
Inc (sp); Inc (sp);
end; end;
if IsTrue(edifact_p >= 4) then if (edifact_p >= 4) then
begin begin
target[tp] := (edifact_buffer[0] shl 2) + ((edifact_buffer[1] and $30) shr 4); target[tp] := (edifact_buffer[0] shl 2) + ((edifact_buffer[1] and $30) shr 4);
Inc (tp); Inc (tp);
@ -929,7 +905,7 @@ begin
edifact_p := edifact_p - 4; edifact_p := edifact_p - 4;
end; end;
end; end;
if IsTrue(current_mode = DM_BASE256) then if (current_mode = DM_BASE256) then
begin begin
next_mode := look_ahead_test (source, inputlen, sp, current_mode, gs1); next_mode := look_ahead_test (source, inputlen, sp, current_mode, gs1);
if IsTrue(next_mode = DM_BASE256) then if IsTrue(next_mode = DM_BASE256) then
@ -950,12 +926,12 @@ begin
end; end;
end; end;
end; end;
if IsTrue(tp > 1558) then if (tp > 1558) then
begin begin
exit (0); exit (0);
end; end;
end; end;
if IsTrue(c40_p = 2) then if (c40_p = 2) then
begin begin
target[tp] := 254; target[tp] := 254;
Inc (tp); Inc (tp);
@ -970,7 +946,7 @@ begin
end; end;
current_mode := DM_ASCII; current_mode := DM_ASCII;
end; end;
if IsTrue(c40_p = 1) then if (c40_p = 1) then
begin begin
target[tp] := 254; target[tp] := 254;
Inc (tp); Inc (tp);
@ -983,7 +959,7 @@ begin
end; end;
current_mode := DM_ASCII; current_mode := DM_ASCII;
end; end;
if IsTrue(text_p = 2) then if (text_p = 2) then
begin begin
target[tp] := 254; target[tp] := 254;
Inc (tp); Inc (tp);
@ -998,7 +974,7 @@ begin
end; end;
current_mode := DM_ASCII; current_mode := DM_ASCII;
end; end;
if IsTrue(text_p = 1) then if (text_p = 1) then
begin begin
target[tp] := 254; target[tp] := 254;
Inc (tp); Inc (tp);
@ -1011,7 +987,7 @@ begin
end; end;
current_mode := DM_ASCII; current_mode := DM_ASCII;
end; end;
if IsTrue(x12_p = 2) then if (x12_p = 2) then
begin begin
target[tp] := 254; target[tp] := 254;
Inc (tp); Inc (tp);
@ -1026,7 +1002,7 @@ begin
end; end;
current_mode := DM_ASCII; current_mode := DM_ASCII;
end; end;
if IsTrue(x12_p = 1) then if (x12_p = 1) then
begin begin
target[tp] := 254; target[tp] := 254;
Inc (tp); Inc (tp);
@ -1042,16 +1018,16 @@ begin
i := 0; i := 0;
while i < tp do while i < tp do
begin begin
if IsTrue(binary[i] = 'b') then if (binary[i] = 'b') then
begin begin
if IsTrue(IsTrue((i = 0)) OR IsTrue((IsTrue((i <> 0)) AND IsTrue((binary[i - 1] <> 'b'))))) then if (i = 0) or ((i <> 0) and (binary[i - 1] <> 'b')) then
begin begin
binary_count := 0; binary_count := 0;
while binary[binary_count + i] = 'b' do while binary[binary_count + i] = 'b' do
begin begin
Inc (binary_count); Inc (binary_count);
end; end;
if IsTrue(binary_count <= 249) then if binary_count <= 249 then
begin begin
dminsert (@binary[0], i, 'b'); dminsert (@binary[0], i, 'b');
insert_value (target, i, tp, binary_count); insert_value (target, i, tp, binary_count);
@ -1071,11 +1047,11 @@ begin
i := 0; i := 0;
while i < tp do while i < tp do
begin begin
if IsTrue(binary[i] = 'b') then if (binary[i] = 'b') then
begin begin
prn := ((149 * (i + 1)) mod 255) + 1; prn := ((149 * (i + 1)) mod 255) + 1;
temp := target[i] + prn; temp := target[i] + prn;
if IsTrue(temp <= 255) then if (temp <= 255) then
begin begin
target[i] := temp; target[i] := temp;
end else begin end else begin
@ -1119,14 +1095,14 @@ begin
i := tail_length; i := tail_length;
while i > 0 do while i > 0 do
begin begin
if IsTrue(i = tail_length) then if (i = tail_length) then
begin begin
target[tp] := 129; target[tp] := 129;
Inc (tp); Inc (tp);
end else begin end else begin
prn := ((149 * (tp + 1)) mod 253) + 1; prn := ((149 * (tp + 1)) mod 253) + 1;
temp := 129 + prn; temp := 129 + prn;
if IsTrue(temp <= 254) then if (temp <= 254) then
begin begin
target[tp] := temp; target[tp] := temp;
Inc (tp); Inc (tp);
@ -1175,12 +1151,12 @@ begin
{INITCODE} grid := nil; {INITCODE} grid := nil;
//inputlen := length; //inputlen := length;
binlen := dm200encode (symbol, source, binary, @last_mode, length); binlen := dm200encode (symbol, source, binary, @last_mode, length);
if IsTrue(binlen = 0) then if (binlen = 0) then
begin begin
strcpy (symbol^.errtxt, 'Data too long to fit in symbol'); strcpy (symbol^.errtxt, 'Data too long to fit in symbol');
exit (ERROR_TOO_LONG); exit (ERROR_TOO_LONG);
end; end;
if IsTrue(IsTrue((symbol^.option_2 >= 1)) AND IsTrue((symbol^.option_2 <= 30))) then if symbol^.option_2 in [1..30] then
begin begin
optionsize := intsymbol[symbol^.option_2 - 1]; optionsize := intsymbol[symbol^.option_2 - 1];
end else begin end else begin
@ -1190,13 +1166,13 @@ begin
i := 29; i := 29;
while i > -1 do while i > -1 do
begin begin
if IsTrue(matrixbytes[i] >= binlen) then if (matrixbytes[i] >= binlen) then
begin begin
calcsize := i; calcsize := i;
end; end;
Dec (i); Dec (i);
end; end;
if IsTrue(symbol^.option_3 = DM_SQUARE) then if (symbol^.option_3 = DM_SQUARE) then
begin begin
case calcsize of case calcsize of
2, 2,
@ -1209,10 +1185,10 @@ begin
end; end;
end; end;
symbolsize := optionsize; symbolsize := optionsize;
if IsTrue(calcsize > optionsize) then if (calcsize > optionsize) then
begin begin
symbolsize := calcsize; symbolsize := calcsize;
if IsTrue(optionsize <> -1) then if (optionsize <> -1) then
begin begin
error_number := WARN_INVALID_OPTION; error_number := WARN_INVALID_OPTION;
strcpy (symbol^.errtxt, 'Data does not fit in selected symbol size'); strcpy (symbol^.errtxt, 'Data does not fit in selected symbol size');
@ -1226,11 +1202,11 @@ begin
datablock := matrixdatablock[symbolsize]; datablock := matrixdatablock[symbolsize];
rsblock := matrixrsblock[symbolsize]; rsblock := matrixrsblock[symbolsize];
taillength := bytes - binlen; taillength := bytes - binlen;
if IsTrue(taillength <> 0) then if (taillength <> 0) then
begin begin
add_tail (binary, binlen, taillength, last_mode); add_tail (binary, binlen, taillength, last_mode);
end; end;
if IsTrue(symbolsize = 29) then if (symbolsize = 29) then
begin begin
skew := 1; skew := 1;
end; end;
@ -1316,7 +1292,7 @@ function dmatrix(symbol: PointerTo_zint_symbol; source: PBYTE; length: Integer):
var var
error_number: Integer; error_number: Integer;
begin begin
if IsTrue(symbol^.option_1 <= 1) then if (symbol^.option_1 <= 1) then
begin begin
error_number := data_matrix_200 (symbol, source, length); error_number := data_matrix_200 (symbol, source, length);
end else begin end else begin

File diff suppressed because it is too large Load Diff