Skip to content

Commit 4e1791d

Browse files
committed
hibccode128: Uplift
1 parent f231bb4 commit 4e1791d

1 file changed

Lines changed: 33 additions & 16 deletions

File tree

src/hibccode128.ps.src

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,44 @@
3838
currentglobal
3939
true setglobal
4040
/setpacking where {pop currentpacking true setpacking} if
41-
10 dict
42-
dup /loadctx dup /uk.co.terryburton.bwipp findresource put
43-
dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
41+
50 dict
4442
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
4543
dup /processoptions dup /uk.co.terryburton.bwipp findresource put
4644
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
4745
dup /code128 dup /uk.co.terryburton.bwipp findresource put
4846
begin
47+
48+
% Module-level definitions for hibccode128
49+
/hibccode128.barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) readonly def
50+
51+
% Lazy initialization of lookup dictionaries
52+
/hibccode128.latevars dup 1 dict def load /init {
53+
54+
currentglobal
55+
true setglobal
56+
57+
//hibccode128.latevars begin
58+
59+
/charvals 43 dict def
60+
0 1 42 {
61+
charvals exch dup //hibccode128.barchars exch 1 getinterval exch put
62+
} for
63+
/charvals charvals readonly def
64+
65+
/init { //hibccode128.latevars {def} forall } def
66+
67+
end
68+
69+
//hibccode128.latevars /init get exec
70+
71+
setglobal
72+
73+
} bind put
74+
4975
/hibccode128 {
5076

77+
//hibccode128.latevars /init get exec
78+
5179
20 dict begin % Confine variables to local scope
5280

5381
/ctx null def
@@ -65,15 +93,6 @@ begin
6593
/bwipp.hibccode128emptyData (The data must not be empty) //raiseerror exec
6694
} if
6795

68-
/hibccode128 //loadctx exec
69-
70-
% Create a string of the available characters
71-
{
72-
/barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
73-
/charvals 43 dict def
74-
0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
75-
} ctxdef
76-
7796
% Validate the input
7897
0 1 barcode length 1 sub {
7998
barcode exch 1 getinterval charvals exch known not {
@@ -90,15 +109,15 @@ begin
90109
} for
91110
/checksum checksum 43 mod def
92111
validatecheck {
93-
barcode barlen get barchars checksum get ne {
112+
barcode barlen get //hibccode128.barchars checksum get ne {
94113
/bwipp.hibccode128badCheckDigit (Incorrect HIBC Code 128 check digit provided) //raiseerror exec
95114
} if
96115
/barcode barcode 0 barlen getinterval def
97116
} if
98117

99118
/barcode barlen 2 add string dup 1 barcode putinterval def
100119
barcode 0 43 put
101-
barcode barlen 1 add barchars checksum get put
120+
barcode barlen 1 add //hibccode128.barchars checksum get put
102121

103122
/text barlen 4 add string def
104123
text 0 42 put
@@ -118,8 +137,6 @@ begin
118137

119138
dontdraw not //renlinear if
120139

121-
//unloadctx exec
122-
123140
end
124141

125142
}

0 commit comments

Comments
 (0)