[Scummvm-cvs-logs] scummvm master -> a6e5b97e9fe20745bddd73e34e9deba57dbda216

fingolfin max at quendi.de
Mon Jun 6 11:30:54 CEST 2011


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
9c86e1a0a8 SWORD25: Fix whitespace
ac1c2124e5 SWORD25: Remove redundant bounds check
a6e5b97e9f COMMON: Remove vfprintf call from XML parser


Commit: 9c86e1a0a8abcee29bf8696b37594d17b589990c
    https://github.com/scummvm/scummvm/commit/9c86e1a0a8abcee29bf8696b37594d17b589990c
Author: Max Horn (max at quendi.de)
Date: 2011-06-06T02:19:07-07:00

Commit Message:
SWORD25: Fix whitespace

Changed paths:
    engines/sword25/gfx/animationresource.h



diff --git a/engines/sword25/gfx/animationresource.h b/engines/sword25/gfx/animationresource.h
index 2a1e3ce..d6c2b1c 100644
--- a/engines/sword25/gfx/animationresource.h
+++ b/engines/sword25/gfx/animationresource.h
@@ -48,36 +48,36 @@ public:
 	AnimationResource(const Common::String &filename);
 	virtual ~AnimationResource();
 
-	virtual const Frame    &getFrame(uint index) const {
+	virtual const Frame &getFrame(uint index) const {
 		assert(index < _frames.size());
 		return _frames[index];
 	}
-	virtual uint    getFrameCount() const {
+	virtual uint getFrameCount() const {
 		return _frames.size();
 	}
-	virtual void            unlock() {
+	virtual void unlock() {
 		release();
 	}
 
-	Animation::ANIMATION_TYPES   getAnimationType() const {
+	Animation::ANIMATION_TYPES getAnimationType() const {
 		return _animationType;
 	}
-	int                             getFPS() const {
+	int getFPS() const {
 		return _FPS;
 	}
-	int                             getMillisPerFrame() const {
+	int getMillisPerFrame() const {
 		return _millisPerFrame;
 	}
-	bool                            isScalingAllowed() const {
+	bool isScalingAllowed() const {
 		return _scalingAllowed;
 	}
-	bool                            isAlphaAllowed() const {
+	bool isAlphaAllowed() const {
 		return _alphaAllowed;
 	}
-	bool                            isColorModulationAllowed() const {
+	bool isColorModulationAllowed() const {
 		return _colorModulationAllowed;
 	}
-	bool                            isValid() const {
+	bool isValid() const {
 		return _valid;
 	}
 


Commit: ac1c2124e5b945fdd426bebc91d2ead79a3bf504
    https://github.com/scummvm/scummvm/commit/ac1c2124e5b945fdd426bebc91d2ead79a3bf504
Author: Max Horn (max at quendi.de)
Date: 2011-06-06T02:19:07-07:00

Commit Message:
SWORD25: Remove redundant bounds check

Changed paths:
    engines/sword25/gfx/animationresource.h



diff --git a/engines/sword25/gfx/animationresource.h b/engines/sword25/gfx/animationresource.h
index d6c2b1c..70291f2 100644
--- a/engines/sword25/gfx/animationresource.h
+++ b/engines/sword25/gfx/animationresource.h
@@ -49,7 +49,6 @@ public:
 	virtual ~AnimationResource();
 
 	virtual const Frame &getFrame(uint index) const {
-		assert(index < _frames.size());
 		return _frames[index];
 	}
 	virtual uint getFrameCount() const {


Commit: a6e5b97e9fe20745bddd73e34e9deba57dbda216
    https://github.com/scummvm/scummvm/commit/a6e5b97e9fe20745bddd73e34e9deba57dbda216
Author: Max Horn (max at quendi.de)
Date: 2011-06-06T02:19:09-07:00

Commit Message:
COMMON: Remove vfprintf call from XML parser

Changed paths:
    common/xmlparser.cpp
    common/xmlparser.h
    engines/sword25/gfx/animationresource.cpp
    engines/sword25/gfx/fontresource.cpp
    gui/ThemeParser.cpp



diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp
index 9bd052f..ea36f0b 100644
--- a/common/xmlparser.cpp
+++ b/common/xmlparser.cpp
@@ -23,9 +23,6 @@
 // FIXME: Avoid using fprintf
 #define FORBIDDEN_SYMBOL_EXCEPTION_fprintf
 
-// FIXME: Avoid using vfprintf
-#define FORBIDDEN_SYMBOL_EXCEPTION_vfprintf
-
 
 #include "common/xmlparser.h"
 #include "common/archive.h"
@@ -83,7 +80,7 @@ void XMLParser::close() {
 	_stream = 0;
 }
 
-bool XMLParser::parserError(const char *errorString, ...) {
+bool XMLParser::parserError(const Common::String &errStr) {
 	_state = kParserError;
 
 	const int startPosition = _stream->pos();
@@ -134,12 +131,7 @@ bool XMLParser::parserError(const char *errorString, ...) {
 		fprintf(stderr, "%c", _stream->readByte());
 
 	fprintf(stderr, "\n\nParser error: ");
-
-	va_list args;
-	va_start(args, errorString);
-	vfprintf(stderr, errorString, args);
-	va_end(args);
-
+	fprintf(stderr, "%s", errStr.c_str());
 	fprintf(stderr, "\n\n");
 
 	return false;
@@ -181,16 +173,16 @@ bool XMLParser::parseActiveKey(bool closed) {
 
 		for (List<XMLKeyLayout::XMLKeyProperty>::const_iterator i = key->layout->properties.begin(); i != key->layout->properties.end(); ++i) {
 			if (i->required && !localMap.contains(i->name))
-				return parserError("Missing required property '%s' inside key '%s'", i->name.c_str(), key->name.c_str());
+				return parserError("Missing required property '" + i->name + "' inside key '" + key->name + "'");
 			else if (localMap.contains(i->name))
 				keyCount--;
 		}
 
 		if (keyCount > 0)
-			return parserError("Unhandled property inside key '%s'.", key->name.c_str());
+			return parserError("Unhandled property inside key '" + key->name + "'.");
 
 	} else {
-		return parserError("Unexpected key in the active scope ('%s').", key->name.c_str());
+		return parserError("Unexpected key in the active scope ('" + key->name + "').");
 	}
 
 	// check if any of the parents must be ignored.
@@ -205,7 +197,7 @@ bool XMLParser::parseActiveKey(bool closed) {
 		// when keyCallback() fails, a parserError() must be set.
 		// We set it manually in that case.
 		if (_state != kParserError)
-			parserError("Unhandled exception when parsing '%s' key.", key->name.c_str());
+			parserError("Unhandled exception when parsing '" + key->name + "' key.");
 
 		return false;
 	}
@@ -395,7 +387,7 @@ bool XMLParser::parse() {
 		case kParserNeedPropertyName:
 			if (activeClosure) {
 				if (!closeKey()) {
-					parserError("Missing data when closing key '%s'.", _activeKey.top()->name.c_str());
+					parserError("Missing data when closing key '" + _activeKey.top()->name + "'.");
 					break;
 				}
 
diff --git a/common/xmlparser.h b/common/xmlparser.h
index 84fca29..7923e43 100644
--- a/common/xmlparser.h
+++ b/common/xmlparser.h
@@ -274,7 +274,7 @@ protected:
 	 * Parser error always returns "false" so we can pass the return value
 	 * directly and break down the parsing.
 	 */
-	bool parserError(const char *errorString, ...) GCC_PRINTF(2, 3);
+	bool parserError(const Common::String &errStr);
 
 	/**
 	 * Skips spaces/whitelines etc.
diff --git a/engines/sword25/gfx/animationresource.cpp b/engines/sword25/gfx/animationresource.cpp
index a9c9cf9..b9d70cf 100644
--- a/engines/sword25/gfx/animationresource.cpp
+++ b/engines/sword25/gfx/animationresource.cpp
@@ -38,11 +38,11 @@
 
 namespace Sword25 {
 
-namespace {
-const int   DEFAULT_FPS = 10;
-const int   MIN_FPS     = 1;
-const int   MAX_FPS     = 200;
-}
+enum {
+	DEFAULT_FPS = 10,
+	MIN_FPS     = 1,
+	MAX_FPS     = 200
+};
 
 AnimationResource::AnimationResource(const Common::String &filename) :
 		Resource(filename, Resource::TYPE_ANIMATION),
@@ -112,8 +112,8 @@ bool AnimationResource::parseBooleanKey(Common::String s, bool &result) {
 
 bool AnimationResource::parserCallback_animation(ParserNode *node) {
 	if (!parseIntegerKey(node->values["fps"], 1, &_FPS) || (_FPS < MIN_FPS) || (_FPS > MAX_FPS)) {
-		return parserError("Illegal or missing fps attribute in <animation> tag in \"%s\". Assuming default (\"%d\").",
-		                 getFileName().c_str(), DEFAULT_FPS);
+		return parserError(Common::String::format("Illegal or missing fps attribute in <animation> tag in \"%s\". Assuming default (\"%d\").",
+		                 getFileName().c_str(), DEFAULT_FPS));
 	}
 
 	// Loop type value
diff --git a/engines/sword25/gfx/fontresource.cpp b/engines/sword25/gfx/fontresource.cpp
index f99987f..7657abb 100644
--- a/engines/sword25/gfx/fontresource.cpp
+++ b/engines/sword25/gfx/fontresource.cpp
@@ -115,23 +115,23 @@ bool FontResource::parserCallback_character(ParserNode *node) {
 	int charCode, top, left, right, bottom;
 
 	if (!parseIntegerKey(node->values["code"], 1, &charCode) || (charCode < 0) || (charCode >= 256)) {
-		return parserError("Illegal or missing code attribute in <character> tag in \"%s\".", getFileName().c_str());
+		return parserError("Illegal or missing code attribute in <character> tag in '" + getFileName() + "'.");
 	}
 
 	if (!parseIntegerKey(node->values["top"], 1, &top) || (top < 0)) {
-		return parserError("Illegal or missing top attribute in <character> tag in \"%s\".", getFileName().c_str());
+		return parserError("Illegal or missing top attribute in <character> tag in '" + getFileName() + "'.");
 	}
 	if (!parseIntegerKey(node->values["left"], 1, &left) || (left < 0)) {
-		return parserError("Illegal or missing left attribute in <character> tag in \"%s\".", getFileName().c_str());
+		return parserError("Illegal or missing left attribute in <character> tag in '" + getFileName() + "'.");
 	}
 	if (!parseIntegerKey(node->values["right"], 1, &right) || (right < 0)) {
-		return parserError("Illegal or missing right attribute in <character> tag in \"%s\".", getFileName().c_str());
+		return parserError("Illegal or missing right attribute in <character> tag in '" + getFileName() + "'.");
 	}
 	if (!parseIntegerKey(node->values["bottom"], 1, &bottom) || (bottom < 0)) {
-		return parserError("Illegal or missing bottom attribute in <character> tag in \"%s\".", getFileName().c_str());
+		return parserError("Illegal or missing bottom attribute in <character> tag in '" + getFileName() + "'.");
 	}
 
-	this->_characterRects[charCode] = Common::Rect(left, top, right, bottom);
+	_characterRects[charCode] = Common::Rect(left, top, right, bottom);
 	return true;
 }
 
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
index 56ee6df..5b1faa4 100644
--- a/gui/ThemeParser.cpp
+++ b/gui/ThemeParser.cpp
@@ -232,7 +232,7 @@ bool ThemeParser::parserCallback_bitmap(ParserNode *node) {
 	}
 
 	if (!_theme->addBitmap(node->values["filename"]))
-		return parserError("Error loading Bitmap file '%s'", node->values["filename"].c_str());
+		return parserError("Error loading Bitmap file '" + node->values["filename"] + "'");
 
 	return true;
 }
@@ -252,7 +252,7 @@ bool ThemeParser::parserCallback_text(ParserNode *node) {
 	TextColor textColorId = parseTextColorId(node->values["text_color"]);
 
 	if (!_theme->addTextData(id, textDataId, textColorId, alignH, alignV))
-		return parserError("Error adding Text Data for '%s'.", id.c_str());
+		return parserError("Error adding Text Data for '" + id + "'.");
 
 	return true;
 }
@@ -279,13 +279,13 @@ bool ThemeParser::parserCallback_color(ParserNode *node) {
 	Common::String name = node->values["name"];
 
 	if (_palette.contains(name))
-		return parserError("Color '%s' has already been defined.", name.c_str());
+		return parserError("Color '" + name + "' has already been defined.");
 
 	int red, green, blue;
 
 	if (parseIntegerKey(node->values["rgb"], 3, &red, &green, &blue) == false ||
 		red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255)
-		return parserError("Error parsing RGB values for palette color '%s'", name.c_str());\
+		return parserError("Error parsing RGB values for palette color '" + name + "'");
 
 	_palette[name].r = red;
 	_palette[name].g = green;
@@ -332,7 +332,7 @@ bool ThemeParser::parserCallback_drawstep(ParserNode *node) {
 	drawstep->drawingCall = getDrawingFunctionCallback(functionName);
 
 	if (drawstep->drawingCall == 0)
-		return parserError("%s is not a valid drawing function name", functionName.c_str());
+		return parserError(functionName + " is not a valid drawing function name");
 
 	if (!parseDrawStep(node, drawstep, true))
 		return false;
@@ -385,11 +385,11 @@ bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawst
 #define __PARSER_ASSIGN_INT(struct_name, key_name, force) \
 	if (stepNode->values.contains(key_name)) { \
 		if (!parseIntegerKey(stepNode->values[key_name], 1, &x)) \
-			return parserError("Error parsing key value for '%s'.", key_name); \
+			return parserError("Error parsing key value for '" + Common::String(key_name) + "'."); \
 		\
 		drawstep->struct_name = x; \
 	} else if (force) { \
-		return parserError("Missing necessary key '%s'.", key_name); \
+		return parserError("Missing necessary key '" + Common::String(key_name) + "'."); \
 	}
 
 /**
@@ -410,7 +410,7 @@ bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawst
 			blue = _palette[val].b; \
 		} else if (parseIntegerKey(val, 3, &red, &green, &blue) == false || \
 			red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255) \
-			return parserError("Error parsing color struct '%s'", val.c_str());\
+			return parserError("Error parsing color struct '" + val + "'");\
 		\
 		drawstep->struct_name.r = red; \
 		drawstep->struct_name.g = green; \
@@ -466,7 +466,7 @@ bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawst
 				else if (val == "right")
 					drawstep->extraData = Graphics::VectorRenderer::kTriangleRight;
 				else
-					return parserError("'%s' is not a valid value for triangle orientation.", val.c_str());
+					return parserError("'" + val + "' is not a valid value for triangle orientation.");
 			}
 		}
 
@@ -545,7 +545,7 @@ bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawst
 		else if (val == "gradient")
 			drawstep->fillMode = Graphics::VectorRenderer::kFillGradient;
 		else
-			return parserError("'%s' is not a valid fill mode for a shape.", stepNode->values["fill"].c_str());
+			return parserError("'" + stepNode->values["fill"] + "' is not a valid fill mode for a shape.");
 	}
 
 #undef __PARSER_ASSIGN_INT
@@ -567,7 +567,7 @@ bool ThemeParser::parserCallback_def(ParserNode *node) {
 		value = _theme->getEvaluator()->getVar(node->values["value"]);
 
 	else if (!parseIntegerKey(node->values["value"], 1, &value))
-		return parserError("Invalid definition for '%s'.", var.c_str());
+		return parserError("Invalid definition for '" + var + "'.");
 
 	_theme->getEvaluator()->setVar(var, value);
 	return true;
@@ -585,7 +585,7 @@ bool ThemeParser::parserCallback_widget(ParserNode *node) {
 
 		var = "Globals." + node->values["name"] + ".";
 		if (!parseCommonLayoutProps(node, var))
-			return parserError("Error parsing Layout properties of '%s'.", var.c_str());
+			return parserError("Error parsing Layout properties of '" + var + "'.");
 
 	} else {
 		// FIXME: Shouldn't we distinguish the name/id and the label of a widget?
@@ -606,7 +606,7 @@ bool ThemeParser::parserCallback_widget(ParserNode *node) {
 				width = _theme->getEvaluator()->getVar(node->values["width"]);
 
 			else if (!parseIntegerKey(node->values["width"], 1, &width))
-				return parserError("Corrupted width value in key for %s", var.c_str());
+				return parserError("Corrupted width value in key for " + var);
 		}
 
 		if (node->values.contains("height")) {
@@ -614,7 +614,7 @@ bool ThemeParser::parserCallback_widget(ParserNode *node) {
 				height = _theme->getEvaluator()->getVar(node->values["height"]);
 
 			else if (!parseIntegerKey(node->values["height"], 1, &height))
-				return parserError("Corrupted height value in key for %s", var.c_str());
+				return parserError("Corrupted height value in key for " + var);
 		}
 
 		Graphics::TextAlign alignH = Graphics::kTextAlignLeft;






More information about the Scummvm-git-logs mailing list