fix invalid superflous #endif from 5bd2890a56125d391b42f34d51e2e0c57b0a80b0
[LibreOffice.git] / librsvg / librsvg-2.32.1-win32.patch
blob0bdf11d571841f8dc16f821203f1cc0081aeb35d
1 --- misc/librsvg-2.32.1/librsvg-features.h 2010-11-13 11:52:49.000000000 +0100
2 +++ misc/build/librsvg-2.32.1/librsvg-features.h 2011-03-28 16:29:01.357827800 +0200
3 @@ -11,7 +11,7 @@
4 (LIBRSVG_MAJOR_VERSION == (major) && LIBRSVG_MINOR_VERSION > (minor)) || \
5 (LIBRSVG_MAJOR_VERSION == (major) && LIBRSVG_MINOR_VERSION == (minor) && LIBRSVG_MICRO_VERSION >= (micro)))
7 -#define LIBRSVG_HAVE_SVGZ (1)
8 +#define LIBRSVG_HAVE_SVGZ (0)
9 #define LIBRSVG_HAVE_CSS (1)
11 #define LIBRSVG_CHECK_FEATURE(FEATURE) (defined(LIBRSVG_HAVE_##FEATURE) && LIBRSVG_HAVE_##FEATURE)
12 --- misc/librsvg-2.32.1/rsvg-image.c 2010-09-27 19:18:35.000000000 +0200
13 +++ misc/build/librsvg-2.32.1/rsvg-image.c 2011-03-28 20:14:53.630005800 +0200
14 @@ -22,8 +22,8 @@
15 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA.
18 - Authors: Raph Levien <raph@artofcode.com>,
19 - Dom Lachowicz <cinamod@hotmail.com>,
20 + Authors: Raph Levien <raph@artofcode.com>,
21 + Dom Lachowicz <cinamod@hotmail.com>,
22 Caleb Moore <c.moore@student.unsw.edu.au>
25 @@ -34,15 +34,167 @@
26 #include <math.h>
27 #include <errno.h>
28 #include "rsvg-css.h"
29 +#ifdef HAVE_GIO
30 #include <gio/gio.h>
31 +#endif
33 +static const char s_UTF8_B64Alphabet[64] = {
34 + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
35 + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, /* A-Z */
36 + 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
37 + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, /* a-z */
38 + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, /* 0-9 */
39 + 0x2b, /* + */
40 + 0x2f /* / */
41 +};
42 +static const char utf8_b64_pad = 0x3d;
44 +static gboolean
45 +b64_decode_char (char c, int *b64)
47 + if ((c >= 0x41) && (c <= 0x5a)) {
48 + *b64 = c - 0x41;
49 + return TRUE;
50 + }
51 + if ((c >= 0x61) && (c <= 0x7a)) {
52 + *b64 = c - (0x61 - 26);
53 + return TRUE;
54 + }
55 + if ((c >= 0x30) && (c <= 0x39)) {
56 + *b64 = c + (52 - 0x30);
57 + return TRUE;
58 + }
59 + if (c == 0x2b) {
60 + *b64 = 62;
61 + return TRUE;
62 + }
63 + if (c == 0x2f) {
64 + *b64 = 63;
65 + return TRUE;
66 + }
67 + return FALSE;
70 +static gboolean
71 +utf8_base64_decode (guchar ** binptr, size_t * binlen, const char *b64ptr, size_t b64len)
73 + gboolean decoded = TRUE;
74 + gboolean padding = FALSE;
76 + int i = 0;
77 + glong ucs4_len, j;
79 + unsigned char byte1 = 0;
80 + unsigned char byte2;
82 + gunichar ucs4, *ucs4_str;
84 + if (b64len == 0)
85 + return TRUE;
87 + if ((binptr == 0) || (b64ptr == 0))
88 + return FALSE;
90 + ucs4_str = g_utf8_to_ucs4_fast (b64ptr, b64len, &ucs4_len);
92 + for (j = 0; j < ucs4_len; j++) {
93 + ucs4 = ucs4_str[j];
94 + if ((ucs4 & 0x7f) == ucs4) {
95 + int b64;
96 + char c = (char) (ucs4);
98 + if (b64_decode_char (c, &b64)) {
99 + if (padding || (*binlen == 0)) {
100 + decoded = FALSE;
101 + break;
104 + switch (i) {
105 + case 0:
106 + byte1 = (unsigned char) (b64) << 2;
107 + i++;
108 + break;
109 + case 1:
110 + byte2 = (unsigned char) (b64);
111 + byte1 |= byte2 >> 4;
112 + *(*binptr)++ = (char) (byte1);
113 + (*binlen)--;
114 + byte1 = (byte2 & 0x0f) << 4;
115 + i++;
116 + break;
117 + case 2:
118 + byte2 = (unsigned char) (b64);
119 + byte1 |= byte2 >> 2;
120 + *(*binptr)++ = (char) (byte1);
121 + (*binlen)--;
122 + byte1 = (byte2 & 0x03) << 6;
123 + i++;
124 + break;
125 + default:
126 + byte1 |= (unsigned char) (b64);
127 + *(*binptr)++ = (char) (byte1);
128 + (*binlen)--;
129 + i = 0;
130 + break;
133 + if (!decoded)
134 + break;
136 + continue;
137 + } else if (c == utf8_b64_pad) {
138 + switch (i) {
139 + case 0:
140 + case 1:
141 + decoded = FALSE;
142 + break;
143 + case 2:
144 + if (*binlen == 0)
145 + decoded = FALSE;
146 + else {
147 + *(*binptr)++ = (char) (byte1);
148 + (*binlen)--;
149 + padding = TRUE;
151 + i++;
152 + break;
153 + default:
154 + if (!padding) {
155 + if (*binlen == 0)
156 + decoded = FALSE;
157 + else {
158 + *(*binptr)++ = (char) (byte1);
159 + (*binlen)--;
160 + padding = TRUE;
163 + i = 0;
164 + break;
166 + if (!decoded)
167 + break;
169 + continue;
172 + if (g_unichar_isspace (ucs4))
173 + continue;
175 + decoded = FALSE;
176 + break;
179 + g_free (ucs4_str);
180 + return decoded;
183 static GByteArray *
184 rsvg_acquire_base64_resource (const char *data, GError ** error)
186 - GByteArray *array = NULL;
187 - gsize data_len, written_len;
188 - int state = 0;
189 - guint save = 0;
190 + GByteArray *array;
192 + guchar *bufptr;
193 + size_t buffer_len, buffer_max_len, data_len;
195 rsvg_return_val_if_fail (data != NULL, NULL, error);
197 @@ -51,10 +203,19 @@
198 break;
200 data_len = strlen (data);
201 - array = g_byte_array_sized_new (data_len / 4 * 3);
202 - written_len = g_base64_decode_step (data, data_len, array->data,
203 - &state, &save);
204 - g_byte_array_set_size (array, written_len);
206 + buffer_max_len = ((data_len >> 2) + 1) * 3;
207 + buffer_len = buffer_max_len;
209 + array = g_byte_array_sized_new (buffer_max_len);
210 + bufptr = array->data;
212 + if (!utf8_base64_decode (&bufptr, &buffer_len, data, data_len)) {
213 + g_byte_array_free (array, TRUE);
214 + return NULL;
217 + array->len = buffer_max_len - buffer_len;
219 return array;
221 @@ -75,7 +236,7 @@
222 if (base_filename != NULL) {
223 tmpcdir = g_path_get_dirname (base_filename);
224 g_free (base_filename);
225 - } else
226 + } else
227 return NULL;
228 } else
229 tmpcdir = g_get_current_dir ();
230 @@ -92,8 +253,10 @@
232 GByteArray *array;
233 gchar *path;
234 - gchar *data = NULL;
235 - gsize length;
237 + guchar buffer[4096];
238 + int length;
239 + FILE *f;
241 rsvg_return_val_if_fail (filename != NULL, NULL, error);
243 @@ -101,20 +264,53 @@
244 if (path == NULL)
245 return NULL;
247 - if (!g_file_get_contents (path, &data, &length, error)) {
248 - g_free (path);
249 + f = fopen (path, "rb");
250 + g_free (path);
252 + if (!f) {
253 + g_set_error (error,
254 + G_FILE_ERROR,
255 + g_file_error_from_errno (errno),
256 + _("Failed to open file '%s': %s"), filename, g_strerror (errno));
257 return NULL;
260 + /* TODO: an optimization is to use the file's size */
261 array = g_byte_array_new ();
263 - g_byte_array_append (array, (guint8 *)data, length);
264 - g_free (data);
265 - g_free (path);
266 + while (!feof (f)) {
267 + length = fread (buffer, 1, sizeof (buffer), f);
268 + if (length > 0) {
269 + if (g_byte_array_append (array, buffer, length) == NULL) {
270 + fclose (f);
271 + g_byte_array_free (array, TRUE);
272 + return NULL;
274 + } else if (ferror (f)) {
275 + fclose (f);
276 + g_byte_array_free (array, TRUE);
277 + return NULL;
281 + fclose (f);
283 return array;
286 +#ifdef HAVE_GIO
288 +static void
289 +rsvg_free_error (GError ** err)
291 + if (err) {
292 + if (*err) {
293 + g_error_free (*err);
294 + *err = NULL;
299 static GByteArray *
300 rsvg_acquire_vfs_resource (const char *filename, const char *base_uri, GError ** error)
302 @@ -133,19 +329,19 @@
303 if (base_uri != NULL) {
304 GFile *base;
306 - g_clear_error (error);
308 - g_object_unref (file);
309 + rsvg_free_error(error);
311 + g_object_unref (file);
313 base = g_file_new_for_uri (base_uri);
314 file = g_file_resolve_relative_path (base, filename);
315 g_object_unref (base);
317 - res = g_file_load_contents (file, NULL, &data, &size, NULL, error);
318 + res = g_file_load_contents (file, NULL, &data, &size, NULL, error);
322 - g_object_unref (file);
323 + g_object_unref (file);
325 if (res) {
326 array = g_byte_array_new ();
327 @@ -158,6 +354,7 @@
329 return array;
331 +#endif
333 GByteArray *
334 _rsvg_acquire_xlink_href_resource (const char *href, const char *base_uri, GError ** err)
335 @@ -173,8 +370,10 @@
336 if (!arr)
337 arr = rsvg_acquire_file_resource (href, base_uri, NULL);
339 +#ifdef HAVE_GIO
340 if (!arr)
341 arr = rsvg_acquire_vfs_resource (href, base_uri, NULL);
342 +#endif
344 return arr;
346 @@ -274,10 +473,9 @@
347 RsvgNodeImage *z = (RsvgNodeImage *) self;
348 rsvg_state_finalize (z->super.state);
349 g_free (z->super.state);
350 - z->super.state = NULL;
351 if (z->img)
352 - g_object_unref (z->img);
353 - _rsvg_node_free(self);
354 + g_object_unref (G_OBJECT (z->img));
355 + g_free (z);
358 static void
359 @@ -300,7 +498,7 @@
361 rsvg_push_discrete_layer (ctx);
363 - if (!rsvg_current_state (ctx)->overflow && (aspect_ratio & RSVG_ASPECT_RATIO_SLICE)) {
364 + if (!rsvg_current_state(ctx)->overflow && (aspect_ratio & RSVG_ASPECT_RATIO_SLICE)) {
365 rsvg_add_clipping_rect (ctx, x, y, w, h);
368 @@ -357,10 +555,11 @@
369 RsvgNodeImage *image;
370 image = g_new (RsvgNodeImage, 1);
371 _rsvg_node_init (&image->super);
372 - g_assert (image->super.state);
373 image->img = NULL;
374 image->preserve_aspect_ratio = RSVG_ASPECT_RATIO_XMID_YMID;
375 image->x = image->y = image->w = image->h = _rsvg_css_parse_length ("0");
376 + image->super.state = g_new (RsvgState, 1);
377 + rsvg_state_init (image->super.state);
378 image->super.free = rsvg_node_image_free;
379 image->super.draw = rsvg_node_image_draw;
380 image->super.set_atts = rsvg_node_image_set_atts;
381 --- misc/librsvg-2.32.1/config.h 2011-03-28 20:38:20.301880800 +0200
382 +++ misc/build/librsvg-2.32.1/config.h 2011-03-28 20:40:54.958130800 +0200
383 @@ -1 +1,27 @@
384 -dummy
385 +#define HAVE_FLOAT_H 1
386 +/* #undef ENABLE_XEMBED */
387 +/* #undef HAVE_BASENAME */
388 +/* #undef HAVE_DLFCN_H */
389 +#define HAVE_GIO 1
390 +/* #undef HAVE_INTTYPES_H */
391 +/* #undef HAVE_LC_MESSAGES */
392 +#define HAVE_LOCALE_H 1
393 +#define HAVE_MEMORY_H 1
394 +/* #undef HAVE_STDINT_H */
395 +#define HAVE_STDLIB_H 1
396 +/* #undef HAVE_STRINGS_H */
397 +#define HAVE_STRING_H 1
398 +/* #undef HAVE_STRTOK_R */
399 +#define HAVE_SYS_STAT_H 1
400 +#define HAVE_SYS_TYPES_H 1
401 +/* #undef HAVE_UNISTD_H */
403 +#define PACKAGE "librsvg"
404 +#define PACKAGE_BUGREPORT ""
405 +#define PACKAGE_NAME ""
406 +#define PACKAGE_STRING ""
407 +#define PACKAGE_TARNAME ""
408 +#define PACKAGE_VERSION ""
409 +#define VERSION "2.32.1"
410 +#define STDC_HEADERS 1
411 +#define X_DISPLAY_MISSING 1
412 --- misc/librsvg-2.32.1/makefile.mk 2011-03-28 20:38:20.489380800 +0200
413 +++ misc/build/librsvg-2.32.1/makefile.mk 2011-03-28 20:40:38.786255800 +0200
414 @@ -1 +1,111 @@
415 -dummy
416 +#*************************************************************************
418 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
420 +# Copyright 2000, 2010 Oracle and/or its affiliates.
422 +# OpenOffice.org - a multi-platform office productivity suite
424 +# This file is part of OpenOffice.org.
426 +# OpenOffice.org is free software: you can redistribute it and/or modify
427 +# it under the terms of the GNU Lesser General Public License version 3
428 +# only, as published by the Free Software Foundation.
430 +# OpenOffice.org is distributed in the hope that it will be useful,
431 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
432 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
433 +# GNU Lesser General Public License version 3 for more details
434 +# (a copy is included in the LICENSE file that accompanied this code).
436 +# You should have received a copy of the GNU Lesser General Public License
437 +# version 3 along with OpenOffice.org. If not, see
438 +# <http://www.openoffice.org/license.html>
439 +# for a copy of the LGPLv3 License.
441 +#*************************************************************************
443 +PRJ=..$/..$/..$/..
444 +PRJINC=.
445 +PRJNAME=librsvg
446 +TARGET=librsvg-2-2
448 +VISIBILITY_HIDDEN=TRUE
449 +EXTERNAL_WARNINGS_NOT_ERRORS=TRUE
451 +# --- Settings ----------------------------------
453 +.INCLUDE : settings.mk
455 +CFLAGS+= -DHAVE_GSF -DHAVE_LIBCROCO \
456 + -I. -I$(SOLARINCDIR)$/external/glib-2.0 \
457 + -I. -I$(SOLARINCDIR)$/external/gdk-pixbuf-2.0 \
458 + -I$(SOLARINCDIR)$/external/pango-1.0 \
459 + -I$(SOLARINCDIR)$/external/cairo \
460 + -I$(SOLARINCDIR)$/external/libgsf-1 \
461 + -I$(SOLARINCDIR)$/external/libcroco-0.6
463 +# --- Files -------------------------------------
465 +SLOFILES=\
466 + $(SLO)$/librsvg-enum-types.obj \
467 + $(SLO)$/librsvg-features.obj \
468 + $(SLO)$/rsvg-affine.obj \
469 + $(SLO)$/rsvg-base-file-util.obj \
470 + $(SLO)$/rsvg-base.obj \
471 + $(SLO)$/rsvg-bpath-util.obj \
472 + $(SLO)$/rsvg-cairo-clip.obj \
473 + $(SLO)$/rsvg-cairo-draw.obj \
474 + $(SLO)$/rsvg-cairo-render.obj \
475 + $(SLO)$/rsvg-cond.obj \
476 + $(SLO)$/rsvg-convert.obj \
477 + $(SLO)$/rsvg-css.obj \
478 + $(SLO)$/rsvg-defs.obj \
479 + $(SLO)$/rsvg-file-util.obj \
480 + $(SLO)$/rsvg-filter.obj \
481 + $(SLO)$/rsvg-gobject.obj \
482 + $(SLO)$/rsvg-image.obj \
483 + $(SLO)$/rsvg-marker.obj \
484 + $(SLO)$/rsvg-mask.obj \
485 + $(SLO)$/rsvg-paint-server.obj \
486 + $(SLO)$/rsvg-path.obj \
487 + $(SLO)$/rsvg-shapes.obj \
488 + $(SLO)$/rsvg-structure.obj \
489 + $(SLO)$/rsvg-styles.obj \
490 + $(SLO)$/rsvg-text.obj \
491 + $(SLO)$/rsvg-xml.obj \
492 + $(SLO)$/rsvg.obj
494 +# --- Library -----------------------------------
496 +SHL1TARGET= $(TARGET)
497 +SHL1OBJS=$(SLOFILES)
498 +SHL1STDLIBS=\
499 + intl.lib \
500 + gobject-2.0.lib \
501 + gmodule-2.0.lib \
502 + glib-2.0.lib \
503 + gio-2.0.lib \
504 + gthread-2.0.lib \
505 + gdk_pixbuf-2.0.lib \
506 + cairo.lib \
507 + libxml2.lib \
508 + igsf-1.lib \
509 + libcroco-0.6-3.lib \
510 + pango-1.0.lib \
511 + pangocairo-1.0.lib
513 +SHL1IMPLIB= i$(TARGET)
514 +SHL1DEF= $(MISC)$/$(SHL1TARGET).def
515 +DEF1NAME= $(SHL1TARGET)
516 +DEF1DEPN= $(MISC)$/$(SHL1TARGET).flt $(SLB)$/$(TARGET).lib
517 +DEFLIB1NAME= $(TARGET)
519 +# --- Targets ----------------------------------
521 +.INCLUDE : target.mk
523 +# --- filter file ------------------------------
525 +$(MISC)$/$(SHL1TARGET).flt: makefile.mk
526 + @echo CLEAR_THE_FILE > $@