X-Git-Url: http://git.draconx.ca/gitweb/liblbx.git/blobdiff_plain/e7aea0c6f323c6bbf364093305e60bb78999a23f..HEAD:/src/error.c diff --git a/src/error.c b/src/error.c index 3e47204..fb74bd5 100644 --- a/src/error.c +++ b/src/error.c @@ -1,7 +1,7 @@ /* * 2ooM: The Master of Orion II Reverse Engineering Project * Utilities for out-of-band error propagation. - * Copyright © 2010, 2013 Nick Bowler + * Copyright © 2010, 2013-2014 Nick Bowler * * 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 @@ -24,11 +24,12 @@ #include #include #include -#include #include "error.h" +#include "misc.h" -#define _(s) dgettext(PACKAGE, s) +// #define _(s) dgettext(PACKAGE, s) +#define _(s) (s) #if !defined(LBX_ERROR_LIMIT) # define LBX_ERROR_LIMIT 256 @@ -40,8 +41,6 @@ static int error_ring[LBX_ERROR_LIMIT]; static const char **user_errors; static int user_error_count, user_error_max = 2; -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - int lbx_error_new(const char *str) { assert(user_error_count >= 0 && user_error_count <= user_error_max); @@ -50,9 +49,9 @@ int lbx_error_new(const char *str) const char **new; size_t size; - if (user_error_max >= MIN(SIZE_MAX, INT_MAX)/2 - LBX_EUBASE) + if (user_error_max >= MIN((size_t)-1, INT_MAX)/2 - LBX_EUBASE) return -1; - if (2 * user_error_max >= SIZE_MAX / sizeof *user_errors) + if (2 * user_error_max >= (size_t)-1 / sizeof *user_errors) return -1; size = 2 * user_error_max * sizeof *user_errors; @@ -105,8 +104,8 @@ static void getmsg(int error, const char **msg) case LBX_EFORMAT: *msg = _("Invalid file format"); break; - case LBX_ENOENT: - *msg = _("Specified item does not exist"); + case LBX_EINVAL: + *msg = _("Invalid argument"); break; case LBX_ENOMEM: *msg = _("Memory allocation failed");