]> git.pld-linux.org Git - packages/gd.git/blob - gd-graphviz.patch
- added gd(imagerotate) Provides, release 9
[packages/gd.git] / gd-graphviz.patch
1 diff -rub gd-2.0.33/entities.h gd-2.0.33jce3/entities.h
2 --- gd-2.0.33/entities.h        2004-10-27 10:22:46.000000000 -0400
3 +++ gd-2.0.33jce3/entities.h    2005-08-15 11:23:47.000000000 -0400
4 @@ -11,7 +11,7 @@
5  extern "C" {
6  #endif
7  
8 -struct entities_s {
9 +static struct entities_s {
10         char    *name;
11         int     value;
12  } entities[] = {
13 diff -rub gd-2.0.33/entities.tcl gd-2.0.33jce3/entities.tcl
14 --- gd-2.0.33/entities.tcl      2004-10-27 10:22:48.000000000 -0400
15 +++ gd-2.0.33jce3/entities.tcl  2005-08-15 10:19:33.000000000 -0400
16 @@ -32,7 +32,7 @@
17  puts $f "extern \"C\" {"
18  puts $f "#endif"
19  puts $f ""
20 -puts $f "struct entities_s {"
21 +puts $f "static struct entities_s {"
22  puts $f "      char    *name;"
23  puts $f "      int     value;"
24  puts $f "} entities\[\] = {"
25 diff -rub gd-2.0.33/gd.c gd-2.0.33jce3/gd.c
26 --- gd-2.0.33/gd.c      2004-11-01 13:28:56.000000000 -0500
27 +++ gd-2.0.33jce3/gd.c  2005-08-15 11:23:47.000000000 -0400
28 @@ -72,9 +72,16 @@
29    int i;
30    gdImagePtr im;
31    im = (gdImage *) gdMalloc (sizeof (gdImage));
32 +  if (!im)
33 +    return NULL;
34    memset (im, 0, sizeof (gdImage));
35    /* Row-major ever since gd 1.3 */
36    im->pixels = (unsigned char **) gdMalloc (sizeof (unsigned char *) * sy);
37 +  if (!im->pixels)
38 +    {
39 +      free(im);
40 +      return NULL;
41 +    }
42    im->polyInts = 0;
43    im->polyAllocated = 0;
44    im->brush = 0;
45 @@ -84,6 +91,15 @@
46      {
47        /* Row-major ever since gd 1.3 */
48        im->pixels[i] = (unsigned char *) gdCalloc (sx, sizeof (unsigned char));
49 +      if (!im->pixels[i]) 
50 +       {
51 +         for (--i ; i >= 0; i--)
52 +           {
53 +             gdFree(im->pixels[i]);
54 +           }
55 +         gdFree(im);
56 +         return NULL;
57 +       }
58      }
59    im->sx = sx;
60    im->sy = sy;
61 diff -rub gd-2.0.33/gd_gif_in.c gd-2.0.33jce3/gd_gif_in.c
62 --- gd-2.0.33/gd_gif_in.c       2004-11-01 13:28:56.000000000 -0500
63 +++ gd-2.0.33jce3/gd_gif_in.c   2005-08-15 11:23:47.000000000 -0400
64 @@ -1,3 +1,7 @@
65 +#ifdef HAVE_CONFIG_H
66 +#include "config.h"
67 +#endif
68 +
69  #include <stdio.h>
70  #include <math.h>
71  #include <string.h>
72 diff -rub gd-2.0.33/gd_gif_out.c gd-2.0.33jce3/gd_gif_out.c
73 --- gd-2.0.33/gd_gif_out.c      2004-11-02 08:41:00.000000000 -0500
74 +++ gd-2.0.33jce3/gd_gif_out.c  2005-08-15 11:23:47.000000000 -0400
75 @@ -1,3 +1,7 @@
76 +#ifdef HAVE_CONFIG_H
77 +#include "config.h"
78 +#endif
79 +
80  #include <stdio.h>
81  #include <math.h>
82  #include <string.h>
83 diff -rub gd-2.0.33/gd_topal.c gd-2.0.33jce3/gd_topal.c
84 --- gd-2.0.33/gd_topal.c        2004-10-28 14:12:08.000000000 -0400
85 +++ gd-2.0.33jce3/gd_topal.c    2005-08-15 11:23:47.000000000 -0400
86 @@ -49,6 +49,10 @@
87    #define ORIGINAL_LIB_JPEG_REVERSE_ODD_ROWS
88   */
89  
90 +#ifdef HAVE_CONFIG_H
91 +#include "config.h"
92 +#endif
93 +
94  #include <string.h>
95  #include "gd.h"
96  #include "gdhelpers.h"
97 diff -rub gd-2.0.33/gdfontg.c gd-2.0.33jce3/gdfontg.c
98 --- gd-2.0.33/gdfontg.c 2004-10-27 10:22:04.000000000 -0400
99 +++ gd-2.0.33jce3/gdfontg.c     2005-08-15 11:23:47.000000000 -0400
100 @@ -10,6 +10,9 @@
101     "Libor Skarvada, libor@informatics.muni.cz"
102   */
103  
104 +#ifdef HAVE_CONFIG_H
105 +#include "config.h"
106 +#endif
107  
108  #include "gdfontg.h"
109  
110 diff -rub gd-2.0.33/gdfontl.c gd-2.0.33jce3/gdfontl.c
111 --- gd-2.0.33/gdfontl.c 2004-10-27 10:22:04.000000000 -0400
112 +++ gd-2.0.33jce3/gdfontl.c     2005-08-15 11:23:47.000000000 -0400
113 @@ -11,6 +11,9 @@
114     "Libor Skarvada, libor@informatics.muni.cz"
115   */
116  
117 +#ifdef HAVE_CONFIG_H
118 +#include "config.h"
119 +#endif
120  
121  #include "gdfontl.h"
122  
123 diff -rub gd-2.0.33/gdfontmb.c gd-2.0.33jce3/gdfontmb.c
124 --- gd-2.0.33/gdfontmb.c        2004-10-27 10:22:04.000000000 -0400
125 +++ gd-2.0.33jce3/gdfontmb.c    2005-08-15 11:23:47.000000000 -0400
126 @@ -9,6 +9,9 @@
127     No copyright info was found in the original bdf.
128   */
129  
130 +#ifdef HAVE_CONFIG_H
131 +#include "config.h"
132 +#endif
133  
134  #include "gdfontmb.h"
135  
136 diff -rub gd-2.0.33/gdfonts.c gd-2.0.33jce3/gdfonts.c
137 --- gd-2.0.33/gdfonts.c 2004-10-27 10:22:04.000000000 -0400
138 +++ gd-2.0.33jce3/gdfonts.c     2005-08-15 11:23:47.000000000 -0400
139 @@ -7,6 +7,9 @@
140     No copyright info was found in the original bdf.
141   */
142  
143 +#ifdef HAVE_CONFIG_H
144 +#include "config.h"
145 +#endif
146  
147  #include "gdfonts.h"
148  
149 diff -rub gd-2.0.33/gdfontt.c gd-2.0.33jce3/gdfontt.c
150 --- gd-2.0.33/gdfontt.c 2004-10-27 10:22:04.000000000 -0400
151 +++ gd-2.0.33jce3/gdfontt.c     2005-08-15 11:23:47.000000000 -0400
152 @@ -10,6 +10,9 @@
153     "Libor Skarvada, libor@informatics.muni.cz"
154   */
155  
156 +#ifdef HAVE_CONFIG_H
157 +#include "config.h"
158 +#endif
159  
160  #include "gdfontt.h"
161  
162 diff -rub gd-2.0.33/gdft.c gd-2.0.33jce3/gdft.c
163 --- gd-2.0.33/gdft.c    2004-11-02 16:00:48.000000000 -0500
164 +++ gd-2.0.33jce3/gdft.c        2005-08-15 11:23:47.000000000 -0400
165 @@ -832,7 +832,7 @@
166    FT_Matrix matrix;
167    FT_Vector penf, oldpenf, delta, total_min = {0,0}, total_max = {0,0}, glyph_min, glyph_max;
168    FT_Face face;
169 -  FT_CharMap charmap;
170 +  FT_CharMap charmap = NULL;
171    FT_Glyph image;
172    FT_GlyphSlot slot;
173    FT_Error err;
174 @@ -966,8 +966,10 @@
175          }
176      }
177  
178 +#if 0
179    if (fg < 0)
180        render_mode |= FT_LOAD_MONOCHROME;
181 +#endif
182  
183    /* find requested charmap */
184    encodingfound = 0;
185 @@ -1208,12 +1210,14 @@
186                 so we don't have to recheck for the terminating number */
187           if (! xshow_alloc) {
188                 xshow_alloc = 100;
189 -               strex->xshow = malloc(xshow_alloc);
190 +               strex->xshow = gdMalloc(xshow_alloc);
191                 xshow_pos = 0;
192           } 
193           else if (xshow_pos + 20 > xshow_alloc) {
194                 xshow_alloc += 100;
195                 strex->xshow = realloc(strex->xshow, xshow_alloc);
196 +               if (! strex->xshow)
197 +                   return "Problem allocating memory with realloc";
198         }
199           xshow_pos += sprintf(strex->xshow + xshow_pos, "%g ",
200                 (double)(penf.x - oldpenf.x) * hdpi / (64 * METRIC_RES));
201 @@ -1322,10 +1326,8 @@
202  
203    if (brect)
204      {                          /* only if need brect */
205 -      double dpix, dpiy;
206 -      
207 -      dpix = 64 * METRIC_RES / hdpi;
208 -      dpiy = 64 * METRIC_RES / vdpi;
209 +      double scalex = (double)hdpi / (64 * METRIC_RES);
210 +      double scaley = (double)vdpi / (64 * METRIC_RES);
211  
212        /* increase by 1 pixel to allow for rounding */
213        total_min.x -= METRIC_RES;
214 @@ -1334,14 +1336,14 @@
215        total_max.y += METRIC_RES;
216   
217        /* rotate bounding rectangle, scale and round to int pixels, and translate */
218 -      brect[0] = x + (total_min.x * cos_a + total_max.y * sin_a)/dpix;
219 -      brect[1] = y - (total_min.x * sin_a - total_max.y * cos_a)/dpiy;
220 -      brect[2] = x + (total_max.x * cos_a + total_max.y * sin_a)/dpix;
221 -      brect[3] = y - (total_max.x * sin_a - total_max.y * cos_a)/dpiy;
222 -      brect[4] = x + (total_max.x * cos_a + total_min.y * sin_a)/dpix;
223 -      brect[5] = y - (total_max.x * sin_a - total_min.y * cos_a)/dpiy;
224 -      brect[6] = x + (total_min.x * cos_a + total_min.y * sin_a)/dpix;
225 -      brect[7] = y - (total_min.x * sin_a - total_min.y * cos_a)/dpiy;
226 +      brect[0] = x + (total_min.x * cos_a + total_max.y * sin_a)*scalex;
227 +      brect[1] = y - (total_min.x * sin_a - total_max.y * cos_a)*scaley;
228 +      brect[2] = x + (total_max.x * cos_a + total_max.y * sin_a)*scalex;
229 +      brect[3] = y - (total_max.x * sin_a - total_max.y * cos_a)*scaley;
230 +      brect[4] = x + (total_max.x * cos_a + total_min.y * sin_a)*scalex;
231 +      brect[5] = y - (total_max.x * sin_a - total_min.y * cos_a)*scaley;
232 +      brect[6] = x + (total_min.x * cos_a + total_min.y * sin_a)*scalex;
233 +      brect[7] = y - (total_min.x * sin_a - total_min.y * cos_a)*scaley;
234      }
235  
236    FT_Done_Size (platform_independent);
237 @@ -1510,6 +1512,66 @@
238  
239  #endif /* HAVE_LIBFONTCONFIG */
240  
241 +#ifdef WIN32
242 +#define FONTSFX "\\FONTS"
243 +#define GDP     "GDFONTPATH="
244 +#define F_OK 0                 /* Needed in Windows */
245 +
246 +/* chkWinFontPath:
247 + * See if environment variable envv is defined and
248 + * if the path $envv/FONTS exists. If so, return the path,
249 + * else return NULL.
250 + */
251 +static char*
252 +chkWinFontPath (char* envv)
253 +{
254 +       char* root;
255 +       char* path;
256 +       root = getenv(envv);
257 +       if (!root) return NULL;
258 +       path = (char*)gdMalloc(strlen(root)+strlen(FONTSFX)+1);
259 +       strcpy (path, root);
260 +       strcat (path, FONTSFX);
261 +       if (access (path, F_OK) == 0) { /* success */
262 +               return path;
263 +       }
264 +       else {
265 +               gdFree (path);
266 +               return NULL;
267 +       }
268 +}
269 +
270 +/* getWinFontPath:
271 + * Find Windows system font directory. Use environment variables to
272 + * find system directory with a FONTS subdirectory.
273 + * If successful, set GDFONTPATH to this value, for caching, and return it.
274 + * Else, return NULL
275 + */
276 +static char*
277 +getWinFontPath ()
278 +{
279 +       char* path = chkWinFontPath("SystemRoot");
280 +       if (!path) {
281 +               path = chkWinFontPath ("WinDir");
282 +               if (!path)
283 +                       return NULL;
284 +       }
285 +#ifdef HAVE_SETENV
286 +       setenv("GDFONTPATH", path, 1);
287 +#else
288 +       {
289 +               char* ebuf = (char*)gdMalloc(strlen(GDP)+strlen(path)+1);
290 +               int rv;
291 +               strcpy(ebuf,GDP);
292 +               strcat(ebuf,path);
293 +               rv = putenv(ebuf);
294 +       }
295 +#endif
296 +       return path;
297 +}
298 +
299 +#endif  /* WIN32 */
300 +
301  /* Look up font using font names as file names. */
302  static char * font_path(char **fontpath, char *name_list)
303  {
304 @@ -1524,6 +1586,10 @@
305     */
306    *fontpath = NULL;
307    fontsearchpath = getenv ("GDFONTPATH");
308 +#ifdef WIN32
309 +  if (!fontsearchpath)
310 +    fontsearchpath = getWinFontPath ();
311 +#endif
312    if (!fontsearchpath)
313      fontsearchpath = DEFAULT_FONTPATH;
314    fontlist = strdup (name_list);
315 diff -rub gd-2.0.33/gdfx.c gd-2.0.33jce3/gdfx.c
316 --- gd-2.0.33/gdfx.c    2004-10-27 10:22:07.000000000 -0400
317 +++ gd-2.0.33jce3/gdfx.c        2005-08-15 11:23:47.000000000 -0400
318 @@ -1,3 +1,7 @@
319 +#ifdef HAVE_CONFIG_H
320 +#include "config.h"
321 +#endif
322 +
323  #include "gd.h"
324  #include <math.h>
325  
326 diff -rub gd-2.0.33/gdhelpers.h gd-2.0.33jce3/gdhelpers.h
327 --- gd-2.0.33/gdhelpers.h       2004-10-28 13:09:12.000000000 -0400
328 +++ gd-2.0.33jce3/gdhelpers.h   2005-08-15 11:23:47.000000000 -0400
329 @@ -29,30 +29,38 @@
330  
331  /* 2.0.16: portable mutex support for thread safety. */
332  
333 -#ifdef WIN32
334 -/* 2.0.18: must include windows.h to get CRITICAL_SECTION. */
335 -#include <windows.h>
336 -#define gdMutexDeclare(x) CRITICAL_SECTION x
337 -#define gdMutexSetup(x) InitializeCriticalSection(&x)
338 -#define gdMutexShutdown(x) DeleteCriticalSection(&x)
339 -#define gdMutexLock(x) EnterCriticalSection(&x)
340 -#define gdMutexUnlock(x) LeaveCriticalSection(&x)
341 -#else
342 -#ifdef HAVE_PTHREAD
343 -#include <pthread.h>
344 -#define gdMutexDeclare(x) pthread_mutex_t x
345 -#define gdMutexSetup(x) pthread_mutex_init(&x, 0)
346 -#define gdMutexShutdown(x) pthread_mutex_destroy(&x)
347 -#define gdMutexLock(x) pthread_mutex_lock(&x)
348 -#define gdMutexUnlock(x) pthread_mutex_unlock(&x)
349 +#ifdef DISABLE_THREADS
350 +#  define gdMutexDeclare(x)
351 +#  define gdMutexSetup(x)
352 +#  define gdMutexShutdown(x)
353 +#  define gdMutexLock(x)
354 +#  define gdMutexUnlock(x)
355  #else
356 -#define gdMutexDeclare(x)
357 -#define gdMutexSetup(x) 
358 -#define gdMutexShutdown(x) 
359 -#define gdMutexLock(x) 
360 -#define gdMutexUnlock(x) 
361 -#endif /* HAVE_PTHREAD */
362 -#endif /* WIN32 */
363 +#  ifdef WIN32
364 +/* 2.0.18: must include windows.h to get CRITICAL_SECTION. */
365 +#    include <windows.h>
366 +#    define gdMutexDeclare(x) CRITICAL_SECTION x
367 +#    define gdMutexSetup(x) InitializeCriticalSection(&x)
368 +#    define gdMutexShutdown(x) DeleteCriticalSection(&x)
369 +#    define gdMutexLock(x) EnterCriticalSection(&x)
370 +#    define gdMutexUnlock(x) LeaveCriticalSection(&x)
371 +#  else
372 +#    ifdef HAVE_PTHREAD
373 +#      include <pthread.h>
374 +#      define gdMutexDeclare(x) pthread_mutex_t x
375 +#      define gdMutexSetup(x) pthread_mutex_init(&x, 0)
376 +#      define gdMutexShutdown(x) pthread_mutex_destroy(&x)
377 +#      define gdMutexLock(x) pthread_mutex_lock(&x)
378 +#      define gdMutexUnlock(x) pthread_mutex_unlock(&x)
379 +#    else
380 +#      define gdMutexDeclare(x)
381 +#      define gdMutexSetup(x) 
382 +#      define gdMutexShutdown(x) 
383 +#      define gdMutexLock(x) 
384 +#      define gdMutexUnlock(x) 
385 +#    endif /* HAVE_PTHREAD */
386 +#  endif /* WIN32 */
387 +#endif /* DISABLE_THREADS */
388  
389  #endif /* GDHELPERS_H */
390  
This page took 0.161804 seconds and 3 git commands to generate.