summaryrefslogtreecommitdiffstats
path: root/src/gdal-1-fixes.patch
blob: 8b34503e5fea490cd1d42c1929fb19eff85bbdbe (plain)
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
This file is part of MXE.
See index.html for further information.

From a0c0640eb7e98db4a9cbe5104abef8425d975712 Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Wed, 4 Jul 2012 10:05:33 +0200
Subject: [PATCH 1/2] giflib compatibility

Taken from http://trac.osgeo.org/gdal/changeset/24491?format=diff&new=24491
---
 frmts/gif/gifdataset.cpp |   30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/frmts/gif/gifdataset.cpp b/frmts/gif/gifdataset.cpp
index c89f34c..1947edd 100644
--- a/frmts/gif/gifdataset.cpp
+++ b/frmts/gif/gifdataset.cpp
@@ -470,6 +470,28 @@ GDALDataset *GIFDataset::Open( GDALOpenInfo * poOpenInfo )
 }
 
 /************************************************************************/
+/*                        GDALPrintGifError()                           */
+/************************************************************************/
+
+static void GDALPrintGifError(const char* pszMsg)
+{
+/* GIFLIB_MAJOR is only defined in libgif >= 4.2.0 */
+/* libgif 4.2.0 has retired PrintGifError() and added GifErrorString() */
+#if defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && \
+        ((GIFLIB_MAJOR == 4 && GIFLIB_MINOR >= 2) || GIFLIB_MAJOR > 4)
+    /* Static string actually, hence the const char* cast */
+    const char* pszGIFLIBError = (const char*) GifErrorString();
+    if (pszGIFLIBError == NULL)
+        pszGIFLIBError = "Unknown error";
+    CPLError( CE_Failure, CPLE_AppDefined,
+              "%s. GIFLib Error : %s", pszMsg, pszGIFLIBError );
+#else
+    PrintGifError();
+    CPLError( CE_Failure, CPLE_AppDefined, "%s", pszMsg );
+#endif
+}
+
+/************************************************************************/
 /*                             CreateCopy()                             */
 /************************************************************************/
 
