From 9aefa2ebf9c0719c47b3867017a64c87653e36de Mon Sep 17 00:00:00 2001 From: ngn Date: Sun, 14 Jul 2024 21:01:02 +0300 Subject: [PATCH] fix: change error variable names --- include/error.h | 3 +++ locale/tr/LC_MESSAGES/libmp.po | 2 +- src/error.c | 32 ++++++++++++++++---------------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/include/error.h b/include/error.h index cb5a5e8..a1d92bc 100644 --- a/include/error.h +++ b/include/error.h @@ -150,3 +150,6 @@ void lm_error_set(lm_error_t code, ...); void lm_error_clear(); lm_error_t lm_error(); char *lm_strerror(); + +extern lm_error_t lm_error_code; +extern char *lm_error_str; diff --git a/locale/tr/LC_MESSAGES/libmp.po b/locale/tr/LC_MESSAGES/libmp.po index d0a00a0..4478003 100644 --- a/locale/tr/LC_MESSAGES/libmp.po +++ b/locale/tr/LC_MESSAGES/libmp.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-13 16:47+0300\n" +"POT-Creation-Date: 2024-07-14 18:02+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/src/error.c b/src/error.c index b8f6925..2d3c685 100644 --- a/src/error.c +++ b/src/error.c @@ -5,13 +5,13 @@ #include #include -lm_error_t error = LM_ERR_NoError; -char *error_str = NULL; +lm_error_t lm_error_code = LM_ERR_NoError; +char *lm_error_str = NULL; void lm_error_clear() { - free(error_str); - error = LM_ERR_NoError; - error_str = NULL; + free(lm_error_str); + lm_error_code = LM_ERR_NoError; + lm_error_str = NULL; } void lm_error_set(lm_error_t code, ...) { @@ -158,16 +158,16 @@ void lm_error_set(lm_error_t code, ...) { {.code = LM_ERR_InfoNotLoaded, .desc = _("pool info is not loaded") }, }; - char *fmt = NULL; - error = code; + char *fmt = NULL; + lm_error_code = code; - if (NULL != error_str) { - free(error_str); - error_str = NULL; + if (NULL != lm_error_str) { + free(lm_error_str); + lm_error_str = NULL; } for (int i = 0; i < sizeof(errors) / sizeof(lm_error_desc_t); i++) { - if (errors[i].code == error) { + if (errors[i].code == lm_error_code) { fmt = errors[i].desc; break; } @@ -180,18 +180,18 @@ void lm_error_set(lm_error_t code, ...) { va_start(args, code); va_copy(argscp, args); - int size = vsnprintf(NULL, 0, fmt, args) + 2; - error_str = malloc(size); - vsnprintf(error_str, size, fmt, argscp); + int size = vsnprintf(NULL, 0, fmt, args) + 2; + lm_error_str = malloc(size); + vsnprintf(lm_error_str, size, fmt, argscp); va_end(args); va_end(argscp); } char *lm_strerror() { - return error_str; + return lm_error_str; } lm_error_t lm_error() { - return error; + return lm_error_code; }