aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/advancedDetector.cpp6
-rw-r--r--common/algorithm.h2
-rw-r--r--common/archive.cpp2
-rw-r--r--common/archive.h8
-rw-r--r--common/config-file.cpp4
-rw-r--r--common/config-manager.cpp8
-rw-r--r--common/error.h6
-rw-r--r--common/events.h2
-rw-r--r--common/file.cpp4
-rw-r--r--common/file.h2
-rw-r--r--common/fs.cpp4
-rw-r--r--common/hashmap.cpp10
-rw-r--r--common/hashmap.h10
-rw-r--r--common/md5.cpp2
-rw-r--r--common/memorypool.cpp12
-rw-r--r--common/memorypool.h8
-rw-r--r--common/ptr.h4
-rw-r--r--common/str.cpp12
-rw-r--r--common/str.h10
-rw-r--r--common/stream.cpp12
-rw-r--r--common/stream.h2
-rw-r--r--common/system.h2
-rw-r--r--common/unarj.cpp18
-rw-r--r--common/unzip.h2
-rw-r--r--common/xmlparser.cpp76
-rw-r--r--common/xmlparser.h60
-rw-r--r--common/zlib.cpp6
-rw-r--r--common/zlib.h2
28 files changed, 148 insertions, 148 deletions
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp
index 3acf44f067..e3637e81c9 100644
--- a/common/advancedDetector.cpp
+++ b/common/advancedDetector.cpp
@@ -445,7 +445,7 @@ static ADGameDescList detectGame(const FSList &fslist, const Common::ADParams &p
if (matched.empty()) {
if (!filesSizeMD5.empty())
reportUnknown(filesSizeMD5);
-
+
// Filename based fallback
if (params.fileBasedFallback != 0)
matched = detectGameFilebased(allFiles, params);
@@ -484,11 +484,11 @@ static ADGameDescList detectGameFilebased(const FileMap &allFiles, const Common:
if (!fileMissing) {
debug(4, "Matched: %s", agdesc->gameid);
-
+
if (numMatchedFiles > maxNumMatchedFiles) {
matchedDesc = agdesc;
maxNumMatchedFiles = numMatchedFiles;
-
+
debug(4, "and overriden");
}
}
diff --git a/common/algorithm.h b/common/algorithm.h
index 3b6c63d55c..2b02dbc016 100644
--- a/common/algorithm.h
+++ b/common/algorithm.h
@@ -45,7 +45,7 @@ Out copy(In first, In last, Out dst) {
* Copies data from the range [first, last) to [dst - (last - first), dst).
* It requires the range [dst - (last - first), dst) to be valid.
* It also requires dst not to be in the range [first, last).
- *
+ *
* Unlike copy copy_backward copies the data from the end to the beginning.
*/
template<class In, class Out>
diff --git a/common/archive.cpp b/common/archive.cpp
index 8a3e08bf78..b4f4dcd3a6 100644
--- a/common/archive.cpp
+++ b/common/archive.cpp
@@ -70,7 +70,7 @@ int Archive::listMatchingMembers(ArchiveMemberList &list, const String &pattern)
* by FSDirectory. It is right now a light wrapper or FSNode.
*/
class FSDirectoryMember : public ArchiveMember {
- FSNode _node;
+ FSNode _node;
public:
FSDirectoryMember(FSNode &node) : _node(node) {
diff --git a/common/archive.h b/common/archive.h
index 0085e997ab..5e331052b2 100644
--- a/common/archive.h
+++ b/common/archive.h
@@ -275,13 +275,13 @@ public:
bool hasArchive(const String &name) const;
/**
- * Empties the searchable set.
- */
+ * Empties the searchable set.
+ */
virtual void clear();
/**
- * Change the order of searches.
- */
+ * Change the order of searches.
+ */
void setPriority(const String& name, int priority);
virtual bool hasFile(const String &name);
diff --git a/common/config-file.cpp b/common/config-file.cpp
index c3764a02da..a05a9ee0d3 100644
--- a/common/config-file.cpp
+++ b/common/config-file.cpp
@@ -135,7 +135,7 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) {
assert(isValidName(section.name));
} else {
// This line should be a line with a 'key=value' pair, or an empty one.
-
+
// Skip leading whitespaces
const char *t = line.c_str();
while (isspace(*t))
@@ -158,7 +158,7 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) {
// Extract the key/value pair
kv.key = String(t, p);
kv.value = String(p + 1);
-
+
// Trim of spaces
kv.key.trim();
kv.value.trim();
diff --git a/common/config-manager.cpp b/common/config-manager.cpp
index 13abe085e2..e0a8dfa56b 100644
--- a/common/config-manager.cpp
+++ b/common/config-manager.cpp
@@ -68,7 +68,7 @@ void ConfigManager::loadDefaultConfigFile() {
// ... load it, if available ...
if (stream)
loadFromStream(*stream);
-
+
// ... and close it again.
delete stream;
@@ -142,7 +142,7 @@ void ConfigManager::loadFromStream(SeekableReadStream &stream) {
_domainSaveOrder.push_back(domain);
} else {
// This line should be a line with a 'key=value' pair, or an empty one.
-
+
// Skip leading whitespaces
const char *t = line.c_str();
while (isspace(*t))
@@ -165,7 +165,7 @@ void ConfigManager::loadFromStream(SeekableReadStream &stream) {
// Extract the key/value pair
String key(t, p);
String value(p + 1);
-
+
// Trim of spaces
key.trim();
value.trim();
@@ -202,7 +202,7 @@ void ConfigManager::flushToDisk() {
delete dump;
return;
}
-
+
stream = dump;
}
diff --git a/common/error.h b/common/error.h
index 1f5fed7ea6..23305a5c2e 100644
--- a/common/error.h
+++ b/common/error.h
@@ -48,11 +48,11 @@ enum Error {
kInvalidPathError, //!< Engine initialization: Invalid game path was passed
kNoGameDataFoundError, //!< Engine initialization: No game data was found in the specified location
kUnsupportedGameidError, //!< Engine initialization: Gameid not supported by this (Meta)Engine
-
-
+
+
kReadPermissionDenied, //!< Unable to read data due to missing read permission
kWritePermissionDenied, //!< Unable to write data due to missing write permission
-
+
// The following three overlap a bit with kInvalidPathError and each other. Which to keep?
kPathDoesNotExist, //!< The specified path does not exist
kPathNotDirectory, //!< The specified path does not point to a directory
diff --git a/common/events.h b/common/events.h
index dd45ca18c1..c1655a17f3 100644
--- a/common/events.h
+++ b/common/events.h
@@ -122,7 +122,7 @@ struct Event {
* screen area as defined by the most recent call to initSize().
*/
Common::Point mouse;
-
+
Event() : type(EVENT_INVALID), synthetic(false) {}
};
diff --git a/common/file.cpp b/common/file.cpp
index 76a9f94505..51736ccd67 100644
--- a/common/file.cpp
+++ b/common/file.cpp
@@ -69,7 +69,7 @@ bool File::open(const String &filename, Archive &archive) {
debug(3, "Opening hashed: %s.", filename.c_str());
stream = archive.openFile(filename + ".");
}
-
+
return open(stream, filename);
}
@@ -110,7 +110,7 @@ bool File::exists(const String &filename) {
// sometimes instead of "GAMEPC" we get "GAMEPC." (note trailing dot)
return true;
}
-
+
return false;
}
diff --git a/common/file.h b/common/file.h
index 43392ba7fa..28c99e0e38 100644
--- a/common/file.h
+++ b/common/file.h
@@ -86,7 +86,7 @@ public:
/**
* Try to open the file corresponding to the give node. Will check whether the
- * node actually refers to an existing file (and not a directory), and handle
+ * node actually refers to an existing file (and not a directory), and handle
* those cases gracefully.
* @note Must not be called if this file already is open (i.e. if isOpen returns true).
*
diff --git a/common/fs.cpp b/common/fs.cpp
index 497e961680..de553d42b7 100644
--- a/common/fs.cpp
+++ b/common/fs.cpp
@@ -32,14 +32,14 @@ namespace Common {
FSNode::FSNode() {
}
-FSNode::FSNode(AbstractFSNode *realNode)
+FSNode::FSNode(AbstractFSNode *realNode)
: _realNode(realNode) {
}
FSNode::FSNode(const Common::String &p) {
FilesystemFactory *factory = g_system->getFilesystemFactory();
AbstractFSNode *tmp = 0;
-
+
if (p.empty() || p == ".")
tmp = factory->makeCurrentDirectoryFileNode();
else
diff --git a/common/hashmap.cpp b/common/hashmap.cpp
index b8f2608901..0fb03ec3f8 100644
--- a/common/hashmap.cpp
+++ b/common/hashmap.cpp
@@ -74,7 +74,7 @@ void updateHashCollisionStats(int collisions, int lookups, int arrsize, int nele
g_capacity += arrsize;
g_size += nele;
g_totalHashmaps++;
-
+
if (3*nele <= 2*8)
g_stats[0]++;
if (3*nele <= 2*16)
@@ -83,7 +83,7 @@ void updateHashCollisionStats(int collisions, int lookups, int arrsize, int nele
g_stats[2]++;
if (3*nele <= 2*64)
g_stats[3]++;
-
+
g_max_capacity = MAX(g_max_capacity, arrsize);
g_max_size = MAX(g_max_size, nele);
@@ -95,9 +95,9 @@ void updateHashCollisionStats(int collisions, int lookups, int arrsize, int nele
g_size / g_totalHashmaps, g_max_size,
g_capacity / g_totalHashmaps, g_max_capacity);
fprintf(stdout, " %d less than %d; %d less than %d; %d less than %d; %d less than %d\n",
- g_stats[0], 2*8/3,
- g_stats[1],2*16/3,
- g_stats[2],2*32/3,
+ g_stats[0], 2*8/3,
+ g_stats[1],2*16/3,
+ g_stats[2],2*32/3,
g_stats[3],2*64/3);
// TODO:
diff --git a/common/hashmap.h b/common/hashmap.h
index bbc227b3ae..d45280133b 100644
--- a/common/hashmap.h
+++ b/common/hashmap.h
@@ -78,15 +78,15 @@ public:
enum {
HASHMAP_PERTURB_SHIFT = 5,
HASHMAP_MIN_CAPACITY = 16,
-
- // The quotient of the next two constants controls how much the
+
+ // The quotient of the next two constants controls how much the
// internal storage of the hashmap may fill up before being
// increased automatically.
// Note: the quotient of these two must be between and different
// from 0 and 1.
HASHMAP_LOADFACTOR_NUMERATOR = 2,
HASHMAP_LOADFACTOR_DENOMINATOR = 3,
-
+
HASHMAP_MEMORYPOOL_SIZE = HASHMAP_MIN_CAPACITY * HASHMAP_LOADFACTOR_NUMERATOR / HASHMAP_LOADFACTOR_DENOMINATOR
};
@@ -95,7 +95,7 @@ public:
Node *allocNode(const Key &key) {
return new (_nodePool) Node(key);
- }
+ }
void freeNode(Node *node) {
_nodePool.deleteChunk(node);
@@ -283,7 +283,7 @@ HashMap<Key, Val, HashFunc, EqualFunc>::HashMap() :
* to heap buffers for the internal storage.
*/
template<class Key, class Val, class HashFunc, class EqualFunc>
-HashMap<Key, Val, HashFunc, EqualFunc>::HashMap(const HM_t &map) :
+HashMap<Key, Val, HashFunc, EqualFunc>::HashMap(const HM_t &map) :
_defaultVal() {
assign(map);
}
diff --git a/common/md5.cpp b/common/md5.cpp
index 107990481f..daaf176b7c 100644
--- a/common/md5.cpp
+++ b/common/md5.cpp
@@ -257,7 +257,7 @@ bool md5_file(const FSNode &file, uint8 digest[16], uint32 length) {
warning("md5_file: using a directory FSNode");
return false;
}
-
+
ReadStream *stream = file.openForReading();
if (!stream) {
warning("md5_file: failed to open '%s'", file.getPath().c_str());
diff --git a/common/memorypool.cpp b/common/memorypool.cpp
index 59772f6a03..68da830cf2 100644
--- a/common/memorypool.cpp
+++ b/common/memorypool.cpp
@@ -41,7 +41,7 @@ MemoryPool::MemoryPool(size_t chunkSize) {
_chunkSize = (_chunkSize + sizeof(void*) - 1) & (~(sizeof(void*) - 1));
_next = NULL;
-
+
_chunksPerPage = INITIAL_CHUNKS_PER_PAGE;
}
@@ -51,8 +51,8 @@ MemoryPool::~MemoryPool() {
}
void MemoryPool::allocPage() {
- Page page;
-
+ Page page;
+
// Allocate a new page
page.numChunks = _chunksPerPage;
assert(page.numChunks * _chunkSize < 16*1024*1024); // Refuse to allocate pages bigger than 16 MB
@@ -61,10 +61,10 @@ void MemoryPool::allocPage() {
assert(page.start);
_pages.push_back(page);
-
+
// Next time, we'll alocate a page twice as big as this one.
_chunksPerPage *= 2;
-
+
// Add the page to the pool of free chunk
addPageToPool(page);
}
@@ -79,7 +79,7 @@ void MemoryPool::addPageToPool(const Page &page) {
current = next;
}
-
+
// Last chunk points to the old _next
*(void**)current = _next;
diff --git a/common/memorypool.h b/common/memorypool.h
index 22326941f3..cb4d6b7180 100644
--- a/common/memorypool.h
+++ b/common/memorypool.h
@@ -36,7 +36,7 @@ class MemoryPool {
protected:
MemoryPool(const MemoryPool&);
MemoryPool& operator=(const MemoryPool&);
-
+
struct Page {
void *start;
size_t numChunks;
@@ -55,11 +55,11 @@ public:
MemoryPool(size_t chunkSize);
~MemoryPool();
- void *allocChunk();
- void freeChunk(void *ptr);
+ void *allocChunk();
+ void freeChunk(void *ptr);
void freeUnusedPages();
-
+
size_t getChunkSize() const { return _chunkSize; }
};
diff --git a/common/ptr.h b/common/ptr.h
index 99bc82a2d3..21656ad32a 100644
--- a/common/ptr.h
+++ b/common/ptr.h
@@ -70,7 +70,7 @@ private:
* To achieve that the object implements an internal reference counting.
* Thus you should try to avoid using the plain pointer after assigning
* it to a SharedPtr object for the first time. If you still use the
- * plain pointer be sure you do not delete it on your own. You may also
+ * plain pointer be sure you do not delete it on your own. You may also
* not use the plain pointer to create a new SharedPtr object, since that
* would result in a double deletion of the pointer sooner or later.
*
@@ -95,7 +95,7 @@ private:
*
* The class has implicit upcast support, so if you got a class B derived
* from class A, you can assign a pointer to B without any problems to a
- * SharedPtr object with template parameter A. The very same applies to
+ * SharedPtr object with template parameter A. The very same applies to
* assignment of a SharedPtr<B> object to a SharedPtr<A> object.
*
* There are also operators != and == to compare two SharedPtr objects
diff --git a/common/str.cpp b/common/str.cpp
index 00e88bfc3b..d3522a665a 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -28,7 +28,7 @@
#include "common/memorypool.h"
-#if !defined(__SYMBIAN32__)
+#if !defined(__SYMBIAN32__)
#include <new>
#endif
@@ -559,12 +559,12 @@ Common::String lastPathComponent(const Common::String &path, const char sep) {
// Path consisted of only slashes -> return empty string
if (last == str)
return Common::String();
-
+
// Now scan the whole component
const char *first = last - 1;
while (first >= str && *first != sep)
--first;
-
+
if (*first == sep)
first++;
@@ -584,15 +584,15 @@ Common::String normalizePath(const Common::String &path, const char sep) {
while (*cur == sep)
++cur;
}
-
+
// Scan till the end of the String
while (*cur != 0) {
const char *start = cur;
-
+
// Scan till the next path separator resp. the end of the string
while (*cur != sep && *cur != 0)
cur++;
-
+
const Common::String component(start, cur);
// Skip empty components and dot components, add all others
diff --git a/common/str.h b/common/str.h
index c3e773c3e4..43b75edc5b 100644
--- a/common/str.h
+++ b/common/str.h
@@ -104,13 +104,13 @@ public:
/** Construct a new string containing exactly len characters read from address str. */
String(const char *str, uint32 len);
-
+
/** Construct a new string containing the characters between beginP (including) and endP (excluding). */
String(const char *beginP, const char *endP);
-
+
/** Construct a copy of the given string. */
String(const String &str);
-
+
/** Construct a string consisting of the given character. */
explicit String(char c);
@@ -186,7 +186,7 @@ public:
/** Remove the last character from the string. */
void deleteLastChar();
-
+
/** Remove the character at position p from the string. */
void deleteChar(uint32 p);
@@ -204,7 +204,7 @@ public:
/** Convert all characters in the string to uppercase. */
void toUppercase();
-
+
/**
* Removes trailing and leading whitespaces. Uses isspace() to decide
* what is whitespace and what not.
diff --git a/common/stream.cpp b/common/stream.cpp
index e17a745ef1..1cdcd50723 100644
--- a/common/stream.cpp
+++ b/common/stream.cpp
@@ -85,7 +85,7 @@ bool MemoryReadStream::seek(int32 offs, int whence) {
assert(_pos <= _size);
// Reset end-of-stream flag on a successful seek
- _eos = false;
+ _eos = false;
return true; // FIXME: STREAM REWRITE
}
@@ -101,7 +101,7 @@ char *SeekableReadStream::readLine_NEW(char *buf, size_t bufSize) {
char c = 0;
// If end-of-file occurs before any characters are read, return NULL
- // and the buffer contents remain unchanged.
+ // and the buffer contents remain unchanged.
if (eos() || err()) {
return 0;
}
@@ -147,7 +147,7 @@ char *SeekableReadStream::readLine_NEW(char *buf, size_t bufSize) {
// Treat CR & CR/LF as plain LF
c = LF;
}
-
+
*p++ = c;
len++;
}
@@ -166,7 +166,7 @@ String SeekableReadStream::readLine() {
break;
line += buf;
}
-
+
if (line.lastChar() == '\n')
line.deleteLastChar();
@@ -256,7 +256,7 @@ uint32 BufferedReadStream::read(void *dataPtr, uint32 dataSize) {
dataPtr = (byte *)dataPtr + bufBytesLeft;
dataSize -= bufBytesLeft;
}
-
+
// At this point the buffer is empty. Now if the read request
// exceeds the buffer size, just satisfy it directly.
if (dataSize > _bufSize)
@@ -299,7 +299,7 @@ bool BufferedSeekableReadStream::seek(int32 offset, int whence) {
_pos = _bufSize;
_parentStream->seek(offset, whence);
}
-
+
return true; // FIXME: STREAM REWRITE
}
diff --git a/common/stream.h b/common/stream.h
index 7dd1b8283e..f98ad6aa92 100644
--- a/common/stream.h
+++ b/common/stream.h
@@ -206,7 +206,7 @@ public:
* Read a signed byte from the stream and return it.
* Performs no error checking. The return value is undefined
* if a read error occurred (for which client code can check by
- * calling err() and eos() ).
+ * calling err() and eos() ).
*/
int8 readSByte() {
int8 b = 0;
diff --git a/common/system.h b/common/system.h
index 91bb091166..f7849a9d17 100644
--- a/common/system.h
+++ b/common/system.h
@@ -403,7 +403,7 @@ public:
* @see endGFXTransaction
*/
enum TransactionError {
- kTransactionSuccess = 0, /**< Everything fine (use EQUAL check for this one!) */
+ kTransactionSuccess = 0, /**< Everything fine (use EQUAL check for this one!) */
kTransactionAspectRatioFailed = (1 << 0), /**< Failed switchting aspect ratio correction mode */
kTransactionFullscreenFailed = (1 << 1), /**< Failed switchting fullscreen mode */
kTransactionModeSwitchFailed = (1 << 2), /**< Failed switchting the GFX graphics mode (setGraphicsMode) */
diff --git a/common/unarj.cpp b/common/unarj.cpp
index 8725321a7a..e69869a720 100644
--- a/common/unarj.cpp
+++ b/common/unarj.cpp
@@ -95,7 +95,7 @@ public:
ArjDecoder(const ArjHeader *hdr) {
_compsize = hdr->compSize;
}
-
+
~ArjDecoder() {
delete _compressed;
delete _outstream;
@@ -117,7 +117,7 @@ public:
void init_getbits();
void fillbuf(int n);
uint16 getbits(int n);
-
+
void make_table(int nchar, byte *bitlen, int tablebits, uint16 *table, int tablesize);
void read_pt_len(int nn, int nbit, int i_special);
@@ -332,8 +332,8 @@ ArjHeader *readHeader(SeekableReadStream &stream) {
strncpy(header.comment, (const char *)&headData[header.firstHdrSize + strlen(header.filename) + 1], ARJ_COMMENT_MAX);
- // Process extended headers, if any
- uint16 extHeaderSize;
+ // Process extended headers, if any
+ uint16 extHeaderSize;
while ((extHeaderSize = stream.readUint16LE()) != 0)
stream.seek((long)(extHeaderSize + 4), SEEK_CUR);
@@ -366,8 +366,8 @@ bool ArjFile::open(const Common::String &filename) {
archiveFile.seek(hdr->pos, SEEK_SET);
if (hdr->method == 0) { // store
- int32 len = archiveFile.read(uncompressedData, hdr->origSize);
- assert(len == hdr->origSize);
+ int32 len = archiveFile.read(uncompressedData, hdr->origSize);
+ assert(len == hdr->origSize);
} else {
ArjDecoder *decoder = new ArjDecoder(hdr);
@@ -381,7 +381,7 @@ bool ArjFile::open(const Common::String &filename) {
decoder->decode(hdr->origSize);
else if (hdr->method == 4)
decoder->decode_f(hdr->origSize);
-
+
delete decoder;
}
@@ -434,7 +434,7 @@ void ArjDecoder::init_getbits() {
}
//
-// Source for fillbuf, getbits: decode.c
+// Source for fillbuf, getbits: decode.c
//
void ArjDecoder::fillbuf(int n) {
@@ -734,7 +734,7 @@ int16 ArjDecoder::decode_ptr() {
int16 pwr;
plus = 0;
- pwr = 1 << 9;
+ pwr = 1 << 9;
for (width = 9; width < 13; width++) {
c = getbits(1);
if (c == 0)
diff --git a/common/unzip.h b/common/unzip.h
index 9a6d957d57..309310ade1 100644
--- a/common/unzip.h
+++ b/common/unzip.h
@@ -42,7 +42,7 @@ public:
ZipArchive(const FSNode &node);
ZipArchive(SeekableReadStream *stream);
~ZipArchive();
-
+
bool isOpen() const;
virtual bool hasFile(const String &name);
diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp
index 3671feec2d..516f4bfcdf 100644
--- a/common/xmlparser.cpp
+++ b/common/xmlparser.cpp
@@ -36,21 +36,21 @@ using namespace Graphics;
bool XMLParser::parserError(const char *errorString, ...) {
_state = kParserError;
-
+
const int startPosition = _stream->pos();
int currentPosition = startPosition;
int lineCount = 1;
char c = 0;
-
+
_stream->seek(0, SEEK_SET);
-
+
while (currentPosition--) {
c = _stream->readByte();
-
+
if (c == '\n' || c == '\r')
lineCount++;
}
-
+
assert(_stream->pos() == startPosition);
currentPosition = startPosition;
@@ -75,9 +75,9 @@ bool XMLParser::parserError(const char *errorString, ...) {
if (c == '>')
keyClosing = currentPosition;
}
-
+
fprintf(stderr, "\n File <%s>, line %d:\n", _fileName.c_str(), lineCount);
-
+
currentPosition = (keyClosing - keyOpening);
_stream->seek(keyOpening, SEEK_SET);
@@ -98,16 +98,16 @@ bool XMLParser::parserError(const char *errorString, ...) {
bool XMLParser::parseXMLHeader(ParserNode *node) {
assert(node->header);
-
+
if (_activeKey.size() != 1)
return parserError("XML Header is expected in the global scope.");
-
+
if (!node->values.contains("version"))
return parserError("Missing XML version in XML header.");
-
+
if (node->values["version"] != "1.0")
return parserError("Unsupported XML version.");
-
+
return true;
}
@@ -116,30 +116,30 @@ bool XMLParser::parseActiveKey(bool closed) {
assert(_activeKey.empty() == false);
ParserNode *key = _activeKey.top();
-
+
if (key->name == "xml" && key->header == true) {
assert(closed);
return parseXMLHeader(key) && closeKey();
}
-
+
XMLKeyLayout *layout = (_activeKey.size() == 1) ? _XMLkeys : getParentNode(key)->layout;
-
+
if (layout->children.contains(key->name)) {
key->layout = layout->children[key->name];
-
+
Common::StringMap localMap = key->values;
int keyCount = localMap.size();
-
+
for (Common::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());
else if (localMap.contains(i->name))
keyCount--;
}
-
+
if (keyCount > 0)
return parserError("Unhandled property inside key '%s'.", key->name.c_str());
-
+
} else {
return parserError("Unexpected key in the active scope ('%s').", key->name.c_str());
}
@@ -157,10 +157,10 @@ bool XMLParser::parseActiveKey(bool closed) {
// We set it manually in that case.
if (_state != kParserError)
parserError("Unhandled exception when parsing '%s' key.", key->name.c_str());
-
+
return false;
}
-
+
if (closed)
return closeKey();
@@ -201,17 +201,17 @@ bool XMLParser::parseKeyValue(Common::String keyName) {
bool XMLParser::closeKey() {
bool ignore = false;
bool result = true;
-
+
for (int i = _activeKey.size() - 1; i >= 0; --i) {
if (_activeKey[i]->ignore)
ignore = true;
}
-
+
if (ignore == false)
result = closedKeyCallback(_activeKey.top());
-
+
freeNode(_activeKey.pop());
-
+
return result;
}
@@ -219,7 +219,7 @@ bool XMLParser::parse() {
if (_stream == 0)
return parserError("XML stream not ready for reading.");
-
+
if (_XMLkeys == 0)
buildLayout();
@@ -236,7 +236,7 @@ bool XMLParser::parse() {
_activeKey.clear();
_char = _stream->readByte();
-
+
while (_char && _state != kParserError) {
if (skipSpaces())
continue;
@@ -262,7 +262,7 @@ bool XMLParser::parse() {
parserError("Expecting XML header.");
break;
}
-
+
_char = _stream->readByte();
activeHeader = true;
} else if (_char == '/') {
@@ -303,7 +303,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 '%s'.", _activeKey.top()->name.c_str());
break;
}
@@ -311,13 +311,13 @@ bool XMLParser::parse() {
if (_char != '>')
parserError("Invalid syntax in key closure.");
- else
+ else
_state = kParserNeedKey;
_char = _stream->readByte();
break;
}
-
+
selfClosure = false;
if (_char == '/' || (_char == '?' && activeHeader)) {
@@ -332,33 +332,33 @@ bool XMLParser::parse() {
_char = _stream->readByte();
_state = kParserNeedKey;
}
-
+
activeHeader = false;
break;
}
-
+
if (selfClosure)
parserError("Expecting key closure after '/' symbol.");
- else if (!parseToken())
+ else if (!parseToken())
parserError("Error when parsing key value.");
- else
+ else
_state = kParserNeedPropertyOperator;
break;
case kParserNeedPropertyOperator:
- if (_char != '=')
+ if (_char != '=')
parserError("Syntax error after key name.");
- else
+ else
_state = kParserNeedPropertyValue;
_char = _stream->readByte();
break;
case kParserNeedPropertyValue:
- if (!parseKeyValue(_token))
+ if (!parseKeyValue(_token))
parserError("Invalid key value.");
- else
+ else
_state = kParserNeedPropertyName;
break;
diff --git a/common/xmlparser.h b/common/xmlparser.h
index ca01c4df0e..435e7c7e0c 100644
--- a/common/xmlparser.h
+++ b/common/xmlparser.h
@@ -39,7 +39,7 @@
namespace Common {
-
+
/*
XMLParser.cpp/h -- Generic XML Parser
=====================================
@@ -49,14 +49,14 @@ namespace Common {
*/
#define MAX_XML_DEPTH 8
-
+
#define XML_KEY(keyName) {\
lay = new CustomXMLKeyLayout;\
lay->callback = (&kLocalParserName::parserCallback_##keyName);\
layout.top()->children[#keyName] = lay;\
layout.push(lay); \
_layoutList.push_back(lay);
-
+
#define XML_KEY_RECURSIVE(keyName) {\
layout.top()->children[#keyName] = layout.top();\
layout.push(layout.top());\
@@ -68,9 +68,9 @@ namespace Common {
prop.name = #propName; \
prop.required = req; \
layout.top()->properties.push_back(prop); }
-
-
+
+
#define CUSTOM_XML_PARSER(parserName) \
protected: \
typedef parserName kLocalParserName; \
@@ -85,7 +85,7 @@ namespace Common {
XMLKeyLayout::XMLKeyProperty prop; \
_XMLkeys = new CustomXMLKeyLayout; \
layout.push(_XMLkeys);
-
+
#define PARSER_END() layout.clear(); }
/**
@@ -132,29 +132,29 @@ public:
kParserError
};
-
+
struct XMLKeyLayout;
struct ParserNode;
-
+
typedef Common::HashMap<Common::String, XMLParser::XMLKeyLayout*, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ChildMap;
-
+
/** nested struct representing the layout of the XML file */
struct XMLKeyLayout {
struct XMLKeyProperty {
Common::String name;
bool required;
};
-
+
Common::List<XMLKeyProperty> properties;
ChildMap children;
-
+
virtual bool doCallback(XMLParser *parent, ParserNode *node) = 0;
-
+
virtual ~XMLKeyLayout() {
properties.clear();
}
};
-
+
XMLKeyLayout *_XMLkeys;
/** Struct representing a parsed node */
@@ -166,12 +166,12 @@ public:
int depth;
XMLKeyLayout *layout;
};
-
+
ObjectPool<ParserNode, MAX_XML_DEPTH> _nodePool;
ParserNode *allocNode() {
return new (_nodePool) ParserNode;
- }
+ }
void freeNode(ParserNode *node) {
_nodePool.deleteChunk(node);
@@ -192,12 +192,12 @@ public:
_fileName = filename;
return true;
}
-
+
bool loadFile(const FSNode &node) {
_stream = node.openForReading();
if (!_stream)
return false;
-
+
_fileName = node.getName();
return true;
}
@@ -218,13 +218,13 @@ public:
_fileName = "Memory Stream";
return true;
}
-
+
bool loadStream(Common::SeekableReadStream *stream) {
_stream = stream;
_fileName = "File Stream";
return true;
}
-
+
void close() {
delete _stream;
_stream = 0;
@@ -255,7 +255,7 @@ public:
}
protected:
-
+
/**
* The buildLayout function builds the layout for the parser to use
* based on a series of helper macros. This function is automatically
@@ -264,10 +264,10 @@ protected:
* See the documentation regarding XML layouts.
*/
virtual void buildLayout() = 0;
-
+
/**
* The keycallback function is automatically overloaded on custom parsers
- * when using the CUSTOM_XML_PARSER() macro.
+ * when using the CUSTOM_XML_PARSER() macro.
*
* Its job is to call the corresponding Callback function for the given node.
* A function for each key type must be declared separately. See the custom
@@ -301,7 +301,7 @@ protected:
virtual bool closedKeyCallback(ParserNode *node) {
return true;
}
-
+
/**
* Called when a node is closed. Manages its cleanup and calls the
* closing callback function if needed.
@@ -354,10 +354,10 @@ protected:
_char = '<';
return false;
}
-
+
if (_stream->readByte() != '-' || _stream->readByte() != '-')
return parserError("Malformed comment syntax.");
-
+
_char = _stream->readByte();
bool dash = false;
@@ -367,13 +367,13 @@ protected:
_char = _stream->readByte();
return true;
}
-
+
dash = !dash;
}
-
+
_char = _stream->readByte();
}
-
+
return parserError("Comment has no closure.");
}
@@ -448,12 +448,12 @@ protected:
va_end(args);
return (*key == 0);
}
-
+
bool parseXMLHeader(ParserNode *node);
/**
* Overload if your parser needs to support parsing the same file
- * several times, so you can clean up the internal state of the
+ * several times, so you can clean up the internal state of the
* parser before each parse.
*/
virtual void cleanup() {}
diff --git a/common/zlib.cpp b/common/zlib.cpp
index 4ed233b4b0..519b7c4806 100644
--- a/common/zlib.cpp
+++ b/common/zlib.cpp
@@ -161,7 +161,7 @@ public:
case SEEK_CUR:
newPos = _pos + offset;
}
-
+
assert(newPos >= 0);
if ((uint32)newPos < _pos) {
@@ -189,7 +189,7 @@ public:
while (!err() && offset > 0) {
offset -= read(tmpBuf, MIN((int32)sizeof(tmpBuf), offset));
}
-
+
_eos = false;
return true; // FIXME: STREAM REWRITE
}
@@ -242,7 +242,7 @@ public:
Z_DEFLATED,
MAX_WBITS + 16,
8,
- Z_DEFAULT_STRATEGY);
+ Z_DEFAULT_STRATEGY);
assert(_zlibErr == Z_OK);
_stream.next_out = _buf;
diff --git a/common/zlib.h b/common/zlib.h
index 5fd13e842d..4da357d23c 100644
--- a/common/zlib.h
+++ b/common/zlib.h
@@ -37,7 +37,7 @@ namespace Common {
* Thin wrapper around zlib's uncompress() function. This wrapper makes
* it possible to uncompress data in engines without being forced to link
* them against zlib, thus simplifying the build system.
- *
+ *
* @return true on success (i.e. Z_OK), false otherwise
*/
bool uncompress(byte *dst, unsigned long *dstLen, const byte *src, unsigned long srcLen);