1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
|
From 3341545edba359b292a8ef6db1b7d342caf3dcf1 Mon Sep 17 00:00:00 2001
From: Leon Bottou <leon@bottou.org>
Date: Wed, 4 May 2011 21:25:35 -0700
Subject: [PATCH] Added include <stddef.h> for gcc-4.6
---
libdjvu/BSByteStream.cpp | 1 +
libdjvu/BSEncodeByteStream.cpp | 1 +
libdjvu/ByteStream.cpp | 1 +
libdjvu/DjVuFileCache.cpp | 1 +
libdjvu/DjVuGlobal.cpp | 2 ++
libdjvu/DjVuGlobalMemory.cpp | 2 ++
libdjvu/DjVuMessage.cpp | 1 +
libdjvu/DjVuMessageLite.cpp | 2 +-
libdjvu/DjVuPalette.cpp | 2 ++
libdjvu/DjVuPort.h | 1 +
libdjvu/DjVuToPS.cpp | 1 +
libdjvu/GBitmap.cpp | 2 ++
libdjvu/GException.cpp | 1 +
libdjvu/GOS.cpp | 1 +
libdjvu/GPixmap.cpp | 2 ++
libdjvu/GSmartPointer.cpp | 1 +
libdjvu/GSmartPointer.h | 2 ++
libdjvu/GString.cpp | 1 +
libdjvu/GString.h | 1 +
libdjvu/GThreads.cpp | 2 ++
libdjvu/GURL.cpp | 1 +
libdjvu/GUnicode.cpp | 2 ++
libdjvu/IFFByteStream.h | 1 +
libdjvu/IW44EncodeCodec.cpp | 1 +
libdjvu/IW44Image.cpp | 1 +
libdjvu/JPEGDecoder.h | 1 +
libdjvu/MMX.cpp | 1 +
libdjvu/UnicodeByteStream.h | 1 +
libdjvu/XMLParser.cpp | 1 +
libdjvu/ZPCodec.cpp | 2 ++
libdjvu/atomic.cpp | 1 +
libdjvu/ddjvuapi.cpp | 1 +
libdjvu/ddjvuapi.h | 1 +
libdjvu/miniexp.cpp | 1 +
libdjvu/miniexp.h | 3 ++-
tools/bzz.cpp | 1 +
tools/c44.cpp | 1 +
tools/cjb2.cpp | 1 +
tools/cpaldjvu.cpp | 1 +
tools/csepdjvu.cpp | 1 +
tools/ddjvu.cpp | 1 +
tools/djvm.cpp | 2 +-
tools/djvmcvt.cpp | 1 +
tools/djvudump.cpp | 1 +
tools/djvuextract.cpp | 1 +
tools/djvumake.cpp | 1 +
tools/djvups.cpp | 1 +
tools/djvused.cpp | 1 +
tools/djvuserve.cpp | 1 +
tools/djvutxt.cpp | 1 +
tools/tiff2pdf.h | 1 +
xmltools/djvutoxml.cpp | 1 +
xmltools/djvuxmlparser.cpp | 1 +
53 files changed, 63 insertions(+), 3 deletions(-)
diff --git a/libdjvu/BSByteStream.cpp b/libdjvu/BSByteStream.cpp
index b762ccf..d662ab0 100644
--- a/libdjvu/BSByteStream.cpp
+++ b/libdjvu/BSByteStream.cpp
@@ -62,6 +62,7 @@
// - Author: Leon Bottou, 07/1998
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/libdjvu/BSEncodeByteStream.cpp b/libdjvu/BSEncodeByteStream.cpp
index 5d80e51..68bc3e3 100644
--- a/libdjvu/BSEncodeByteStream.cpp
+++ b/libdjvu/BSEncodeByteStream.cpp
@@ -71,6 +71,7 @@
#include "GOS.h"
#endif
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/libdjvu/ByteStream.cpp b/libdjvu/ByteStream.cpp
index 158c33c..be01847 100644
--- a/libdjvu/ByteStream.cpp
+++ b/libdjvu/ByteStream.cpp
@@ -73,6 +73,7 @@
#include "GOS.h"
#include "GURL.h"
#include "DjVuMessage.h"
+#include <stddef.h>
#include <fcntl.h>
#if defined(WIN32) || defined(__CYGWIN32__)
# include <io.h>
diff --git a/libdjvu/DjVuFileCache.cpp b/libdjvu/DjVuFileCache.cpp
index 6b1e85d..7d7a192 100644
--- a/libdjvu/DjVuFileCache.cpp
+++ b/libdjvu/DjVuFileCache.cpp
@@ -63,6 +63,7 @@
#include "DjVuFileCache.h"
#include "debug.h"
+#include <stddef.h>
#include <stdlib.h>
diff --git a/libdjvu/DjVuGlobal.cpp b/libdjvu/DjVuGlobal.cpp
index e6d3cec..df9278e 100644
--- a/libdjvu/DjVuGlobal.cpp
+++ b/libdjvu/DjVuGlobal.cpp
@@ -76,6 +76,8 @@
#include "GThreads.h"
#include "GException.h"
#include "GContainer.h"
+
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/libdjvu/DjVuGlobalMemory.cpp b/libdjvu/DjVuGlobalMemory.cpp
index 3c6012c..c8ba309 100644
--- a/libdjvu/DjVuGlobalMemory.cpp
+++ b/libdjvu/DjVuGlobalMemory.cpp
@@ -67,6 +67,8 @@
#include "DjVuGlobal.h"
#include "GException.h"
+
+#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "debug.h"
diff --git a/libdjvu/DjVuMessage.cpp b/libdjvu/DjVuMessage.cpp
index 6f5a735..1726025 100644
--- a/libdjvu/DjVuMessage.cpp
+++ b/libdjvu/DjVuMessage.cpp
@@ -71,6 +71,7 @@
#include "debug.h"
#include <ctype.h>
#include <string.h>
+#include <stddef.h>
#include <stdlib.h>
#ifdef WIN32
# include <tchar.h>
diff --git a/libdjvu/DjVuMessageLite.cpp b/libdjvu/DjVuMessageLite.cpp
index b8c1010..5daa9d9 100644
--- a/libdjvu/DjVuMessageLite.cpp
+++ b/libdjvu/DjVuMessageLite.cpp
@@ -73,8 +73,8 @@
#include "debug.h"
#include <ctype.h>
#include <string.h>
+#include <stddef.h>
#include <stdlib.h>
-// #include <stdio.h>
#ifdef WIN32
#include <tchar.h>
#include <windows.h>
diff --git a/libdjvu/DjVuPalette.cpp b/libdjvu/DjVuPalette.cpp
index c489f7b..76b0bf4 100644
--- a/libdjvu/DjVuPalette.cpp
+++ b/libdjvu/DjVuPalette.cpp
@@ -64,6 +64,8 @@
#include "ByteStream.h"
#include "BSByteStream.h"
#include "DjVuPalette.h"
+
+#include <stddef.h>
#include <stdlib.h>
#include <math.h>
diff --git a/libdjvu/DjVuPort.h b/libdjvu/DjVuPort.h
index f6a92f6..e2b3125 100644
--- a/libdjvu/DjVuPort.h
+++ b/libdjvu/DjVuPort.h
@@ -65,6 +65,7 @@
#include "GThreads.h"
#include "GURL.h"
+#include "stddef.h"
#ifdef HAVE_NAMESPACES
namespace DJVU {
diff --git a/libdjvu/DjVuToPS.cpp b/libdjvu/DjVuToPS.cpp
index 5517bf3..6914ff9 100644
--- a/libdjvu/DjVuToPS.cpp
+++ b/libdjvu/DjVuToPS.cpp
@@ -72,6 +72,7 @@
#include "GPixmap.h"
#include "debug.h"
#include <stdarg.h>
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
diff --git a/libdjvu/GBitmap.cpp b/libdjvu/GBitmap.cpp
index ab5c0de..797edcc 100644
--- a/libdjvu/GBitmap.cpp
+++ b/libdjvu/GBitmap.cpp
@@ -66,6 +66,8 @@
#include "GString.h"
#include "GThreads.h"
#include "GException.h"
+#include <stddef.h>
+#include <stdlib.h>
#include <string.h>
// - Author: Leon Bottou, 05/1997
diff --git a/libdjvu/GException.cpp b/libdjvu/GException.cpp
index 2ea179a..89da70f 100644
--- a/libdjvu/GException.cpp
+++ b/libdjvu/GException.cpp
@@ -60,6 +60,7 @@
# pragma implementation
#endif
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/libdjvu/GOS.cpp b/libdjvu/GOS.cpp
index e784932..d2088e2 100644
--- a/libdjvu/GOS.cpp
+++ b/libdjvu/GOS.cpp
@@ -65,6 +65,7 @@
#include "GOS.h"
#include "GURL.h"
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
diff --git a/libdjvu/GPixmap.cpp b/libdjvu/GPixmap.cpp
index 392df54..4bf6f57 100644
--- a/libdjvu/GPixmap.cpp
+++ b/libdjvu/GPixmap.cpp
@@ -75,6 +75,8 @@
#include "GThreads.h"
#include "Arrays.h"
#include "JPEGDecoder.h"
+
+#include <stddef.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
diff --git a/libdjvu/GSmartPointer.cpp b/libdjvu/GSmartPointer.cpp
index 6e523e7..58aef5b 100644
--- a/libdjvu/GSmartPointer.cpp
+++ b/libdjvu/GSmartPointer.cpp
@@ -67,6 +67,7 @@
// Our original implementation consisted of multiple classes.
// <http://prdownloads.sourceforge.net/djvu/DjVu2_2b-src.tgz>.
+#include <stddef.h>
#include <string.h>
#if PARANOID_DEBUG
# include <assert.h>
diff --git a/libdjvu/GSmartPointer.h b/libdjvu/GSmartPointer.h
index 82781bd..8a8bb8a 100644
--- a/libdjvu/GSmartPointer.h
+++ b/libdjvu/GSmartPointer.h
@@ -97,6 +97,8 @@
#include "DjVuGlobal.h"
#include "atomic.h"
+#include <stddef.h>
+
#ifdef HAVE_NAMESPACES
namespace DJVU {
# ifdef NOT_DEFINED // Just to fool emacs c++ mode
diff --git a/libdjvu/GString.cpp b/libdjvu/GString.cpp
index 03f6226..350b11b 100644
--- a/libdjvu/GString.cpp
+++ b/libdjvu/GString.cpp
@@ -73,6 +73,7 @@
#include "GThreads.h"
#include "debug.h"
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/libdjvu/GString.h b/libdjvu/GString.h
index b63b753..3aa1f76 100644
--- a/libdjvu/GString.h
+++ b/libdjvu/GString.h
@@ -108,6 +108,7 @@
#include "DjVuGlobal.h"
#include "GContainer.h"
+#include <stddef.h>
#include <stdlib.h>
#include <stdarg.h>
#ifdef WIN32
diff --git a/libdjvu/GThreads.cpp b/libdjvu/GThreads.cpp
index d81f3c3..253fed8 100644
--- a/libdjvu/GThreads.cpp
+++ b/libdjvu/GThreads.cpp
@@ -71,6 +71,8 @@
#include "GThreads.h"
#include "GException.h"
#include "DjVuMessageLite.h"
+
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/libdjvu/GURL.cpp b/libdjvu/GURL.cpp
index c37bf52..a80078c 100644
--- a/libdjvu/GURL.cpp
+++ b/libdjvu/GURL.cpp
@@ -72,6 +72,7 @@
#include "GURL.h"
#include "debug.h"
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
diff --git a/libdjvu/GUnicode.cpp b/libdjvu/GUnicode.cpp
index 415c081..a8b25b8 100644
--- a/libdjvu/GUnicode.cpp
+++ b/libdjvu/GUnicode.cpp
@@ -62,6 +62,8 @@
#include "GString.h"
+#include <stddef.h>
+
#if HAS_ICONV
#include <iconv.h>
#endif
diff --git a/libdjvu/IFFByteStream.h b/libdjvu/IFFByteStream.h
index a653f8c..e31b216 100644
--- a/libdjvu/IFFByteStream.h
+++ b/libdjvu/IFFByteStream.h
@@ -124,6 +124,7 @@
#include "DjVuGlobal.h"
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/libdjvu/IW44EncodeCodec.cpp b/libdjvu/IW44EncodeCodec.cpp
index 8d7b12c..49081b7 100644
--- a/libdjvu/IW44EncodeCodec.cpp
+++ b/libdjvu/IW44EncodeCodec.cpp
@@ -76,6 +76,7 @@
#include "IFFByteStream.h"
#include "GRect.h"
+#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
diff --git a/libdjvu/IW44Image.cpp b/libdjvu/IW44Image.cpp
index 9476726..4a19fb5 100644
--- a/libdjvu/IW44Image.cpp
+++ b/libdjvu/IW44Image.cpp
@@ -76,6 +76,7 @@
#include "IFFByteStream.h"
#include "GRect.h"
+#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
diff --git a/libdjvu/JPEGDecoder.h b/libdjvu/JPEGDecoder.h
index bd430a0..fad1d4c 100644
--- a/libdjvu/JPEGDecoder.h
+++ b/libdjvu/JPEGDecoder.h
@@ -64,6 +64,7 @@
#ifdef NEED_JPEG_DECODER
+#include <stddef.h>
#include <string.h>
#include <setjmp.h>
diff --git a/libdjvu/MMX.cpp b/libdjvu/MMX.cpp
index 5ab60bb..528dab6 100644
--- a/libdjvu/MMX.cpp
+++ b/libdjvu/MMX.cpp
@@ -62,6 +62,7 @@
#include "MMX.h"
#include <stdio.h>
+#include <stddef.h>
#include <stdlib.h>
diff --git a/libdjvu/UnicodeByteStream.h b/libdjvu/UnicodeByteStream.h
index 0ae112b..9b49a17 100644
--- a/libdjvu/UnicodeByteStream.h
+++ b/libdjvu/UnicodeByteStream.h
@@ -88,6 +88,7 @@
#include "GString.h"
#include "ByteStream.h"
+#include <stddef.h>
#ifdef HAVE_NAMESPACES
namespace DJVU {
diff --git a/libdjvu/XMLParser.cpp b/libdjvu/XMLParser.cpp
index 84386c5..7da923a 100644
--- a/libdjvu/XMLParser.cpp
+++ b/libdjvu/XMLParser.cpp
@@ -75,6 +75,7 @@
#include "debug.h"
#include <stdio.h>
#include <ctype.h>
+#include <stddef.h>
#include <stdlib.h>
diff --git a/libdjvu/ZPCodec.cpp b/libdjvu/ZPCodec.cpp
index f6e971d..ff5b9bf 100644
--- a/libdjvu/ZPCodec.cpp
+++ b/libdjvu/ZPCodec.cpp
@@ -66,6 +66,8 @@
#include "ZPCodec.h"
#include "ByteStream.h"
#include "GException.h"
+
+#include <stddef.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
diff --git a/libdjvu/atomic.cpp b/libdjvu/atomic.cpp
index bdc193e..63fd483 100644
--- a/libdjvu/atomic.cpp
+++ b/libdjvu/atomic.cpp
@@ -28,6 +28,7 @@
# include "config.h"
#endif
+#include <stddef.h>
#include <stdlib.h>
#include <assert.h>
#include "atomic.h"
diff --git a/libdjvu/ddjvuapi.cpp b/libdjvu/ddjvuapi.cpp
index b18b84b..f40f5aa 100644
--- a/libdjvu/ddjvuapi.cpp
+++ b/libdjvu/ddjvuapi.cpp
@@ -60,6 +60,7 @@
# pragma implementation "ddjvuapi.h"
#endif
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/libdjvu/ddjvuapi.h b/libdjvu/ddjvuapi.h
index d0ed48f..841f223 100644
--- a/libdjvu/ddjvuapi.h
+++ b/libdjvu/ddjvuapi.h
@@ -64,6 +64,7 @@ extern "C" {
}
#endif
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/libdjvu/miniexp.cpp b/libdjvu/miniexp.cpp
index e0fb087..fc51297 100644
--- a/libdjvu/miniexp.cpp
+++ b/libdjvu/miniexp.cpp
@@ -23,6 +23,7 @@
# pragma implementation "miniexp.h"
#endif
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
diff --git a/libdjvu/miniexp.h b/libdjvu/miniexp.h
index 91e345d..993005b 100644
--- a/libdjvu/miniexp.h
+++ b/libdjvu/miniexp.h
@@ -38,7 +38,8 @@ extern "C" {
#ifndef MINILISPAPI
# define MINILISPAPI /**/
#endif
-
+
+#include <stddef.h>
/* -------------------------------------------------- */
/* LISP EXPRESSIONS */
diff --git a/tools/bzz.cpp b/tools/bzz.cpp
index ca092e1..2ebc7b9 100644
--- a/tools/bzz.cpp
+++ b/tools/bzz.cpp
@@ -94,6 +94,7 @@
#include "GURL.h"
#include "DjVuMessage.h"
#include <locale.h>
+#include <stddef.h>
#include <stdlib.h>
static const char *program = "(unknown)";
diff --git a/tools/c44.cpp b/tools/c44.cpp
index 6f23b53..855504b 100644
--- a/tools/c44.cpp
+++ b/tools/c44.cpp
@@ -226,6 +226,7 @@
#include <locale.h>
#include <stdio.h>
#include <string.h>
+#include <stddef.h>
#include <stdlib.h>
// command line data
diff --git a/tools/cjb2.cpp b/tools/cjb2.cpp
index 8cf89b9..11eb662 100644
--- a/tools/cjb2.cpp
+++ b/tools/cjb2.cpp
@@ -120,6 +120,7 @@
#include "jb2tune.h"
#include <locale.h>
+#include <stddef.h>
#include <stdlib.h>
#if HAVE_TIFF
#include <tiffio.h>
diff --git a/tools/cpaldjvu.cpp b/tools/cpaldjvu.cpp
index 111cbd3..b640a7a 100644
--- a/tools/cpaldjvu.cpp
+++ b/tools/cpaldjvu.cpp
@@ -118,6 +118,7 @@
#include "jb2tune.h"
#include <locale.h>
+#include <stddef.h>
#include <stdlib.h>
#include <math.h>
diff --git a/tools/csepdjvu.cpp b/tools/csepdjvu.cpp
index cd721f8..d5203d5 100644
--- a/tools/csepdjvu.cpp
+++ b/tools/csepdjvu.cpp
@@ -162,6 +162,7 @@
#include "jb2tune.h"
#include <locale.h>
+#include <stddef.h>
#include <stdlib.h>
#undef MIN
diff --git a/tools/ddjvu.cpp b/tools/ddjvu.cpp
index 817e045..981a270 100644
--- a/tools/ddjvu.cpp
+++ b/tools/ddjvu.cpp
@@ -62,6 +62,7 @@
# include "config.h"
#endif
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
diff --git a/tools/djvm.cpp b/tools/djvm.cpp
index 951bd66..6ea88c2 100644
--- a/tools/djvm.cpp
+++ b/tools/djvm.cpp
@@ -135,9 +135,9 @@
#include "DjVuMessage.h"
#include <locale.h>
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
-#include <stdlib.h>
static const char * progname;
diff --git a/tools/djvmcvt.cpp b/tools/djvmcvt.cpp
index 9ca1c54..20b468a 100644
--- a/tools/djvmcvt.cpp
+++ b/tools/djvmcvt.cpp
@@ -144,6 +144,7 @@
#include <locale.h>
#include <stdio.h>
+#include <stddef.h>
#include <stdlib.h>
static const char * progname;
diff --git a/tools/djvudump.cpp b/tools/djvudump.cpp
index 6a0215a..2dddbdf 100644
--- a/tools/djvudump.cpp
+++ b/tools/djvudump.cpp
@@ -119,6 +119,7 @@ xxx
#include <locale.h>
#include <stdio.h>
#include <ctype.h>
+#include <stddef.h>
#include <stdlib.h>
void
diff --git a/tools/djvuextract.cpp b/tools/djvuextract.cpp
index 4a9f381..907b99c 100644
--- a/tools/djvuextract.cpp
+++ b/tools/djvuextract.cpp
@@ -105,6 +105,7 @@
#include "GOS.h"
#include "DjVuMessage.h"
#include <locale.h>
+#include <stddef.h>
#include <stdlib.h>
diff --git a/tools/djvumake.cpp b/tools/djvumake.cpp
index 7020484..4c5fc0f 100644
--- a/tools/djvumake.cpp
+++ b/tools/djvumake.cpp
@@ -153,6 +153,7 @@
#include <locale.h>
#include <stdio.h>
+#include <stddef.h>
#include <stdlib.h>
#include <ctype.h>
diff --git a/tools/djvups.cpp b/tools/djvups.cpp
index 51aa999..632b832 100644
--- a/tools/djvups.cpp
+++ b/tools/djvups.cpp
@@ -57,6 +57,7 @@
# include "config.h"
#endif
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
diff --git a/tools/djvused.cpp b/tools/djvused.cpp
index de84dcd..687fdca 100644
--- a/tools/djvused.cpp
+++ b/tools/djvused.cpp
@@ -61,6 +61,7 @@
#endif
#include <stdio.h>
+#include <stddef.h>
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
diff --git a/tools/djvuserve.cpp b/tools/djvuserve.cpp
index 19a17da..818fe78 100644
--- a/tools/djvuserve.cpp
+++ b/tools/djvuserve.cpp
@@ -73,6 +73,7 @@
#include <locale.h>
#include <stdio.h>
+#include <stddef.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <time.h>
diff --git a/tools/djvutxt.cpp b/tools/djvutxt.cpp
index ba2c745..9e9124c 100644
--- a/tools/djvutxt.cpp
+++ b/tools/djvutxt.cpp
@@ -61,6 +61,7 @@
# include "config.h"
#endif
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
diff --git a/tools/tiff2pdf.h b/tools/tiff2pdf.h
index 082f5fb..656dc43 100644
--- a/tools/tiff2pdf.h
+++ b/tools/tiff2pdf.h
@@ -22,6 +22,7 @@
# endif
# if HAVE_TIFF
# include <stdio.h>
+# include <stddef.h>
# include <stdlib.h>
# include <tiff.h>
# include <tiffio.h>
diff --git a/xmltools/djvutoxml.cpp b/xmltools/djvutoxml.cpp
index 17c769b..b40535e 100644
--- a/xmltools/djvutoxml.cpp
+++ b/xmltools/djvutoxml.cpp
@@ -71,6 +71,7 @@
#include <locale.h>
#include <stdio.h>
+#include <stddef.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <assert.h>
diff --git a/xmltools/djvuxmlparser.cpp b/xmltools/djvuxmlparser.cpp
index bdc5768..6679a9d 100644
--- a/xmltools/djvuxmlparser.cpp
+++ b/xmltools/djvuxmlparser.cpp
@@ -70,6 +70,7 @@
#include <stdio.h>
#include <ctype.h>
#include <locale.h>
+#include <stddef.h>
#include <stdlib.h>
static void
--
1.7.4.1
From 3cc41e2a72bbd6d34e81a9a214abbebf41cc00c7 Mon Sep 17 00:00:00 2001
From: Leon Bottou <leon@bottou.org>
Date: Sat, 21 May 2011 09:27:17 -0700
Subject: [PATCH] Added ddjvu option to skip corrupted pages.
---
tools/ddjvu.1 | 7 +++++++
tools/ddjvu.cpp | 49 +++++++++++++++++++++++++++++++++----------------
2 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/tools/ddjvu.1 b/tools/ddjvu.1
index 29285c3..7d3d105 100644
--- a/tools/ddjvu.1
+++ b/tools/ddjvu.1
@@ -178,6 +178,13 @@ select specific layers of a DjVu image.
These modes can fail if the DjVu image does
not contain the selected layer.
.RE
+.TP
+.BI "-skip"
+Instead of aborting when encountering a corrupted page,
+this option causes
+.BR ddjvu
+to simply skip the corrupted page and continue with the next.
+This is useful for processing certain damaged files.
.SH RESOLUTION OPTIONS
The following options control the resolution of the output image.
diff --git a/tools/ddjvu.cpp b/tools/ddjvu.cpp
index 981a270..b9cb038 100644
--- a/tools/ddjvu.cpp
+++ b/tools/ddjvu.cpp
@@ -132,6 +132,7 @@ ddjvu_rect_t info_size;
ddjvu_rect_t info_segment;
const char *inputfilename = 0;
const char *outputfilename = 0;
+int flag_skip_corrupted = 0;
#if HAVE_TIFF2PDF
char *tempfilename = 0;
@@ -164,7 +165,6 @@ handle(int wait)
if (msg->m_error.filename)
fprintf(stderr,"ddjvu: '%s:%d'\n",
msg->m_error.filename, msg->m_error.lineno);
- exit(10);
default:
break;
}
@@ -554,8 +554,16 @@ dopage(int pageno)
while (! ddjvu_page_decoding_done(page))
handle(TRUE);
if (ddjvu_page_decoding_error(page))
- die(i18n("Cannot decode page %d."), pageno);
-
+ {
+ handle(FALSE);
+ fprintf(stderr,"ddjvu: ");
+ fprintf(stderr,i18n("Cannot decode page %d."), pageno);
+ fprintf(stderr,"\n");
+ if (flag_skip_corrupted)
+ return;
+ else
+ exit(10);
+ }
timingdata[1] = ticks();
/* Open files */
if (flag_format == 't')
@@ -753,19 +761,20 @@ usage()
i18n("DjVu decompression utility\n\n"
"Usage: ddjvu [options] [<djvufile> [<outputfile>]]\n\n"
"Options:\n"
- " -verbose Prints various informational messages.\n"
- " -format=FMT Selects output format: pbm,pgm,ppm,pnm,rle,tiff.\n"
- " -scale=N Selects display scale.\n"
- " -size=WxH Selects size of rendered image.\n"
- " -subsample=N Selects direct subsampling factor.\n"
- " -aspect=no Authorizes aspect ratio changes\n"
- " -segment=WxH+X+Y Selects which segment of the rendered image\n"
- " -mode=black Renders a meaningful bitonal image.\n"
- " -mode=mask Only renders the mask layer.\n"
- " -mode=foreground Only renders the foreground layer.\n"
- " -mode=background Only renders the background layer.\n"
- " -page=PAGESPEC Selects page(s) to be decoded.\n"
- " -quality=QUALITY Specifies jpeg quality for lossy tiff output.\n"
+ " -verbose Print various informational messages.\n"
+ " -format=FMT Select output format: pbm,pgm,ppm,pnm,rle,tiff.\n"
+ " -scale=N Select display scale.\n"
+ " -size=WxH Select size of rendered image.\n"
+ " -subsample=N Select direct subsampling factor.\n"
+ " -aspect=no Authorize aspect ratio changes\n"
+ " -segment=WxH+X+Y Select which segment of the rendered image\n"
+ " -mode=black Render a meaningful bitonal image.\n"
+ " -mode=mask Only render the mask layer.\n"
+ " -mode=foreground Only render the foreground layer.\n"
+ " -mode=background Only render the background layer.\n"
+ " -page=PAGESPEC Select page(s) to be decoded.\n"
+ " -skip Skip corrupted pages instead of aborting.\n"
+ " -quality=QUALITY Specify jpeg quality for lossy tiff output.\n"
"\n"
"If <outputfile> is a single dash or omitted, the decompressed image\n"
"is sent to the standard output. If <djvufile> is a single dash or\n"
@@ -846,6 +855,12 @@ parse_option(int argc, char **argv, int i)
die(i18n(errarg), opt);
flag_verbose = 1;
}
+ if (!strcmp(opt,"skip"))
+ {
+ if (arg)
+ die(i18n(errarg), opt);
+ flag_skip_corrupted = 1;
+ }
else if (!strcmp(opt,"scale"))
{
if (!arg)
@@ -1012,6 +1027,8 @@ main(int argc, char **argv)
die(i18n("Cannot open djvu document '%s'."), inputfilename);
while (! ddjvu_document_decoding_done(doc))
handle(TRUE);
+ if (ddjvu_document_decoding_error(doc))
+ die(i18n("Cannot decode document."));
/* Process all pages */
i = ddjvu_document_get_pagenum(doc);
--
1.7.4.1
From 6a6e6a047b41a431cfc091bd71fcad554fd79437 Mon Sep 17 00:00:00 2001
From: Leon Bottou <leon@bottou.org>
Date: Mon, 30 May 2011 18:52:33 -0700
Subject: [PATCH] Added option -o outputfile to djvudump.
---
tools/djvudump.1 | 2 +-
tools/djvudump.cpp | 34 +++++++++++++++++++++++++---------
2 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/tools/djvudump.1 b/tools/djvudump.1
index c86b7d5..e39a318 100644
--- a/tools/djvudump.1
+++ b/tools/djvudump.1
@@ -27,7 +27,7 @@
djvudump \- Display internal structure of DjVu files.
.SH SYNOPSIS
-.BI "djvudump " "djvufiles" "..."
+.BI "djvudump [-o " "outputfile" "] " "djvufiles" "..."
.SH DESCRIPTION
Program
diff --git a/tools/djvudump.cpp b/tools/djvudump.cpp
index 2dddbdf..6daaf2c 100644
--- a/tools/djvudump.cpp
+++ b/tools/djvudump.cpp
@@ -122,6 +122,9 @@ xxx
#include <stddef.h>
#include <stdlib.h>
+const char *outputfile = 0;
+FILE *outputf = stdout;
+
void
display(const GURL &url)
{
@@ -134,7 +137,7 @@ display(const GURL &url)
obs->seek(0);
obs->readall(buf, size);
GNativeString ns = str;
- fputs((const char*)ns, stdout);
+ fputs((const char*)ns, outputf);
}
@@ -146,7 +149,7 @@ usage()
"DJVUDUMP --- DjVuLibre-" DJVULIBRE_VERSION "\n"
#endif
"Describes DjVu and IFF85 files\n\n"
- "Usage: djvudump <iff_filenames>\n" );
+ "Usage: djvudump [-o outputfile] <iff_filenames>\n" );
exit(1);
}
@@ -156,24 +159,37 @@ main(int argc, char **argv)
setlocale(LC_ALL,"");
setlocale(LC_NUMERIC,"C");
djvu_programname(argv[0]);
- GArray<GUTF8String> dargv(0,argc-1);
+ // get output file name
+ if (argc>2 && !strcmp(argv[1],"-o"))
+ {
+ outputfile = argv[2];
+ argv += 2;
+ argc -= 2;
+ }
+ // convert iff file name
+ GArray<GUTF8String> dargv(0, argc-1);
for(int i=0;i<argc;++i)
dargv[i]=GNativeString(argv[i]);
+ if (argc <= 1)
+ usage();
+ if (outputfile && !(outputf = fopen(outputfile,"w")))
+ {
+ DjVuPrintErrorUTF8("djvudump: Cannot open output file.\n");
+ exit(1);
+ }
G_TRY
{
- if (argc<=1)
- usage();
for (int i=1; i<argc; i++)
- {
+ {
const GURL::Filename::UTF8 url(dargv[i]);
display(url);
- }
+ }
}
G_CATCH(ex)
- {
+ {
ex.perror();
exit(1);
- }
+ }
G_ENDCATCH;
return 0;
}
--
1.7.4.1
From 6db359d1ad5e7e863fac53301e7ff884cfe44423 Mon Sep 17 00:00:00 2001
From: Bill C Riemers <briemers@redhat.com>
Date: Thu, 2 Jun 2011 13:17:27 -0400
Subject: [PATCH] Correct error copying an error in the annotation class of assigning a tempory
GUTF8String directly to a const char *.
---
libdjvu/DjVuAnno.cpp | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/libdjvu/DjVuAnno.cpp b/libdjvu/DjVuAnno.cpp
index 6ca5b4e..e2a9108 100644
--- a/libdjvu/DjVuAnno.cpp
+++ b/libdjvu/DjVuAnno.cpp
@@ -261,7 +261,8 @@ GLObject::print(ByteStream & str, int compact, int indent, int * cur_pos) const
to_print=buffer.format("%d",number);
break;
case STRING:
- to_print=make_c_string(string);
+ buffer=make_c_string(string);
+ to_print=(const char *)buffer;
break;
case SYMBOL:
to_print=buffer.format("%s",(const char *)symbol);
--
1.7.4.1
From 2b26415c3c46ffb7532ca250990668564be62d39 Mon Sep 17 00:00:00 2001
From: Leon Bottou <leon@bottou.org>
Date: Thu, 2 Jun 2011 09:48:49 -0700
Subject: [PATCH] Corrected polarity of xmp annotation saving
---
libdjvu/DjVuAnno.cpp | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/libdjvu/DjVuAnno.cpp b/libdjvu/DjVuAnno.cpp
index e2a9108..8e16dd8 100644
--- a/libdjvu/DjVuAnno.cpp
+++ b/libdjvu/DjVuAnno.cpp
@@ -254,25 +254,24 @@ GLObject::print(ByteStream & str, int compact, int indent, int * cur_pos) const
if (!cur_pos) { cur_pos = &local_cur_pos; }
GUTF8String buffer;
- const char * to_print=0;
switch(type)
{
case NUMBER:
- to_print=buffer.format("%d",number);
+ buffer.format("%d",number);
break;
case STRING:
- buffer=make_c_string(string);
- to_print=(const char *)buffer;
+ buffer = make_c_string(string);
break;
case SYMBOL:
- to_print=buffer.format("%s",(const char *)symbol);
+ buffer.format("%s",(const char *)symbol);
break;
case LIST:
- to_print=buffer.format("(%s",(const char *)name);
+ buffer.format("(%s",(const char *)name);
break;
case INVALID:
break;
}
+ const char * to_print = (const char*)buffer;
if (!compact && *cur_pos+strlen(to_print)>70)
{
char ch='\n';
@@ -1375,7 +1374,7 @@ DjVuANT::encode_raw(void) const
}
//*** XMP Metadata
del_all_items(XMP_TAG, parser);
- if (!xmpmetadata)
+ if (!!xmpmetadata)
{
GUTF8String mdatabuffer("(");
mdatabuffer += XMP_TAG;
@@ -1385,8 +1384,10 @@ DjVuANT::encode_raw(void) const
//*** Mapareas
del_all_items(GMapArea::MAPAREA_TAG, parser);
for(GPosition pos=map_areas;pos;++pos)
- parser.parse(map_areas[pos]->print());
-
+ {
+ GUTF8String mapareabuffer = map_areas[pos]->print();
+ parser.parse(mapareabuffer);
+ }
GP<ByteStream> gstr=ByteStream::create();
ByteStream &str=*gstr;
parser.print(str, 1);
--
1.7.4.1
From 65600b5801d11ff8ca8db3a25bf004fc06f4515b Mon Sep 17 00:00:00 2001
From: Leon Bottou <leon@bottou.org>
Date: Sat, 4 Jun 2011 15:29:18 -0700
Subject: [PATCH] Eliminate warnings with gcc-4.6.0
---
libdjvu/Arrays.cpp | 2 -
libdjvu/DjVuDocEditor.cpp | 37 +++++++++----------
libdjvu/GString.cpp | 44 ++++++++--------------
libdjvu/JPEGDecoder.cpp | 2 -
libdjvu/XMLParser.cpp | 7 +---
tools/ddjvu.cpp | 2 +-
tools/jb2cmp/patterns.cpp | 87 +-------------------------------------------
tools/tiff2pdf.c | 9 ++---
8 files changed, 40 insertions(+), 150 deletions(-)
diff --git a/libdjvu/Arrays.cpp b/libdjvu/Arrays.cpp
index c4f74ca..6c7f23a 100644
--- a/libdjvu/Arrays.cpp
+++ b/libdjvu/Arrays.cpp
@@ -239,9 +239,7 @@ ArrayRep::ins(int n, const void * what, unsigned int howmany)
copy(ndata, lobound-minlo, hibound-minlo,
data, lobound-minlo, hibound-minlo);
destroy(data, lobound-minlo, hibound-minlo);
- void *tmp=data;
data=ndata;
- tmp=data;
maxhi = nmaxhi;
}
diff --git a/libdjvu/DjVuDocEditor.cpp b/libdjvu/DjVuDocEditor.cpp
index 2247e40..f1d8b0d 100644
--- a/libdjvu/DjVuDocEditor.cpp
+++ b/libdjvu/DjVuDocEditor.cpp
@@ -555,27 +555,24 @@ DjVuDocEditor::insert_file(const GURL &file_url, bool is_page,
can_compress_flag);
}
- // Oh. It does exist... Check that it has IFF structure
+ // Oh. It does exist... Check that it has IFF structure
{
- const GP<IFFByteStream> giff(
- IFFByteStream::create(file_pool->get_stream()));
- IFFByteStream &iff=*giff;
- GUTF8String chkid;
-
- int length;
- length=iff.get_chunk(chkid);
- if (chkid!="FORM:DJVI" && chkid!="FORM:DJVU" &&
- chkid!="FORM:BM44" && chkid!="FORM:PM44")
- G_THROW( ERR_MSG("DjVuDocEditor.not_1_page") "\t"+file_url.get_string());
-
- // Wonderful. It's even a DjVu file. Scan for NDIR chunks.
- // If NDIR chunk is found, ignore the file
- while(iff.get_chunk(chkid))
- {
- if (chkid=="NDIR")
- return false;
- iff.close_chunk();
- }
+ const GP<IFFByteStream> giff(
+ IFFByteStream::create(file_pool->get_stream()));
+ IFFByteStream &iff=*giff;
+ GUTF8String chkid;
+ if (chkid!="FORM:DJVI" && chkid!="FORM:DJVU" &&
+ chkid!="FORM:BM44" && chkid!="FORM:PM44")
+ G_THROW( ERR_MSG("DjVuDocEditor.not_1_page") "\t"
+ + file_url.get_string());
+ // Wonderful. It's even a DjVu file. Scan for NDIR chunks.
+ // If NDIR chunk is found, ignore the file
+ while(iff.get_chunk(chkid))
+ {
+ if (chkid=="NDIR")
+ return false;
+ iff.close_chunk();
+ }
}
return insert_file(file_pool,file_url,is_page,file_pos,name2id,source);
}
diff --git a/libdjvu/GString.cpp b/libdjvu/GString.cpp
index 350b11b..ed92a7f 100644
--- a/libdjvu/GString.cpp
+++ b/libdjvu/GString.cpp
@@ -643,26 +643,22 @@ GBaseString::UTF8ToNative(
const char *source=(*this);
GP<GStringRep> retval;
if(source && source[0])
- {
-#if DO_CHANGELOCALE
- GUTF8String lc_ctype(setlocale(LC_CTYPE,0));
-#endif
- bool repeat;
- for(repeat=!currentlocale;;repeat=false)
{
- retval=(*this)->toNative((GStringRep::EscapeMode)escape);
#if DO_CHANGELOCALE
- if (!repeat || retval || (lc_ctype == setlocale(LC_CTYPE,"")))
+ GUTF8String lc_ctype(setlocale(LC_CTYPE,0));
+ bool repeat;
+ for(repeat=!currentlocale;;repeat=false)
+ {
#endif
- break;
- }
+ retval=(*this)->toNative((GStringRep::EscapeMode)escape);
#if DO_CHANGELOCALE
- if(!repeat)
- {
+ if (!repeat || retval || (lc_ctype == setlocale(LC_CTYPE,"")))
+ break;
+ }
+ if(!repeat)
setlocale(LC_CTYPE,(const char *)lc_ctype);
- }
#endif
- }
+ }
return GNativeString(retval);
}
@@ -697,27 +693,19 @@ GBaseString::NativeToUTF8(void) const
const char *source=(*this);
#if DO_CHANGELOCALE
GUTF8String lc_ctype=setlocale(LC_CTYPE,0);
-#endif
bool repeat;
for(repeat=true;;repeat=false)
- {
- if( (retval=GStringRep::NativeToUTF8(source)) )
{
- if(GStringRep::cmp(retval->toNative(),source))
- {
- retval=GStringRep::UTF8::create((unsigned int)0);
- }
- }
-#if DO_CHANGELOCALE
- if(!repeat || retval || (lc_ctype == setlocale(LC_CTYPE,"")))
#endif
- break;
- }
+ if( (retval=GStringRep::NativeToUTF8(source)) )
+ if(GStringRep::cmp(retval->toNative(),source))
+ retval=GStringRep::UTF8::create((unsigned int)0);
#if DO_CHANGELOCALE
+ if(!repeat || retval || (lc_ctype == setlocale(LC_CTYPE,"")))
+ break;
+ }
if(!repeat)
- {
setlocale(LC_CTYPE,(const char *)lc_ctype);
- }
#endif
}
return GUTF8String(retval);
diff --git a/libdjvu/JPEGDecoder.cpp b/libdjvu/JPEGDecoder.cpp
index cb7aa97..f22f77a 100644
--- a/libdjvu/JPEGDecoder.cpp
+++ b/libdjvu/JPEGDecoder.cpp
@@ -153,7 +153,6 @@ JPEGDecoder::decode(ByteStream & bs,GPixmap &pix)
JSAMPARRAY buffer; /* Output row buffer */
int row_stride; /* physical row width in output buffer */
- int full_buf_size;
int isGrey,i;
cinfo.err = jpeg_std_error(&jerr.pub);
@@ -184,7 +183,6 @@ JPEGDecoder::decode(ByteStream & bs,GPixmap &pix)
/* JSAMPLEs per row in output buffer */
row_stride = cinfo.output_width * cinfo.output_components;
- full_buf_size = row_stride * cinfo.output_height;
/* Make a one-row-high sample array that will go away when done with image */
buffer = (*cinfo.mem->alloc_sarray)
diff --git a/libdjvu/XMLParser.cpp b/libdjvu/XMLParser.cpp
index 7da923a..026b27d 100644
--- a/libdjvu/XMLParser.cpp
+++ b/libdjvu/XMLParser.cpp
@@ -646,17 +646,12 @@ lt_XMLParser::Impl::parse(const lt_XMLTags &tags, GURL *pdjvufile)
GPosition datapos=args.contains("data");
if(datapos)
{
- bool isDjVuType=false;
GPosition typePos(args.contains("type"));
if(typePos)
- {
- if(args[typePos] != mimetype)
{
- // DjVuPrintErrorUTF8("Ignoring %s Object tag\n",mimetype);
+ if(args[typePos] != mimetype)
continue;
}
- isDjVuType=true;
- }
const GURL url = (pdjvufile) ? *pdjvufile
: GURL::UTF8(args[datapos],
(args[datapos][0] == '/') ? codebase.base() : codebase);
diff --git a/tools/ddjvu.cpp b/tools/ddjvu.cpp
index b9cb038..3b4ce16 100644
--- a/tools/ddjvu.cpp
+++ b/tools/ddjvu.cpp
@@ -855,7 +855,7 @@ parse_option(int argc, char **argv, int i)
die(i18n(errarg), opt);
flag_verbose = 1;
}
- if (!strcmp(opt,"skip"))
+ else if (!strcmp(opt,"skip"))
{
if (arg)
die(i18n(errarg), opt);
diff --git a/tools/jb2cmp/patterns.cpp b/tools/jb2cmp/patterns.cpp
index e456902..b31cf4e 100644
--- a/tools/jb2cmp/patterns.cpp
+++ b/tools/jb2cmp/patterns.cpp
@@ -303,11 +303,8 @@ static int32 distance_by_pixeldiff_functions(Image *i1, Image *i2,
int32 (*compare_row)(byte *, byte *, int32),
int32 (*compare_with_white)(byte *, int32), int32 ceiling)
{
- byte **p1, **p2;
int32 w1, w2, h1, h2;
int32 shift_x, shift_y; /* of i1's coordinate system with respect to i2 */
- /*int32 s = 0, i, i_start, i_cap;
- int32 right_margin_start, right_margin_width;*/
/* make i1 to be narrower than i2 */
if (i1->width > i2->width)
@@ -317,8 +314,8 @@ static int32 distance_by_pixeldiff_functions(Image *i1, Image *i2,
i2 = img;
}
- w1 = i1->width; h1 = i1->height; p1 = i1->pixels;
- w2 = i2->width; h2 = i2->height; p2 = i2->pixels;
+ w1 = i1->width; h1 = i1->height;
+ w2 = i2->width; h2 = i2->height;
/* (shift_x, shift_y) */
/* is what should be added to i1's coordinates to get i2's coordinates. */
@@ -339,86 +336,6 @@ static int32 distance_by_pixeldiff_functions(Image *i1, Image *i2,
return distance_by_pixeldiff_functions_by_shift(
i1, i2, compare_row, compare_with_white, ceiling, shift_x, shift_y);
-
-/* FIXME */
-#if 0
- /* Compute difference in the non-overlapping top margin */
-
- if (shift_y < 0)
- {
- /* i1 has top rows not covered by i2 */
- i_cap = -shift_y;
- for (i = 0; i < i_cap; i++)
- {
- assert(i >= 0 && i < h1);
- s += compare_with_white(p1[i], w1);
- if (s > ceiling) return maxint;
- }
- i_start = i_cap; /* topmost overlapping row in i1's coords */
- }
- else
- {
- /* i2 has top rows not covered by i1 */
- for (i = 0; i < shift_y; i++)
- {
- assert(i >= 0 && i < h2);
- s += compare_with_white(p2[i], w2);
- if (s > ceiling) return maxint;
- }
- i_start = 0;
- }
-
- /* Compute difference in the overlapping area */
-
- i_cap = h2 - shift_y;
- if (h1 < i_cap) i_cap = h1;
-
- right_margin_start = shift_x + w1;
- right_margin_width = w2 - right_margin_start;
-
- for (i = i_start; i < i_cap; i++) /* i is a coordinate in i1 system */
- {
- int32 y = i + shift_y; /* same row coordinate in i2 system */
- assert(y >= 0 && y < h2);
- s += compare_with_white(p2[y], shift_x);
- if (s > ceiling) return maxint;
- assert(i >= 0 && i < h1);
- assert(shift_x + w1 <= w2);
- assert(i < h1);
- s += compare_row(p2[y] + shift_x, p1[i], w1);
- if (s > ceiling) return maxint;
- s += compare_with_white(p2[y] + right_margin_start, right_margin_width);
- if (s > ceiling) return maxint;
- }
-
-
- /* Compute difference in the non-overlapping bottom margin */
-
- if (i_cap == h1)
- {
- /* i2 has bottom rows not covered by i1 */
- i_start = i_cap + shift_y;
- for (i = i_start; i < h2; i++)
- {
- assert(i >= 0 && i < h2);
- s += compare_with_white(p2[i], w2);
- if (s > ceiling) return maxint;
- }
- }
- else
- {
- /* i1 has bottom rows not covered by i2 */
- i_start = i_cap;
- for (i = i_cap; i < h1; i++)
- {
- assert(i >= 0 && i < h1);
- s += compare_with_white(p1[i], w1);
- if (s > ceiling) return maxint;
- }
- }
-
- return s;
-#endif
}
#endif
diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
index 36949f1..2db8703 100644
--- a/tools/tiff2pdf.c
+++ b/tools/tiff2pdf.c
@@ -721,7 +721,6 @@ tiff2pdf(TIFF *input, FILE *outputfile, int argc, const char **argv)
const char *outfilename = "<null>";
T2P *t2p = NULL;
TIFF *output = NULL;
- tsize_t written=0;
int c;
/* T2P */
@@ -874,7 +873,7 @@ tiff2pdf(TIFF *input, FILE *outputfile, int argc, const char **argv)
TIFFSeekFile(output, (toff_t) 0, SEEK_SET);
/* Write */
- written = t2p_write_pdf(t2p, input, output);
+ t2p_write_pdf(t2p, input, output);
if(t2p->t2p_error != 0){
TIFFError(TIFF2PDF_MODULE, "An error occurred creating output PDF file");
goto fail;
@@ -2633,7 +2632,6 @@ static tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output,
tsize_t read=0;
uint16 i=0;
ttile_t tilecount=0;
- tsize_t tilesize=0;
ttile_t septilecount=0;
tsize_t septilesize=0;
#ifdef JPEG_SUPPORT
@@ -2819,7 +2817,6 @@ static tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output,
if(t2p->pdf_sample == T2P_SAMPLE_PLANAR_SEPARATE_TO_CONTIG){
septilesize=TIFFTileSize(input);
septilecount=TIFFNumberOfTiles(input);
- tilesize=septilesize*t2p->tiff_samplesperpixel;
tilecount=septilecount/t2p->tiff_samplesperpixel;
buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize);
if(buffer==NULL){
@@ -3802,7 +3799,6 @@ static tsize_t t2p_write_pdf_info(T2P* t2p, TIFF* input, TIFF* output){
tsize_t written=0;
char* info;
char buffer[512];
- int buflen=0;
if(t2p->pdf_datetime==NULL){
t2p_pdf_tifftime(t2p, input);
@@ -3815,7 +3811,8 @@ static tsize_t t2p_write_pdf_info(T2P* t2p, TIFF* input, TIFF* output){
}
written += TIFFWriteFile(output, (tdata_t) "\r/Producer ", 11);
_TIFFmemset((tdata_t)buffer, 0x00, 512);
- buflen=sprintf(buffer, "libtiff / tiff2pdf - %d / %s", TIFFLIB_VERSION, T2P_VERSION);
+ sprintf(buffer, "libtiff / tiff2pdf - %d / %s",
+ TIFFLIB_VERSION, T2P_VERSION);
written += t2p_write_pdf_string(buffer, output);
written += TIFFWriteFile(output, (tdata_t) "\r", 1);
if(t2p->pdf_creator != NULL){
--
1.7.4.1
From 5b3d074c2b315e7339ce279c559c3a99f26bef6a Mon Sep 17 00:00:00 2001
From: Leon Bottou <leon@bottou.org>
Date: Sat, 4 Jun 2011 17:37:00 -0700
Subject: [PATCH] Fix MMX code when using gcc-4.6
Fix MMX macros
Enable MMX on x86_64
---
libdjvu/MMX.cpp | 17 ++++++++++++++++-
libdjvu/MMX.h | 11 ++++++-----
tools/ddjvu.cpp | 1 -
3 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/libdjvu/MMX.cpp b/libdjvu/MMX.cpp
index 528dab6..e70fdd8 100644
--- a/libdjvu/MMX.cpp
+++ b/libdjvu/MMX.cpp
@@ -167,8 +167,23 @@ MMXControl::enable_mmx()
: "=m" (cpuflags) :
: "eax","ecx","edx");
#endif
+#if defined(MMX) && defined(__GNUC__) && defined(__x86_64__)
+ // Detection of MMX for GCC
+ __asm__ volatile (// Check that CR0:EM is clear
+ "xorl %%edx,%%edx\n\t"
+ "smsw %%ax\n\t"
+ "andl $4,%%eax\n\t"
+ "jnz 1f\n\t"
+ // Execute CPUID
+ "movl $1,%%eax\n\t"
+ "cpuid\n"
+ // Finish
+ "1:\tmovl %%edx, %0"
+ : "=m" (cpuflags) :
+ : "eax","ebx","ecx","edx");
+#endif
#if defined(MMX) && defined(_MSC_VER) && defined(_M_IX86)
- // Detection of MMX for MSVC
+ // Detection of MMX for MSVC 32 bits
__asm { pushfd
pop ecx
xor edx,edx
diff --git a/libdjvu/MMX.h b/libdjvu/MMX.h
index b0af5e5..f8780af 100644
--- a/libdjvu/MMX.h
+++ b/libdjvu/MMX.h
@@ -143,17 +143,18 @@ class MMXControl
#ifndef NO_MMX
-#if defined(__GNUC__) && defined(__i386__)
+#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
+typedef struct{ char c[8]; } MMX_t;
#define MMXemms \
__asm__ volatile("emms" : : : "memory" )
#define MMXrr(op,src,dst) \
- __asm__ volatile( #op " %%" #src ",%%" #dst : : : "memory")
+ __asm__ volatile( #op " %%" #src ",%%" #dst : : : "memory" )
#define MMXir(op,imm,dst) \
- __asm__ volatile( #op " %0,%%" #dst : : "i" (imm) : "memory")
+ __asm__ volatile( #op " %0,%%" #dst : : "i" (imm) : "memory" )
#define MMXar(op,addr,dst) \
- __asm__ volatile( #op " %0,%%" #dst : : "m" (*(addr)) : "memory")
+ __asm__ volatile( #op " %0,%%" #dst : : "m" (*(MMX_t*)(addr)) : "memory" )
#define MMXra(op,src,addr) \
- __asm__ volatile( #op " %%" #src ",%0" : : "m" (*(addr)) : "memory")
+ __asm__ volatile( #op " %%" #src ",%0" : "=m" (*(MMX_t*)(addr)) : : "memory")
#define MMX 1
#endif
diff --git a/tools/ddjvu.cpp b/tools/ddjvu.cpp
index 3b4ce16..216c6cb 100644
--- a/tools/ddjvu.cpp
+++ b/tools/ddjvu.cpp
@@ -846,7 +846,6 @@ parse_option(int argc, char **argv, int i)
arg = opt;
opt = "subsample";
}
-
/* Parse options */
if (!strcmp(opt,"v") ||
!strcmp(opt,"verbose"))
--
1.7.4.1
From fbed8e51e5970b12ce36afb0dec8c4e02992c0f8 Mon Sep 17 00:00:00 2001
From: Leon Bottou <leon@bottou.org>
Date: Thu, 9 Jun 2011 14:37:52 -0700
Subject: [PATCH] Fixed regression in djvm.
---
libdjvu/DjVuDocEditor.cpp | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/libdjvu/DjVuDocEditor.cpp b/libdjvu/DjVuDocEditor.cpp
index f1d8b0d..baeb7dd 100644
--- a/libdjvu/DjVuDocEditor.cpp
+++ b/libdjvu/DjVuDocEditor.cpp
@@ -561,6 +561,7 @@ DjVuDocEditor::insert_file(const GURL &file_url, bool is_page,
IFFByteStream::create(file_pool->get_stream()));
IFFByteStream &iff=*giff;
GUTF8String chkid;
+ iff.get_chunk(chkid);
if (chkid!="FORM:DJVI" && chkid!="FORM:DJVU" &&
chkid!="FORM:BM44" && chkid!="FORM:PM44")
G_THROW( ERR_MSG("DjVuDocEditor.not_1_page") "\t"
--
1.7.4.1
From f63327438954b8831a1a9f43afc8b6d16e1d3baf Mon Sep 17 00:00:00 2001
From: Leon Bottou <leon@bottou.org>
Date: Wed, 15 Jun 2011 00:05:50 -0700
Subject: [PATCH] Encode oblique text as separate lines.
---
tools/csepdjvu.cpp | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/csepdjvu.cpp b/tools/csepdjvu.cpp
index d5203d5..08f7a27 100644
--- a/tools/csepdjvu.cpp
+++ b/tools/csepdjvu.cpp
@@ -1288,7 +1288,7 @@ Comments::textmark(GP<TxtMark> mark)
int shx = (mark->x - lastx) * 100 / fontsize;
int shy = (mark->y - lasty) * 100 / fontsize;
int inter = dirx * shx + diry * shy;
- if ( (dirx == lastdirx) && (diry == lastdiry) &&
+ if ( (dirx || diry) && (dirx == lastdirx) && (diry == lastdiry) &&
(inter > -150) && (inter < 300) &&
abs(diry * shx + dirx * shy) < 80 )
mark->inter = inter;
--
1.7.4.1
From ea9fd2acab2e298ba721eb79f5026d34e6ef141f Mon Sep 17 00:00:00 2001
From: Barak A. Pearlmutter <barak+git@cs.nuim.ie>
Date: Wed, 22 Jun 2011 11:21:41 +0100
Subject: [PATCH] consistent prototype for ddjvu_anno_get_xmp
---
libdjvu/ddjvuapi.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libdjvu/ddjvuapi.h b/libdjvu/ddjvuapi.h
index 841f223..14b63eb 100644
--- a/libdjvu/ddjvuapi.h
+++ b/libdjvu/ddjvuapi.h
@@ -1619,7 +1619,7 @@ ddjvu_anno_get_metadata(miniexp_t annotations, miniexp_t key);
Returns zero if no such key is present. */
DDJVUAPI const char *
-ddjvu_anno_get_xmp(miniexp_t annotations, miniexp_t xmp);
+ddjvu_anno_get_xmp(miniexp_t annotations);
/* -------------------------------------------------- */
--
1.7.4.1
From 701d1261493e175955aac97921949f4e4241750d Mon Sep 17 00:00:00 2001
From: Leon Bottou <leon@bottou.org>
Date: Sun, 11 Sep 2011 09:59:26 -0700
Subject: [PATCH] Fixed typo in man page.
---
tools/ddjvu.1 | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/ddjvu.1 b/tools/ddjvu.1
index 7d3d105..cbb8307 100644
--- a/tools/ddjvu.1
+++ b/tools/ddjvu.1
@@ -66,7 +66,7 @@ and
.BR "ppm"
respectively produce a Portable Bitmap (PBM),
Portable Graymap (PGM),
-or Portable Pixmap (PGM) file.
+or Portable Pixmap (PPM) file.
Format
.B "pnm"
produces a PBM, PGM, or PPM
--
1.7.4.1
|