~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

« back to all changes in this revision

Viewing changes to lib/gs_btokn.ps

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-01-20 16:40:45 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120164045-lnfhi0n30o5lwhwa
Tags: 8.64.dfsg.1~svn9377-0ubuntu1
* New upstream release (SVN rev 9377)
   o Fixes many bugs concerning PDF rendering, to make the PDF printing
     workflow correctly working.
   o Fixes long-standing bugs in many drivers, like input paper tray and
     duplex options not working for the built-in PCL 4, 5, 5c, 5e, and
     6/XL drivers, PDF input not working for bjc600, bjc800, and cups
     output devices, several options not working and uninitialized
     memory with cups output device.
   o Merged nearly all patches of the Ubuntu and Debian packages upstream.
   o Fixes LP: #317810, LP: #314439, LP: #314018.
* debian/patches/03_libpaper_support.dpatch,
  debian/patches/11_gs-cjk_font_glyph_handling_fix.dpatch,
  debian/patches/12_gs-cjk_vertical_writing_metrics_fix.dpatch,
  debian/patches/13_gs-cjk_cjkps_examples.dpatch,
  debian/patches/20_bbox_segv_fix.dpatch,
  debian/patches/21_brother_7x0_gdi_fix.dpatch,
  debian/patches/22_epsn_margin_workaround.dpatch,
  debian/patches/24_gs_man_fix.dpatch,
  debian/patches/25_toolbin_insecure_tmp_usage_fix.dpatch,
  debian/patches/26_assorted_script_fixes.dpatch,
  debian/patches/29_gs_css_fix.dpatch,
  debian/patches/30_ps2pdf_man_improvement.dpatch,
  debian/patches/31_fix-gc-sigbus.dpatch,
  debian/patches/34_ftbfs-on-hurd-fix.dpatch,
  debian/patches/35_disable_libcairo.dpatch,
  debian/patches/38_pxl-duplex.dpatch,
  debian/patches/39_pxl-resolution.dpatch,
  debian/patches/42_gs-init-ps-delaybind-fix.dpatch,
  debian/patches/45_bjc600-bjc800-pdf-input.dpatch,
  debian/patches/48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch,
  debian/patches/50_lips4-floating-point-exception.dpatch,
  debian/patches/52_cups-device-logging.dpatch,
  debian/patches/55_pcl-input-slot-fix.dpatch,
  debian/patches/57_pxl-input-slot-fix.dpatch,
  debian/patches/60_pxl-cups-driver-pdf.dpatch,
  debian/patches/62_onebitcmyk-pdf.dpatch,
  debian/patches/65_too-big-temp-files-1.dpatch,
  debian/patches/67_too-big-temp-files-2.dpatch,
  debian/patches/70_take-into-account-data-in-stream-buffer-before-refill.dpatch:
  Removed, applied upstream.
* debian/patches/01_docdir_fix_for_debian.dpatch,
  debian/patches/02_gs_man_fix_debian.dpatch,
  debian/patches/01_docdir-fix-for-debian.dpatch,
  debian/patches/02_docdir-fix-for-debian.dpatch: Renamed patches to
  make merging with Debian easier.
* debian/patches/32_improve-handling-of-media-size-changes-from-gv.dpatch, 
  debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch:
  regenerated for new source directory structure.
* debian/rules: Corrected paths to remove cidfmap (it is in Resource/Init/
  in GS 8.64) and to install headers (source paths are psi/ and base/ now).
* debian/rules: Remove all fontmaps, as DeFoMa replaces them.
* debian/local/pdftoraster/pdftoraster.c,
  debian/local/pdftoraster/pdftoraster.convs, debian/rules: Removed
  added pdftoraster filter and use the one which comes with Ghostscript.
* debian/ghostscript.links: s/8.63/8.64/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%    Copyright (C) 1994, 2000 Aladdin Enterprises.  All rights reserved.
2
 
3
 
% This software is provided AS-IS with no warranty, either express or
4
 
% implied.
5
 
6
 
% This software is distributed under license and may not be copied,
7
 
% modified or distributed except as expressly authorized under the terms
8
 
