0003-Any-transient-procedures-that-call-.force-operators.patch 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. From f0397dbfbe5eea325613ff375b30eb0db5551ffe Mon Sep 17 00:00:00 2001
  2. From: Chris Liddell <chris.liddell@artifex.com>
  3. Date: Thu, 13 Dec 2018 15:28:34 +0000
  4. Subject: [PATCH] Any transient procedures that call .force* operators
  5. (i.e. for conditionals or loops) make them executeonly.
  6. Signed-off-by: Baruch Siach <baruch@tkos.co.il>
  7. ---
  8. Upstream status: commit 2db98f9c661
  9. Resource/Init/gs_diskn.ps | 2 +-
  10. Resource/Init/gs_dps1.ps | 4 ++--
  11. Resource/Init/gs_fntem.ps | 4 ++--
  12. Resource/Init/gs_fonts.ps | 12 ++++++------
  13. Resource/Init/gs_init.ps | 4 ++--
  14. Resource/Init/gs_lev2.ps | 11 ++++++-----
  15. Resource/Init/gs_pdfwr.ps | 2 +-
  16. Resource/Init/gs_res.ps | 4 ++--
  17. Resource/Init/gs_setpd.ps | 2 +-
  18. Resource/Init/pdf_base.ps | 13 ++++++++-----
  19. Resource/Init/pdf_draw.ps | 16 +++++++++-------
  20. Resource/Init/pdf_font.ps | 6 +++---
  21. Resource/Init/pdf_main.ps | 4 ++--
  22. Resource/Init/pdf_ops.ps | 7 ++++---
  23. 14 files changed, 49 insertions(+), 42 deletions(-)
  24. diff --git a/Resource/Init/gs_diskn.ps b/Resource/Init/gs_diskn.ps
  25. index fd694bc44b5a..8bf20542040d 100644
  26. --- a/Resource/Init/gs_diskn.ps
  27. +++ b/Resource/Init/gs_diskn.ps
  28. @@ -51,7 +51,7 @@ systemdict begin
  29. mark 5 1 roll ] mark exch { { } forall } forall ]
  30. //systemdict /.searchabledevs 2 index .forceput
  31. exch .setglobal
  32. - }
  33. + } executeonly
  34. if
  35. } .bind executeonly odef % must be bound and hidden for .forceput
  36. diff --git a/Resource/Init/gs_dps1.ps b/Resource/Init/gs_dps1.ps
  37. index ec5db61b9f03..4fae2839940c 100644
  38. --- a/Resource/Init/gs_dps1.ps
  39. +++ b/Resource/Init/gs_dps1.ps
  40. @@ -78,7 +78,7 @@ level2dict begin
  41. .currentglobal
  42. { % Current mode is global; delete from local directory too.
  43. //systemdict /LocalFontDirectory .knownget
  44. - { 1 index .forceundef } % LocalFontDirectory is readonly
  45. + { 1 index .forceundef } executeonly % LocalFontDirectory is readonly
  46. if
  47. }
  48. { % Current mode is local; if there was a shadowed global
  49. @@ -126,7 +126,7 @@ level2dict begin
  50. }
  51. ifelse
  52. } forall
  53. - pop counttomark 2 idiv { .forceundef } repeat pop % readonly
  54. + pop counttomark 2 idiv { .forceundef } executeonly repeat pop % readonly
  55. }
  56. if
  57. //SharedFontDirectory exch .forcecopynew pop
  58. diff --git a/Resource/Init/gs_fntem.ps b/Resource/Init/gs_fntem.ps
  59. index c1f7651f18cc..6eb672a6840e 100644
  60. --- a/Resource/Init/gs_fntem.ps
  61. +++ b/Resource/Init/gs_fntem.ps
  62. @@ -401,12 +401,12 @@ currentdict end def
  63. .forceput % FontInfo can be read-only.
  64. pop % bool <font>
  65. exit
  66. - } if
  67. + } executeonly if
  68. dup /FontInfo get % bool <font> <FI>
  69. /GlyphNames2Unicode /Unicode /Decoding findresource
  70. .forceput % FontInfo can be read-only.
  71. exit
  72. - } loop
  73. + } executeonly loop
  74. exch setglobal
  75. } .bind executeonly odef % must be bound and hidden for .forceput
  76. diff --git a/Resource/Init/gs_fonts.ps b/Resource/Init/gs_fonts.ps
  77. index 803faca4918d..290da0cd6819 100644
  78. --- a/Resource/Init/gs_fonts.ps
  79. +++ b/Resource/Init/gs_fonts.ps
  80. @@ -374,7 +374,7 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if
  81. /.setnativefontmapbuilt { % set whether we've been run
  82. dup type /booleantype eq {
  83. systemdict exch /.nativefontmapbuilt exch .forceput
  84. - }
  85. + } executeonly
  86. {pop}
  87. ifelse
  88. } .bind executeonly odef
  89. @@ -1007,11 +1007,11 @@ $error /SubstituteFont { } put
  90. { 2 index gcheck currentglobal
  91. 2 copy eq {
  92. pop pop .forceput
  93. - } {
  94. + } executeonly {
  95. 5 1 roll setglobal
  96. dup length string copy
  97. .forceput setglobal
  98. - } ifelse
  99. + } executeonly ifelse
  100. } .bind executeonly odef % must be bound and hidden for .forceput
  101. % Attempt to load a font from a file.
  102. @@ -1084,7 +1084,7 @@ $error /SubstituteFont { } put
  103. .FontDirectory 3 index .forceundef % readonly
  104. 1 index (r) file .loadfont .FontDirectory exch
  105. /.setglobal .systemvar exec
  106. - }
  107. + } executeonly
  108. { .loadfont .FontDirectory
  109. }
  110. ifelse
  111. @@ -1105,7 +1105,7 @@ $error /SubstituteFont { } put
  112. dup 3 index .fontknownget
  113. { dup /PathLoad 4 index .putgstringcopy
  114. 4 1 roll pop pop pop //true exit
  115. - } if
  116. + } executeonly if
  117. % Maybe the file had a different FontName.
  118. % See if we can get a FontName from the file, and if so,
  119. @@ -1134,7 +1134,7 @@ $error /SubstituteFont { } put
  120. ifelse % Stack: origfontname fontdict
  121. exch pop //true exit
  122. % Stack: fontdict
  123. - }
  124. + } executeonly
  125. if pop % Stack: origfontname fontdirectory path
  126. }
  127. if pop pop % Stack: origfontname
  128. diff --git a/Resource/Init/gs_init.ps b/Resource/Init/gs_init.ps
  129. index d733124b96d1..56c0bd268b53 100644
  130. --- a/Resource/Init/gs_init.ps
  131. +++ b/Resource/Init/gs_init.ps
  132. @@ -2357,7 +2357,7 @@ SAFER { .setsafeglobal } if
  133. % Update the copy of the user parameters.
  134. mark .currentuserparams counttomark 2 idiv {
  135. userparams 3 1 roll .forceput % userparams is read-only
  136. - } repeat pop
  137. + } executeonly repeat pop
  138. % Turn on idiom recognition, if available.
  139. currentuserparams /IdiomRecognition known {
  140. /IdiomRecognition //true .definepsuserparam
  141. @@ -2376,7 +2376,7 @@ SAFER { .setsafeglobal } if
  142. % Remove real system params from pssystemparams.
  143. mark .currentsystemparams counttomark 2 idiv {
  144. pop pssystemparams exch .forceundef
  145. - } repeat pop
  146. + } executeonly repeat pop
  147. } if
  148. % Set up AlignToPixels :
  149. diff --git a/Resource/Init/gs_lev2.ps b/Resource/Init/gs_lev2.ps
  150. index 44fe61956659..0f0d57331c23 100644
  151. --- a/Resource/Init/gs_lev2.ps
  152. +++ b/Resource/Init/gs_lev2.ps
  153. @@ -154,7 +154,8 @@ end
  154. % protect top level of parameters that we copied
  155. dup type dup /arraytype eq exch /stringtype eq or { readonly } if
  156. /userparams .systemvar 3 1 roll .forceput % userparams is read-only
  157. - } {
  158. + } executeonly
  159. + {
  160. pop pop
  161. } ifelse
  162. } forall
  163. @@ -224,7 +225,7 @@ end
  164. % protect top level parameters that we copied
  165. dup type dup /arraytype eq exch /stringtype eq or { readonly } if
  166. //pssystemparams 3 1 roll .forceput % pssystemparams is read-only
  167. - }
  168. + } executeonly
  169. { pop pop
  170. }
  171. ifelse
  172. @@ -934,7 +935,7 @@ mark
  173. dup /PaintProc get
  174. 1 index /Implementation known not {
  175. 1 index dup /Implementation //null .forceput readonly pop
  176. - } if
  177. + } executeonly if
  178. exec
  179. }.bind odef
  180. @@ -958,7 +959,7 @@ mark
  181. dup /PaintProc get
  182. 1 index /Implementation known not {
  183. 1 index dup /Implementation //null .forceput readonly pop
  184. - } if
  185. + } executeonly if
  186. /UNROLLFORMS where {/UNROLLFORMS get}{false}ifelse not
  187. %% [CTM] <<Form>> PaintProc .beginform -
  188. {
  189. @@ -1005,7 +1006,7 @@ mark
  190. %% Form dictioanry using the /Implementation key).
  191. 1 dict dup /FormID 4 -1 roll put
  192. 1 index exch /Implementation exch .forceput readonly pop
  193. - }
  194. + } executeonly
  195. ifelse
  196. }
  197. {
  198. diff --git a/Resource/Init/gs_pdfwr.ps b/Resource/Init/gs_pdfwr.ps
  199. index 58e75d3a4831..b425103d1cf3 100644
  200. --- a/Resource/Init/gs_pdfwr.ps
  201. +++ b/Resource/Init/gs_pdfwr.ps
  202. @@ -650,7 +650,7 @@ currentdict /.pdfmarkparams .undef
  203. } ifelse
  204. } bind .makeoperator .forceput
  205. systemdict /.pdf_hooked_DSC_Creator //true .forceput
  206. - } if
  207. + } executeonly if
  208. pop
  209. } if
  210. } {
  211. diff --git a/Resource/Init/gs_res.ps b/Resource/Init/gs_res.ps
  212. index 8eb8bb0e5829..d9b34599e7c2 100644
  213. --- a/Resource/Init/gs_res.ps
  214. +++ b/Resource/Init/gs_res.ps
  215. @@ -152,7 +152,7 @@ setglobal
  216. % use .forceput / .forcedef later to replace the dummy,
  217. % empty .Instances dictionary with the real one later.
  218. readonly
  219. - } {
  220. + }{
  221. /defineresource cvx /typecheck signaloperror
  222. } ifelse
  223. } bind executeonly odef
  224. @@ -424,7 +424,7 @@ status {
  225. % As noted above, Category dictionaries are read-only,
  226. % so we have to use .forcedef here.
  227. /.Instances 1 index .forcedef % Category dict is read-only
  228. - } if
  229. + } executeonly if
  230. }
  231. { .LocalInstances dup //.emptydict eq
  232. { pop 3 dict localinstancedict Category 2 index put
  233. diff --git a/Resource/Init/gs_setpd.ps b/Resource/Init/gs_setpd.ps
  234. index e22597ebb5f3..7875d1f2f131 100644
  235. --- a/Resource/Init/gs_setpd.ps
  236. +++ b/Resource/Init/gs_setpd.ps
  237. @@ -634,7 +634,7 @@ NOMEDIAATTRS {
  238. SETPDDEBUG { (Rolling back.) = pstack flush } if
  239. 3 index 2 index 3 -1 roll .forceput
  240. 4 index 1 index .knownget
  241. - { 4 index 3 1 roll .forceput }
  242. + { 4 index 3 1 roll .forceput } executeonly
  243. { 3 index exch .undef }
  244. ifelse
  245. } bind executeonly odef
  246. diff --git a/Resource/Init/pdf_base.ps b/Resource/Init/pdf_base.ps
  247. index b45e9803165e..73127296c221 100644
  248. --- a/Resource/Init/pdf_base.ps
  249. +++ b/Resource/Init/pdf_base.ps
  250. @@ -130,26 +130,29 @@ currentdict /num-chars-dict .undef
  251. /.pdfexectoken { % <count> <opdict> <exectoken> .pdfexectoken ?
  252. PDFDEBUG {
  253. - pdfdict /PDFSTEPcount known not { pdfdict /PDFSTEPcount 1 .forceput } if
  254. + pdfdict /PDFSTEPcount known not { pdfdict /PDFSTEPcount 1 .forceput } executeonly if
  255. PDFSTEP {
  256. pdfdict /PDFtokencount 2 copy .knownget { 1 add } { 1 } ifelse .forceput
  257. PDFSTEPcount 1 gt {
  258. pdfdict /PDFSTEPcount PDFSTEPcount 1 sub .forceput
  259. - } {
  260. + } executeonly
  261. + {
  262. dup ==only
  263. ( step # ) print PDFtokencount =only
  264. ( ? ) print flush 1 //false .outputpage
  265. (%stdin) (r) file 255 string readline {
  266. token {
  267. exch pop pdfdict /PDFSTEPcount 3 -1 roll .forceput
  268. - } {
  269. + } executeonly
  270. + {
  271. pdfdict /PDFSTEPcount 1 .forceput
  272. - } ifelse % token
  273. + } executeonly ifelse % token
  274. } {
  275. pop /PDFSTEP //false def % EOF on stdin
  276. } ifelse % readline
  277. } ifelse % PDFSTEPcount > 1
  278. - } {
  279. + } executeonly
  280. + {
  281. dup ==only () = flush
  282. } ifelse % PDFSTEP
  283. } if % PDFDEBUG
  284. diff --git a/Resource/Init/pdf_draw.ps b/Resource/Init/pdf_draw.ps
  285. index 6b0ba93e1e73..40c6ac80acce 100644
  286. --- a/Resource/Init/pdf_draw.ps
  287. +++ b/Resource/Init/pdf_draw.ps
  288. @@ -1118,14 +1118,14 @@ currentdict end readonly def
  289. pdfdict /.Qqwarning_issued //true .forceput
  290. .setglobal
  291. pdfformaterror
  292. - } ifelse
  293. + } executeonly ifelse
  294. }
  295. {
  296. currentglobal pdfdict gcheck .setglobal
  297. pdfdict /.Qqwarning_issued //true .forceput
  298. .setglobal
  299. pdfformaterror
  300. - } ifelse
  301. + } executeonly ifelse
  302. end
  303. } ifelse
  304. } loop
  305. @@ -1141,14 +1141,14 @@ currentdict end readonly def
  306. pdfdict /.Qqwarning_issued //true .forceput
  307. .setglobal
  308. pdfformaterror
  309. - } ifelse
  310. + } executeonly ifelse
  311. }
  312. {
  313. currentglobal pdfdict gcheck .setglobal
  314. pdfdict /.Qqwarning_issued //true .forceput
  315. .setglobal
  316. pdfformaterror
  317. - } ifelse
  318. + } executeonly ifelse
  319. } if
  320. pop
  321. @@ -2350,9 +2350,10 @@ currentdict /last-ditch-bpc-csp undef
  322. /IncrementAppearanceNumber {
  323. pdfdict /AppearanceNumber .knownget {
  324. 1 add pdfdict /AppearanceNumber 3 -1 roll .forceput
  325. - }{
  326. + } executeonly
  327. + {
  328. pdfdict /AppearanceNumber 0 .forceput
  329. - } ifelse
  330. + } executeonly ifelse
  331. }bind executeonly odef
  332. /MakeAppearanceName {
  333. @@ -2510,7 +2511,8 @@ currentdict /last-ditch-bpc-csp undef
  334. %% want to preserve it.
  335. pdfdict /.PreservePDFForm false .forceput
  336. /q cvx /execform cvx 5 -2 roll
  337. - }{
  338. + } executeonly
  339. + {
  340. /q cvx /PDFexecform cvx 5 -2 roll
  341. } ifelse
  342. diff --git a/Resource/Init/pdf_font.ps b/Resource/Init/pdf_font.ps
  343. index bea9ea95ad1d..4cd62b9d9bb4 100644
  344. --- a/Resource/Init/pdf_font.ps
  345. +++ b/Resource/Init/pdf_font.ps
  346. @@ -714,7 +714,7 @@ currentdict end readonly def
  347. pop pop pop
  348. currentdict /.stackdepth .forceundef
  349. currentdict /.dstackdepth .forceundef
  350. - }
  351. + } executeonly
  352. {pop pop pop}
  353. ifelse
  354. @@ -1232,7 +1232,7 @@ currentdict /eexec_pdf_param_dict .undef
  355. (\n **** Warning: Type 3 glyph has unbalanced q/Q operators \(too many q's\)\n Output may be incorrect.\n)
  356. pdfformatwarning
  357. pdfdict /.Qqwarning_issued //true .forceput
  358. - } if
  359. + } executeonly if
  360. Q
  361. } repeat
  362. Q
  363. @@ -2016,7 +2016,7 @@ currentdict /CMap_read_dict undef
  364. /CIDFallBack /CIDFont findresource
  365. } if
  366. exit
  367. - } if
  368. + } executeonly if
  369. } if
  370. } if
  371. diff --git a/Resource/Init/pdf_main.ps b/Resource/Init/pdf_main.ps
  372. index 00da47a48711..37e69b39ac98 100644
  373. --- a/Resource/Init/pdf_main.ps
  374. +++ b/Resource/Init/pdf_main.ps
  375. @@ -2701,14 +2701,14 @@ currentdict /PDF2PS_matrix_key undef
  376. pdfdict /.Qqwarning_issued //true .forceput
  377. .setglobal
  378. pdfformaterror
  379. - } ifelse
  380. + } executeonly ifelse
  381. }
  382. {
  383. currentglobal pdfdict gcheck .setglobal
  384. pdfdict /.Qqwarning_issued //true .forceput
  385. .setglobal
  386. pdfformaterror
  387. - } ifelse
  388. + } executeonly ifelse
  389. } if
  390. } if
  391. pop
  392. diff --git a/Resource/Init/pdf_ops.ps b/Resource/Init/pdf_ops.ps
  393. index 8672d617f363..aa0964139a56 100644
  394. --- a/Resource/Init/pdf_ops.ps
  395. +++ b/Resource/Init/pdf_ops.ps
  396. @@ -184,14 +184,14 @@ currentdict /gput_always_allow .undef
  397. pdfdict /.Qqwarning_issued //true .forceput
  398. .setglobal
  399. pdfformaterror
  400. - } ifelse
  401. + } executeonly ifelse
  402. }
  403. {
  404. currentglobal pdfdict gcheck .setglobal
  405. pdfdict /.Qqwarning_issued //true .forceput
  406. .setglobal
  407. pdfformaterror
  408. - } ifelse
  409. + } executeonly ifelse
  410. } if
  411. } bind executeonly odef
  412. @@ -439,7 +439,8 @@ currentdict /gput_always_allow .undef
  413. dup type /booleantype eq {
  414. .currentSMask type /dicttype eq {
  415. .currentSMask /Processed 2 index .forceput
  416. - } {
  417. + } executeonly
  418. + {
  419. .setSMask
  420. }ifelse
  421. }{
  422. --
  423. 2.20.1