]> gitweb.michael.orlitzky.com - libsvgtiny.git/blobdiff - src/svgtiny.c
add a .gitattributes so .gitignore is not exported
[libsvgtiny.git] / src / svgtiny.c
index 137f2b065d9afed42440342a3c24d781e8bcf112..0bcfe7daf94412c899f04b082062680553e67549 100644 (file)
@@ -42,12 +42,12 @@ static svgtiny_code svgtiny_parse_poly(dom_element *poly,
                struct svgtiny_parse_state state, bool polygon);
 static svgtiny_code svgtiny_parse_text(dom_element *text,
                struct svgtiny_parse_state state);
-static void svgtiny_parse_position_attributes(const dom_element *node,
+static void svgtiny_parse_position_attributes(dom_element *node,
                const struct svgtiny_parse_state state,
                float *x, float *y, float *width, float *height);
-static void svgtiny_parse_paint_attributes(const dom_element *node,
+static void svgtiny_parse_paint_attributes(dom_element *node,
                struct svgtiny_parse_state *state);
-static void svgtiny_parse_font_attributes(const dom_element *node,
+static void svgtiny_parse_font_attributes(dom_element *node,
                struct svgtiny_parse_state *state);
 static void svgtiny_parse_transform_attributes(dom_element *node,
                struct svgtiny_parse_state *state);
@@ -1008,9 +1008,13 @@ svgtiny_code svgtiny_parse_text(dom_element *text,
                                dom_node_unref(child);
                                return svgtiny_LIBDOM_ERROR;
                        }
-                       shape->text = strndup(dom_string_data(content),
-                                             dom_string_byte_length(content));
-                       dom_string_unref(content);
+                       if (content != NULL) {
+                               shape->text = strndup(dom_string_data(content),
+                                                     dom_string_byte_length(content));
+                               dom_string_unref(content);
+                       } else {
+                               shape->text = strdup("");
+                       }
                        shape->text_x = px;
                        shape->text_y = py;
                        state.diagram->shape_count++;
@@ -1035,7 +1039,7 @@ svgtiny_code svgtiny_parse_text(dom_element *text,
  * Parse x, y, width, and height attributes, if present.
  */
 
-void svgtiny_parse_position_attributes(const dom_element *node,
+void svgtiny_parse_position_attributes(dom_element *node,
                const struct svgtiny_parse_state state,
                float *x, float *y, float *width, float *height)
 {
@@ -1127,7 +1131,7 @@ float svgtiny_parse_length(dom_string *s, int viewport_size,
  * Parse paint attributes, if present.
  */
 
-void svgtiny_parse_paint_attributes(const dom_element *node,
+void svgtiny_parse_paint_attributes(dom_element *node,
                struct svgtiny_parse_state *state)
 {
        dom_string *attr;
@@ -1264,7 +1268,7 @@ void svgtiny_parse_color(dom_string *s, svgtiny_colour *c,
  * Parse font attributes, if present.
  */
 
-void svgtiny_parse_font_attributes(const dom_element *node,
+void svgtiny_parse_font_attributes(dom_element *node,
                struct svgtiny_parse_state *state)
 {
        /* TODO: Implement this, it never used to be */