[cairo-commit] libsvg/src svg_parser.c, 1.34, 1.35 svg_style.c, 1.20, 1.21 svg_text.c, 1.12, 1.13

Carl Worth commit at pdx.freedesktop.org
Thu Apr 21 12:29:21 PDT 2005


Committed by: cworth

Update of /cvs/cairo/libsvg/src
In directory gabe:/tmp/cvs-serv31644/src

Modified Files:
	svg_parser.c svg_style.c svg_text.c 
Log Message:

        * src/svg_parser.c: (_svg_parser_parse_gradient_stop): Use
        symbolic value.

        * src/svg_style.c: (_svg_style_init_empty): Add missing
        initialization for style->num_dashes.

        * src/svg_style.c (_svg_style_init_copy): Fix to actually copy
        memory for style->font_family and style->stroke_dash_array.

        * src/svg_text.c: (_svg_text_init_copy): Fix zero termination of
        text->chars.


Index: svg_parser.c
===================================================================
RCS file: /cvs/cairo/libsvg/src/svg_parser.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- svg_parser.c	11 Apr 2005 16:20:09 -0000	1.34
+++ svg_parser.c	21 Apr 2005 19:29:19 -0000	1.35
@@ -725,7 +725,7 @@
 
     /* XXX: This ad-hoc style parsing breaks inheritance I believe. */
     _svg_style_init_empty (&style, parser->svg);
-    style.flags = 0;
+    style.flags = SVG_STYLE_FLAG_NONE;
     _svg_style_apply_attributes (&style, attributes);
     color = style.color;
     opacity = style.opacity;

Index: svg_style.c
===================================================================
RCS file: /cvs/cairo/libsvg/src/svg_style.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- svg_style.c	11 Apr 2005 16:20:09 -0000	1.20
+++ svg_style.c	21 Apr 2005 19:29:19 -0000	1.21
@@ -166,6 +166,7 @@
     style->flags = SVG_STYLE_FLAG_NONE;
     style->font_family = NULL;
     _svg_length_init_from_str (&style->font_size, "10px");
+    style->num_dashes = 0;
     style->stroke_dash_array = NULL;
     style->stroke_dash_offset.value = 0;
 
@@ -182,7 +183,49 @@
 svg_status_t
 _svg_style_init_copy (svg_style_t *style, svg_style_t *other)
 {
-	*style = *other;
+    style->svg = other->svg;
+
+    style->flags = other->flags;
+
+    style->fill_opacity = other->fill_opacity;
+    style->fill_paint = other->fill_paint;
+    style->fill_rule = other->fill_rule;
+
+    if (other->font_family) {
+	style->font_family = strdup (other->font_family);
+	if (style->font_family == NULL)
+	    return SVG_STATUS_NO_MEMORY;
+    } else {
+	style->font_family = NULL;
+    }
+
+    style->font_size = other->font_size;
+    style->font_style = other->font_style;
+    style->font_weight = other->font_weight;
+
+    style->opacity = other->opacity;
+
+    style->num_dashes = other->num_dashes;
+    if (style->num_dashes) {
+	style->stroke_dash_array = malloc (style->num_dashes * sizeof (double));
+	if (style->stroke_dash_array == NULL)
+	    return SVG_STATUS_NO_MEMORY;
+	memcpy (style->stroke_dash_array, other->stroke_dash_array,
+		style->num_dashes * sizeof (double));
+    } else {
+	style->stroke_dash_array = NULL;
+    }
+    style->stroke_dash_offset = other->stroke_dash_offset;
+
+    style->stroke_line_cap = other->stroke_line_cap;
+    style->stroke_line_join = other->stroke_line_join;
+    style->stroke_miter_limit = other->stroke_miter_limit;
+    style->stroke_opacity = other->stroke_opacity;
+    style->stroke_paint = other->stroke_paint;
+    style->stroke_width = other->stroke_width;
+
+    style->color = other->color;
+    style->text_anchor = other->text_anchor;
 
     return SVG_STATUS_SUCCESS;
 }

Index: svg_text.c
===================================================================
RCS file: /cvs/cairo/libsvg/src/svg_text.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- svg_text.c	21 Apr 2005 17:58:21 -0000	1.12
+++ svg_text.c	21 Apr 2005 19:29:19 -0000	1.13
@@ -39,10 +39,19 @@
 _svg_text_init_copy (svg_text_t *text,
 		     svg_text_t *other)
 {
-    *text = *other;
-    text->chars = strdup (other->chars);
-    if (text->chars == NULL)
-	return SVG_STATUS_NO_MEMORY;
+    text->x = other->x;
+    text->y = other->y;
+
+    text->len = other->len;
+    if (text->len) {
+	text->chars = malloc (text->len + 1);
+	if (text->chars == NULL)
+	    return SVG_STATUS_NO_MEMORY;
+	memcpy (text->chars, other->chars, text->len);
+	text->chars[text->len] = '\0';
+    } else {
+	text->chars = NULL;
+    }
 
     return SVG_STATUS_SUCCESS;
 }




More information about the cairo-commit mailing list