From 3867a6643441b175cc2af0f2b7e2ae259a97ae2a Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Fri, 14 Sep 2012 15:42:06 -0500 Subject: [PATCH] pkg: pkg_get_parent_dir() should fall back to '/' directory separator if necessary Some environments such as the MingW-MSYS shell environment use both \ and / as directory separators, thusly we should fall back to the POSIX directory separator. Both directory separators are fully supported by Windows. --- pkg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg.c b/pkg.c index dbc9d8d..fbfc6cc 100644 --- a/pkg.c +++ b/pkg.c @@ -131,7 +131,10 @@ pkg_get_parent_dir(pkg_t *pkg) char *pathbuf; strlcpy(buf, pkg->filename, sizeof buf); - if ((pathbuf = strrchr(buf, PKG_DIR_SEP_S)) != NULL) + pathbuf = strrchr(buf, PKG_DIR_SEP_S); + if (pathbuf == NULL) + pathbuf = strrchr(buf, '/'); + if (pathbuf != NULL) pathbuf[0] = '\0'; return buf;