summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dd3ac46)
raw | patch | inline | side by side (parent: dd3ac46)
author | pjrm <pjrm@users.sourceforge.net> | |
Thu, 5 Jun 2008 06:28:20 +0000 (06:28 +0000) | ||
committer | pjrm <pjrm@users.sourceforge.net> | |
Thu, 5 Jun 2008 06:28:20 +0000 (06:28 +0000) |
src/2geom/elliptical-arc.cpp | patch | blob | history | |
src/PylogFormatter.h | patch | blob | history | |
src/common-context.cpp | patch | blob | history | |
src/dom/svgimpl.cpp | patch | blob | history |
index 55b23961b269d764ad61f5da493ead7cdcea4e60..a433ca370f0fa257b1f2cc1791f4ad50da427766 100644 (file)
#include "poly.h"
#include <cfloat>
+#include <limits>
diff --git a/src/PylogFormatter.h b/src/PylogFormatter.h
index f2d72ea041449ed697ac9a7a95b8b9ee83d6847c..adfc9a7f15e524c9a7fcd4eb00d4efcbf14b6b6c 100644 (file)
--- a/src/PylogFormatter.h
+++ b/src/PylogFormatter.h
#ifndef PYLOG_FORMATTER_H_SEEN
#define PYLOG_FORMATTER_H_SEEN
+#include <cstring>
#include <cxxtest/Flags.h>
#ifndef _CXXTEST_HAVE_STD
virtual void leaveWorld( const WorldDescription & desc )
{
+ using std::strlen;
unsigned int skippedCount = 0;
unsigned int failedCount = 0;
unsigned int warnedCount = 0;
(*_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 c28e704ee789f7ee3ede1b0b90db17684137dcd3..d20b43b1234e602bd1ea820996702016336253a8 100644 (file)
--- a/src/common-context.cpp
+++ b/src/common-context.cpp
#include "forward.h"
#include "message-context.h"
+#include "streq.h"
#define MIN_PRESSURE 0.0
#define MAX_PRESSURE 1.0
}
}
+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 6b2a7fe70391f57593a290b8a385a3cb51ced24c..cc73bd6f6c7277482290f1397e73185c13cb5527 100644 (file)
--- a/src/dom/svgimpl.cpp
+++ b/src/dom/svgimpl.cpp
*/
#include "svgimpl.h"
+#include <cstring>
+using std::strcmp;
/**
* This is the .cpp side of the SVG implementations classes. Note that many