work around different dirname()/basename() implementations.

This commit is contained in:
Joris Vink 2020-06-09 12:22:22 +02:00
parent 30e9b642a0
commit 8a39d18196
1 changed files with 13 additions and 5 deletions

View File

@ -2425,12 +2425,19 @@ python_import(const char *path)
fatal("python_import: '%s' is not a file or directory", path);
copy = kore_strdup(path);
if ((file = basename(copy)) == NULL)
fatal("basename: %s: %s", path, errno_s);
if ((dir = dirname(copy)) == NULL)
if ((p = dirname(copy)) == NULL)
fatal("dirname: %s: %s", path, errno_s);
dir = kore_strdup(p);
kore_free(copy);
copy = kore_strdup(path);
if ((p = basename(copy)) == NULL)
fatal("basename: %s: %s", path, errno_s);
file = kore_strdup(p);
kore_free(copy);
if ((p = strrchr(file, '.')) != NULL)
*p = '\0';
@ -2443,7 +2450,8 @@ python_import(const char *path)
if (module == NULL)
PyErr_Print();
kore_free(copy);
kore_free(dir);
kore_free(file);
return (module);
}