Re: [AD] Version check patch |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: alleg-developers@xxxxxxxxxx
- Subject: Re: [AD] Version check patch
- From: Chris <chris.kcat@xxxxxxxxxx>
- Date: Sun, 28 Nov 2004 19:14:26 -0800
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:return-path:message-id:date:from:user-agent:x-accept-language:mime-version:to:subject:references:in-reply-to:x-enigmail-version:x-enigmail-supports:content-type; b=mILLRfMf+NouoTPbp/qeZfz6fYv4o+aUSuCpBHovfqfutJ0tN8iZL8eV4TwQH8Bu4uu4/EzWkec8bHwtkQHMVx89CP3ydKxRsZhvQh8Y0z5R3jUGnCgmhpXSb8l0ze7pOGyNNeLY+lauV7muHHUpn37o6QoqwlxNLS6iTMb1mJc=
tjaden@xxxxxxxxxx wrote:
It makes it harder to sift through patches later on. Don't make
gratuitous whitespace changes, please! If you must, do it in a separate
patch or combine it with one for general cosmetic fixes.
I didn't realize it happened until after I made the patch. It's just
kind of hard to tell since you can't see the whitespace. The only time I
can tell is when the patch is already made (and I happen look through
it). And short of reconfiguring the editor (and SciTE can be a pain to
reconfigure), undoing the patch, and redoing all the changes, there's
nothing that can be done.
Is there maybe a diff option to ignore trailing whitespace differences?
I found the -b option, but I think that ignores leading whitespace
differences as well. In either case, it works fine for this patch, so
here's another updated patch.
Index: src/allegro.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/allegro.c,v
retrieving revision 1.45
diff -u -b -r1.45 allegro.c
--- src/allegro.c 28 Feb 2004 16:17:03 -0000 1.45
+++ src/allegro.c 29 Nov 2004 03:13:51 -0000
@@ -228,6 +228,16 @@
+/* _get_allegro_version:
+ * Retrieves the library version.
+ */
+int _get_allegro_version(void)
+{
+ return MAKE_VERSION(ALLEGRO_VERSION, ALLEGRO_SUB_VERSION, ALLEGRO_WIP_VERSION);
+}
+
+
+
/* _add_exit_func:
* Adds a function to the list that need to be called by allegro_exit().
*/
@@ -285,10 +295,10 @@
-/* install_allegro:
+/* _install_allegro:
* Initialises the Allegro library, activating the system driver.
*/
-int install_allegro(int system_id, int *errno_ptr, int (*atexit_ptr)(void (*func)(void)))
+int _install_allegro(int system_id, int *errno_ptr, int (*atexit_ptr)(void (*func)(void)))
{
RGB black_rgb = {0, 0, 0, 0};
char tmp1[64], tmp2[64];
Index: include/allegro/system.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/system.h,v
retrieving revision 1.12
diff -u -b -r1.12 system.h
--- include/allegro/system.h 19 May 2003 15:32:46 -0000 1.12
+++ include/allegro/system.h 29 Nov 2004 03:13:51 -0000
@@ -20,6 +20,8 @@
#define ALLEGRO_SYSTEM_H
#include "base.h"
+#include "unicode.h"
+#include "config.h"
#ifdef __cplusplus
extern "C" {
@@ -67,7 +69,25 @@
#define SYSTEM_AUTODETECT 0
#define SYSTEM_NONE AL_ID('N','O','N','E')
-AL_FUNC(int, install_allegro, (int system_id, int *errno_ptr, AL_METHOD(int, atexit_ptr, (AL_METHOD(void, func, (void))))));
+#if (ALLEGRO_SUB_VERSION&1)
+#define MAKE_VERSION(a, b, c) (((a)<<16)|((b)<<8)|(c))
+#else
+#define MAKE_VERSION(a, b, c) (((a)<<16)|((b)<<8))
+#endif
+
+AL_FUNC(int, _get_allegro_version, (void));
+AL_FUNC(int, _install_allegro, (int system_id, int *errno_ptr, AL_METHOD(int, atexit_ptr, (AL_METHOD(void, func, (void))))));
+
+AL_INLINE(int, install_allegro, (int system_id, int *errno_ptr, AL_METHOD(int, atexit_ptr, (AL_METHOD(void, func, (void))))),
+{
+ if (MAKE_VERSION(ALLEGRO_VERSION, ALLEGRO_SUB_VERSION, ALLEGRO_WIP_VERSION) !=
+ _get_allegro_version()) {
+ ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Library version mismatch"));
+ return !0;
+ }
+
+ return _install_allegro(system_id, errno_ptr, atexit_ptr);
+})
#define allegro_init() install_allegro(SYSTEM_AUTODETECT, &errno, (int (*)(void (*)(void)))atexit)
AL_FUNC(void, allegro_exit, (void));