Commit 3f3dbe22eaae56df48af304c35a1c0b5dd976135

Authored by Jay Berkenbilt
1 parent 4b674b42

Remove array null flattening

For some reason, qpdf from the beginning was replacing indirect
references to null with literal null in arrays even after removing the
old behavior of flattening scalar references. This seems like a bad
idea.
ChangeLog
  1 +2019-08-22 Jay Berkenbilt <ejb@ql.org>
  2 +
  3 + * Stop replacing indirect references to null with literal null in
  4 + arrays when writing output with QPDFWriter.
  5 +
1 2019-08-19 Jay Berkenbilt <ejb@ql.org> 6 2019-08-19 Jay Berkenbilt <ejb@ql.org>
2 7
3 * Accept (and warn for) extraneous whitespace preceding the xref 8 * Accept (and warn for) extraneous whitespace preceding the xref
libqpdf/QPDFWriter.cc
@@ -2390,13 +2390,7 @@ QPDFWriter::prepareFileForWrite() @@ -2390,13 +2390,7 @@ QPDFWriter::prepareFileForWrite()
2390 for (int i = 0; i < nitems; ++i) 2390 for (int i = 0; i < nitems; ++i)
2391 { 2391 {
2392 QPDFObjectHandle oh = node.getArrayItem(i); 2392 QPDFObjectHandle oh = node.getArrayItem(i);
2393 - if (oh.isIndirect() && oh.isNull())  
2394 - {  
2395 - QTC::TC("qpdf", "QPDFWriter flatten array null");  
2396 - oh.makeDirect();  
2397 - node.setArrayItem(i, oh);  
2398 - }  
2399 - else if (! oh.isScalar()) 2393 + if (! oh.isScalar())
2400 { 2394 {
2401 queue.push_back(oh); 2395 queue.push_back(oh);
2402 } 2396 }
qpdf/qpdf.testcov
@@ -27,7 +27,6 @@ QPDF lin outlines in part 1 @@ -27,7 +27,6 @@ QPDF lin outlines in part 1
27 QPDF lin nshared_total > nshared_first_page 1 27 QPDF lin nshared_total > nshared_first_page 1
28 QPDF lin part 8 empty 1 28 QPDF lin part 8 empty 1
29 QPDF lin check shared past first page 0 29 QPDF lin check shared past first page 0
30 -QPDFWriter flatten array null 0  
31 main QTest implicit 0 30 main QTest implicit 0
32 main QTest indirect 1 31 main QTest indirect 1
33 main QTest null 0 32 main QTest null 0
qpdf/qtest/qpdf/dangling-refs-dangling-out.pdf
No preview for this file type
qpdf/qtest/qpdf/merge-three-files-1.pdf
No preview for this file type
qpdf/qtest/qpdf/three-files-collate-out.pdf
@@ -775,12 +775,12 @@ endobj @@ -775,12 +775,12 @@ endobj
775 << 775 <<
776 /Count -2 776 /Count -2
777 /Dest [ 777 /Dest [
778 - null 778 + 57 0 R
779 /FitV 779 /FitV
780 100 780 100
781 ] 781 ]
782 - /First 57 0 R  
783 - /Last 58 0 R 782 + /First 58 0 R
  783 + /Last 59 0 R
784 /Next 54 0 R 784 /Next 54 0 R
785 /Parent 19 0 R 785 /Parent 19 0 R
786 /Title (Isosicle 1.1.1 -> 12: /FitV 100) 786 /Title (Isosicle 1.1.1 -> 12: /FitV 100)
@@ -793,14 +793,14 @@ endobj @@ -793,14 +793,14 @@ endobj
793 << 793 <<
794 /Count 1 794 /Count 1
795 /Dest [ 795 /Dest [
796 - null 796 + 57 0 R
797 /XYZ 797 /XYZ
798 null 798 null
799 null 799 null
800 null 800 null
801 ] 801 ]
802 - /First 59 0 R  
803 - /Last 59 0 R 802 + /First 60 0 R
  803 + /Last 60 0 R
804 /Parent 19 0 R 804 /Parent 19 0 R
805 /Prev 53 0 R 805 /Prev 53 0 R
806 /Title (Isosicle 1.1.2 -> 12: /XYZ null null null) 806 /Title (Isosicle 1.1.2 -> 12: /XYZ null null null)
@@ -843,17 +843,22 @@ endobj @@ -843,17 +843,22 @@ endobj
843 >> 843 >>
844 endobj 844 endobj
845 845
846 -%% Original object ID: 44 0 846 +%% Original object ID: 12 0
847 57 0 obj 847 57 0 obj
  848 +null
  849 +endobj
  850 +
  851 +%% Original object ID: 44 0
  852 +58 0 obj
848 << 853 <<
849 /Dest [ 854 /Dest [
850 - null 855 + 61 0 R
851 /XYZ 856 /XYZ
852 null 857 null
853 null 858 null
854 null 859 null
855 ] 860 ]
856 - /Next 58 0 R 861 + /Next 59 0 R
857 /Parent 53 0 R 862 /Parent 53 0 R
858 /Title (Isosicle 1.1.1.1 -> 18: /XYZ null null null) 863 /Title (Isosicle 1.1.1.1 -> 18: /XYZ null null null)
859 /Type /Outline 864 /Type /Outline
@@ -861,7 +866,7 @@ endobj @@ -861,7 +866,7 @@ endobj
861 endobj 866 endobj
862 867
863 %% Original object ID: 45 0 868 %% Original object ID: 45 0
864 -58 0 obj 869 +59 0 obj
865 << 870 <<
866 /Dest [ 871 /Dest [
867 null 872 null
@@ -871,17 +876,17 @@ endobj @@ -871,17 +876,17 @@ endobj
871 null 876 null
872 ] 877 ]
873 /Parent 53 0 R 878 /Parent 53 0 R
874 - /Prev 57 0 R 879 + /Prev 58 0 R
875 /Title (Isosicle 1.1.1.2 -> 19: /XYZ null null null) 880 /Title (Isosicle 1.1.1.2 -> 19: /XYZ null null null)
876 /Type /Outline 881 /Type /Outline
877 >> 882 >>
878 endobj 883 endobj
879 884
880 %% Original object ID: 46 0 885 %% Original object ID: 46 0
881 -59 0 obj 886 +60 0 obj
882 << 887 <<
883 /Dest [ 888 /Dest [
884 - null 889 + 62 0 R
885 /XYZ 890 /XYZ
886 null 891 null
887 null 892 null
@@ -893,8 +898,18 @@ endobj @@ -893,8 +898,18 @@ endobj
893 >> 898 >>
894 endobj 899 endobj
895 900
  901 +%% Original object ID: 15 0
  902 +61 0 obj
  903 +null
  904 +endobj
  905 +
  906 +%% Original object ID: 17 0
  907 +62 0 obj
  908 +null
  909 +endobj
  910 +
896 xref 911 xref
897 -0 60 912 +0 63
898 0000000000 65535 f 913 0000000000 65535 f
899 0000000052 00000 n 914 0000000052 00000 n
900 0000000853 00000 n 915 0000000853 00000 n
@@ -949,17 +964,20 @@ xref @@ -949,17 +964,20 @@ xref
949 0000007949 00000 n 964 0000007949 00000 n
950 0000008052 00000 n 965 0000008052 00000 n
951 0000008100 00000 n 966 0000008100 00000 n
952 -0000008327 00000 n  
953 -0000008581 00000 n  
954 -0000008801 00000 n  
955 -0000009014 00000 n  
956 -0000009228 00000 n  
957 -0000009442 00000 n 967 +0000008329 00000 n
  968 +0000008585 00000 n
  969 +0000008805 00000 n
  970 +0000009018 00000 n
  971 +0000009068 00000 n
  972 +0000009284 00000 n
  973 +0000009498 00000 n
  974 +0000009699 00000 n
  975 +0000009749 00000 n
958 trailer << 976 trailer <<
959 /Root 1 0 R 977 /Root 1 0 R
960 - /Size 60 978 + /Size 63
961 /ID [<d3fab8d0603e683dc94e42ac31141868><31415926535897932384626433832795>] 979 /ID [<d3fab8d0603e683dc94e42ac31141868><31415926535897932384626433832795>]
962 >> 980 >>
963 startxref 981 startxref
964 -9613 982 +9771
965 %%EOF 983 %%EOF