From 69340304f32eac4d438c67b5e1f6bc2f0a05ea22 Mon Sep 17 00:00:00 2001 From: pjrm Date: Thu, 5 Jun 2008 06:28:20 +0000 Subject: [PATCH] fix compile with g++-4.3. --- src/2geom/elliptical-arc.cpp | 1 + src/PylogFormatter.h | 6 ++++-- src/common-context.cpp | 40 +++++++++++++++++++++++------------- src/dom/svgimpl.cpp | 2 ++ 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/2geom/elliptical-arc.cpp b/src/2geom/elliptical-arc.cpp index 55b23961b..a433ca370 100644 --- a/src/2geom/elliptical-arc.cpp +++ b/src/2geom/elliptical-arc.cpp @@ -33,6 +33,7 @@ #include "poly.h" #include +#include diff --git a/src/PylogFormatter.h b/src/PylogFormatter.h index f2d72ea04..adfc9a7f1 100644 --- a/src/PylogFormatter.h +++ b/src/PylogFormatter.h @@ -1,6 +1,7 @@ #ifndef PYLOG_FORMATTER_H_SEEN #define PYLOG_FORMATTER_H_SEEN +#include #include #ifndef _CXXTEST_HAVE_STD @@ -38,6 +39,7 @@ public: virtual void leaveWorld( const WorldDescription & desc ) { + using std::strlen; unsigned int skippedCount = 0; unsigned int failedCount = 0; unsigned int warnedCount = 0; @@ -59,8 +61,8 @@ public: (*_o) << test.suiteName() << "_|_" << test.testName(); (*_o) << " "; - int sent = strlen( test.suiteName() ) + strlen( test.testName() ) + 1; - for ( int z = sent; z < 56; z++ ) { + unsigned const sent = strlen( test.suiteName() ) + strlen( test.testName() ) + 1; + for ( unsigned z = sent; z < 56; z++ ) { (*_o) << " "; } diff --git a/src/common-context.cpp b/src/common-context.cpp index c28e704ee..d20b43b12 100644 --- a/src/common-context.cpp +++ b/src/common-context.cpp @@ -7,6 +7,7 @@ #include "forward.h" #include "message-context.h" +#include "streq.h" #define MIN_PRESSURE 0.0 #define MAX_PRESSURE 1.0 @@ -153,39 +154,50 @@ static void sp_common_context_setup(SPEventContext *ec) } } +static inline bool +get_bool_value(char const *const val) +{ + return ( val && *val == '1' ); + /* The only possible values if written by inkscape are NULL (attribute not present) + * or "0" or "1". + * + * For other values (e.g. if modified by a human without following the above rules), the + * current implementation does the right thing for empty string, "no", "false", "n", "f" + * but the wrong thing for "yes", "true", "y", "t". */ +} static void sp_common_context_set(SPEventContext *ec, gchar const *key, gchar const *value) { SPCommonContext *ctx = SP_COMMON_CONTEXT(ec); - if (!strcmp(key, "mass")) { + if (streq(key, "mass")) { double const dval = ( value ? g_ascii_strtod (value, NULL) : 0.2 ); ctx->mass = CLAMP(dval, -1000.0, 1000.0); - } else if (!strcmp(key, "wiggle")) { + } else if (streq(key, "wiggle")) { double const dval = ( value ? g_ascii_strtod (value, NULL) : (1 - DRAG_DEFAULT)); ctx->drag = CLAMP((1 - dval), DRAG_MIN, DRAG_MAX); // drag is inverse to wiggle - } else if (!strcmp(key, "angle")) { + } else if (streq(key, "angle")) { double const dval = ( value ? g_ascii_strtod (value, NULL) : 0.0); ctx->angle = CLAMP (dval, -90, 90); - } else if (!strcmp(key, "width")) { + } else if (streq(key, "width")) { double const dval = ( value ? g_ascii_strtod (value, NULL) : 0.1 ); ctx->width = CLAMP(dval, -1000.0, 1000.0); - } else if (!strcmp(key, "thinning")) { + } else if (streq(key, "thinning")) { double const dval = ( value ? g_ascii_strtod (value, NULL) : 0.1 ); ctx->vel_thin = CLAMP(dval, -1.0, 1.0); - } else if (!strcmp(key, "tremor")) { + } else if (streq(key, "tremor")) { double const dval = ( value ? g_ascii_strtod (value, NULL) : 0.0 ); ctx->tremor = CLAMP(dval, 0.0, 1.0); - } else if (!strcmp(key, "flatness")) { + } else if (streq(key, "flatness")) { double const dval = ( value ? g_ascii_strtod (value, NULL) : 1.0 ); ctx->flatness = CLAMP(dval, 0, 1.0); - } else if (!strcmp(key, "usepressure")) { - ctx->usepressure = ( value && strcmp(value, "0")); - } else if (!strcmp(key, "usetilt")) { - ctx->usetilt = ( value && strcmp(value, "0")); - } else if (!strcmp(key, "abs_width")) { - ctx->abs_width = ( value && strcmp(value, "0")); - } else if (!strcmp(key, "cap_rounding")) { + } else if (streq(key, "usepressure")) { + ctx->usepressure = get_bool_value(value); + } else if (streq(key, "usetilt")) { + ctx->usetilt = get_bool_value(value); + } else if (streq(key, "abs_width")) { + ctx->abs_width = get_bool_value(value); + } else if (streq(key, "cap_rounding")) { ctx->cap_rounding = ( value ? g_ascii_strtod (value, NULL) : 0.0 ); } } diff --git a/src/dom/svgimpl.cpp b/src/dom/svgimpl.cpp index 6b2a7fe70..cc73bd6f6 100644 --- a/src/dom/svgimpl.cpp +++ b/src/dom/svgimpl.cpp @@ -28,6 +28,8 @@ */ #include "svgimpl.h" +#include +using std::strcmp; /** * This is the .cpp side of the SVG implementations classes. Note that many -- 2.30.2