Mercurial > hg > forks > geeqie
changeset 2783:cb5b42c6d741
Fix #618: Avoid using PATH_MAX where not available
https://github.com/BestImageViewer/geeqie/pull/618
Geeqie fails to build on Hurd because of not finding PATH_MAX, this fix would avoid using PATH_MAX on systems where it isn't available.
author | Andreas Rönnquist <> |
---|---|
date | Mon, 25 Jun 2018 10:19:46 +0100 |
parents | 1537bf3a3c56 |
children | 03dd5a7bb410 |
files | src/ui_fileops.c |
diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ui_fileops.c Sun Jun 24 20:20:23 2018 +0100 +++ b/src/ui_fileops.c Mon Jun 25 10:19:46 2018 +0100 @@ -570,10 +570,20 @@ { gchar *absolute; - absolute = g_malloc(PATH_MAX + 1); char *lastslash = strrchr(sl, G_DIR_SEPARATOR); int len = lastslash - sl + 1; + int path_max; +#ifdef PATH_MAX + path_max = PATH_MAX; +#else + path_max = pathconf(sl, _PC_PATH_MAX); + if (path_max <= 0) + path_max = 4096; +#endif + + absolute = g_malloc(path_max + 1); + strncpy(absolute, sl, len); strcpy(absolute + len, link_target); strcpy(link_target, absolute);