From adc17549c5f0485a30a87e7674c7779ef3155d6c Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sat, 12 May 2012 13:16:29 +0200 Subject: syntx of null pointer dereference checks (bzr r11358) --- src/xml/repr-util.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/xml/repr-util.cpp') diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp index 6899e77ee..5b8ab12ae 100644 --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@ -261,8 +261,13 @@ gchar const *sp_xml_ns_uri_prefix(gchar const *uri, gchar const *suggested) GQuark const prefix_key=g_quark_from_string(suggested); SPXMLNs *found=namespaces; - while ( found && found->prefix != prefix_key ) { - found = found->next; + while (found) { + if (found->prefix != prefix_key) { + found = found->next; + } + else { + break; + } } if (found) { // prefix already used? -- cgit v1.2.3 From aca1914d674a5e81234208248e3c8515a60dd19d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 4 Oct 2012 12:30:12 +1000 Subject: code cleanup: make more functions static, add includes. (bzr r11737) --- src/xml/repr-util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xml/repr-util.cpp') diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp index 5b8ab12ae..7e9f9c484 100644 --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@ -75,7 +75,7 @@ static char *sp_xml_ns_auto_prefix(char const *uri); /** * Locale-independent double to string conversion */ -unsigned int sp_xml_dtoa(gchar *buf, double val, unsigned int tprec, unsigned int fprec, unsigned int padf) +static unsigned int sp_xml_dtoa(gchar *buf, double val, unsigned int tprec, unsigned int fprec, unsigned int padf) { double dival, fval, epsilon; int idigits, ival, i; -- cgit v1.2.3 From 6753a094002684a8f14232934c9cdeba13e00e8e Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 18 Mar 2013 00:36:01 +0000 Subject: Fix -Wunused-function warnings (bzr r12221) --- src/xml/repr-util.cpp | 65 --------------------------------------------------- 1 file changed, 65 deletions(-) (limited to 'src/xml/repr-util.cpp') diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp index 7e9f9c484..6ea20b87a 100644 --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@ -68,71 +68,6 @@ struct SPXMLNs { static void sp_xml_ns_register_defaults(); static char *sp_xml_ns_auto_prefix(char const *uri); -/*##################### -# UTILITY -#####################*/ - -/** - * Locale-independent double to string conversion - */ -static unsigned int sp_xml_dtoa(gchar *buf, double val, unsigned int tprec, unsigned int fprec, unsigned int padf) -{ - double dival, fval, epsilon; - int idigits, ival, i; - i = 0; - if (val < 0.0) { - buf[i++] = '-'; - val = -val; - } - /* Determine number of integral digits */ - if (val >= 1.0) { - idigits = (int) floor(log10(val)); - } else { - idigits = 0; - } - /* Determine the actual number of fractional digits */ - fprec = MAX(fprec, tprec - idigits); - /* Find epsilon */ - epsilon = 0.5 * pow(10.0, - (double) fprec); - /* Round value */ - val += epsilon; - /* Extract integral and fractional parts */ - dival = floor(val); - ival = (int) dival; - fval = val - dival; - /* Write integra */ - if (ival > 0) { - char c[32]; - int j; - j = 0; - while (ival > 0) { - c[32 - (++j)] = '0' + (ival % 10); - ival /= 10; - } - memcpy(buf + i, &c[32 - j], j); - i += j; - tprec -= j; - } else { - buf[i++] = '0'; - tprec -= 1; - } - if ((fprec > 0) && (padf || (fval > epsilon))) { - buf[i++] = '.'; - while ((fprec > 0) && (padf || (fval > epsilon))) { - fval *= 10.0; - dival = floor(fval); - fval -= dival; - buf[i++] = '0' + (int) dival; - fprec -= 1; - } - - } - buf[i] = 0; - return i; -} - - - /*##################### # MAIN #####################*/ -- cgit v1.2.3 From 5ceb89e41d788ae9ed18b972cedbbfcb923ddc27 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sat, 20 Apr 2013 20:34:35 -0400 Subject: Throw better error when attribute isn't available (bzr r12288) --- src/xml/repr-util.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/xml/repr-util.cpp') diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp index 6ea20b87a..8c8425de0 100644 --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@ -524,6 +524,8 @@ unsigned int sp_repr_get_point(Inkscape::XML::Node *repr, gchar const *key, Geom gchar const *v = repr->attribute(key); + g_return_val_if_fail(v != NULL, FALSE); + gchar ** strarray = g_strsplit(v, ",", 2); if (strarray && strarray[0] && strarray[1]) { -- cgit v1.2.3 From cb9e75a639073d83a523b2dff5ca91be730faf19 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Tue, 24 Sep 2013 11:49:31 -0400 Subject: Replace xml node get_double with simple direct value. Fixed bugs: - https://launchpad.net/bugs/1229558 (bzr r12585) --- src/xml/repr-util.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/xml/repr-util.cpp') diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp index 8c8425de0..12280ea5a 100644 --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@ -432,13 +432,11 @@ unsigned int sp_repr_get_int(Inkscape::XML::Node *repr, gchar const *key, int *v unsigned int sp_repr_get_double(Inkscape::XML::Node *repr, gchar const *key, double *val) { - gchar const *v; - g_return_val_if_fail(repr != NULL, FALSE); g_return_val_if_fail(key != NULL, FALSE); g_return_val_if_fail(val != NULL, FALSE); - v = repr->attribute(key); + gchar const *v = repr->attribute(key); if (v != NULL) { *val = g_ascii_strtod(v, NULL); -- cgit v1.2.3