summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2016-06-12 08:07:44 +0200
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2016-06-12 08:12:00 +0200
commit2f7bb2cb5ea670b9dc4ef6acd3136af9f024b65c (patch)
tree1f8f30109ba1e5962ba66c0b2e5a9e9c889d39d8 /src/main.c
parenta7db3b88bd0a9cc60e3e6b9c2ab03df2b510f3dc (diff)
downloadratpoison-2f7bb2cb5ea670b9dc4ef6acd3136af9f024b65c.zip
Read the system config even if the homedir can't be found.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/main.c b/src/main.c
index 18ee598..11d7ca0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -431,38 +431,41 @@ read_startup_files (const char *alt_rcfile)
}
else
{
- /* first check $HOME/.ratpoisonrc and if that does not exist then try
- $sysconfdir/ratpoisonrc */
const char *homedir;
+ char *filename;
+ /* first check $HOME/.ratpoisonrc */
homedir = get_homedir ();
-
if (!homedir)
PRINT_ERROR (("ratpoison: no home directory!?\n"));
else
{
- char *filename;
filename = xsprintf ("%s/.ratpoisonrc", homedir);
-
if ((fileptr = fopen (filename, "r")) == NULL)
{
if (errno != ENOENT)
PRINT_ERROR (("ratpoison: could not open %s (%s)\n",
filename, strerror (errno)));
+ }
+ free (filename);
+ }
- free (filename);
- filename = xsprintf ("%s/ratpoisonrc", SYSCONFDIR);
+ if (fileptr == NULL)
+ {
+ /* couldn't open $HOME/.ratpoisonrc, fall back on system config */
+ filename = xsprintf ("%s/ratpoisonrc", SYSCONFDIR);
- if ((fileptr = fopen (filename, "r")) == NULL)
- if (errno != ENOENT)
- PRINT_ERROR (("ratpoison: could not open %s (%s)\n",
- filename, strerror (errno)));
+ if ((fileptr = fopen (filename, "r")) == NULL)
+ {
+ if (errno != ENOENT)
+ PRINT_ERROR (("ratpoison: could not open %s (%s)\n",
+ filename, strerror (errno)));
}
free (filename);
}
}
- if (fileptr)
+ if (fileptr != NULL)
{
set_close_on_exec (fileno (fileptr));
read_rc_file (fileptr);