summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <sthibault@debian.org>2009-10-15 16:52:40 -0400
committerDavid Zeuthen <davidz@redhat.com>2009-10-15 16:52:40 -0400
commitd7a5e544a47f5dcaa4737ddf73b959756503ab66 (patch)
treed5121f853e26e29c5f53a637e47024e31c8693b4
parentce29effd0d2405e2adea7dc496be8ed841083ed1 (diff)
downloadpolkit-d7a5e544a47f5dcaa4737ddf73b959756503ab66.tar.gz
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 <mbiebl@gmail.com> Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r--src/examples/frobnicate.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/examples/frobnicate.c b/src/examples/frobnicate.c
index 9de4b49..c87c2dc 100644
--- a/src/examples/frobnicate.c
+++ b/src/examples/frobnicate.c
@@ -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);