diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2015-04-25 12:56:44 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2015-04-25 12:56:44 +0200 |
commit | ae1211d4abd28da43e75a73ea9748b9af3dc1961 (patch) | |
tree | b52b906f0555d7bbd95da24a223e215bf43812e8 | |
parent | da184957b9a794bbbaf7c1dd10285a2d10c2ff85 (diff) | |
download | weechat-ae1211d4abd28da43e75a73ea9748b9af3dc1961.zip |
core: rename function and argument to set home path
-rw-r--r-- | src/core/weechat.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/core/weechat.c b/src/core/weechat.c index 3af8b8a0e..fe224c1eb 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -271,17 +271,16 @@ weechat_parse_args (int argc, char *argv[]) } /* - * Helper function for weechat_create_home_dir. - * Expands and assigns given string to weechat_home + * Expands and assigns given path to "weechat_home". */ void -weechat_create_home_dir_set_path (char* local_weechat_home) +weechat_set_home_path (char *home_path) { char *ptr_home; int dir_length; - if (local_weechat_home[0] == '~') + if (home_path[0] == '~') { /* replace leading '~' by $HOME */ ptr_home = getenv ("HOME"); @@ -293,17 +292,17 @@ weechat_create_home_dir_set_path (char* local_weechat_home) /* make C static analyzer happy (never executed) */ return; } - dir_length = strlen (ptr_home) + strlen (local_weechat_home + 1) + 1; + dir_length = strlen (ptr_home) + strlen (home_path + 1) + 1; weechat_home = malloc (dir_length); if (weechat_home) { snprintf (weechat_home, dir_length, - "%s%s", ptr_home, local_weechat_home + 1); + "%s%s", ptr_home, home_path + 1); } } else { - weechat_home = strdup (local_weechat_home); + weechat_home = strdup (home_path); } if (!weechat_home) @@ -330,24 +329,22 @@ weechat_create_home_dir () char *ptr_weechat_home, *config_weechat_home; struct stat statinfo; - /* weechat home is not set yet. Look for environment variable WEECHAT_HOME */ + /* + * weechat_home is not set yet: look for environment variable + * "WEECHAT_HOME" + */ if (!weechat_home) { ptr_weechat_home = getenv ("WEECHAT_HOME"); - - /* Proceed only if environment variable WEECHAT_HOME is set to some value */ - if (ptr_weechat_home && strlen (ptr_weechat_home) != 0) - { - weechat_create_home_dir_set_path (ptr_weechat_home); - } + if (ptr_weechat_home && ptr_weechat_home[0]) + weechat_set_home_path (ptr_weechat_home); } - /* If weechat_home is still not set, try to use compile time default */ + /* weechat_home is still not set: try to use compile time default */ if (!weechat_home) { config_weechat_home = WEECHAT_HOME; - - if (strlen (config_weechat_home) == 0) + if (!config_weechat_home[0]) { string_iconv_fprintf (stderr, _("Error: WEECHAT_HOME is undefined, check " @@ -356,8 +353,7 @@ weechat_create_home_dir () /* make C static analyzer happy (never executed) */ return; } - - weechat_create_home_dir_set_path (config_weechat_home); + weechat_set_home_path (config_weechat_home); } /* if home already exists, it has to be a directory */ @@ -369,6 +365,8 @@ weechat_create_home_dir () _("Error: home (%s) is not a directory\n"), weechat_home); weechat_shutdown (EXIT_FAILURE, 0); + /* make C static analyzer happy (never executed) */ + return; } } @@ -379,6 +377,8 @@ weechat_create_home_dir () _("Error: cannot create directory \"%s\"\n"), weechat_home); weechat_shutdown (EXIT_FAILURE, 0); + /* make C static analyzer happy (never executed) */ + return; } } |