summaryrefslogtreecommitdiff
path: root/src/locale.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2023-01-14 12:32:28 +0000
committerBram Moolenaar <Bram@vim.org>2023-01-14 12:32:28 +0000
commite8575988969579f9e1439181ae338b2ff74054a8 (patch)
treef4c8a1242cb67b073bb0e375740c764c2136af21 /src/locale.c
parent378e6c03f98efc88e8c2675e05a548f9bb7889a1 (diff)
downloadvim-git-e8575988969579f9e1439181ae338b2ff74054a8.tar.gz
patch 9.0.1196: code is indented more than necessaryv9.0.1196
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11813)
Diffstat (limited to 'src/locale.c')
-rw-r--r--src/locale.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/src/locale.c b/src/locale.c
index d0378ffb5..ccdb479a8 100644
--- a/src/locale.c
+++ b/src/locale.c
@@ -151,20 +151,20 @@ get_mess_env(void)
char_u *p;
p = mch_getenv((char_u *)"LC_ALL");
- if (p == NULL || *p == NUL)
- {
- p = mch_getenv((char_u *)"LC_MESSAGES");
- if (p == NULL || *p == NUL)
- {
- p = mch_getenv((char_u *)"LANG");
- if (p != NULL && VIM_ISDIGIT(*p))
- p = NULL; // ignore something like "1043"
+ if (p != NULL && *p != NUL)
+ return p;
+
+ p = mch_getenv((char_u *)"LC_MESSAGES");
+ if (p != NULL && *p != NUL)
+ return p;
+
+ p = mch_getenv((char_u *)"LANG");
+ if (p != NULL && VIM_ISDIGIT(*p))
+ p = NULL; // ignore something like "1043"
# ifdef HAVE_GET_LOCALE_VAL
- if (p == NULL || *p == NUL)
- p = get_locale_val(LC_CTYPE);
+ if (p == NULL || *p == NUL)
+ p = get_locale_val(LC_CTYPE);
# endif
- }
- }
return p;
}
#endif
@@ -504,11 +504,11 @@ find_locales(void)
static void
init_locales(void)
{
- if (!did_init_locales)
- {
- did_init_locales = TRUE;
- locales = find_locales();
- }
+ if (did_init_locales)
+ return;
+
+ did_init_locales = TRUE;
+ locales = find_locales();
}
# if defined(EXITFREE) || defined(PROTO)
@@ -516,12 +516,13 @@ init_locales(void)
free_locales(void)
{
int i;
- if (locales != NULL)
- {
- for (i = 0; locales[i] != NULL; i++)
- vim_free(locales[i]);
- VIM_CLEAR(locales);
- }
+
+ if (locales == NULL)
+ return;
+
+ for (i = 0; locales[i] != NULL; i++)
+ vim_free(locales[i]);
+ VIM_CLEAR(locales);
}
# endif