From bbf0bbcd646873bf89516ec13fc8c671531e3c00 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Wed, 5 Sep 2012 22:57:10 -0400 Subject: COMMON: Allow for parsing QuickTime MIDI files --- common/quicktime.cpp | 4 ++++ common/quicktime.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/quicktime.cpp b/common/quicktime.cpp index 173d3c6a97..5ac9bee40f 100644 --- a/common/quicktime.cpp +++ b/common/quicktime.cpp @@ -165,6 +165,8 @@ void QuickTimeParser::initParseTable() { { &QuickTimeParser::readWAVE, MKTAG('w', 'a', 'v', 'e') }, { &QuickTimeParser::readESDS, MKTAG('e', 's', 'd', 's') }, { &QuickTimeParser::readSMI, MKTAG('S', 'M', 'I', ' ') }, + { &QuickTimeParser::readDefault, MKTAG('g', 'm', 'h', 'd') }, + { &QuickTimeParser::readLeaf, MKTAG('g', 'm', 'i', 'n') }, { 0, 0 } }; @@ -477,6 +479,8 @@ int QuickTimeParser::readHDLR(Atom atom) { track->codecType = CODEC_TYPE_VIDEO; else if (type == MKTAG('s', 'o', 'u', 'n')) track->codecType = CODEC_TYPE_AUDIO; + else if (type == MKTAG('m', 'u', 's', 'i')) + track->codecType = CODEC_TYPE_MIDI; _fd->readUint32BE(); // component manufacture _fd->readUint32BE(); // component flags diff --git a/common/quicktime.h b/common/quicktime.h index 08ca35ad51..5a02fc8afb 100644 --- a/common/quicktime.h +++ b/common/quicktime.h @@ -120,7 +120,8 @@ protected: enum CodecType { CODEC_TYPE_MOV_OTHER, CODEC_TYPE_VIDEO, - CODEC_TYPE_AUDIO + CODEC_TYPE_AUDIO, + CODEC_TYPE_MIDI }; struct Track { -- cgit v1.2.3 From 4a458236f625d28706cfe4560690770a395ee6e3 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 9 Sep 2012 13:47:40 -0400 Subject: COMMON: Make QuickTimeParser::readSampleDesc take the desc size --- common/quicktime.cpp | 2 +- common/quicktime.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/quicktime.cpp b/common/quicktime.cpp index 5ac9bee40f..5b3659b0d5 100644 --- a/common/quicktime.cpp +++ b/common/quicktime.cpp @@ -544,7 +544,7 @@ int QuickTimeParser::readSTSD(Atom atom) { _fd->readUint16BE(); // reserved _fd->readUint16BE(); // index - track->sampleDescs[i] = readSampleDesc(track, format); + track->sampleDescs[i] = readSampleDesc(track, format, size - 16); debug(0, "size=%d 4CC= %s codec_type=%d", size, tag2str(format), track->codecType); diff --git a/common/quicktime.h b/common/quicktime.h index 5a02fc8afb..0948a5010f 100644 --- a/common/quicktime.h +++ b/common/quicktime.h @@ -162,7 +162,7 @@ protected: byte objectTypeMP4; }; - virtual SampleDesc *readSampleDesc(Track *track, uint32 format) = 0; + virtual SampleDesc *readSampleDesc(Track *track, uint32 format, uint32 descSize) = 0; uint32 _timeScale; uint32 _duration; -- cgit v1.2.3 From 6b6e6c92c7c797560745651c1b16f1b5764bf297 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Thu, 13 Dec 2012 00:02:22 -0500 Subject: COMMON: Fix potential uninitialized memory usage --- common/macresman.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/macresman.cpp b/common/macresman.cpp index f2f020c6de..00562f746a 100644 --- a/common/macresman.cpp +++ b/common/macresman.cpp @@ -360,8 +360,8 @@ bool MacResManager::load(SeekableReadStream &stream) { _mapLength = stream.readUint32BE(); // do sanity check - if (_dataOffset >= (uint32)stream.size() || _mapOffset >= (uint32)stream.size() || - _dataLength + _mapLength > (uint32)stream.size()) { + if (stream.eos() || _dataOffset >= (uint32)stream.size() || _mapOffset >= (uint32)stream.size() || + _dataLength + _mapLength > (uint32)stream.size()) { _resForkOffset = -1; _mode = kResForkNone; return false; -- cgit v1.2.3 From b0ba4b01a4fee3409768bdced4de6719b51297bc Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 13 Dec 2012 20:52:09 +0100 Subject: COMMON: Add wrapper for isprint. This is done in the spirit of 658080deeda79d20ea40643569fbcb072573e7cf. --- common/forbidden.h | 5 +++++ common/str.cpp | 2 +- common/util.cpp | 5 +++++ common/util.h | 13 ++++++++++++- 4 files changed, 23 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/forbidden.h b/common/forbidden.h index eec80bba59..46890e0269 100644 --- a/common/forbidden.h +++ b/common/forbidden.h @@ -358,6 +358,11 @@ #define isupper(a) FORBIDDEN_SYMBOL_REPLACEMENT #endif + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_isprint + #undef isprint + #define isprint(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + #endif // FORBIDDEN_SYMBOL_EXCEPTION_ctype_h #ifndef FORBIDDEN_SYMBOL_EXCEPTION_mkdir diff --git a/common/str.cpp b/common/str.cpp index 84805082ac..8210ca6bb8 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -764,7 +764,7 @@ String tag2string(uint32 tag) { str[4] = '\0'; // Replace non-printable chars by dot for (int i = 0; i < 4; ++i) { - if (!isprint((unsigned char)str[i])) + if (!Common::isPrint(str[i])) str[i] = '.'; } return String(str); diff --git a/common/util.cpp b/common/util.cpp index 4d9ff11c5c..3d40fffff5 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -26,6 +26,7 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_islower #define FORBIDDEN_SYMBOL_EXCEPTION_isspace #define FORBIDDEN_SYMBOL_EXCEPTION_isupper +#define FORBIDDEN_SYMBOL_EXCEPTION_isprint #include "common/util.h" @@ -144,4 +145,8 @@ bool isUpper(int c) { return isupper((byte)c); } +bool isPrint(int c) { + ENSURE_ASCII_CHAR(c); + return isprint((byte)c); +} } // End of namespace Common diff --git a/common/util.h b/common/util.h index 78340980d5..4ca1c42929 100644 --- a/common/util.h +++ b/common/util.h @@ -165,6 +165,17 @@ bool isSpace(int c); */ bool isUpper(int c); -} // End of namespace Common +/** + * Test whether the given character is printable. This includes the space + * character (' '). + * + * If the parameter is outside the range of a signed or unsigned char, then + * false is returned. + * + * @param c the character to test + * @return true if the character is printable, false otherwise. + */ +bool isPrint(int c); +} // End of namespace Common #endif -- cgit v1.2.3 From 2773f5d7afc381205b5e0fcb8b20700007472516 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 13 Dec 2012 20:58:55 +0100 Subject: COMMON: Forbid symbols for the rest of is* from ctype.h. I also moved the isprint case to the correct position. This adds a FIXME to our lua code from sword25, which uses iscntrl directly. --- common/forbidden.h | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/forbidden.h b/common/forbidden.h index 46890e0269..9050114442 100644 --- a/common/forbidden.h +++ b/common/forbidden.h @@ -333,11 +333,21 @@ #define isalpha(a) FORBIDDEN_SYMBOL_REPLACEMENT #endif + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_iscntrl + #undef iscntrl + #define iscntrl(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_isdigit #undef isdigit #define isdigit(a) FORBIDDEN_SYMBOL_REPLACEMENT #endif + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_isgraph + #undef isgraph + #define isgraph(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_isnumber #undef isnumber #define isnumber(a) FORBIDDEN_SYMBOL_REPLACEMENT @@ -348,6 +358,16 @@ #define islower(a) FORBIDDEN_SYMBOL_REPLACEMENT #endif + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_isprint + #undef isprint + #define isprint(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_ispunct + #undef ispunct + #define ispunct(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_isspace #undef isspace #define isspace(a) FORBIDDEN_SYMBOL_REPLACEMENT @@ -358,9 +378,9 @@ #define isupper(a) FORBIDDEN_SYMBOL_REPLACEMENT #endif - #ifndef FORBIDDEN_SYMBOL_EXCEPTION_isprint - #undef isprint - #define isprint(a) FORBIDDEN_SYMBOL_REPLACEMENT + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_isxdigit + #undef isxdigit + #define isxdigit(a) FORBIDDEN_SYMBOL_REPLACEMENT #endif #endif // FORBIDDEN_SYMBOL_EXCEPTION_ctype_h -- cgit v1.2.3 From f01d4c5aa84d80bac1355f8b709f4e1244fec3dc Mon Sep 17 00:00:00 2001 From: Tomas Jakobsson Date: Sun, 30 Dec 2012 19:33:59 +0100 Subject: COMMON: Add PackBitsReadStream to iff_container --- common/iff_container.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ common/iff_container.h | 41 +++++++++++++++++++++++++++++++++-------- 2 files changed, 80 insertions(+), 8 deletions(-) (limited to 'common') diff --git a/common/iff_container.cpp b/common/iff_container.cpp index 7bcbf86e0f..ffaa5c6d06 100644 --- a/common/iff_container.cpp +++ b/common/iff_container.cpp @@ -22,6 +22,7 @@ #include "common/iff_container.h" #include "common/substream.h" +#include "common/util.h" namespace Common { @@ -75,4 +76,50 @@ void IFFParser::parse(IFFCallback &callback) { } while (!stop); } + +PackBitsReadStream::PackBitsReadStream(Common::ReadStream &input) : _input(&input) { +} + +PackBitsReadStream::~PackBitsReadStream() { +} + +bool PackBitsReadStream::eos() const { + return _input->eos(); +} + +uint32 PackBitsReadStream::read(void *dataPtr, uint32 dataSize) { + byte *out = (byte *)dataPtr; + uint32 left = dataSize; + + uint32 lenR = 0, lenW = 0; + while (left > 0 && !_input->eos()) { + lenR = _input->readByte(); + + if (lenR == 128) { + // no-op + lenW = 0; + } else if (lenR <= 127) { + // literal run + lenR++; + lenW = MIN(lenR, left); + for (uint32 j = 0; j < lenW; j++) { + *out++ = _input->readByte(); + } + for (; lenR > lenW; lenR--) { + _input->readByte(); + } + } else { // len > 128 + // expand run + lenW = MIN((256 - lenR) + 1, left); + byte val = _input->readByte(); + memset(out, val, lenW); + out += lenW; + } + + left -= lenW; + } + + return dataSize - left; +} + } // End of namespace Common diff --git a/common/iff_container.h b/common/iff_container.h index 104ecf0f36..a730930b2c 100644 --- a/common/iff_container.h +++ b/common/iff_container.h @@ -77,22 +77,22 @@ page 376) */ #define ID_copy MKTAG('(','c',')',' ') /* EA IFF 85 Generic Copyright text chunk */ -/* ILBM chunks */ +/* IFF chunks */ #define ID_BMHD MKTAG('B','M','H','D') -/* ILBM BitmapHeader */ +/* IFF BitmapHeader */ #define ID_CMAP MKTAG('C','M','A','P') -/* ILBM 8bit RGB colormap */ +/* IFF 8bit RGB colormap */ #define ID_GRAB MKTAG('G','R','A','B') -/* ILBM "hotspot" coordiantes */ +/* IFF "hotspot" coordiantes */ #define ID_DEST MKTAG('D','E','S','T') -/* ILBM destination image info */ +/* IFF destination image info */ #define ID_SPRT MKTAG('S','P','R','T') -/* ILBM sprite identifier */ +/* IFF sprite identifier */ #define ID_CAMG MKTAG('C','A','M','G') /* Amiga viewportmodes */ #define ID_BODY MKTAG('B','O','D','Y') -/* ILBM image data */ +/* IFF image data */ #define ID_CRNG MKTAG('C','R','N','G') /* color cycling */ #define ID_CCRT MKTAG('C','C','R','T') @@ -114,7 +114,7 @@ page 376) */ #define ID_PCHG MKTAG('P','C','H','G') /* Line by line palette control information (Sebastiano Vigna) */ #define ID_PRVW MKTAG('P','R','V','W') -/* A mini duplicate ILBM used for preview (Gary Bonham) */ +/* A mini duplicate IFF used for preview (Gary Bonham) */ #define ID_XBMI MKTAG('X','B','M','I') /* eXtended BitMap Information (Soft-Logik) */ #define ID_CTBL MKTAG('C','T','B','L') @@ -239,6 +239,31 @@ public: }; +/** + * Decode a given PackBits encoded stream. + * + * PackBits is an RLE compression algorithm introduced by Apple. It is also + * used to encode ILBM and PBM subtypes of IFF files, and some flavors of + * TIFF. + * + * As there is no compression across row boundaries in the above formats, + * read() will extract a *new* line on each call, discarding any alignment + * or padding. + */ +class PackBitsReadStream : public Common::ReadStream { + +protected: + Common::ReadStream *_input; + +public: + PackBitsReadStream(Common::ReadStream &input); + ~PackBitsReadStream(); + + virtual bool eos() const; + + uint32 read(void *dataPtr, uint32 dataSize); +}; + } // namespace Common #endif -- cgit v1.2.3 From 178365f5e934ef7b5866a0cae244c5a4f0ab0344 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 9 Jan 2013 07:36:05 +0100 Subject: COMMON: Add a header for C++11 keywords for pre-C++11 compilers. This currently adds defines for nullptr and override, so we can use them in pre-C++11 compilers, while taking advantage of them with C++11 compilers. --- common/c++11-compat.h | 42 ++++++++++++++++++++++++++++++++++++++++++ common/scummsys.h | 5 ++++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 common/c++11-compat.h (limited to 'common') diff --git a/common/c++11-compat.h b/common/c++11-compat.h new file mode 100644 index 0000000000..50d79bd79e --- /dev/null +++ b/common/c++11-compat.h @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef COMMON_CPP11_COMPAT_H +#define COMMON_CPP11_COMPAT_H + +#if __cplusplus >= 201103L +#error "c++11-compat.h included when C++11 is available" +#endif + +// +// Custom nullptr replacement. This is not type safe as the real C++11 nullptr +// though. +// +#define nullptr 0 + +// +// Replacement for the override keyword. This allows compilation of code +// which uses it, but does not feature any semantic. +// +#define override + +#endif diff --git a/common/scummsys.h b/common/scummsys.h index 2f4efe702f..cd8a949ce7 100644 --- a/common/scummsys.h +++ b/common/scummsys.h @@ -144,7 +144,10 @@ #endif #endif - +// Include our C++11 compatability header for pre-C++11 compilers. +#if __cplusplus < 201103L +#include "common/c++11-compat.h" +#endif // Use config.h, generated by configure #if defined(HAVE_CONFIG_H) -- cgit v1.2.3 From 5d4d65d6d9316b17a3d72fb11bbcca0b3a0f45ef Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 24 Jan 2013 20:15:13 +0100 Subject: JANITORIAL: Fix ){ -> ) { --- common/quicktime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/quicktime.cpp b/common/quicktime.cpp index 5b3659b0d5..a3efc2b443 100644 --- a/common/quicktime.cpp +++ b/common/quicktime.cpp @@ -444,7 +444,7 @@ int QuickTimeParser::readELST(Atom atom) { uint32 offset = 0; - for (uint32 i = 0; i < track->editCount; i++){ + for (uint32 i = 0; i < track->editCount; i++) { track->editList[i].trackDuration = _fd->readUint32BE(); track->editList[i].mediaTime = _fd->readSint32BE(); track->editList[i].mediaRate = Rational(_fd->readUint32BE(), 0x10000); -- cgit v1.2.3 From 36bfaa6a308654862c5d233fe4e86d9f8c4c02bd Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 15 Jul 2012 02:36:47 +0200 Subject: COMMON: Return NULL in wrapCompressedReadStream for compressed streams when ZLIB is disabled. --- common/zlib.cpp | 10 +++++++--- common/zlib.h | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/zlib.cpp b/common/zlib.cpp index fc8f351054..62904cb150 100644 --- a/common/zlib.cpp +++ b/common/zlib.cpp @@ -392,17 +392,21 @@ public: #endif // USE_ZLIB SeekableReadStream *wrapCompressedReadStream(SeekableReadStream *toBeWrapped, uint32 knownSize) { -#if defined(USE_ZLIB) if (toBeWrapped) { uint16 header = toBeWrapped->readUint16BE(); bool isCompressed = (header == 0x1F8B || ((header & 0x0F00) == 0x0800 && header % 31 == 0)); toBeWrapped->seek(-2, SEEK_CUR); - if (isCompressed) + if (isCompressed) { +#if defined(USE_ZLIB) return new GZipReadStream(toBeWrapped, knownSize); - } +#else + delete toBeWrapped; + return NULL; #endif + } + } return toBeWrapped; } diff --git a/common/zlib.h b/common/zlib.h index 6a840f5fdc..2772ffba06 100644 --- a/common/zlib.h +++ b/common/zlib.h @@ -103,7 +103,9 @@ bool inflateZlibInstallShield(byte *dst, uint dstLen, const byte *src, uint srcL * provides transparent on-the-fly decompression. Assumes the data it * retrieves from the wrapped stream to be either uncompressed or in gzip * format. In the former case, the original stream is returned unmodified - * (and in particular, not wrapped). + * (and in particular, not wrapped). In the latter case the stream is + * returned wrapped, unless there is no ZLIB support, then NULL is returned + * and the old stream is destroyed. * * Certain GZip-formats don't supply an easily readable length, if you * still need the length carried along with the stream, and you know -- cgit v1.2.3 From edfcd768ba394150df34d59f08765c3e061e6c72 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Sat, 26 Jan 2013 19:00:22 +0100 Subject: COMMON: Make BufferedSeekableReadStream use the buffer with SEEK_SET and SEEK_END --- common/stream.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/stream.cpp b/common/stream.cpp index 85647bfe3a..d3cfce4066 100644 --- a/common/stream.cpp +++ b/common/stream.cpp @@ -379,12 +379,25 @@ BufferedSeekableReadStream::BufferedSeekableReadStream(SeekableReadStream *paren bool BufferedSeekableReadStream::seek(int32 offset, int whence) { // If it is a "local" seek, we may get away with "seeking" around // in the buffer only. - // Note: We could try to handle SEEK_END and SEEK_SET, too, but - // since they are rarely used, it seems not worth the effort. _eos = false; // seeking always cancels EOS - if (whence == SEEK_CUR && (int)_pos + offset >= 0 && _pos + offset <= _bufSize) { - _pos += offset; + int relOffset = 0; + switch (whence) { + case SEEK_SET: + relOffset = offset - pos(); + break; + case SEEK_CUR: + relOffset = offset; + break; + case SEEK_END: + relOffset = (size() + offset) - pos(); + break; + default: + break; + } + + if ((int)_pos + relOffset >= 0 && _pos + relOffset <= _bufSize) { + _pos += relOffset; // Note: we do not need to reset parent's eos flag here. It is // sufficient that it is reset when actually seeking in the parent. -- cgit v1.2.3 From b4d0a8ba66e2c99949d1fa14d801c7de77db76ba Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 26 Jan 2013 19:33:27 +0100 Subject: JANITORIAL: Enforce "} // End of namespace" with a single space after }. --- common/bufferedstream.h | 2 +- common/config-file.cpp | 2 +- common/config-file.h | 2 +- common/config-manager.h | 2 +- common/debug-channels.h | 2 +- common/debug.cpp | 2 +- common/file.cpp | 2 +- common/fs.cpp | 2 +- common/func.h | 2 +- common/hash-str.h | 2 +- common/hashmap.cpp | 2 +- common/hashmap.h | 2 +- common/iff_container.cpp | 2 +- common/language.h | 2 +- common/memorypool.h | 2 +- common/memstream.h | 2 +- common/mutex.cpp | 2 +- common/platform.h | 2 +- common/random.cpp | 2 +- common/random.h | 2 +- common/rect.h | 2 +- common/singleton.h | 2 +- common/str.cpp | 2 +- common/stream.cpp | 8 ++++---- common/stream.h | 2 +- common/taskbar.h | 2 +- common/textconsole.cpp | 2 +- common/textconsole.h | 2 +- common/unzip.cpp | 2 +- common/unzip.h | 2 +- common/updates.h | 2 +- common/zlib.cpp | 2 +- common/zlib.h | 2 +- 33 files changed, 36 insertions(+), 36 deletions(-) (limited to 'common') diff --git a/common/bufferedstream.h b/common/bufferedstream.h index 55ea8dc13b..6c859c98fe 100644 --- a/common/bufferedstream.h +++ b/common/bufferedstream.h @@ -61,6 +61,6 @@ SeekableReadStream *wrapBufferedSeekableReadStream(SeekableReadStream *parentStr */ WriteStream *wrapBufferedWriteStream(WriteStream *parentStream, uint32 bufSize); -} // End of namespace Common +} // End of namespace Common #endif diff --git a/common/config-file.cpp b/common/config-file.cpp index 4224d7491d..fe042e9eda 100644 --- a/common/config-file.cpp +++ b/common/config-file.cpp @@ -380,4 +380,4 @@ void ConfigFile::Section::removeKey(const String &key) { } } -} // End of namespace Common +} // End of namespace Common diff --git a/common/config-file.h b/common/config-file.h index 7bc5604b4c..8bd731c038 100644 --- a/common/config-file.h +++ b/common/config-file.h @@ -134,6 +134,6 @@ private: */ -} // End of namespace Common +} // End of namespace Common #endif diff --git a/common/config-manager.h b/common/config-manager.h index 02d4ec3438..d43a7bec51 100644 --- a/common/config-manager.h +++ b/common/config-manager.h @@ -175,7 +175,7 @@ private: String _filename; }; -} // End of namespace Common +} // End of namespace Common /** Shortcut for accessing the configuration manager. */ #define ConfMan Common::ConfigManager::instance() diff --git a/common/debug-channels.h b/common/debug-channels.h index 54de9d491e..40d1ea667e 100644 --- a/common/debug-channels.h +++ b/common/debug-channels.h @@ -124,6 +124,6 @@ private: /** Shortcut for accessing the debug manager. */ #define DebugMan Common::DebugManager::instance() -} // End of namespace Common +} // End of namespace Common #endif diff --git a/common/debug.cpp b/common/debug.cpp index 9c3a93e5a6..ba5479c34d 100644 --- a/common/debug.cpp +++ b/common/debug.cpp @@ -102,7 +102,7 @@ bool DebugManager::isDebugChannelEnabled(uint32 channel) { return (gDebugChannelsEnabled & channel) != 0; } -} // End of namespace Common +} // End of namespace Common #ifndef DISABLE_TEXT_CONSOLE diff --git a/common/file.cpp b/common/file.cpp index 12d73c9973..7ad6bc2e81 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -202,4 +202,4 @@ bool DumpFile::flush() { return _handle->flush(); } -} // End of namespace Common +} // End of namespace Common diff --git a/common/fs.cpp b/common/fs.cpp index 0143c936d4..19a01074ea 100644 --- a/common/fs.cpp +++ b/common/fs.cpp @@ -335,4 +335,4 @@ int FSDirectory::listMembers(ArchiveMemberList &list) const { } -} // End of namespace Common +} // End of namespace Common diff --git a/common/func.h b/common/func.h index db57d73668..a4a80e5406 100644 --- a/common/func.h +++ b/common/func.h @@ -535,6 +535,6 @@ GENERATE_TRIVIAL_HASH_FUNCTOR(unsigned long); #undef GENERATE_TRIVIAL_HASH_FUNCTOR -} // End of namespace Common +} // End of namespace Common #endif diff --git a/common/hash-str.h b/common/hash-str.h index 08f0558bfd..190e6922eb 100644 --- a/common/hash-str.h +++ b/common/hash-str.h @@ -79,7 +79,7 @@ typedef HashMap StringMap; -} // End of namespace Common +} // End of namespace Common #endif diff --git a/common/hashmap.cpp b/common/hashmap.cpp index ff8f9db9ce..e505d1dd25 100644 --- a/common/hashmap.cpp +++ b/common/hashmap.cpp @@ -106,4 +106,4 @@ void updateHashCollisionStats(int collisions, int dummyHits, int lookups, int ar } #endif -} // End of namespace Common +} // End of namespace Common diff --git a/common/hashmap.h b/common/hashmap.h index 7cf54997e8..42509d67e5 100644 --- a/common/hashmap.h +++ b/common/hashmap.h @@ -632,6 +632,6 @@ void HashMap::erase(const Key &key) { #undef HASHMAP_DUMMY_NODE -} // End of namespace Common +} // End of namespace Common #endif diff --git a/common/iff_container.cpp b/common/iff_container.cpp index ffaa5c6d06..9c6e5f124a 100644 --- a/common/iff_container.cpp +++ b/common/iff_container.cpp @@ -122,4 +122,4 @@ uint32 PackBitsReadStream::read(void *dataPtr, uint32 dataSize) { return dataSize - left; } -} // End of namespace Common +} // End of namespace Common diff --git a/common/language.h b/common/language.h index db552fc9c4..03b9ebaf8e 100644 --- a/common/language.h +++ b/common/language.h @@ -81,6 +81,6 @@ const String getGameGUIOptionsDescriptionLanguage(Common::Language lang); // TODO: Document this GUIO related function bool checkGameGUIOptionLanguage(Common::Language lang, const String &str); -} // End of namespace Common +} // End of namespace Common #endif diff --git a/common/memorypool.h b/common/memorypool.h index 9a4e523d53..1cd725b99d 100644 --- a/common/memorypool.h +++ b/common/memorypool.h @@ -141,7 +141,7 @@ public: } }; -} // End of namespace Common +} // End of namespace Common /** * A custom placement new operator, using an arbitrary MemoryPool. diff --git a/common/memstream.h b/common/memstream.h index 497a178ab9..260fb64d84 100644 --- a/common/memstream.h +++ b/common/memstream.h @@ -173,6 +173,6 @@ public: bool seek(int32 offset, int whence = SEEK_SET); }; -} // End of namespace Common +} // End of namespace Common #endif diff --git a/common/mutex.cpp b/common/mutex.cpp index 4e6316528c..f912e79591 100644 --- a/common/mutex.cpp +++ b/common/mutex.cpp @@ -75,4 +75,4 @@ void StackLock::unlock() { g_system->unlockMutex(_mutex); } -} // End of namespace Common +} // End of namespace Common diff --git a/common/platform.h b/common/platform.h index 1891c7096d..5a4f3f1802 100644 --- a/common/platform.h +++ b/common/platform.h @@ -75,6 +75,6 @@ extern const char *getPlatformCode(Platform id); extern const char *getPlatformAbbrev(Platform id); extern const char *getPlatformDescription(Platform id); -} // End of namespace Common +} // End of namespace Common #endif diff --git a/common/random.cpp b/common/random.cpp index 55fa3cbd30..fd75534c44 100644 --- a/common/random.cpp +++ b/common/random.cpp @@ -59,4 +59,4 @@ uint RandomSource::getRandomNumberRng(uint min, uint max) { return getRandomNumber(max - min) + min; } -} // End of namespace Common +} // End of namespace Common diff --git a/common/random.h b/common/random.h index 90f2ed5cb0..c8aec58946 100644 --- a/common/random.h +++ b/common/random.h @@ -74,6 +74,6 @@ public: uint getRandomNumberRng(uint min, uint max); }; -} // End of namespace Common +} // End of namespace Common #endif diff --git a/common/rect.h b/common/rect.h index 8d1243f7e4..5790cf7c0f 100644 --- a/common/rect.h +++ b/common/rect.h @@ -266,6 +266,6 @@ struct Rect { } }; -} // End of namespace Common +} // End of namespace Common #endif diff --git a/common/singleton.h b/common/singleton.h index d7078360f3..6e47f119ba 100644 --- a/common/singleton.h +++ b/common/singleton.h @@ -97,6 +97,6 @@ protected: #define DECLARE_SINGLETON(T) \ template<> T *Singleton::_singleton = 0 -} // End of namespace Common +} // End of namespace Common #endif diff --git a/common/str.cpp b/common/str.cpp index 8210ca6bb8..61fdcfaf31 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -850,7 +850,7 @@ size_t strlcat(char *dst, const char *src, size_t size) { return dstLength + (src - srcStart); } -} // End of namespace Common +} // End of namespace Common // Portable implementation of stricmp / strcasecmp / strcmpi. // TODO: Rename this to Common::strcasecmp diff --git a/common/stream.cpp b/common/stream.cpp index 85647bfe3a..a240d4e790 100644 --- a/common/stream.cpp +++ b/common/stream.cpp @@ -342,7 +342,7 @@ uint32 BufferedReadStream::read(void *dataPtr, uint32 dataSize) { return alreadyRead + dataSize; } -} // End of nameless namespace +} // End of nameless namespace ReadStream *wrapBufferedReadStream(ReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream) { @@ -400,7 +400,7 @@ bool BufferedSeekableReadStream::seek(int32 offset, int whence) { return true; } -} // End of nameless namespace +} // End of nameless namespace SeekableReadStream *wrapBufferedSeekableReadStream(SeekableReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream) { if (parentStream) @@ -482,7 +482,7 @@ public: }; -} // End of nameless namespace +} // End of nameless namespace WriteStream *wrapBufferedWriteStream(WriteStream *parentStream, uint32 bufSize) { if (parentStream) @@ -490,4 +490,4 @@ WriteStream *wrapBufferedWriteStream(WriteStream *parentStream, uint32 bufSize) return 0; } -} // End of namespace Common +} // End of namespace Common diff --git a/common/stream.h b/common/stream.h index 26c04e5bf6..33ebc95a86 100644 --- a/common/stream.h +++ b/common/stream.h @@ -454,6 +454,6 @@ public: }; -} // End of namespace Common +} // End of namespace Common #endif diff --git a/common/taskbar.h b/common/taskbar.h index 6f28028e74..b4ec673739 100644 --- a/common/taskbar.h +++ b/common/taskbar.h @@ -136,7 +136,7 @@ public: virtual void clearError() {} }; -} // End of namespace Common +} // End of namespace Common #endif diff --git a/common/textconsole.cpp b/common/textconsole.cpp index ffa42e63a0..a721c121d5 100644 --- a/common/textconsole.cpp +++ b/common/textconsole.cpp @@ -40,7 +40,7 @@ void setErrorHandler(ErrorHandler handler) { } -} // End of namespace Common +} // End of namespace Common #ifndef DISABLE_TEXT_CONSOLE diff --git a/common/textconsole.h b/common/textconsole.h index 364c49b2e9..12f15e5e4b 100644 --- a/common/textconsole.h +++ b/common/textconsole.h @@ -56,7 +56,7 @@ typedef void (*ErrorHandler)(const char *msg); */ void setErrorHandler(ErrorHandler handler); -} // End of namespace Common +} // End of namespace Common void NORETURN_PRE error(const char *s, ...) GCC_PRINTF(1, 2) NORETURN_POST; diff --git a/common/unzip.cpp b/common/unzip.cpp index ab659343a2..69b9ff67cb 100644 --- a/common/unzip.cpp +++ b/common/unzip.cpp @@ -1534,4 +1534,4 @@ Archive *makeZipArchive(SeekableReadStream *stream) { return new ZipArchive(zipFile); } -} // End of namespace Common +} // End of namespace Common diff --git a/common/unzip.h b/common/unzip.h index 06480b0054..2e0dae831a 100644 --- a/common/unzip.h +++ b/common/unzip.h @@ -56,6 +56,6 @@ Archive *makeZipArchive(const FSNode &node); */ Archive *makeZipArchive(SeekableReadStream *stream); -} // End of namespace Common +} // End of namespace Common #endif diff --git a/common/updates.h b/common/updates.h index 4d58a216fb..0012808a17 100644 --- a/common/updates.h +++ b/common/updates.h @@ -95,7 +95,7 @@ public: virtual UpdateInterval getUpdateCheckInterval() { return kUpdateIntervalNotSupported; } }; -} // End of namespace Common +} // End of namespace Common #endif diff --git a/common/zlib.cpp b/common/zlib.cpp index 62904cb150..920338e57e 100644 --- a/common/zlib.cpp +++ b/common/zlib.cpp @@ -419,4 +419,4 @@ WriteStream *wrapCompressedWriteStream(WriteStream *toBeWrapped) { } -} // End of namespace Common +} // End of namespace Common diff --git a/common/zlib.h b/common/zlib.h index 2772ffba06..d940f3f3a1 100644 --- a/common/zlib.h +++ b/common/zlib.h @@ -131,6 +131,6 @@ SeekableReadStream *wrapCompressedReadStream(SeekableReadStream *toBeWrapped, ui */ WriteStream *wrapCompressedWriteStream(WriteStream *toBeWrapped); -} // End of namespace Common +} // End of namespace Common #endif -- cgit v1.2.3 From 354aa0f5f34d33e32b6f35bcbf4e6f18e2bac783 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 26 Jan 2013 19:36:12 +0100 Subject: JANITORIAL: Use "End of anonymous namespace" as comment for anonymous namespaces. --- common/stream.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/stream.cpp b/common/stream.cpp index a240d4e790..57b1b8ba93 100644 --- a/common/stream.cpp +++ b/common/stream.cpp @@ -342,7 +342,7 @@ uint32 BufferedReadStream::read(void *dataPtr, uint32 dataSize) { return alreadyRead + dataSize; } -} // End of nameless namespace +} // End of anonymous namespace ReadStream *wrapBufferedReadStream(ReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream) { @@ -400,7 +400,7 @@ bool BufferedSeekableReadStream::seek(int32 offset, int whence) { return true; } -} // End of nameless namespace +} // End of anonymous namespace SeekableReadStream *wrapBufferedSeekableReadStream(SeekableReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream) { if (parentStream) @@ -482,7 +482,7 @@ public: }; -} // End of nameless namespace +} // End of anonymous namespace WriteStream *wrapBufferedWriteStream(WriteStream *parentStream, uint32 bufSize) { if (parentStream) -- cgit v1.2.3 From 5bfd2f675620f69e23cefbaf8553cb341a9f992c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 28 Jan 2013 17:30:57 +0100 Subject: COMMON: Fix successive seeks in BufferedSeekableReadStream. This fixes the failing test case added in da8eeb9dbed2102764b3ca0697d6882bae0402cc. Thanks to wjp for his input on this. --- common/stream.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/stream.cpp b/common/stream.cpp index 57b1b8ba93..2851b3a320 100644 --- a/common/stream.cpp +++ b/common/stream.cpp @@ -393,7 +393,14 @@ bool BufferedSeekableReadStream::seek(int32 offset, int whence) { // just seek normally in the parent stream. if (whence == SEEK_CUR) offset -= (_bufSize - _pos); - _pos = _bufSize; + // We invalidate the buffer here. This assures that successive seeks + // do not have the chance to incorrectly think they seeked back into + // the buffer. + // Note: This does not take full advantage of the buffer. But it is + // a simple way to prevent nasty errors. It would be possible to take + // full advantage of the buffer by saving its actual start position. + // This seems not worth the effort for this seemingly uncommon use. + _pos = _bufSize = 0; _parentStream->seek(offset, whence); } -- cgit v1.2.3