forked from ariadne/pkgconf
Merge pull request #36 from bdrewery/fix-crash-without-pathseps
Fix crash when specified filename has no path separatorsfeature/tap-sh
commit
5bd921b312
6
pkg.c
6
pkg.c
|
@ -131,7 +131,7 @@ pkg_get_parent_dir(pkg_t *pkg)
|
||||||
char *pathbuf;
|
char *pathbuf;
|
||||||
|
|
||||||
strlcpy(buf, pkg->filename, sizeof buf);
|
strlcpy(buf, pkg->filename, sizeof buf);
|
||||||
pathbuf = strrchr(buf, PKG_DIR_SEP_S);
|
if ((pathbuf = strrchr(buf, PKG_DIR_SEP_S)) != NULL)
|
||||||
pathbuf[0] = '\0';
|
pathbuf[0] = '\0';
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
|
@ -154,8 +154,10 @@ pkg_new_from_file(const char *filename, FILE *f)
|
||||||
pkg->vars = pkg_tuple_add(pkg->vars, "pcfiledir", pkg_get_parent_dir(pkg));
|
pkg->vars = pkg_tuple_add(pkg->vars, "pcfiledir", pkg_get_parent_dir(pkg));
|
||||||
|
|
||||||
/* make module id */
|
/* make module id */
|
||||||
idptr = strrchr(pkg->filename, PKG_DIR_SEP_S);
|
if ((idptr = strrchr(pkg->filename, PKG_DIR_SEP_S)) != NULL)
|
||||||
idptr++;
|
idptr++;
|
||||||
|
else
|
||||||
|
idptr = pkg->filename;
|
||||||
|
|
||||||
pkg->id = strdup(idptr);
|
pkg->id = strdup(idptr);
|
||||||
idptr = strrchr(pkg->id, '.');
|
idptr = strrchr(pkg->id, '.');
|
||||||
|
|
Loading…
Reference in New Issue