if (!FR_DIR_IS_RELATIVE(filename)) {
strlcpy(dir, filename, sizeof(dir));
p = strrchr(dir, FR_DIR_SEP);
- if (p) p[1] = '\0';
+ if (p) {
+ p[1] = '\0';
+ } else {
+ strlcat(dir, "/", sizeof(dir));
+ }
strlcpy(fn, filename, sizeof(fn));
} else {
strlcpy(dir, parent, sizeof(dir));
p = strrchr(dir, FR_DIR_SEP);
- if (p && p[1]) strlcat(dir, "/", sizeof(dir));
+ if (p) {
+ if (p[1]) strlcat(dir, "/", sizeof(dir));
+ } else {
+ strlcat(dir, "/", sizeof(dir));
+ }
strlcat(dir, filename, sizeof(dir));
p = strrchr(dir, FR_DIR_SEP);
- if (p) p[1] = '\0';
+ if (p) {
+ p[1] = '\0';
+ } else {
+ strlcat(dir, "/", sizeof(dir));
+ }
p = strrchr(filename, FR_DIR_SEP);
if (p) {
}
- fprintf(stderr, "PARENT %s %s FINAL %s %s\n",
- parent, filename, dir, fn);
-
-
if ((fp = fopen(fn, "r")) == NULL) {
if (!src_file) {
fr_strerror_printf("dict_init: Couldn't open dictionary \"%s\": %s",