[cairo-commit] libsvg/src svg_parser.c, 1.36, 1.37 svg_text.c, 1.16, 1.17 svgint.h, 1.48, 1.49

Keith Packard commit at pdx.freedesktop.org
Thu Dec 1 10:29:49 PST 2005


Committed by: keithp

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

Modified Files:
	svg_parser.c svg_text.c svgint.h 
Log Message:
2005-12-01  Keith Packard  <keithp at keithp.com>

	* src/svg_parser.c: (_svg_parser_sax_start_element),
	(_svg_parser_parse_text), (_svg_parser_parse_tspan),
	(_svg_parser_parse_text_characters):
	Some file elements don't create data structures. Don't attempt to
	apply attributes through the resulting uninitialized pointer.
	* src/svg_text.c: (_svg_tspan_init):
	* src/svgint.h:
	Strip characters from <text> elements which have embedded <tspan>
	elements.


Index: svg_parser.c
===================================================================
RCS file: /cvs/cairo/libsvg/src/svg_parser.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- svg_parser.c	18 Jul 2005 21:55:06 -0000	1.36
+++ svg_parser.c	1 Dec 2005 18:29:47 -0000	1.37
@@ -222,6 +222,7 @@
     if (parser->status)
 	return;
 
+    element = NULL;
     parser->status = (cb->parse_element) (parser, attributes, &element);
     if (parser->status) {
 	if (parser->status == SVGINT_STATUS_UNKNOWN_ELEMENT)
@@ -229,12 +230,15 @@
 	return;
     }
 
-    parser->status = _svg_element_apply_attributes (element, attributes);
-    if (parser->status)
-	return;
-
-    if (element->id)
-	_svg_store_element_by_id (parser->svg, element);
+    if (element)
+    {
+	parser->status = _svg_element_apply_attributes (element, attributes);
+	if (parser->status)
+	    return;
+    
+	if (element->id)
+	    _svg_store_element_by_id (parser->svg, element);
+    }
 
     return;
 }
@@ -646,6 +650,7 @@
 	return status;
 
     parser->state->text = &(*text_element)->e.text;
+    parser->state->tspan = NULL;
 
     return SVG_STATUS_SUCCESS;
 }
@@ -657,11 +662,22 @@
 {
     svg_status_t status;
     svg_text_t *text;
+    svg_tspan_t *tspan;
 
     text = parser->state->text;
     if (text == NULL)
 	return SVG_STATUS_PARSE_ERROR;
 
+    tspan = parser->state->tspan;
+    
+    if (tspan && tspan->from_text) 
+    {
+	if (tspan->chars)
+	    free (tspan->chars);
+	_svg_tspan_init (tspan);
+	return SVG_STATUS_SUCCESS;
+    }
+	
     status = _svg_parser_new_leaf_element (parser,
 					   tspan_element,
 					   SVG_ELEMENT_TYPE_TSPAN);
@@ -816,10 +832,15 @@
     if (text == NULL)
 	return SVG_STATUS_PARSE_ERROR;
 
+    if (parser->state->tspan)
+	return SVG_STATUS_SUCCESS;
+
     status = _svg_parser_parse_tspan (parser, NULL, &tspan);
     if (status)
 	return status;
     
+    tspan->e.tspan.from_text = 1;
+    
     status = _svg_parser_parse_tspan_characters (parser, ch, len);
     if (status)
 	return status;

Index: svg_text.c
===================================================================
RCS file: /cvs/cairo/libsvg/src/svg_text.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- svg_text.c	19 Jul 2005 16:56:00 -0000	1.16
+++ svg_text.c	1 Dec 2005 18:29:47 -0000	1.17
@@ -29,6 +29,7 @@
 {
     tspan->chars = NULL;
     tspan->len = 0;
+    tspan->from_text = 0;
     return SVG_STATUS_SUCCESS;
 }
 

Index: svgint.h
===================================================================
RCS file: /cvs/cairo/libsvg/src/svgint.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- svgint.h	19 Jul 2005 16:56:00 -0000	1.48
+++ svgint.h	1 Dec 2005 18:29:47 -0000	1.49
@@ -237,6 +237,7 @@
 typedef struct svg_tspan {
     char *chars;
     unsigned int len;
+    int from_text;
 } svg_tspan_t;
 
 typedef struct svg_text {



More information about the cairo-commit mailing list