You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
945 B

diff --git a/src/magic.c b/src/magic.c
index 5403951..2b61080 100644
--- a/src/magic.c
+++ b/src/magic.c
@@ -101,16 +101,21 @@ get_default_magic(void)
if ((home = getenv("HOME")) == NULL)
return MAGIC;
- if (asprintf(&hmagicpath, "%s/.magic", home) < 0)
+ if (asprintf(&hmagicpath, "%s/.magic.mgc", home) < 0)
return MAGIC;
- if (stat(hmagicpath, &st) == -1)
- goto out;
- if (S_ISDIR(st.st_mode)) {
+ if (stat(hmagicpath, &st) == -1) {
free(hmagicpath);
- if (asprintf(&hmagicpath, "%s/%s", home, hmagic) < 0)
+ if (asprintf(&hmagicpath, "%s/.magic", home) < 0)
return MAGIC;
- if (access(hmagicpath, R_OK) == -1)
+ if (stat(hmagicpath, &st) == -1)
goto out;
+ if (S_ISDIR(st.st_mode)) {
+ free(hmagicpath);
+ if (asprintf(&hmagicpath, "%s/%s", home, hmagic) < 0)
+ return MAGIC;
+ if (access(hmagicpath, R_OK) == -1)
+ goto out;
+ }
}
if (asprintf(&default_magic, "%s:%s", hmagicpath, MAGIC) < 0)