% of the license contained in the file LICENSE in this distribution.
9
 
10
 
% For more information about licensing, please refer to
11
 
% http://www.ghostscript.com/licensing/. For information on
12
 
% commercial licensing, go to http://www.artifex.com/licensing/ or
13
 
% contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14
 
% San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
 
 
16
 
% $Id: gs_btokn.ps 7631 2007-01-22 03:26:28Z lpd $
17
 
% Initialization file for binary tokens.
18
 
% When this is run, systemdict is still writable,
19
 
% but everything defined here goes into level2dict.
20
 
 
21
 
% Define whether or not to allow writing dictionaries.
22
 
% This is a non-standard feature!
23
 
/WRITEDICTS false def
24
 
 
25
 
languagelevel 1 .setlanguagelevel
26
 
level2dict begin
27
 
 
28
 
% Initialization for the system name table.
29
 
 
30
 
mark
31
 
% 0
32
 
        /abs /add /aload /anchorsearch /and
33
 
        /arc /arcn /arct /arcto /array
34
 
        /ashow /astore /awidthshow /begin /bind
35
 
        /bitshift /ceiling /charpath /clear /cleartomark
36
 
% 20
37
 
        /clip /clippath /closepath /concat /concatmatrix
38
 
        /copy /count /counttomark /currentcmykcolor /currentdash
39
 
        /currentdict /currentfile /currentfont /currentgray /currentgstate
40
 
        /currenthsbcolor /currentlinecap /currentlinejoin /currentlinewidth /currentmatrix
41
 
% 40
42
 
        /currentpoint /currentrgbcolor /currentshared /curveto /cvi
43
 
        /cvlit /cvn /cvr /cvrs /cvs
44
 
        /cvx /def /defineusername /dict /div
45
 
        /dtransform /dup /end /eoclip /eofill
46
 
% 60
47
 
        /eoviewclip /eq /exch /exec /exit
48
 
        /file /fill /findfont /flattenpath /floor
49
 
        /flush /flushfile /for /forall /ge
50
 
        /get /getinterval /grestore /gsave /gstate
51
 
% 80
52
 
        /gt /identmatrix /idiv /idtransform /if
53
 
        /ifelse /image /imagemask /index /ineofill
54
 
        /infill /initviewclip /inueofill /inufill /invertmatrix
55
 
        /itransform /known /le /length /lineto
56
 
% 100
57
 
        /load /loop /lt /makefont /matrix
58
 
        /maxlength /mod /moveto /mul /ne
59
 
        /neg /newpath /not /null /or
60
 
        /pathbbox /pathforall /pop /print /printobject
61
 
% 120
62
 
        /put /putinterval /rcurveto /read /readhexstring
63
 
        /readline /readstring /rectclip /rectfill /rectstroke
64
 
        /rectviewclip /repeat /restore /rlineto /rmoveto
65
 
        /roll /rotate /round /save /scale
66
 
% 140
67
 
        /scalefont /search /selectfont /setbbox /setcachedevice
68
 
        /setcachedevice2 /setcharwidth /setcmykcolor /setdash /setfont
69
 
        /setgray /setgstate /sethsbcolor /setlinecap /setlinejoin
70
 
        /setlinewidth /setmatrix /setrgbcolor /setshared /shareddict
71
 
% 160
72
 
        /show /showpage /stop /stopped /store
73
 
        /string /stringwidth /stroke /strokepath /sub
74
 
        /systemdict /token /transform /translate /truncate
75
 
        /type /uappend /ucache /ueofill /ufill
76
 
% 180
77
 
        /undef /upath /userdict /ustroke /viewclip
78
 
        /viewclippath /where /widthshow /write /writehexstring
79
 
        /writeobject /writestring /wtranslation /xor /xshow
80
 
        /xyshow /yshow /FontDirectory /SharedFontDirectory /Courier
81
 
% 200
82
 
        /Courier-Bold /Courier-BoldOblique /Courier-Oblique /Helvetica /Helvetica-Bold
83
 
        /Helvetica-BoldOblique /Helvetica-Oblique /Symbol /Times-Bold /Times-BoldItalic
