Commit d7a5e544 authored by Samuel Thibault's avatar Samuel Thibault Committed by David Zeuthen

Bug 24495 – Fails to build on platforms without PATH_MAX (like hurd)

PATH_MAX, which hurd-i386 doesn't define since it doesn't have such
arbitrary limitation.  The attached patch fixes it by just using
glibc's get_current_dir_name() extension when available.
Signed-off-by: Michael Biebl's avatarMichael Biebl <mbiebl@gmail.com>
Signed-off-by: default avatarDavid Zeuthen <davidz@redhat.com>
parent ce29effd
......@@ -19,8 +19,10 @@
* Author: David Zeuthen <davidz@redhat.com>
*/
#define _GNU_SOURCE
#include <glib.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
......@@ -31,13 +33,21 @@ main (int argc, char *argv[])
gchar **env;
guint n;
int ret;
#ifdef __GLIBC__
gchar *cwd = NULL;
#else
gchar cwd[PATH_MAX];
#endif
ret = 1;
args = NULL;
env = NULL;
#ifdef __GLIBC__
if ((cwd = get_current_dir_name ()))
#else
if (getcwd (cwd, sizeof cwd) == NULL)
#endif
{
g_printerr ("Error getting cwd: %s", g_strerror (errno));
goto out;
......@@ -62,6 +72,9 @@ main (int argc, char *argv[])
out:
#ifdef __GLIBC__
free (cwd);
#endif
g_free (args);
g_strfreev (env);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment