libpkgconf: path: pkgconf_path_relocate(): implement realpath backend

feature/tap-sh
William Pitcock 2017-01-19 10:36:07 -06:00
parent 0315832285
commit fa927fd379
1 changed files with 16 additions and 1 deletions

View File

@ -240,7 +240,7 @@ pkgconf_path_free(pkgconf_list_t *dirlist)
bool bool
pkgconf_path_relocate(char *buf, size_t buflen) pkgconf_path_relocate(char *buf, size_t buflen)
{ {
#ifdef HAVE_CYGWIN_CONV_PATH #if defined(HAVE_CYGWIN_CONV_PATH)
ssize_t size; ssize_t size;
char *tmpbuf, *ti; char *tmpbuf, *ti;
@ -261,6 +261,21 @@ pkgconf_path_relocate(char *buf, size_t buflen)
if (*ti == '\\') if (*ti == '\\')
*ti = '/'; *ti = '/';
} }
#elif defined(HAVE_REALPATH)
char *tmpbuf;
if ((tmpbuf = realpath(buf, NULL)) != NULL)
{
size_t tmpbuflen = strlen(tmpbuf);
if (tmpbuflen > buflen)
{
free(tmpbuf);
return false;
}
pkgconf_strlcpy(buf, tmpbuf, buflen);
free(tmpbuf);
}
#else #else
(void) buf; (void) buf;
(void) buflen; (void) buflen;