omega-pdf
Omega PDF: read and write PDF files in Omega
Brought by drakestapleton
omega-pdf / tests / mkcases.om
| 1 | om2 |
| 2 | note First-party Apache-2.0 PDF fixtures. Run from repository root. |
| 3 | note ISO 32000-1: 7.3 objects, 7.4 filters, 7.5 xrefs/object streams/incremental updates, |
| 4 | note 7.7 page trees, 9.4 text, 9.6 simple fonts, 9.7 composite fonts, 9.10 ToUnicode. |
| 5 | note RFC1950 Adler-32 and RFC1951 stored blocks; all byte offsets calculated here. |
| 6 | global ob uchar 1048576 |
| 7 | global nb ulong 1 |
| 8 | global cb uchar 262144 |
| 9 | global nc ulong 1 |
| 10 | global tmp uchar 262144 |
| 11 | global ofs ulong 256 |
| 12 | global typ ulong 256 |
| 13 | global val ulong 256 |
| 14 | global mx ulong 1 |
| 15 | global xp ulong 1 |
| 16 | global pv ulong 1 |
| 17 | global md ulong 1 |
| 18 | text hdr "%PDF-1.7\n%" |
| 19 | text nl "\n" |
| 20 | text oh " 0 obj\n" |
| 21 | text oe "\nendobj\n" |
| 22 | text xd "xref\n" |
| 23 | text fr "0000000000 65535 f \n" |
| 24 | text en " 00000 n \n" |
| 25 | text tr "trailer\n<< /Size " |
| 26 | text rt " /Root 1 0 R " |
| 27 | text ep ">>\nstartxref\n" |
| 28 | text eof "\n%%EOF\n" |
| 29 | text prev " /Prev " |
| 30 | text xs " /XRefStm " |
| 31 | text enc " /Encrypt << /Filter /Standard /V 1 /R 2 /O (01234567890123456789012345678901) /U (01234567890123456789012345678901) /P -4 >> " |
| 32 | text cat "<< /Type /Catalog /Pages 2 0 R >>" |
| 33 | text pts "<< /Type /Pages /Kids [3 0 R] /Count 1 >>" |
| 34 | text pg "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Resources << /Font << /F1 4 0 R >> >> /Contents 5 0 R >>" |
| 35 | text ft "<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica" |
| 36 | text win " /Encoding /WinAnsiEncoding >>" |
| 37 | text mac " /Encoding /MacRomanEncoding >>" |
| 38 | text std " >>" |
| 39 | text dif " /Encoding << /Type /Encoding /Differences [65 /Aacute /fi /Lslash /adieresis /Euro] >> >>" |
| 40 | text ff "<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding /ToUnicode 6 0 R >>" |
| 41 | text body "BT /F1 12 Tf 72 700 Td (Hello corpus) Tj ET\n" |
| 42 | text words "BT /F1 12 Tf 72 700 Td <41424344452080e982> Tj ET\n" |
| 43 | text stdw "BT /F1 12 Tf 72 700 Td <41272060ae20afb1e1fb> Tj ET\n" |
| 44 | text difw "BT /F1 12 Tf 72 700 Td <4142434445> Tj ET\n" |
| 45 | text opsx "BT /F1 12 Tf 14 TL 1 0 0 1 72 700 Tm (First) Tj 0 -20 Td (Second) Tj 0 -20 TD (Third) Tj T* (Fourth) Tj (Fifth) ' 0 0 (Sixth) \" T* [(wide) -900 (gap)] TJ ET\n" |
| 46 | text cmhead "/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def\n/CMapName /Test def\n/CMapType 2 def\n" |
| 47 | text cmone "1 begincodespacerange\n<00> <ff>\nendcodespacerange\n3 beginbfchar\n<41> <0041>\n<42> <00660069>\n<43> <d83dde00>\nendbfchar\n2 beginbfrange\n<44> <45> <0064>\n<46> <48> [<0058> <0059> <005a>]\nendbfrange\n" |
| 48 | text cmtwo "1 begincodespacerange\n<0000> <ffff>\nendcodespacerange\n2 beginbfchar\n<0001> <0048>\n<0002> <0069>\nendbfchar\n" |
| 49 | text cmbad "1 begincodespacerange\n<00> <ff>\nendcodespacerange\n1 beginbfrange\n<41> <48> [<0041> <0042>]\nendbfrange\n" |
| 50 | text cmend "endcmap\nCMapName currentdict /CMap defineresource pop\nend\nend\n" |
| 51 | text cmtext "BT /F1 12 Tf 72 700 Td (ABCDEFGH) Tj ET\n" |
| 52 | text cidtext "BT /F1 12 Tf 72 700 Td <00010002> Tj ET\n" |
| 53 | text cidfont "<< /Type /Font /Subtype /Type0 /BaseFont /HeiseiKakuGo-W5 /Encoding /Identity-H /DescendantFonts [7 0 R] /ToUnicode 6 0 R >>" |
| 54 | text cidnou "<< /Type /Font /Subtype /Type0 /BaseFont /HeiseiKakuGo-W5 /Encoding /Identity-H /DescendantFonts [7 0 R] >>" |
| 55 | text cidv "<< /Type /Font /Subtype /Type0 /BaseFont /HeiseiKakuGo-W5 /Encoding /Identity-V /DescendantFonts [7 0 R] /ToUnicode 6 0 R >>" |
| 56 | text frl " /Filter /RunLengthDecode" |
| 57 | text pgpi "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Resources << /Font << /F1 4 0 R >> >> /Contents 5 0 R /PieceInfo 6 0 R >>" |
| 58 | text oh4 "4 0 " |
| 59 | text extst "<< /Length 0 /F (external-content.bin) >>\nstream\n\nendstream" |
| 60 | text cid "<< /Type /Font /Subtype /CIDFontType0 /BaseFont /HeiseiKakuGo-W5 /CIDSystemInfo << /Registry (Adobe) /Ordering (Japan1) /Supplement 2 >> /FontDescriptor 8 0 R /DW 1000 >>" |
| 61 | text cidd "<< /Type /FontDescriptor /FontName /HeiseiKakuGo-W5 /Flags 4 /FontBBox [-250 -250 1100 1100] /ItalicAngle 0 /Ascent 880 /Descent -120 /CapHeight 700 /StemV 80 >>" |
| 62 | text sl "<< /Length " |
| 63 | text ss " >>\nstream\n" |
| 64 | text se "\nendstream" |
| 65 | text blank " " |
| 66 | text fx " /Filter /FlateDecode" |
| 67 | text fh " /Filter /ASCIIHexDecode" |
| 68 | text fa " /Filter /ASCII85Decode" |
| 69 | text fc " /Filter [/ASCII85Decode /FlateDecode]" |
| 70 | text fl " /Filter /LZWDecode" |
| 71 | text lr "<< /Length 6 0 R >>\nstream\n" |
| 72 | text tree "<< /Type /Pages /Kids [6 0 R] /Count 2 /MediaBox [0 0 400 800] /Rotate 90 /Resources << /Font << /F1 4 0 R >> >> >>" |
| 73 | text branch "<< /Type /Pages /Parent 2 0 R /Kids [3 0 R 7 0 R] /Count 2 >>" |
| 74 | text leaf2 "<< /Type /Page /Parent 6 0 R /MediaBox [0 0 500 750] /Rotate 180 /Contents 5 0 R >>" |
| 75 | text leaf "<< /Type /Page /Parent 6 0 R /Contents 5 0 R >>" |
| 76 | text arrpg "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Resources << /Font << /F1 4 0 R >> >> /Contents [5 0 R 6 0 R] >>" |
| 77 | text second "BT /F1 12 Tf 72 670 Td (Second stream) Tj ET\n" |
| 78 | text imgpg "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Resources << /Font << /F1 4 0 R >> /XObject << /Im1 6 0 R >> >> /Contents 5 0 R >>" |
| 79 | text image " /Type /XObject /Subtype /Image /Width 1 /Height 1 /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode" |
| 80 | text arbdata "Unused arbitrary JPEG bytes: text must not decode this resource." |
| 81 | text xt " /Type /XRef /Size " |
| 82 | text xw " /Root 1 0 R /W [1 4 2] /Filter /FlateDecode /DecodeParms << /Predictor 12 /Columns 7 >>" |
| 83 | text ot " /Type /ObjStm /N 1 /First 4" |
| 84 | text oh3 "3 0 " |
| 85 | text upd "BT /F1 12 Tf 72 700 Td (Updated text) Tj ET\n" |
| 86 | text cyc "<< /Type /Pages /Kids [2 0 R] /Count 1 >>" |
| 87 | text lpre "<< /Type /Pages /Kids [3 0 R] /Count 1 /Unused /" |
| 88 | text junk "<< /Unused " |
| 89 | text close ">>" |
| 90 | text gn "corpus/gen/" |
| 91 | text rn "corpus/refuse/" |
| 92 | text sd "corpus/s1refuse/" |
| 93 | text names "inherit winansi macroman standard differences tounicode type0 textops lenref ahx a85 a85flate xrefstm objstm incr hybrid carray image lzw" |
| 94 | text badnames "bad-startxref bad-xref-offset bad-object-number missing-endstream wrong-length encrypted kids-cycle prev-cycle objstm-self nesting name-long lzw-text runlength cid-no-tounicode identity-v bad-cmap w-objstm-ref w-external" |
| 95 | text vend "e-empty.raw s-trunc.raw f-trunc.raw b-type3.raw s-nlen.raw d-manylen.raw d-manydist.raw d-clinc.raw d-clover.raw d-repfirst.raw d-reppast.raw d-litinc.raw d-litover.raw d-distinc.raw d-distover.raw d-noeob.raw f-lit286.raw f-dist30.raw f-far.raw zl-fcheck.zlib zl-cinfo.zlib zl-method.zlib zl-dict.zlib zl-adler.zlib zl-trunc.zlib" |
| 96 | text vnames "v10-e-empty v10-s-trunc v10-f-trunc v11-b-type3 v12-s-nlen v13-d-manylen v13-d-manydist v14-d-clinc v14-d-clover v15-d-repfirst v15-d-reppast v16-d-litinc v16-d-litover v17-d-distinc v17-d-distover v18-d-noeob v19-f-lit286 v20-f-dist30 v21-f-far v30-zl-fcheck v30-zl-cinfo v30-zl-method v31-zl-dict v32-zl-adler v10-zl-trunc" |
| 97 | text suffix ".pdf" |
| 98 | text err "mkcases: I/O failure\n" |
| 99 | text deep "<< /Type /Pages /Kids [3 0 R] /Count 1 /Resources 6 0 R >>" |
| 100 | text xstart "startxref\n" |
| 101 | fn die to void |
| 102 | r = write 2 err 0 len err |
| 103 | exit 1 |
| 104 | end |
| 105 | fn byteout c ulong to void |
| 106 | put ob get nb 0 uchar and c 255 |
| 107 | put nb 0 add get nb 0 1 |
| 108 | end |
| 109 | fn emit t view uchar * to void |
| 110 | for i ulong len t bound 262144 |
| 111 | byteout ulong get t i |
| 112 | end |
| 113 | end |
| 114 | fn num n ulong width ulong to void |
| 115 | b = new uchar 24 0 |
| 116 | p = ulong 24 |
| 117 | v = n |
| 118 | while true bound 24 |
| 119 | p = sub p 1 |
| 120 | put b p uchar add rem v 10 48 |
| 121 | v = div v 10 |
| 122 | if and eq v 0 ge sub 24 p width |
| 123 | break |
| 124 | end |
| 125 | end |
| 126 | emit part b p sub 24 p |
| 127 | end |
| 128 | fn beginobj id ulong to void |
| 129 | put ofs id get nb 0 |
| 130 | put typ id 1 |
| 131 | if ge id get mx 0 |
| 132 | put mx 0 add id 1 |
| 133 | end |
| 134 | num id 0 |
| 135 | emit oh |
| 136 | end |
| 137 | fn object id ulong t view uchar * to void |
| 138 | beginobj id |
| 139 | emit t |
| 140 | emit oe |
| 141 | end |
| 142 | fn reset to void |
| 143 | put nb 0 0 |
| 144 | put nc 0 0 |
| 145 | put mx 0 1 |
| 146 | put pv 0 0 |
| 147 | put md 0 0 |
| 148 | for i ulong 256 |
| 149 | put ofs i 0 |
| 150 | put typ i 0 |
| 151 | put val i 0 |
| 152 | end |
| 153 | emit hdr |
| 154 | for i ulong 4 |
| 155 | byteout 200 |
| 156 | end |
| 157 | emit nl |
| 158 | end |
| 159 | fn cbyte c ulong to void |
| 160 | put cb get nc 0 uchar and c 255 |
| 161 | put nc 0 add get nc 0 1 |
| 162 | end |
| 163 | fn content t view uchar * to void |
| 164 | put nc 0 0 |
| 165 | for i ulong len t bound 262144 |
| 166 | cbyte ulong get t i |
| 167 | end |
| 168 | end |
| 169 | fn catblob t view uchar * to void |
| 170 | for i ulong len t bound 262144 |
| 171 | cbyte ulong get t i |
| 172 | end |
| 173 | end |
| 174 | fn blobout to void |
| 175 | for i ulong get nc 0 bound 262144 |
| 176 | byteout ulong get cb i |
| 177 | end |
| 178 | end |
| 179 | fn stream id ulong extra view uchar * to void |
| 180 | beginobj id |
| 181 | emit sl |
| 182 | num get nc 0 0 |
| 183 | emit extra |
| 184 | emit ss |
| 185 | blobout |
| 186 | emit se |
| 187 | emit oe |
| 188 | end |
| 189 | fn font t view uchar * to void |
| 190 | beginobj 4 |
| 191 | emit ft |
| 192 | emit t |
| 193 | emit oe |
| 194 | end |
| 195 | fn base to void |
| 196 | reset |
| 197 | object 1 cat |
| 198 | object 2 pts |
| 199 | object 3 pg |
| 200 | font win |
| 201 | end |
| 202 | fn table to void |
| 203 | put xp 0 get nb 0 |
| 204 | emit xd |
| 205 | m = get mx 0 |
| 206 | i = ulong 0 |
| 207 | while lt i m bound 256 |
| 208 | if eq get typ i 2 |
| 209 | i = add i 1 |
| 210 | continue |
| 211 | end |
| 212 | j = i |
| 213 | while lt j m bound 256 |
| 214 | if eq get typ j 2 |
| 215 | break |
| 216 | end |
| 217 | j = add j 1 |
| 218 | end |
| 219 | num i 0 |
| 220 | emit blank |
| 221 | num sub j i 0 |
| 222 | emit nl |
| 223 | for q ulong sub j i bound 256 |
| 224 | id = add i q |
| 225 | if and ne id 0 eq get typ id 1 |
| 226 | num get ofs id 10 |
| 227 | emit en |
| 228 | else |
| 229 | emit fr |
| 230 | end |
| 231 | end |
| 232 | i = j |
| 233 | end |
| 234 | end |
| 235 | fn tailer extra view uchar * to void |
| 236 | emit tr |
| 237 | num get mx 0 0 |
| 238 | emit rt |
| 239 | emit extra |
| 240 | if ne get pv 0 0 |
| 241 | emit prev |
| 242 | num get pv 0 0 |
| 243 | end |
| 244 | emit ep |
| 245 | num get xp 0 0 |
| 246 | emit eof |
| 247 | end |
| 248 | fn finish to void |
| 249 | table |
| 250 | tailer blank |
| 251 | end |
| 252 | fn word t view uchar * idx ulong dst edit uchar * pos ulong to ulong |
| 253 | w = ulong 0 |
| 254 | p = pos |
| 255 | inside = false |
| 256 | for i ulong len t bound 4096 |
| 257 | c = get t i |
| 258 | if eq c 32 |
| 259 | if inside |
| 260 | w = add w 1 |
| 261 | end |
| 262 | inside = false |
| 263 | else |
| 264 | inside = true |
| 265 | if eq w idx |
| 266 | put dst p c |
| 267 | p = add p 1 |
| 268 | end |
| 269 | end |
| 270 | end |
| 271 | ret p |
| 272 | end |
| 273 | fn save dir view uchar * list view uchar * idx ulong to void |
| 274 | p = new uchar 256 0 |
| 275 | n = ulong 0 |
| 276 | for i ulong len dir bound 256 |
| 277 | put p n get dir i |
| 278 | n = add n 1 |
| 279 | end |
| 280 | n = word list idx p n |
| 281 | for i ulong len suffix bound 8 |
| 282 | put p n get suffix i |
| 283 | n = add n 1 |
| 284 | end |
| 285 | fd = fopen p 0 n 577 420 |
| 286 | if lt fd 0 |
| 287 | die |
| 288 | end |
| 289 | off = ulong 0 |
| 290 | while lt off get nb 0 bound 1048576 |
| 291 | r = write int fd ob off sub get nb 0 off |
| 292 | if le r 0 |
| 293 | die |
| 294 | end |
| 295 | off = add off ulong r |
| 296 | end |
| 297 | r = fclose int fd |
| 298 | if lt r 0 |
| 299 | die |
| 300 | end |
| 301 | end |
| 302 | fn snapshot to ulong |
| 303 | n = get nc 0 |
| 304 | for i ulong n bound 262144 |
| 305 | put tmp i get cb i |
| 306 | end |
| 307 | put nc 0 0 |
| 308 | ret n |
| 309 | end |
| 310 | fn zlibstored to void |
| 311 | n = snapshot |
| 312 | cbyte 120 |
| 313 | cbyte 1 |
| 314 | a = ulong 1 |
| 315 | b = ulong 0 |
| 316 | p = ulong 0 |
| 317 | while lt p n bound 262144 |
| 318 | k = sub n p |
| 319 | if gt k 65535 |
| 320 | k = 65535 |
| 321 | end |
| 322 | final = ulong 0 |
| 323 | if eq add p k n |
| 324 | final = 1 |
| 325 | end |
| 326 | cbyte final |
| 327 | cbyte k |
| 328 | cbyte shr k 8 |
| 329 | cbyte xor k 65535 |
| 330 | cbyte shr xor k 65535 8 |
| 331 | for j ulong k bound 65535 |
| 332 | v = ulong get tmp add p j |
| 333 | cbyte v |
| 334 | a = rem add a v 65521 |
| 335 | b = rem add b a 65521 |
| 336 | end |
| 337 | p = add p k |
| 338 | end |
| 339 | cbyte shr b 8 |
| 340 | cbyte b |
| 341 | cbyte shr a 8 |
| 342 | cbyte a |
| 343 | end |
| 344 | fn hexencode to void |
| 345 | n = snapshot |
| 346 | for i ulong n bound 262144 |
| 347 | v = ulong get tmp i |
| 348 | for j ulong 2 |
| 349 | d = and shr v mul sub 1 j 4 15 |
| 350 | if lt d 10 |
| 351 | cbyte add d 48 |
| 352 | else |
| 353 | cbyte add d 55 |
| 354 | end |
| 355 | end |
| 356 | end |
| 357 | cbyte 62 |
| 358 | end |
| 359 | fn a85 to void |
| 360 | b = new uchar 5 0 |
| 361 | n = snapshot |
| 362 | p = ulong 0 |
| 363 | while lt p n bound 262144 |
| 364 | k = sub n p |
| 365 | if gt k 4 |
| 366 | k = 4 |
| 367 | end |
| 368 | v = ulong 0 |
| 369 | for i ulong 4 |
| 370 | v = mul v 256 |
| 371 | if lt i k |
| 372 | v = add v ulong get tmp add p i |
| 373 | end |
| 374 | end |
| 375 | for j ulong 5 |
| 376 | put b sub 4 j uchar add rem v 85 33 |
| 377 | v = div v 85 |
| 378 | end |
| 379 | for j ulong add k 1 bound 5 |
| 380 | cbyte ulong get b j |
| 381 | end |
| 382 | p = add p k |
| 383 | end |
| 384 | cbyte 126 |
| 385 | cbyte 62 |
| 386 | end |
| 387 | fn rle to void |
| 388 | n = snapshot |
| 389 | p = ulong 0 |
| 390 | while lt p n bound 262144 |
| 391 | k = sub n p |
| 392 | if gt k 128 |
| 393 | k = 128 |
| 394 | end |
| 395 | cbyte sub k 1 |
| 396 | for j ulong k bound 128 |
| 397 | cbyte ulong get tmp add p j |
| 398 | end |
| 399 | p = add p k |
| 400 | end |
| 401 | cbyte 128 |
| 402 | end |
| 403 | fn lzw to void |
| 404 | note Literal-only nine-bit LZW with Clear before 200 input bytes; fixture is shorter. |
| 405 | n = snapshot |
| 406 | bits = ulong 0 |
| 407 | count = ulong 0 |
| 408 | for i ulong add n 2 bound 262144 |
| 409 | v = ulong 256 |
| 410 | if gt i 0 |
| 411 | v = 257 |
| 412 | if le i n |
| 413 | v = ulong get tmp sub i 1 |
| 414 | end |
| 415 | end |
| 416 | bits = or shl bits 9 v |
| 417 | count = add count 9 |
| 418 | while ge count 8 bound 3 |
| 419 | count = sub count 8 |
| 420 | cbyte shr bits count |
| 421 | end |
| 422 | end |
| 423 | if gt count 0 |
| 424 | cbyte shl bits sub 8 count |
| 425 | end |
| 426 | end |
| 427 | fn cmap kind ulong to void |
| 428 | content cmhead |
| 429 | if eq kind 1 |
| 430 | catblob cmtwo |
| 431 | end |
| 432 | if eq kind 0 |
| 433 | catblob cmone |
| 434 | end |
| 435 | if eq kind 2 |
| 436 | catblob cmbad |
| 437 | end |
| 438 | catblob cmend |
| 439 | stream 6 blank |
| 440 | end |
| 441 | fn xrefrows id ulong to void |
| 442 | row = new uchar 7 0 |
| 443 | last = new uchar 7 0 |
| 444 | put ofs id get nb 0 |
| 445 | put typ id 1 |
| 446 | put mx 0 add id 1 |
| 447 | put nc 0 0 |
| 448 | for i ulong get mx 0 bound 256 |
| 449 | t = get typ i |
| 450 | a = get ofs i |
| 451 | b = ulong 0 |
| 452 | if eq i 0 |
| 453 | b = 65535 |
| 454 | end |
| 455 | if eq t 2 |
| 456 | b = get val i |
| 457 | end |
| 458 | put row 0 uchar t |
| 459 | for j ulong 4 |
| 460 | sh = mul sub 3 j 8 |
| 461 | v = and shr a sh 255 |
| 462 | put row add j 1 uchar v |
| 463 | end |
| 464 | put row 5 uchar shr b 8 |
| 465 | put row 6 uchar and b 255 |
| 466 | cbyte 2 |
| 467 | for j ulong 7 |
| 468 | cbyte sub ulong get row j ulong get last j |
| 469 | put last j get row j |
| 470 | end |
| 471 | end |
| 472 | zlibstored |
| 473 | end |
| 474 | fn xrefstream id ulong to void |
| 475 | xrefrows id |
| 476 | put xp 0 get nb 0 |
| 477 | beginobj id |
| 478 | emit sl |
| 479 | num get nc 0 0 |
| 480 | emit xt |
| 481 | num get mx 0 0 |
| 482 | emit xw |
| 483 | emit ss |
| 484 | blobout |
| 485 | emit se |
| 486 | emit oe |
| 487 | end |
| 488 | fn xend to void |
| 489 | emit xstart |
| 490 | num get xp 0 0 |
| 491 | emit eof |
| 492 | end |
| 493 | fn gen k ulong to void |
| 494 | base |
| 495 | if eq k 0 |
| 496 | object 2 tree |
| 497 | object 6 branch |
| 498 | object 3 leaf |
| 499 | object 7 leaf2 |
| 500 | end |
| 501 | if eq k 2 |
| 502 | font mac |
| 503 | end |
| 504 | if eq k 3 |
| 505 | font std |
| 506 | end |
| 507 | if eq k 4 |
| 508 | font dif |
| 509 | end |
| 510 | content body |
| 511 | if and ge k 1 le k 2 |
| 512 | content words |
| 513 | end |
| 514 | if eq k 3 |
| 515 | content stdw |
| 516 | end |
| 517 | if eq k 4 |
| 518 | content difw |
| 519 | end |
| 520 | if eq k 5 |
| 521 | object 4 ff |
| 522 | cmap 0 |
| 523 | content cmtext |
| 524 | end |
| 525 | if eq k 6 |
| 526 | object 4 cidfont |
| 527 | object 7 cid |
| 528 | object 8 cidd |
| 529 | cmap 1 |
| 530 | content cidtext |
| 531 | end |
| 532 | if eq k 7 |
| 533 | content opsx |
| 534 | end |
| 535 | if eq k 8 |
| 536 | beginobj 6 |
| 537 | num get nc 0 0 |
| 538 | emit oe |
| 539 | beginobj 5 |
| 540 | emit lr |
| 541 | blobout |
| 542 | emit se |
| 543 | emit oe |
| 544 | else |
| 545 | if eq k 9 |
| 546 | hexencode |
| 547 | stream 5 fh |
| 548 | else |
| 549 | if eq k 10 |
| 550 | catblob blank |
| 551 | a85 |
| 552 | stream 5 fa |
| 553 | else |
| 554 | if eq k 11 |
| 555 | zlibstored |
| 556 | a85 |
| 557 | stream 5 fc |
| 558 | else |
| 559 | if eq k 18 |
| 560 | lzw |
| 561 | stream 5 fl |
| 562 | else |
| 563 | stream 5 blank |
| 564 | end |
| 565 | end |
| 566 | end |
| 567 | end |
| 568 | end |
| 569 | if eq k 16 |
| 570 | object 3 arrpg |
| 571 | content second |
| 572 | stream 6 blank |
| 573 | end |
| 574 | if eq k 17 |
| 575 | object 3 imgpg |
| 576 | content arbdata |
| 577 | stream 6 image |
| 578 | end |
| 579 | if or eq k 13 eq k 15 |
| 580 | content oh3 |
| 581 | catblob pg |
| 582 | stream 6 ot |
| 583 | put typ 3 2 |
| 584 | put ofs 3 6 |
| 585 | put val 3 0 |
| 586 | end |
| 587 | if or or eq k 12 eq k 13 eq k 15 |
| 588 | xrefstream 9 |
| 589 | if eq k 15 |
| 590 | old = get xp 0 |
| 591 | table |
| 592 | emit tr |
| 593 | num get mx 0 0 |
| 594 | emit rt |
| 595 | emit xs |
| 596 | num old 0 |
| 597 | emit ep |
| 598 | num get xp 0 0 |
| 599 | emit eof |
| 600 | else |
| 601 | xend |
| 602 | end |
| 603 | else |
| 604 | finish |
| 605 | end |
| 606 | if eq k 14 |
| 607 | put pv 0 get xp 0 |
| 608 | content upd |
| 609 | stream 5 blank |
| 610 | finish |
| 611 | end |
| 612 | save gn names k |
| 613 | end |
| 614 | fn bad k ulong to void |
| 615 | base |
| 616 | content body |
| 617 | if and ge k 13 le k 15 |
| 618 | if eq k 13 |
| 619 | object 4 cidnou |
| 620 | end |
| 621 | if eq k 14 |
| 622 | object 4 cidv |
| 623 | cmap 1 |
| 624 | end |
| 625 | if eq k 15 |
| 626 | object 4 ff |
| 627 | cmap 2 |
| 628 | content cmtext |
| 629 | else |
| 630 | object 7 cid |
| 631 | object 8 cidd |
| 632 | content cidtext |
| 633 | end |
| 634 | end |
| 635 | if eq k 3 |
| 636 | beginobj 5 |
| 637 | emit sl |
| 638 | num get nc 0 0 |
| 639 | emit ss |
| 640 | blobout |
| 641 | emit oe |
| 642 | else |
| 643 | if eq k 4 |
| 644 | beginobj 5 |
| 645 | emit sl |
| 646 | num add get nc 0 9 0 |
| 647 | emit ss |
| 648 | blobout |
| 649 | emit se |
| 650 | emit oe |
| 651 | else |
| 652 | if eq k 11 |
| 653 | lzw |
| 654 | stream 5 fl |
| 655 | else |
| 656 | if eq k 12 |
| 657 | rle |
| 658 | stream 5 frl |
| 659 | else |
| 660 | if eq k 17 |
| 661 | beginobj 5 |
| 662 | emit extst |
| 663 | emit oe |
| 664 | else |
| 665 | stream 5 blank |
| 666 | end |
| 667 | end |
| 668 | end |
| 669 | end |
| 670 | end |
| 671 | if eq k 6 |
| 672 | object 2 cyc |
| 673 | end |
| 674 | if eq k 8 |
| 675 | content oh3 |
| 676 | catblob pg |
| 677 | stream 6 ot |
| 678 | put typ 3 2 |
| 679 | put ofs 3 6 |
| 680 | put val 3 0 |
| 681 | put typ 6 2 |
| 682 | put ofs 6 6 |
| 683 | xrefstream 9 |
| 684 | xend |
| 685 | save rn badnames k |
| 686 | ret |
| 687 | end |
| 688 | if eq k 16 |
| 689 | object 3 pgpi |
| 690 | content oh4 |
| 691 | catblob ft |
| 692 | catblob win |
| 693 | stream 6 ot |
| 694 | put typ 4 2 |
| 695 | put ofs 4 6 |
| 696 | put val 4 0 |
| 697 | xrefstream 9 |
| 698 | xend |
| 699 | save rn badnames k |
| 700 | ret |
| 701 | end |
| 702 | if eq k 9 |
| 703 | beginobj 6 |
| 704 | emit junk |
| 705 | for i ulong 70 |
| 706 | byteout 91 |
| 707 | end |
| 708 | byteout 48 |
| 709 | for i ulong 70 |
| 710 | byteout 93 |
| 711 | end |
| 712 | emit close |
| 713 | emit oe |
| 714 | note Make the deeply nested object reachable from a required page attribute. |
| 715 | object 2 deep |
| 716 | end |
| 717 | if eq k 10 |
| 718 | beginobj 2 |
| 719 | emit lpre |
| 720 | for i ulong 300 |
| 721 | byteout 65 |
| 722 | end |
| 723 | emit close |
| 724 | emit oe |
| 725 | end |
| 726 | if eq k 1 |
| 727 | put ofs 3 add get ofs 3 1 |
| 728 | end |
| 729 | if eq k 2 |
| 730 | put ob get ofs 3 57 |
| 731 | end |
| 732 | table |
| 733 | if eq k 0 |
| 734 | put xp 0 999999 |
| 735 | end |
| 736 | if eq k 7 |
| 737 | put pv 0 get xp 0 |
| 738 | end |
| 739 | if eq k 5 |
| 740 | tailer enc |
| 741 | else |
| 742 | tailer blank |
| 743 | end |
| 744 | save rn badnames k |
| 745 | end |
| 746 | fn vendor k ulong to void |
| 747 | p = new uchar 256 0 |
| 748 | n = ulong 0 |
| 749 | for i ulong len sd bound 256 |
| 750 | put p n get sd i |
| 751 | n = add n 1 |
| 752 | end |
| 753 | n = word vend k p n |
| 754 | fd = fopen p 0 n 0 0 |
| 755 | if lt fd 0 |
| 756 | die |
| 757 | end |
| 758 | base |
| 759 | put nc 0 0 |
| 760 | if lt k 19 |
| 761 | cbyte 120 |
| 762 | cbyte 1 |
| 763 | end |
| 764 | while true bound 262144 |
| 765 | r = read int fd cb get nc 0 sub 262144 get nc 0 |
| 766 | if lt r 0 |
| 767 | die |
| 768 | end |
| 769 | if eq r 0 |
| 770 | break |
| 771 | end |
| 772 | put nc 0 add get nc 0 ulong r |
| 773 | end |
| 774 | r = fclose int fd |
| 775 | stream 5 fx |
| 776 | finish |
| 777 | save rn vnames k |
| 778 | end |
| 779 | fn main to int |
| 780 | r = makedir gn 0 len gn 493 |
| 781 | r = makedir rn 0 len rn 493 |
| 782 | for i ulong 19 |
| 783 | gen i |
| 784 | end |
| 785 | for i ulong 18 |
| 786 | bad i |
| 787 | end |
| 788 | for i ulong 25 |
| 789 | vendor i |
| 790 | end |
| 791 | ret 0 |
| 792 | end |