gnu: python-babel: Update to 2.7.0.
[guix.git] / gnu / packages / patches / ghostscript-no-header-id.patch
blobda1aa5530fac5041906a920e16f6666361611442
1 This patch makes the "/ID" field optional.
3 If the environment variable GS_GENERATE_UUIDS is set to "0" or "no", it will
4 not write out the "/ID" field (if that's permissible).
6 Upstream does not want to do this.
8 See: https://bugs.ghostscript.com/show_bug.cgi?id=698208
9 diff -ur orig/gnu-ghostscript-9.14.0/devices/vector/gdevpdf.c gnu-ghostscript-9.14.0/devices/vector/gdevpdf.c
10 --- orig/gnu-ghostscript-9.14.0/devices/vector/gdevpdf.c 2017-07-09 23:30:28.960479189 +0200
11 +++ gnu-ghostscript-9.14.0/devices/vector/gdevpdf.c 2017-07-09 23:34:34.306524488 +0200
12 @@ -1785,8 +1785,11 @@
13 * +1 for the linearisation dict and +1 for the primary hint stream.
15 linear_params->FirsttrailerOffset = gp_ftell_64(linear_params->Lin_File.file);
16 - gs_sprintf(LDict, "\ntrailer\n<</Size %ld/Info %d 0 R/Root %d 0 R/ID[%s%s]/Prev %d>>\nstartxref\r\n0\n%%%%EOF\n \n",
17 - linear_params->LastResource + 3, pdev->ResourceUsage[linear_params->Info_id].NewObjectNumber, pdev->ResourceUsage[linear_params->Catalog_id].NewObjectNumber, fileID, fileID, 0);
18 + gs_sprintf(LDict, "\ntrailer\n<</Size %ld/Info %d 0 R/Root %d 0 R",
19 + linear_params->LastResource + 3, pdev->ResourceUsage[linear_params->Info_id].NewObjectNumber, pdev->ResourceUsage[linear_params->Catalog_id].NewObjectNumber);
20 + if (pdev->OwnerPassword.size > 0 || !(!getenv("GS_GENERATE_UUIDS") || (strcasecmp(getenv("GS_GENERATE_UUIDS"), "0") != 0 && strcasecmp(getenv("GS_GENERATE_UUIDS"), "no") != 0))) /* ID is mandatory when encrypting */
21 + gs_sprintf(LDict, "/ID[%s%s]", fileID, fileID);
22 + gs_sprintf(LDict, "/Prev %d>>\nstartxref\r\n0\n%%%%EOF\n \n", 0);
23 fwrite(LDict, strlen(LDict), 1, linear_params->Lin_File.file);
25 /* Write document catalog (Part 4) */
26 @@ -2321,8 +2324,11 @@
27 if (code != 0)
28 return_error(gs_error_ioerror);
30 - gs_sprintf(LDict, "\ntrailer\n<</Size %ld/Info %d 0 R/Root %d 0 R/ID[%s%s]/Prev %"PRId64">>\nstartxref\r\n0\n%%%%EOF\n",
31 - linear_params->LastResource + 3, pdev->ResourceUsage[linear_params->Info_id].NewObjectNumber, pdev->ResourceUsage[linear_params->Catalog_id].NewObjectNumber, fileID, fileID, mainxref);
32 + gs_sprintf(LDict, "\ntrailer\n<</Size %ld/Info %d 0 R/Root %d 0 R",
33 + linear_params->LastResource + 3, pdev->ResourceUsage[linear_params->Info_id].NewObjectNumber, pdev->ResourceUsage[linear_params->Catalog_id].NewObjectNumber);
34 + if (pdev->OwnerPassword.size > 0 || !(!getenv("GS_GENERATE_UUIDS") || (strcasecmp(getenv("GS_GENERATE_UUIDS"), "0") != 0 || strcasecmp(getenv("GS_GENERATE_UUIDS"), "no") != 0))) /* ID is mandatory when encrypting */
35 + gs_sprintf(LDict, "/ID[%s%s]", fileID, fileID);
36 + gs_sprintf(LDict, "/Prev %"PRId64">>\nstartxref\r\n0\n%%%%EOF\n", mainxref);
37 fwrite(LDict, strlen(LDict), 1, linear_params->sfile);
39 code = gp_fseek_64(linear_params->sfile, pdev->ResourceUsage[HintStreamObj].LinearisedOffset, SEEK_SET);
40 @@ -3016,10 +3022,12 @@
41 stream_puts(s, "trailer\n");
42 pprintld3(s, "<< /Size %ld /Root %ld 0 R /Info %ld 0 R\n",
43 pdev->next_id, Catalog_id, Info_id);
44 - stream_puts(s, "/ID [");
45 - psdf_write_string(pdev->strm, pdev->fileID, sizeof(pdev->fileID), 0);
46 - psdf_write_string(pdev->strm, pdev->fileID, sizeof(pdev->fileID), 0);
47 - stream_puts(s, "]\n");
48 + if (pdev->OwnerPassword.size > 0 || !(!getenv("GS_GENERATE_UUIDS") || (strcasecmp(getenv("GS_GENERATE_UUIDS"), "0") != 0 || strcasecmp(getenv("GS_GENERATE_UUIDS"), "no") != 0))) { /* ID is mandatory when encrypting */
49 + stream_puts(s, "/ID [");
50 + psdf_write_string(pdev->strm, pdev->fileID, sizeof(pdev->fileID), 0);
51 + psdf_write_string(pdev->strm, pdev->fileID, sizeof(pdev->fileID), 0);
52 + stream_puts(s, "]\n");
53 + }
54 if (pdev->OwnerPassword.size > 0) {
55 pprintld1(s, "/Encrypt %ld 0 R ", Encrypt_id);