@@ -596,9 +618,7 @@ GIFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
                           psGifCT->ColorCount, 255, psGifCT) == GIF_ERROR)
     {
         FreeMapObject(psGifCT);
-        PrintGifError();
-        CPLError( CE_Failure, CPLE_AppDefined, 
-                  "Error writing gif file." );
+        GDALPrintGifError("Error writing gif file.");
         EGifCloseFile(hGifFile);
         VSIFCloseL( fp );
         return NULL;
@@ -622,9 +642,7 @@ GIFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
 
     if (EGifPutImageDesc(hGifFile, 0, 0, nXSize, nYSize, bInterlace, NULL) == GIF_ERROR )
     {
-        PrintGifError();
-        CPLError( CE_Failure, CPLE_AppDefined, 
-                  "Error writing gif file." );
+        GDALPrintGifError("Error writing gif file.");
         EGifCloseFile(hGifFile);
         VSIFCloseL( fp );
         return NULL;
-- 
1.7.10.4


From 7411f59dd769a72a79838e932d1a0988b04dc4d5 Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Wed, 4 Jul 2012 10:42:33 +0200
Subject: [PATCH 2/2] giflib 5 compatibility

taken from
http://trac.osgeo.org/gdal/changeset/24627
---
 frmts/gif/biggifdataset.cpp |    5 +++++
 frmts/gif/gifdataset.cpp    |   43 ++++++++++++++++++++++++++++++++++++-------
 2 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/frmts/gif/biggifdataset.cpp b/frmts/gif/biggifdataset.cpp
index e3029e5..6bed0dc 100644
--- a/frmts/gif/biggifdataset.cpp
+++ b/frmts/gif/biggifdataset.cpp
@@ -371,7 +371,12 @@ CPLErr BIGGIFDataset::ReOpen()
     VSIFSeekL( fp, 0, SEEK_SET );
 
     nLastLineRead = -1;
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
+    int nError;
+    hGifFile = DGifOpen( fp, VSIGIFReadFunc, &nError );
+#else
     hGifFile = DGifOpen( fp, VSIGIFReadFunc );
+#endif
     if( hGifFile == NULL )
     {
         CPLError( CE_Failure, CPLE_OpenFailed, 
diff --git a/frmts/gif/gifdataset.cpp b/frmts/gif/gifdataset.cpp
index 1947edd..0b99158 100644
--- a/frmts/gif/gifdataset.cpp
+++ b/frmts/gif/gifdataset.cpp
@@ -36,8 +36,17 @@ CPL_CVSID("$Id: gifdataset.cpp 23621 2011-12-20 23:26:56Z rouault $");
 CPL_C_START
 void	GDALRegister_GIF(void);
 
+#if !(defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5)
+
 // This prototype seems to have been messed up!
 GifFileType * EGifOpen(void* userData, OutputFunc writeFunc);
+
+// Define alias compatible with giflib >= 5.0.0
+#define GifMakeMapObject MakeMapObject
+#define GifFreeMapObject FreeMapObject
+
+#endif // defined(GIFLIB_MAJOR) && GIFLIB_MAJOR < 5
+
 CPL_C_END
 
 static const int InterlacedOffset[] = { 0, 4, 2, 1 }; 
@@ -322,7 +331,12 @@ GDALDataset *GIFDataset::Open( GDALOpenInfo * poOpenInfo )
     if( fp == NULL )
         return NULL;
 
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
+    int nError;
+    hGifFile = DGifOpen( fp, VSIGIFReadFunc, &nError );
+#else
     hGifFile = DGifOpen( fp, VSIGIFReadFunc );
+#endif
     if( hGifFile == NULL )
     {
         VSIFCloseL( fp );
@@ -380,7 +394,12 @@ GDALDataset *GIFDataset::Open( GDALOpenInfo * poOpenInfo )
     DGifCloseFile( hGifFile );
 
     VSIFSeekL( fp, 0, SEEK_SET);
+
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
+    hGifFile = DGifOpen( fp, VSIGIFReadFunc, &nError );
+#else
     hGifFile = DGifOpen( fp, VSIGIFReadFunc );
+#endif
     if( hGifFile == NULL )
     {
         VSIFCloseL( fp );
@@ -473,14 +492,19 @@ GDALDataset *GIFDataset::Open( GDALOpenInfo * poOpenInfo )
 /*                        GDALPrintGifError()                           */
 /************************************************************************/
 
-static void GDALPrintGifError(const char* pszMsg)
+static void GDALPrintGifError(GifFileType *hGifFile, const char* pszMsg)
 {
 /* GIFLIB_MAJOR is only defined in libgif >= 4.2.0 */
 /* libgif 4.2.0 has retired PrintGifError() and added GifErrorString() */
 #if defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && \
         ((GIFLIB_MAJOR == 4 && GIFLIB_MINOR >= 2) || GIFLIB_MAJOR > 4)
     /* Static string actually, hence the const char* cast */
+
+#if GIFLIB_MAJOR >= 5
+    const char* pszGIFLIBError = (const char*) GifErrorString(hGifFile->Error);
+#else
     const char* pszGIFLIBError = (const char*) GifErrorString();
+#endif
     if (pszGIFLIBError == NULL)
         pszGIFLIBError = "Unknown error";
     CPLError( CE_Failure, CPLE_AppDefined,
@@ -557,7 +581,12 @@ GIFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
         return NULL;
     }
 
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
+    int nError;
+    hGifFile = EGifOpen( fp, VSIGIFWriteFunc, &nError );
+#else
     hGifFile = EGifOpen( fp, VSIGIFWriteFunc );
+#endif
     if( hGifFile == NULL )
     {
         VSIFCloseL( fp );
@@ -577,7 +606,7 @@ GIFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
 
     if( poBand->GetColorTable() == NULL )
     {
-        psGifCT = MakeMapObject( 256, NULL );
+        psGifCT = GifMakeMapObject( 256, NULL );
         for( iColor = 0; iColor < 256; iColor++ )
         {
             psGifCT->Colors[iColor].Red = (GifByteType) iColor;
@@ -593,7 +622,7 @@ GIFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
         while( nFullCount < poCT->GetColorEntryCount() )
             nFullCount = nFullCount * 2;
 
-        psGifCT = MakeMapObject( nFullCount, NULL );
+        psGifCT = GifMakeMapObject( nFullCount, NULL );
         for( iColor = 0; iColor < poCT->GetColorEntryCount(); iColor++ )
         {
             GDALColorEntry	sEntry;
@@ -617,14 +646,14 @@ GIFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
     if (EGifPutScreenDesc(hGifFile, nXSize, nYSize, 
                           psGifCT->ColorCount, 255, psGifCT) == GIF_ERROR)
     {
-        FreeMapObject(psGifCT);
-        GDALPrintGifError("Error writing gif file.");
+        GifFreeMapObject(psGifCT);
+        GDALPrintGifError(hGifFile, "Error writing gif file.");
         EGifCloseFile(hGifFile);
         VSIFCloseL( fp );
         return NULL;
     }
     
-    FreeMapObject(psGifCT);
+    GifFreeMapObject(psGifCT);
     psGifCT = NULL;
 
     /* Support for transparency */
@@ -642,7 +671,7 @@ GIFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
 
     if (EGifPutImageDesc(hGifFile, 0, 0, nXSize, nYSize, bInterlace, NULL) == GIF_ERROR )
     {
-        GDALPrintGifError("Error writing gif file.");
+        GDALPrintGifError(hGifFile, "Error writing gif file.");
         EGifCloseFile(hGifFile);
         VSIFCloseL( fp );
         return NULL;
-- 
1.7.10.4