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);
dom_node_unref(document);
cleanup:
+ if (state.gradient_x1 != NULL)
+ dom_string_unref(state.gradient_x1);
+ if (state.gradient_x2 != NULL)
+ dom_string_unref(state.gradient_x2);
+ if (state.gradient_y1 != NULL)
+ dom_string_unref(state.gradient_y1);
+ if (state.gradient_y2 != NULL)
+ dom_string_unref(state.gradient_y2);
#define SVGTINY_STRING_ACTION2(s,n) \
if (state.interned_##s != NULL) \
dom_string_unref(state.interned_##s);
-//#include "svgtiny_strings.h"
+#include "svgtiny_strings.h"
#undef SVGTINY_STRING_ACTION2
return code;
}
if (view_box) {
char *s = strndup(dom_string_data(view_box),
- dom_string_length(view_box));
+ dom_string_byte_length(view_box));
float min_x, min_y, vwidth, vheight;
if (sscanf(s, "%f,%f,%f,%f",
&min_x, &min_y, &vwidth, &vheight) == 4 ||
svgtiny_parse_transform_attributes(svg, &state);
- exc = dom_node_get_first_child(svg, &child);
+ exc = dom_node_get_first_child(svg, (dom_node **) (void *) &child);
if (exc != DOM_NO_ERR) {
return svgtiny_LIBDOM_ERROR;
}
dom_node_unref(child);
return code;
}
- exc = dom_node_get_next_sibling(child, &next);
+ exc = dom_node_get_next_sibling(child,
+ (dom_node **) (void *) &next);
dom_node_unref(child);
if (exc != DOM_NO_ERR) {
return svgtiny_LIBDOM_ERROR;
}
s = path_d = strndup(dom_string_data(path_d_str),
- dom_string_length(path_d_str));
+ dom_string_byte_length(path_d_str));
dom_string_unref(path_d_str);
if (s == NULL) {
return svgtiny_OUT_OF_MEMORY;
}
s = points = strndup(dom_string_data(points_str),
- dom_string_length(points_str));
+ dom_string_byte_length(points_str));
dom_string_unref(points_str);
/* read points attribute */
if (s == NULL)
dom_node_unref(child);
return svgtiny_LIBDOM_ERROR;
}
- shape->text = strndup(dom_string_data(content),
- dom_string_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++;
* 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)
{
float svgtiny_parse_length(dom_string *s, int viewport_size,
const struct svgtiny_parse_state state)
{
- char *ss = strndup(dom_string_data(s), dom_string_length(s));
+ char *ss = strndup(dom_string_data(s), dom_string_byte_length(s));
float ret = _svgtiny_parse_length(ss, viewport_size, state);
free(ss);
return ret;
* 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;
exc = dom_element_get_attribute(node, state->interned_style, &attr);
if (exc == DOM_NO_ERR && attr != NULL) {
char *style = strndup(dom_string_data(attr),
- dom_string_length(attr));
+ dom_string_byte_length(attr));
const char *s;
char *value;
if ((s = strstr(style, "fill:"))) {
void svgtiny_parse_color(dom_string *s, svgtiny_colour *c,
struct svgtiny_parse_state *state)
{
- char *ss = strndup(dom_string_data(s), dom_string_length(s));
+ char *ss = strndup(dom_string_data(s), dom_string_byte_length(s));
_svgtiny_parse_color(ss, c, state);
free(ss);
}
* 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 */
&attr);
if (exc == DOM_NO_ERR && attr != NULL) {
transform = strndup(dom_string_data(attr),
- dom_string_length(attr));
+ dom_string_byte_length(attr));
svgtiny_parse_transform(transform, &state->ctm.a, &state->ctm.b,
&state->ctm.c, &state->ctm.d,
&state->ctm.e, &state->ctm.f);