84
 
        /Times-Italic /Times-Roman /execuserobject /currentcolor /currentcolorspace
85
 
        /currentglobal /execform /filter /findresource /globaldict
86
 
% 220
87
 
        /makepattern /setcolor /setcolorspace /setglobal /setpagedevice
88
 
        /setpattern
89
 
% pad to 256
90
 
        counttomark 256 exch sub { 0 } repeat
91
 
% 256
92
 
        /= /== /ISOLatin1Encoding /StandardEncoding
93
 
% 260
94
 
        ([) cvn (]) cvn /atan /banddevice /bytesavailable
95
 
        /cachestatus /closefile /colorimage /condition /copypage
96
 
        /cos /countdictstack /countexecstack /cshow /currentblackgeneration
97
 
        /currentcacheparams /currentcolorscreen /currentcolortransfer /currentcontext /currentflat
98
 
% 280
99
 
        /currenthalftone /currenthalftonephase /currentmiterlimit /currentobjectformat /currentpacking
100
 
        /currentscreen /currentstrokeadjust /currenttransfer /currentundercolorremoval /defaultmatrix
101
 
        /definefont /deletefile /detach /deviceinfo /dictstack
102
 
        /echo /erasepage /errordict /execstack /executeonly
103
 
% 300
104
 
        /exp /false /filenameforall /fileposition /fork
105
 
        /framedevice /grestoreall /handleerror /initclip /initgraphics
106
 
        /initmatrix /instroke /inustroke /join /kshow
107
 
        /ln /lock /log /mark /monitor
108
 
% 320
109
 
        /noaccess /notify /nulldevice /packedarray /quit
110
 
        /rand /rcheck /readonly /realtime /renamefile
111
 
        /renderbands /resetfile /reversepath /rootfont /rrand
112
 
        /run /scheck /setblackgeneration /setcachelimit /setcacheparams
113
 
% 340
114
 
        /setcolorscreen /setcolortransfer /setfileposition /setflat /sethalftone
115
 
        /sethalftonephase /setmiterlimit /setobjectformat /setpacking /setscreen
116
 
        /setstrokeadjust /settransfer /setucacheparams /setundercolorremoval /sin
117
 
        /sqrt /srand /stack /status /statusdict
118
 
% 360
119
 
        /true /ucachestatus /undefinefont /usertime /ustrokepath
120
 
        /version /vmreclaim /vmstatus /wait /wcheck
121
 
        /xcheck /yield /defineuserobject /undefineuserobject /UserObjects
122
 
        /cleardictstack
123
 
% 376
124
 
        /A /B /C /D /E /F /G /H /I /J /K /L /M
125
 
        /N /O /P /Q /R /S /T /U /V /W /X /Y /Z
126
 
        /a /b /c /d /e /f /g /h /i /j /k /l /m
127
 
        /n /o /p /q /r /s /t /u /v /w /x /y /z
128
 
% 428
129
 
        /setvmthreshold (<<) cvn
130
 
        (>>) cvn /currentcolorrendering /currentdevparams /currentoverprint /currentpagedevice
131
 
        /currentsystemparams /currentuserparams /defineresource /findencoding /gcheck
132
 
% 440
133
 
        /glyphshow /languagelevel /product /pstack /resourceforall
134
 
        /resourcestatus /revision /serialnumber /setcolorrendering /setdevparams
135
 
        /setoverprint /setsystemparams /setuserparams /startjob /undefineresource
136
 
        /GlobalFontDirectory /ASCII85Decode /ASCII85Encode /ASCIIHexDecode /ASCIIHexEncode
137
 
% 460
138
 
        /CCITTFaxDecode /CCITTFaxEncode /DCTDecode /DCTEncode /LZWDecode
139
 
        /LZWEncode /NullEncode /RunLengthDecode /RunLengthEncode /SubFileDecode
140
 
        /CIEBasedA /CIEBasedABC /DeviceCMYK /DeviceGray /DeviceRGB
141
 
        /Indexed /Pattern /Separation /CIEBasedDEF /CIEBasedDEFG
142
 
% 480
143
 
        /DeviceN
