diff options
Diffstat (limited to 'common')
92 files changed, 283 insertions, 480 deletions
diff --git a/common/EventDispatcher.cpp b/common/EventDispatcher.cpp index d295cb9f81..e97068c0d0 100644 --- a/common/EventDispatcher.cpp +++ b/common/EventDispatcher.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/events.h" diff --git a/common/EventRecorder.cpp b/common/EventRecorder.cpp index d2ad4bc475..eb22e1ea88 100644 --- a/common/EventRecorder.cpp +++ b/common/EventRecorder.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/EventRecorder.h" @@ -254,7 +251,7 @@ void EventRecorder::deinit() { g_system->deleteMutex(_recorderMutex); } -void EventRecorder::registerRandomSource(RandomSource &rnd, const char *name) { +void EventRecorder::registerRandomSource(RandomSource &rnd, const String &name) { if (_recordMode == kRecorderRecord) { RandomSourceRecord rec; rec.name = name; diff --git a/common/EventRecorder.h b/common/EventRecorder.h index 19272c4e29..8377d9e8bd 100644 --- a/common/EventRecorder.h +++ b/common/EventRecorder.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_EVENTRECORDER_H @@ -54,7 +51,7 @@ public: void deinit(); /** Register random source so it can be serialized in game test purposes */ - void registerRandomSource(RandomSource &rnd, const char *name); + void registerRandomSource(RandomSource &rnd, const String &name); /** TODO: Add documentation, this is only used by the backend */ void processMillis(uint32 &millis); diff --git a/common/algorithm.h b/common/algorithm.h index e5c5f81433..00c0e1c98f 100644 --- a/common/algorithm.h +++ b/common/algorithm.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_ALGORITHM_H @@ -237,6 +234,13 @@ void sort(T first, T last) { sort(first, last, Common::Less<typename T::ValueType>()); } +// MSVC is complaining about the minus operator being applied to an unsigned type +// We disable this warning for the affected section of code +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable: 4146) +#endif + /** * Euclid's algorithm to compute the greatest common divisor. */ @@ -259,6 +263,10 @@ T gcd(T a, T b) { return b; } +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + } // End of namespace Common #endif diff --git a/common/archive.cpp b/common/archive.cpp index c2c9c8e702..0ef3893a8c 100644 --- a/common/archive.cpp +++ b/common/archive.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/archive.h" diff --git a/common/archive.h b/common/archive.h index 375136fa15..3c75970d60 100644 --- a/common/archive.h +++ b/common/archive.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_ARCHIVE_H diff --git a/common/array.h b/common/array.h index e3aab66dc6..7ab4a1b042 100644 --- a/common/array.h +++ b/common/array.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_ARRAY_H @@ -27,6 +24,7 @@ #include "common/scummsys.h" #include "common/algorithm.h" +#include "common/textconsole.h" // For error() namespace Common { @@ -75,8 +73,7 @@ public: Array(const Array<T> &array) : _capacity(array._size), _size(array._size), _storage(0) { if (array._storage) { - _storage = new T[_capacity]; - assert(_storage); + allocCapacity(_size); copy(array._storage, array._storage + _size, _storage); } } @@ -86,9 +83,8 @@ public: */ template<class T2> Array(const T2 *data, int n) { - _capacity = _size = n; - _storage = new T[_capacity]; - assert(_storage); + _size = n; + allocCapacity(n); copy(data, data + _size, _storage); } @@ -182,9 +178,7 @@ public: delete[] _storage; _size = array._size; - _capacity = _size + 32; - _storage = new T[_capacity]; - assert(_storage); + allocCapacity(_size); copy(array._storage, array._storage + _size, _storage); return *this; @@ -241,15 +235,13 @@ public: if (newCapacity <= _capacity) return; - T *old_storage = _storage; - _capacity = newCapacity; - _storage = new T[newCapacity]; - assert(_storage); + T *oldStorage = _storage; + allocCapacity(newCapacity); - if (old_storage) { + if (oldStorage) { // Copy old data - copy(old_storage, old_storage + _size, _storage); - delete[] old_storage; + copy(oldStorage, oldStorage + _size, _storage); + delete[] oldStorage; } } @@ -270,6 +262,17 @@ protected: return capa; } + void allocCapacity(uint capacity) { + _capacity = capacity; + if (capacity) { + _storage = new T[capacity]; + if (!_storage) + ::error("Common::Array: failure to allocate %d bytes", capacity); + } else { + _storage = 0; + } + } + /** * Insert a range of elements coming from this or another array. * Unlike std::vector::insert, this method does not accept @@ -289,29 +292,28 @@ protected: const uint n = last - first; if (n) { const uint idx = pos - _storage; - T *newStorage = _storage; - if (_size + n > _capacity) { + T *oldStorage = _storage; + if (_size + n > _capacity || (_storage <= first && first <= _storage + _size) ) { // If there is not enough space, allocate more and // copy old elements over. - uint newCapacity = roundUpCapacity(_size + n); - newStorage = new T[newCapacity]; - assert(newStorage); - copy(_storage, _storage + idx, newStorage); - pos = newStorage + idx; + // Likewise, if this is a self-insert, we allocate new + // storage to avoid conflicts. This is not the most efficient + // way to ensure that, but probably the simplest on. + allocCapacity(roundUpCapacity(_size + n)); + copy(oldStorage, oldStorage + idx, _storage); + pos = _storage + idx; } // Make room for the new elements by shifting back // existing ones. - copy_backward(_storage + idx, _storage + _size, newStorage + _size + n); + copy_backward(oldStorage + idx, oldStorage + _size, _storage + _size + n); // Insert the new elements. copy(first, last, pos); // Finally, update the internal state - if (newStorage != _storage) { - delete[] _storage; - _capacity = roundUpCapacity(_size + n); - _storage = newStorage; + if (_storage != oldStorage) { + delete[] oldStorage; } _size += n; } diff --git a/common/bufferedstream.h b/common/bufferedstream.h index bb09e77d1d..55ea8dc13b 100644 --- a/common/bufferedstream.h +++ b/common/bufferedstream.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_BUFFEREDSTREAM_H diff --git a/common/config-file.cpp b/common/config-file.cpp index cd8f0989fc..55941131ac 100644 --- a/common/config-file.cpp +++ b/common/config-file.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/config-file.h" diff --git a/common/config-file.h b/common/config-file.h index 231162fb3c..d28ad34036 100644 --- a/common/config-file.h +++ b/common/config-file.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_CONFIG_FILE_H diff --git a/common/config-manager.cpp b/common/config-manager.cpp index 5f5c14f8de..03fcb20abf 100644 --- a/common/config-manager.cpp +++ b/common/config-manager.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/config-manager.h" diff --git a/common/config-manager.h b/common/config-manager.h index b9e4e32399..6f3f554459 100644 --- a/common/config-manager.h +++ b/common/config-manager.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_CONFIG_MANAGER_H diff --git a/common/dcl.cpp b/common/dcl.cpp index efe1de0415..b75f7f3fa6 100644 --- a/common/dcl.cpp +++ b/common/dcl.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/dcl.h" diff --git a/common/dcl.h b/common/dcl.h index 88cf9335cf..12c4e12772 100644 --- a/common/dcl.h +++ b/common/dcl.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ /** diff --git a/common/debug-channels.h b/common/debug-channels.h index 445d0e0261..54de9d491e 100644 --- a/common/debug-channels.h +++ b/common/debug-channels.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_DEBUG_CHANNELS_H diff --git a/common/debug.cpp b/common/debug.cpp index a8711055fd..dbbb204deb 100644 --- a/common/debug.cpp +++ b/common/debug.cpp @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #include "common/debug.h" diff --git a/common/debug.h b/common/debug.h index 03de7f4f77..dc94839082 100644 --- a/common/debug.h +++ b/common/debug.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_DEBUG_H diff --git a/common/endian.h b/common/endian.h index c645243654..9cb703858a 100644 --- a/common/endian.h +++ b/common/endian.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_ENDIAN_H diff --git a/common/error.cpp b/common/error.cpp index b07e5ebd74..a6c52a0ce9 100644 --- a/common/error.cpp +++ b/common/error.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/error.h" @@ -70,9 +67,6 @@ static String errorToString(ErrorCode errorCode) { case kEnginePluginNotSupportSaves: return _s("Engine plugin does not support save states"); - case kArgumentNotProcessed: - return _s("Command line argument not processed"); - case kUnknownError: default: return _s("Unknown error"); diff --git a/common/error.h b/common/error.h index 1ffbba723a..23c12b67e4 100644 --- a/common/error.h +++ b/common/error.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_ERROR_H @@ -50,7 +47,6 @@ enum ErrorCode { kUnsupportedGameidError, ///< Engine initialization: Gameid not supported by this (Meta)Engine kUnsupportedColorMode, ///< Engine initialization: Engine does not support backend's color mode - kReadPermissionDenied, ///< Unable to read data due to missing read permission kWritePermissionDenied, ///< Unable to write data due to missing write permission @@ -66,8 +62,6 @@ enum ErrorCode { kEnginePluginNotFound, ///< Failed to find plugin to handle target kEnginePluginNotSupportSaves, ///< Failed if plugin does not support listing save states - kArgumentNotProcessed, ///< Used in command line parsing - kUnknownError ///< Catch-all error, used if no other error code matches }; diff --git a/common/events.h b/common/events.h index 120d7d9dea..371080c1b2 100644 --- a/common/events.h +++ b/common/events.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_EVENTS_H @@ -309,7 +306,7 @@ public: /** - * Initialise the event manager. + * Initialize the event manager. * @note called after graphics system has been set up */ virtual void init() {} diff --git a/common/file.cpp b/common/file.cpp index 485255bbdb..381bf12ecf 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/archive.h" diff --git a/common/file.h b/common/file.h index c3805baed7..86c67c077c 100644 --- a/common/file.h +++ b/common/file.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_FILE_H diff --git a/common/forbidden.h b/common/forbidden.h index af22b2ee21..c551110d0e 100644 --- a/common/forbidden.h +++ b/common/forbidden.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_FORBIDDEN_H @@ -128,6 +125,27 @@ #endif +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_getc +#undef getc +#define getc(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_getchar +#undef getchar +#define getchar() FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_putc +#undef putc +#define putc(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_putchar +#undef putchar +#define putchar(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_setjmp #undef setjmp #define setjmp(a) FORBIDDEN_SYMBOL_REPLACEMENT @@ -143,6 +161,31 @@ #define system(a) FORBIDDEN_SYMBOL_REPLACEMENT #endif +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_exit +#undef exit +#define exit(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_getenv +#undef getenv +#define getenv(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_putenv +#undef putenv +#define putenv(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_setenv +#undef setenv +#define setenv(a,b,c) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_unsetenv +#undef unsetenv +#define unsetenv(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + // // Disable various symbols from time.h @@ -247,6 +290,64 @@ #define setvbuf(a,b,c,d) FORBIDDEN_SYMBOL_REPLACEMENT #endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_tmpfile +#undef tmpfile +#define tmpfile() FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_tmpnam +#undef tmpnam +#define tmpnam(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_tempnam +#undef tempnam +#define tempnam(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_rand +#undef rand +#define rand() FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_srand +#undef srand +#define srand(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_random +#undef random +#define random() FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_srandom +#undef srandom +#define srandom(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_stricmp +#undef stricmp +#define stricmp(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_strnicmp +#undef strnicmp +#define strnicmp(a,b,c) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_strcasecmp +#undef strcasecmp +#define strcasecmp(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_strncasecmp +#undef strncasecmp +#define strncasecmp(a,b,c) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + + /* * We also would like to disable the following symbols; * however, these are also frequently used in regular code, diff --git a/common/frac.h b/common/frac.h index b1e6c518d1..d402878825 100644 --- a/common/frac.h +++ b/common/frac.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_FRAC_H diff --git a/common/fs.cpp b/common/fs.cpp index d3cdc0697f..3dc8c289aa 100644 --- a/common/fs.cpp +++ b/common/fs.cpp @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #include "common/system.h" diff --git a/common/fs.h b/common/fs.h index f93c11159e..aeaa14718e 100644 --- a/common/fs.h +++ b/common/fs.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_FS_H diff --git a/common/func.h b/common/func.h index b89a64e5fb..e09ab1a438 100644 --- a/common/func.h +++ b/common/func.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_FUNC_H diff --git a/common/hash-str.h b/common/hash-str.h index 40557037e7..1b8a57827a 100644 --- a/common/hash-str.h +++ b/common/hash-str.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_HASH_STR_H diff --git a/common/hashmap.cpp b/common/hashmap.cpp index 5fe18f33ee..ff8f9db9ce 100644 --- a/common/hashmap.cpp +++ b/common/hashmap.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ // The hash map (associative array) implementation in this file is diff --git a/common/hashmap.h b/common/hashmap.h index 907a107163..f2a4d843b8 100644 --- a/common/hashmap.h +++ b/common/hashmap.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ // The hash map (associative array) implementation in this file is diff --git a/common/iff_container.cpp b/common/iff_container.cpp index c447d93f12..02b445ae05 100644 --- a/common/iff_container.cpp +++ b/common/iff_container.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/iff_container.h" diff --git a/common/iff_container.h b/common/iff_container.h index 43a551a239..1b12ef70e5 100644 --- a/common/iff_container.h +++ b/common/iff_container.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_IFF_CONTAINER_H diff --git a/common/keyboard.h b/common/keyboard.h index 40491fda6b..74b8775a0f 100644 --- a/common/keyboard.h +++ b/common/keyboard.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_KEYBOARD_H diff --git a/common/list.h b/common/list.h index ad6193c297..a1e761f55d 100644 --- a/common/list.h +++ b/common/list.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_LIST_H diff --git a/common/list_intern.h b/common/list_intern.h index b7fbaffc47..daa7446781 100644 --- a/common/list_intern.h +++ b/common/list_intern.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_LIST_INTERN_H diff --git a/common/macresman.cpp b/common/macresman.cpp index 0ecb430532..70c6e0a7ce 100644 --- a/common/macresman.cpp +++ b/common/macresman.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/scummsys.h" diff --git a/common/macresman.h b/common/macresman.h index f588d8f853..4d86e46d11 100644 --- a/common/macresman.h +++ b/common/macresman.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ /** diff --git a/common/md5.cpp b/common/md5.cpp index bea9ca0dc5..52fe8b8f8d 100644 --- a/common/md5.cpp +++ b/common/md5.cpp @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ /* diff --git a/common/md5.h b/common/md5.h index e613028a5e..d1be8c8e39 100644 --- a/common/md5.h +++ b/common/md5.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_MD5_H diff --git a/common/memorypool.cpp b/common/memorypool.cpp index c4dbb5fbbd..3a570ac50e 100644 --- a/common/memorypool.cpp +++ b/common/memorypool.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/memorypool.h" diff --git a/common/memorypool.h b/common/memorypool.h index e19d982913..5ba09cebed 100644 --- a/common/memorypool.h +++ b/common/memorypool.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_MEMORYPOOL_H diff --git a/common/memstream.h b/common/memstream.h index ac42e1bad9..69fe6ec18e 100644 --- a/common/memstream.h +++ b/common/memstream.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_MEMSTREAM_H diff --git a/common/mutex.cpp b/common/mutex.cpp index 8ebfa2254b..4e6316528c 100644 --- a/common/mutex.cpp +++ b/common/mutex.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/debug.h" diff --git a/common/mutex.h b/common/mutex.h index 3addaa6b18..26f69a3996 100644 --- a/common/mutex.h +++ b/common/mutex.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_MUTEX_H diff --git a/common/noncopyable.h b/common/noncopyable.h index f639d9abf7..0cbe41388a 100644 --- a/common/noncopyable.h +++ b/common/noncopyable.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_NONCOPYABLE_H diff --git a/common/pack-end.h b/common/pack-end.h index 701b12dccc..04633b7635 100644 --- a/common/pack-end.h +++ b/common/pack-end.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #if defined(SCUMMVM_USE_PRAGMA_PACK) diff --git a/common/pack-start.h b/common/pack-start.h index 0b2c3eff82..631a6529d3 100644 --- a/common/pack-start.h +++ b/common/pack-start.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #if defined(SCUMMVM_USE_PRAGMA_PACK) diff --git a/common/ptr.h b/common/ptr.h index 4d7fff1fc2..e0d026f964 100644 --- a/common/ptr.h +++ b/common/ptr.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_PTR_H diff --git a/common/queue.h b/common/queue.h index df8dcfe04c..3a2d6aad4b 100644 --- a/common/queue.h +++ b/common/queue.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_QUEUE_H diff --git a/common/random.cpp b/common/random.cpp index 9fd9c33e30..55fa3cbd30 100644 --- a/common/random.cpp +++ b/common/random.cpp @@ -17,23 +17,26 @@ * 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. - * - * $URL$ - * $Id$ */ #include "common/random.h" #include "common/system.h" +#include "common/EventRecorder.h" namespace Common { -RandomSource::RandomSource() { +RandomSource::RandomSource(const String &name) { // Use system time as RNG seed. Normally not a good idea, if you are using // a RNG for security purposes, but good enough for our purposes. assert(g_system); uint32 seed = g_system->getMillis(); setSeed(seed); + + // Register this random source with the event recorder. This may end + // up querying or resetting the current seed, so we must call it + // *after* the initial seed has been set. + g_eventRec.registerRandomSource(*this, name); } void RandomSource::setSeed(uint32 seed) { diff --git a/common/random.h b/common/random.h index 8fc5c4cf7d..90f2ed5cb0 100644 --- a/common/random.h +++ b/common/random.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_RANDOM_H @@ -29,6 +26,8 @@ namespace Common { +class String; + /** * Simple random number generator. Although it is definitely not suitable for * cryptographic purposes, it serves our purposes just fine. @@ -38,10 +37,17 @@ private: uint32 _randSeed; public: - RandomSource(); + /** + * Construct a new randomness source with the specific name. + * The name used name must be globally unique, and is used to + * register the randomness source with the active event recorder, + * if any. + */ + RandomSource(const String &name); + void setSeed(uint32 seed); - uint32 getSeed() { + uint32 getSeed() const { return _randSeed; } @@ -51,12 +57,14 @@ public: * @return a random number in the interval [0, max] */ uint getRandomNumber(uint max); + /** * Generates a random bit, i.e. either 0 or 1. - * Identical to getRandomNumber(1), but faster, hopefully. + * Identical to getRandomNumber(1), but potentially faster. * @return a random bit, either 0 or 1 */ uint getRandomBit(); + /** * Generates a random unsigned integer in the interval [min, max]. * @param min the lower bound diff --git a/common/rational.cpp b/common/rational.cpp index af38dd9144..cb287869bb 100644 --- a/common/rational.cpp +++ b/common/rational.cpp @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #include "common/debug.h" diff --git a/common/rational.h b/common/rational.h index bee09d8ddb..45aa6a7a20 100644 --- a/common/rational.h +++ b/common/rational.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_RATIONAL_H diff --git a/common/rect.h b/common/rect.h index 03ad02d27a..768d1ebbb9 100644 --- a/common/rect.h +++ b/common/rect.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_RECT_H diff --git a/common/savefile.h b/common/savefile.h index 793aec3ba9..03a7b52add 100644 --- a/common/savefile.h +++ b/common/savefile.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_SAVEFILE_H @@ -145,7 +142,7 @@ public: /** * Request a list of available savegames with a given DOS-style pattern, - * also known as "glob" in the UNIX world. Refer to the Common::matchString() + * also known as "glob" in the POSIX world. Refer to the Common::matchString() * function to learn about the precise pattern format. * @param pattern Pattern to match. Wildcards like * or ? are available. * @return list of strings for all present file names. diff --git a/common/scummsys.h b/common/scummsys.h index 8ba983fd6c..62e244585a 100644 --- a/common/scummsys.h +++ b/common/scummsys.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_SCUMMSYS_H @@ -47,6 +44,9 @@ #if (_MSC_VER < 1500) #define vsnprintf _vsnprintf #endif + // FIXME: Is this actually necessary for WinCE or Windows? + // If yes, please add corresponding comments. Otherwise, let's get rid of it! + #define snprintf _snprintf #endif #if !defined(_WIN32_WCE) @@ -110,21 +110,6 @@ #include "config.h" #endif -// -// Define scumm_stricmp and scumm_strnicmp -// -#if defined(_WIN32_WCE) || defined(_MSC_VER) - #define scumm_stricmp stricmp - #define scumm_strnicmp _strnicmp - #define snprintf _snprintf -#elif defined(__MINGW32__) || defined(__GP32__) || defined(__DS__) - #define scumm_stricmp stricmp - #define scumm_strnicmp strnicmp -#else - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp -#endif - // In the following we configure various targets, in particular those // which can't use our "configure" tool and hence don't use config.h. @@ -154,82 +139,47 @@ // #define SCUMMVM_USE_PRAGMA_PACK +// +// Determine the host endianess and whether memory alignment is required. +// +#if !defined(HAVE_CONFIG_H) + #if defined(SDL_BACKEND) + /* need this for the SDL_BYTEORDER define */ + #include <SDL_endian.h> + + #if SDL_BYTEORDER == SDL_LIL_ENDIAN + #define SCUMM_LITTLE_ENDIAN + #elif SDL_BYTEORDER == SDL_BIG_ENDIAN + #define SCUMM_BIG_ENDIAN + #else + #error Neither SDL_BIG_ENDIAN nor SDL_LIL_ENDIAN is set. + #endif -#if defined(HAVE_CONFIG_H) - // All settings should have been set in config.h - -#elif defined(__SYMBIAN32__) - - #define SCUMM_LITTLE_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined(_WIN32_WCE) - - #define SCUMM_LITTLE_ENDIAN + #elif defined(__DC__) || \ + defined(__DS__) || \ + defined(__GP32__) || \ + defined(IPHONE) || \ + defined(__PLAYSTATION2__) || \ + defined(__PSP__) || \ + defined(__SYMBIAN32__) -#elif defined(_MSC_VER) + #define SCUMM_LITTLE_ENDIAN + #define SCUMM_NEED_ALIGNMENT - #define SCUMM_LITTLE_ENDIAN + #elif defined(_WIN32_WCE) || defined(_MSC_VER) || defined(__MINGW32__) -#elif defined(__MINGW32__) + #define SCUMM_LITTLE_ENDIAN - #define SCUMM_LITTLE_ENDIAN + #elif defined(__amigaos4__) || defined(__N64__) || defined(__WII__) -#elif defined(SDL_BACKEND) - /* need this for the SDL_BYTEORDER define */ - #include <SDL_byteorder.h> + #define SCUMM_BIG_ENDIAN + #define SCUMM_NEED_ALIGNMENT - #if SDL_BYTEORDER == SDL_LIL_ENDIAN - #define SCUMM_LITTLE_ENDIAN - #elif SDL_BYTEORDER == SDL_BIG_ENDIAN - #define SCUMM_BIG_ENDIAN #else - #error Neither SDL_BIG_ENDIAN nor SDL_LIL_ENDIAN is set. - #endif - -#elif defined(__DC__) - - #define SCUMM_LITTLE_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined(__GP32__) - #define SCUMM_LITTLE_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined(__PLAYSTATION2__) - - #define SCUMM_LITTLE_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined(__N64__) - - #define SCUMM_BIG_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined(__PSP__) - - #define SCUMM_LITTLE_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined(__amigaos4__) - - #define SCUMM_BIG_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined(__DS__) - - #define SCUMM_NEED_ALIGNMENT - #define SCUMM_LITTLE_ENDIAN - -#elif defined(__WII__) - - #define SCUMM_BIG_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#else - #error No system type defined + #error No system type defined, host endianess unknown. + #endif #endif @@ -237,17 +187,7 @@ // Some more system specific settings. // TODO/FIXME: All of these should be moved to backend specific files (such as portdefs.h) // -#if defined(__SYMBIAN32__) - - #define SMALL_SCREEN_DEVICE - -#elif defined(_WIN32_WCE) - - #if _WIN32_WCE < 300 - #define SMALL_SCREEN_DEVICE - #endif - -#elif defined(DINGUX) +#if defined(DINGUX) // Very BAD hack following, used to avoid triggering an assert in uClibc dingux library // "toupper" when pressing keyboard function keys. @@ -306,7 +246,7 @@ #if defined(_MSC_VER) #define NORETURN_PRE __declspec(noreturn) #else - #define NORETURN_PRE + #define NORETURN_PRE #endif #endif @@ -314,7 +254,7 @@ #if defined(__GNUC__) || defined(__INTEL_COMPILER) #define NORETURN_POST __attribute__((__noreturn__)) #else - #define NORETURN_POST + #define NORETURN_POST #endif #endif @@ -332,60 +272,10 @@ // -// Typedef our system types +// Typedef our system types unless they have already been defined by config.h, +// or SCUMMVM_DONT_DEFINE_TYPES is set. // -#if !defined(HAVE_CONFIG_H) && defined(__SYMBIAN32__) - - // Enable Symbians own datatypes - // This is done for two reasons - // a) uint is already defined by Symbians libc component - // b) Symbian is using its "own" datatyping, and the Scummvm port - // should follow this to ensure the best compability possible. - typedef unsigned char byte; - - typedef unsigned char uint8; - typedef signed char int8; - - typedef unsigned short int uint16; - typedef signed short int int16; - - typedef unsigned long int uint32; - typedef signed long int int32; - -#elif !defined(HAVE_CONFIG_H) && defined(__GP32__) - - // Override typenames. uint is already defined by system header files. - typedef unsigned char byte; - - typedef unsigned char uint8; - typedef signed char int8; - - typedef unsigned short int uint16; - typedef signed short int int16; - - typedef unsigned long int uint32; - typedef signed long int int32; - -#elif !defined(HAVE_CONFIG_H) && defined(__N64__) - - typedef unsigned char byte; - - typedef unsigned char uint8; - typedef signed char int8; - - typedef unsigned short int uint16; - typedef signed short int int16; - - typedef unsigned int uint32; - typedef signed int int32; - -#elif !defined(HAVE_CONFIG_H) && defined(__DS__) - - // Do nothing, the SDK defines all types we need in nds/ndstypes.h, - // which we include in our portsdef.h - -#else - +#if !defined(HAVE_CONFIG_H) && !defined(SCUMMVM_DONT_DEFINE_TYPES) typedef unsigned char byte; typedef unsigned char uint8; typedef signed char int8; @@ -397,18 +287,11 @@ #endif - // // Overlay color type (FIXME: shouldn't be declared here) // -#if defined(NEWGUI_256) - // 256 color only on PalmOS - typedef byte OverlayColor; -#else - // 15/16 bit color mode everywhere else... - typedef uint16 OverlayColor; -#endif +typedef uint16 OverlayColor; -#include "common/forbidden.h" +#include "common/forbidden.h" #endif diff --git a/common/serializer.h b/common/serializer.h index b8c62727d4..b874624d38 100644 --- a/common/serializer.h +++ b/common/serializer.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_SERIALIZER_H diff --git a/common/singleton.h b/common/singleton.h index c5aa35f68d..2f5fa41877 100644 --- a/common/singleton.h +++ b/common/singleton.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_SINGLETON_H diff --git a/common/stack.h b/common/stack.h index 5d447d5424..0d13049f2e 100644 --- a/common/stack.h +++ b/common/stack.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_STACK_H diff --git a/common/str-array.h b/common/str-array.h index 5c8324bdea..57c76bf305 100644 --- a/common/str-array.h +++ b/common/str-array.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_STRING_ARRAY_H diff --git a/common/str.cpp b/common/str.cpp index c21e4412db..740e7b6a06 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #include "common/str.h" @@ -836,3 +833,36 @@ size_t strlcat(char *dst, const char *src, size_t size) { } } // End of namespace Common + +// Portable implementation of stricmp / strcasecmp / strcmpi. +// TODO: Rename this to Common::strcasecmp +int scumm_stricmp(const char *s1, const char *s2) { + byte l1, l2; + do { + // Don't use ++ inside tolower, in case the macro uses its + // arguments more than once. + l1 = (byte)*s1++; + l1 = tolower(l1); + l2 = (byte)*s2++; + l2 = tolower(l2); + } while (l1 == l2 && l1 != 0); + return l1 - l2; +} + +// Portable implementation of strnicmp / strncasecmp / strncmpi. +// TODO: Rename this to Common::strncasecmp +int scumm_strnicmp(const char *s1, const char *s2, uint n) { + byte l1, l2; + do { + if (n-- == 0) + return 0; // no difference found so far -> signal equality + + // Don't use ++ inside tolower, in case the macro uses its + // arguments more than once. + l1 = (byte)*s1++; + l1 = tolower(l1); + l2 = (byte)*s2++; + l2 = tolower(l2); + } while (l1 == l2 && l1 != 0); + return l1 - l2; +} diff --git a/common/str.h b/common/str.h index 21c0483a04..7b97dfe945 100644 --- a/common/str.h +++ b/common/str.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_STRING_H @@ -41,7 +38,7 @@ namespace Common { * a certain length do we allocate a buffer on the heap. * * The presence of \0 characters in the string will cause undefined - * behaviour in some operations. + * behavior in some operations. */ class String { protected: @@ -381,4 +378,7 @@ size_t strlcat(char *dst, const char *src, size_t size); } // End of namespace Common +extern int scumm_stricmp(const char *s1, const char *s2); +extern int scumm_strnicmp(const char *s1, const char *s2, uint n); + #endif diff --git a/common/stream.cpp b/common/stream.cpp index a785ac5164..60b40d0df2 100644 --- a/common/stream.cpp +++ b/common/stream.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/stream.h" diff --git a/common/stream.h b/common/stream.h index 530b50e431..26c04e5bf6 100644 --- a/common/stream.h +++ b/common/stream.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_STREAM_H @@ -45,12 +42,18 @@ public: * Returns true if an I/O failure occurred. * This flag is never cleared automatically. In order to clear it, * client code has to call clearErr() explicitly. + * + * @note The semantics of any implementation of this method are + * supposed to match those of ISO C ferror(). */ virtual bool err() const { return false; } /** * Reset the I/O error status as returned by err(). * For a ReadStream, also reset the end-of-stream status returned by eos(). + * + * @note The semantics of any implementation of this method are + * supposed to match those of ISO C clearerr(). */ virtual void clearErr() {} }; @@ -64,6 +67,9 @@ public: * Write data into the stream. Subclasses must implement this * method; all other write methods are implemented using it. * + * @note The semantics of any implementation of this method are + * supposed to match those of ISO C fwrite(). + * * @param dataPtr pointer to the data to be written * @param dataSize number of bytes to be written * @return the number of bytes which were actually written. @@ -75,6 +81,9 @@ public: * storage medium; unbuffered streams can use the default * implementation. * + * @note The semantics of any implementation of this method are + * supposed to match those of ISO C fflush(). + * * @return true on success, false in case of a failure */ virtual bool flush() { return true; } @@ -158,6 +167,11 @@ public: * Returns true if a read failed because the stream end has been reached. * This flag is cleared by clearErr(). * For a SeekableReadStream, it is also cleared by a successful seek. + * + * @note The semantics of any implementation of this method are + * supposed to match those of ISO C feof(). In particular, in a stream + * with N bytes, reading exactly N bytes from the start should *not* + * set eos; only reading *beyond* the available data should set it. */ virtual bool eos() const = 0; @@ -165,6 +179,10 @@ public: * Read data from the stream. Subclasses must implement this * method; all other read methods are implemented using it. * + * @note The semantics of any implementation of this method are + * supposed to match those of ISO C fread(), in particular where + * it concerns setting error and end of file/stream flags. + * * @param dataPtr pointer to a buffer into which the data is read * @param dataSize number of bytes to be read * @return the number of bytes which were actually read. @@ -338,6 +356,9 @@ public: * position indicator, or end-of-file, respectively. A successful call * to the seek() method clears the end-of-file indicator for the stream. * + * @note The semantics of any implementation of this method are + * supposed to match those of ISO C fseek(). + * * @param offset the relative offset in bytes * @param whence the seek reference: SEEK_SET, SEEK_CUR, or SEEK_END * @return true on success, false in case of a failure diff --git a/common/substream.h b/common/substream.h index 8b83dbda2e..f4f79ff02f 100644 --- a/common/substream.h +++ b/common/substream.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_SUBSTREAM_H diff --git a/common/system.cpp b/common/system.cpp index 4e902bcb14..1f2f8cc6d5 100644 --- a/common/system.cpp +++ b/common/system.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ // Disable symbol overrides so that we can use system headers. diff --git a/common/system.h b/common/system.h index 540ffde5a5..b584739b77 100644 --- a/common/system.h +++ b/common/system.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_SYSTEM_H @@ -1034,7 +1031,7 @@ public: }; -/** The global OSystem instance. Initialised in main(). */ +/** The global OSystem instance. Initialized in main(). */ extern OSystem *g_system; #endif diff --git a/common/textconsole.cpp b/common/textconsole.cpp index 8d62cd4cb2..f2325ac9ad 100644 --- a/common/textconsole.cpp +++ b/common/textconsole.cpp @@ -17,11 +17,10 @@ * 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. - * - * $URL$ - * $Id$ */ +#define FORBIDDEN_SYMBOL_EXCEPTION_exit + #include "common/textconsole.h" #include "common/system.h" #include "common/str.h" diff --git a/common/textconsole.h b/common/textconsole.h index 5a535f3206..364c49b2e9 100644 --- a/common/textconsole.h +++ b/common/textconsole.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_CONSOLE_H diff --git a/common/timer.h b/common/timer.h index c87c2b3240..40438f078c 100644 --- a/common/timer.h +++ b/common/timer.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_TIMER_H diff --git a/common/tokenizer.cpp b/common/tokenizer.cpp index 8bca133b5b..395ff0767a 100644 --- a/common/tokenizer.cpp +++ b/common/tokenizer.cpp @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #include "common/tokenizer.h" diff --git a/common/tokenizer.h b/common/tokenizer.h index 0ee6e37da7..8485094997 100644 --- a/common/tokenizer.h +++ b/common/tokenizer.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_TOKENIZER_H diff --git a/common/translation.cpp b/common/translation.cpp index 5494849f4c..dc71ddc52f 100644 --- a/common/translation.cpp +++ b/common/translation.cpp @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifdef WIN32 diff --git a/common/translation.h b/common/translation.h index f8183b6350..9e5245702e 100644 --- a/common/translation.h +++ b/common/translation.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_TRANSLATION_H diff --git a/common/types.h b/common/types.h index bed204ae1b..ab86f3afc2 100644 --- a/common/types.h +++ b/common/types.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_TYPES_H diff --git a/common/unarj.cpp b/common/unarj.cpp index 4bda7ac753..f45dddaa38 100644 --- a/common/unarj.cpp +++ b/common/unarj.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ // diff --git a/common/unarj.h b/common/unarj.h index fe23ba5694..2be514c936 100644 --- a/common/unarj.h +++ b/common/unarj.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ /** diff --git a/common/unzip.cpp b/common/unzip.cpp index d56893f3cd..91f352f40a 100644 --- a/common/unzip.cpp +++ b/common/unzip.cpp @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ /* unzip.c -- IO on .zip files using zlib @@ -352,7 +349,7 @@ typedef struct { z_stream stream; /* zLib stream structure for inflate */ uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ - uLong stream_initialised; /* flag set if stream structure is initialised*/ + uLong stream_initialized; /* flag set if stream structure is initialized*/ uLong offset_local_extrafield;/* offset of the local extra field */ uInt size_local_extrafield;/* size of the local extra field */ @@ -1076,7 +1073,7 @@ int unzOpenCurrentFile (unzFile file) { return UNZ_INTERNALERROR; } - pfile_in_zip_read_info->stream_initialised=0; + pfile_in_zip_read_info->stream_initialized=0; if ((s->cur_file_info.compression_method!=0) && (s->cur_file_info.compression_method!=Z_DEFLATED)) @@ -1099,7 +1096,7 @@ int unzOpenCurrentFile (unzFile file) { err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); if (err == Z_OK) - pfile_in_zip_read_info->stream_initialised = 1; + pfile_in_zip_read_info->stream_initialized = 1; /* windowBits is passed < 0 to tell that there is no zlib header. * Note that in this case inflate *requires* an extra "dummy" byte * after the compressed stream in order to complete decompression and @@ -1368,7 +1365,7 @@ int unzCloseCurrentFile(unzFile file) { if (pfile_in_zip_read_info->crc32_data != pfile_in_zip_read_info->crc32_wait) err=UNZ_CRCERROR; } - if (pfile_in_zip_read_info->stream_initialised) + if (pfile_in_zip_read_info->stream_initialized) inflateEnd(&pfile_in_zip_read_info->stream); #endif @@ -1376,7 +1373,7 @@ int unzCloseCurrentFile(unzFile file) { free(pfile_in_zip_read_info->read_buffer); pfile_in_zip_read_info->read_buffer = NULL; - pfile_in_zip_read_info->stream_initialised = 0; + pfile_in_zip_read_info->stream_initialized = 0; free(pfile_in_zip_read_info); s->pfile_in_zip_read=NULL; diff --git a/common/unzip.h b/common/unzip.h index fe7acdcc54..06480b0054 100644 --- a/common/unzip.h +++ b/common/unzip.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_UNZIP_H diff --git a/common/util.cpp b/common/util.cpp index 22cf33b130..a7ec1a9de7 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #include "common/util.h" diff --git a/common/util.h b/common/util.h index 3af9b49086..5837c8beab 100644 --- a/common/util.h +++ b/common/util.h @@ -17,9 +17,6 @@ * 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. - * - * $URL$ - * $Id$ */ #ifndef COMMON_UTIL_H diff --git a/common/winexe.cpp b/common/winexe.cpp index 9602e84c88..7cfc140452 100644 --- a/common/winexe.cpp +++ b/common/winexe.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/str.h" diff --git a/common/winexe.h b/common/winexe.h index ce2f19cb81..bec156d2e7 100644 --- a/common/winexe.h +++ b/common/winexe.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_WINEXE_H diff --git a/common/winexe_ne.cpp b/common/winexe_ne.cpp index 844127b0e1..80266ba87e 100644 --- a/common/winexe_ne.cpp +++ b/common/winexe_ne.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/debug.h" diff --git a/common/winexe_ne.h b/common/winexe_ne.h index 2988132040..4a1b2343df 100644 --- a/common/winexe_ne.h +++ b/common/winexe_ne.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_WINEXE_NE_H diff --git a/common/winexe_pe.cpp b/common/winexe_pe.cpp index 6bb831b9c6..e5f6a24bcd 100644 --- a/common/winexe_pe.cpp +++ b/common/winexe_pe.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/array.h" diff --git a/common/winexe_pe.h b/common/winexe_pe.h index 60c4adb916..cc1d0c9770 100644 --- a/common/winexe_pe.h +++ b/common/winexe_pe.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_WINEXE_PE_H diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp index e2e1dbdfc7..9bd052fb3d 100644 --- a/common/xmlparser.cpp +++ b/common/xmlparser.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ // FIXME: Avoid using fprintf diff --git a/common/xmlparser.h b/common/xmlparser.h index c456fd0826..84fca294a0 100644 --- a/common/xmlparser.h +++ b/common/xmlparser.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef XML_PARSER_H diff --git a/common/zlib.cpp b/common/zlib.cpp index 96e9f8cb15..b047586af0 100644 --- a/common/zlib.cpp +++ b/common/zlib.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ // Disable symbol overrides so that we can use zlib.h diff --git a/common/zlib.h b/common/zlib.h index 641d4553cf..1925034310 100644 --- a/common/zlib.h +++ b/common/zlib.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_ZLIB_H |