File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -136,10 +136,6 @@ begin
136136 /barlen barcode length def
137137 options (parse) undef
138138
139- numeric barlen 2 mod 0 ne and {
140- /bwipp.telepenNumericOddLength (Telepen Numeric must have an even length) //raiseerror exec
141- } if
142-
143139 %
144140 % Apply AST spec overrides and resolve physical specification
145141 %
@@ -156,11 +152,14 @@ begin
156152 /l enc length def
157153
158154 /checksum 0 def
159- /i 0 def /j 0 def
155+ /i 0 def
160156 { % loop
161157 i barlen eq {exit} if
162158 numeric {
163- barcode i get 16 gt { % 00-99 or 0X-9X
159+ barcode i get dup 16 gt exch 127 lt and { % 00-99 or 0X-9X
160+ barlen i sub 2 lt { % Check for pair
161+ /bwipp.telepenNumericNotDigitPair (Telepen Numeric must be in digit pairs) //raiseerror exec
162+ } if
164163 /np barcode i 2 getinterval def
165164 np 0 get dup 48 lt exch 57 gt or
166165 np 1 get dup 48 lt 1 index 57 gt or exch 88 eq not and
@@ -177,8 +176,11 @@ begin
177176 /indx exch def
178177 % numeric pair displayed via barcode
179178 /i i 2 add def
180- } { % Ordinal values 0-16
179+ } { % Ordinal values 0-16 and 127 (DEL)
181180 /indx barcode i get def
181+ indx 127 gt {
182+ /bwipp.telepenInvalidNumericControlCharacter (Telepen Numeric control characters must have ordinal values 0 to 16 or 127) //raiseerror exec
183+ } if
182184 /i i 1 add def
183185 } ifelse
184186 } { % ASCII mode
@@ -192,7 +194,6 @@ begin
192194 /enc //telepen.encs indx get def
193195 sbs l enc putinterval % Put encoded digit into sbs
194196 /l l enc length add def
195- /j j 1 add def
196197 } loop
197198
198199 %
Original file line number Diff line number Diff line change 33%
44% vim: set sw=4 sts=4 et:
55%
6- % Copyright (c) 2004-2025 Terry Burton
6+ % Copyright (c) 2004-2026 Terry Burton
77%
88
99/telepen dup /uk.co.terryburton.bwipp findresource cvx def
1616% Error tests
1717%
1818
19- { (123) (numeric dontdraw) telepen } /bwipp.telepenNumericOddLength isError
19+ { (123) (numeric dontdraw) telepen } /bwipp.telepenNumericNotDigitPair isError
2020{ (X123) (numeric dontdraw) telepen } /bwipp.telepenInvalidNumericCharacter isError
2121{ (ABC\200) (dontdraw) telepen } /bwipp.telepenInvalidAlphaCharacter isError
22+ { (123^016) (numeric parse dontdraw) telepen } /bwipp.telepenInvalidNumericCharacter isError
23+ { (123^200) (numeric parse dontdraw) telepen } /bwipp.telepenInvalidNumericCharacter isError
24+ { (12^0153) (numeric parse dontdraw) telepen } /bwipp.telepenNumericNotDigitPair isError
25+ { (12^1273) (numeric parse dontdraw) telepen } /bwipp.telepenNumericNotDigitPair isError
26+ { (12^20034) (numeric parse dontdraw) telepen } /bwipp.telepenInvalidNumericControlCharacter isError
2227
2328{ 501 string (dontdraw) telepen } /bwipp.telepeninputTooLong isError
2429
Original file line number Diff line number Diff line change 33%
44% vim: set sw=4 sts=4 et:
55%
6- % Copyright (c) 2004-2025 Terry Burton
6+ % Copyright (c) 2004-2026 Terry Burton
77%
88
99/telepennumeric dup /uk.co.terryburton.bwipp findresource cvx def
1010
1111{ (01234567) (dontdraw) telepennumeric /sbs get
1212} [ 1 1 1 1 1 1 1 1 1 1 3 3 3 1 1 1 1 1 1 1 3 1 1 1 3 3 1 3 1 3 1 1 3 1 3 3 3 3 1 3 1 1 1 1 1 3 1 1 1 1 3 3 1 1 3 1 3 1 3 3 1 1 1 1 1 1 1 1 1 1 ] debugIsEqual
13+
14+ { (12^01534) (parse dontdraw) telepennumeric /sbs get % May be odd length if contains control chars
15+ } [ 1 1 1 1 1 1 1 1 1 1 3 3 1 1 1 1 1 1 3 1 1 1 3 1 1 1 1 1 1 1 1 1 3 1 3 1 1 1 1 3 1 1 1 1 1 3 1 1 3 1 1 1 1 1 3 1 3 1 3 3 1 1 1 1 1 1 1 1 1 1 ] debugIsEqual
16+
17+ { (12^12734) (parse dontdraw) telepennumeric /sbs get % DEL control char
18+ } [ 1 1 1 1 1 1 1 1 1 1 3 3 1 1 1 1 1 1 3 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 3 1 1 1 1 1 1 1 3 1 3 3 1 3 3 1 1 1 1 1 1 1 1 1 1 ] debugIsEqual
You can’t perform that action at this time.
0 commit comments