144
 
% 481 -- end
145
 
.packtomark .installsystemnames
146
 
 
147
 
% Define printobject and writeobject.
148
 
% These are mostly implemented in PostScript, so that we don't have to
149
 
% worry about interrupts or callbacks when writing to the output file.
150
 
 
151
 
% Define procedures for accumulating the space required to represent
152
 
% an object in binary form.  The procedures for composite objects (arrays
153
 
% and dictionaries) leave different results on the stack:
154
 
%       <#refs> <#chars> <simple_obj> -proc- <#refs> <#chars>
155
 
%       <#refs> <#chars> <array|dict> -proc- <array|dict> <#refs> <#chars>
156
 
% This is required so that .writeobjects can also accumulate the actual
157
 
% list of composite objects to write in the binary object sequence.
158
 
/cntdict mark
159
 
  /integertype /pop load
160
 
  /realtype 1 index
161
 
  /marktype 1 index
162
 
  /nulltype 1 index
163
 
  /booleantype 1 index
164
 
  /nametype { length add } bind
165
 
  /stringtype 1 index
166
 
  /arraytype null
167
 
  /dicttype null
168
 
.dicttomark def
169
 
/.cntobj {      % <<arguments and results as for procedures in cntdict>>
170
 
  dup type //cntdict exch get exec
171
 
} .bind def
172
 
cntdict /arraytype {
173
 
  dup dup length 5 -1 roll add 4 2 roll { .cntobj } forall
174
 
} bind put
175
 
cntdict /dicttype {
176
 
  WRITEDICTS {
177
 
    dup dup length 2 mul 5 -1 roll add 4 2 roll {
178
 
        % We have to use .execn here, rather than simply rolling the
179
 
        % value under the top elements, because key might involve arrays
180
 
        % or dictionaries.
181
 
      cvlit {.cntobj} exch 2 .execn .cntobj
182
 
    } forall
183
 
  } {
184
 
    /writeobject .systemvar /typecheck signalerror
185
 
  } ifelse
186
 
} bind put
187
 
 
188
 
/w2dict mark
189
 
  /nametype { 2 copy .writecvs pop } bind
190
 
  /stringtype 1 index
191
 
.dicttomark def
192
 
 
193
 
/.bosheader {           % <top_length> <total_length> <string8> .bosheader
194
 
                        %   <string4|8>
195
 
  dup 0 currentobjectformat 127 add put         % object format => BOS tag
196
 
  2 index 255 le 2 index 65531 le and {
197
 
        % Use the short header format: tag toplen(1) totlen(2)
198
 
    exch 4 add exch
199
 
    0 4 getinterval
200
 
    dup 1 5 -1 roll put
201
 
  } {
202
 
        % Use the long header format: tag 0(1) toplen(2) totlen(4)
203
 
    exch 8 add exch
204
 
     0 0 4 2 roll .bosobject exch pop exch pop  % store with byte swapping
205
 
  } ifelse              % Stack: shortlen str
206
 
  exch dup -8 bitshift exch 255 and     % str hibyte lobyte
207
 
  currentobjectformat 1 and 0 eq {      % lsb first
208
 
    exch
209
 
  } if
210
 
  2 index 3 3 -1 roll put
211
 
  1 index 2 3 -1 roll put
212
 
} .bind def
213
 
 
214
 
