From 2a67507e7a675c7c516ab207418d3a5c7bfe5989 Mon Sep 17 00:00:00 2001 From: buliabyak Date: Sun, 18 Feb 2007 05:47:11 +0000 Subject: [PATCH] standardize converting from number to string and back --- src/number-opt-number.h | 16 +++++++++------- src/sp-filter.cpp | 5 +++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/number-opt-number.h b/src/number-opt-number.h index ff3b17dfa..51966a101 100644 --- a/src/number-opt-number.h +++ b/src/number-opt-number.h @@ -17,6 +17,7 @@ #include //todo: use glib instead of stdlib #include +#include "svg/stringstream.h" #ifdef HAVE_CONFIG_H #include "config.h" @@ -69,20 +70,22 @@ public: number = num; } - gchar *getValueString(gchar *str) + gchar *getValueString() { + Inkscape::SVGOStringStream os; + if( _set ) { if( optNumber_set ) { - g_sprintf(str, "%lf %lf", number, optNumber); + os << number << " " << optNumber; } else { - g_sprintf(str, "%lf", number); + os << number; } } - return str; + return g_strdup(os.str().c_str()); } void set(gchar const *str) @@ -94,13 +97,12 @@ public: if( values[0] != NULL ) { - sscanf(values[0], "%f", &number); + number = g_ascii_strtod(values[0], NULL); _set = TRUE; if( values[1] != NULL ) { - // optNumber = g_ascii_strtod(values[1], NULL); - sscanf(values[1], "%f", &optNumber); + optNumber = g_ascii_strtod(values[1], NULL); optNumber_set = TRUE; } else diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 66cdf9aa0..c60ffb44f 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -319,8 +319,9 @@ sp_filter_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) } if (filter->filterRes.getNumber()>=0) { - char filterRes[32]; - repr->setAttribute("filterRes", filter->filterRes.getValueString(filterRes)); + gchar *tmp = filter->filterRes.getValueString(); + repr->setAttribute("filterRes", tmp); + g_free(tmp); } else { repr->setAttribute("filterRes", NULL); } -- 2.30.2