/.writeobjects {        % <file> <tag> <array> .writeobjects -
215
 
  mark exch
216
 
 
217
 
        % Count the space required for refs and strings.
218
 
 
219
 
  dup length 0 3 -1 roll
220
 
        % Stack: file tag -mark- #refs #chars array
221
 
  dup 4 1 roll { .cntobj } forall
222
 
 
223
 
        % Write the header.
224
 
 
225
 
        % Stack: file tag -mark- array1 ... (array|dict)N #refs #chars
226
 
  counttomark 3 add -2 roll 4 1 roll
227
 
        % Stack: -mark- array1 ... (array|dict)N tag #refs #chars file
228
 
  dup counttomark 1 sub index length
229
 
  4 index 3 bitshift 4 index add
230
 
  (xxxxxxxx) .bosheader writestring
231
 
 
232
 
        % Write the objects per se.
233
 
 
234
 
  3 1 roll pop
235
 
  counttomark 1 sub index length 3 bitshift exch
236
 
  3 bitshift
237
 
        % Stack: -mark- array1 ... (array|dict)N tag file ref# char#
238
 
  counttomark 4 sub {
239
 
    counttomark -1 roll dup 6 1 roll
240
 
        % Stack: ... objN tag file ref# char# objN
241
 
    dup type /dicttype eq {             % can't be first object
242
 
      { 5 1 roll (x\000xxxxxx) .bosobject
243
 
        3 index exch writestring
244
 
        4 -1 roll (x\000xxxxxx) .bosobject
245
 
        3 index exch writestring
246
 
      } forall
247
 
    } {
248
 
      { (x\000xxxxxx) .bosobject
249
 
        dup 1 6 index put
250
 
        3 index exch writestring
251
 
        4 -1 roll pop 0 4 1 roll        % clear tag
252
 
      } forall
253
 
    } ifelse
254
 
  } repeat
255
 
 
256
 
        % Write the strings and names.
257
 
 
258
 
  pop pop exch pop
259
 
        % Stack: -mark- array1 ... array|dictN file
260
 
  counttomark 1 sub {
261
 
    counttomark -1 roll {
262
 
                % The counting pass ensured that the keys and values
263
 
                % of any dictionary must be writable objects.
264
 
                % Hence, we are processing a dictionary iff
265
 
                % the next-to-top stack element is not a file.
266
 
      1 index type /filetype ne {
267
 
        exch 2 index exch dup type //w2dict exch .knownget
268
 
         { exec } { pop } ifelse pop
269
 
      } if
270
 
      dup type //w2dict exch .knownget { exec } { pop } ifelse
271
 
    } forall
272
 
  } repeat
273
 
 
274
 
        % Clean up.
275
 
 
276
 
        % Stack: -mark- file
277
 
  pop pop
278
 
 
279
 
} .bind def
280
 
 
281
 
/printobject {          % <obj> <tag> printobject -
282
 
  currentobjectformat 0 eq {
283
 
      /printobject .systemvar /undefined signalerror
284
 
  } if
285
 
  (%stdout) (w) file 2 index 2 index .writeobject pop pop
286
 
} odef
287
 
/writeobject {          % <file> <obj> <tag> writeobject -
288
 
  currentobjectformat 0 eq {
289
 
      /writeobject .systemvar /undefined signalerror
290
 
  } if
291
 
  2 .argindex pop       % check # of args
292
 
  .writeobject
293
 
} odef
294
 
/.writeobject {
295
 
  3 copy exch
296
 
                % We must allocate the array in local VM
297
 
                % to avoid a possible invalidaccess.
298
 
  .currentglobal false .setglobal exch 1 array astore exch .setglobal
299
 
  .writeobjects pop pop pop
300
 
} .bind def
301
 
 
302
 
% Implement binary error message output.
303
 
/.objectprinttest {             % <obj> .objectprinttest -
304
 
                % This is a pseudo-operator so it will restore the stack
305
 
                % if it gets an error.
306
 
  mark 0 0 3 .argindex .cntobj cleartomark pop
307
 
} bind odef
308
 
/.printerror {
309
 
  $error /binary get .languagelevel 2 ge and {
310
 
    currentobjectformat 0 ne {
311
 
      [ /Error $error /errorname get $error /command get
312
 
                % Convert the object with cvs if it isn't printable.
313
 
      dup { .objectprinttest } .internalstopped {
314
 
        pop 100 string cvs
315
 
      } if
316
 
      false ] 250 printobject
317
 
    }
318
 
    //.printerror       % known to be a procedure
319
 
    ifelse
320
 
  }
321
 
  //.printerror         % known to be a procedure
322
 
  ifelse
323
 
} bind def
324
 
 
325
 
currentdict /cntdict .undef
326
 
currentdict /w2dict .undef
327
 
 
328
 
% End of level2dict
329
 
 
330
 
end
331
 
.setlanguagelevel