summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2007-05-14 15:35:37 +0000
committerEmmanuele Bassi <ebassi@src.gnome.org>2007-05-14 15:35:37 +0000
commit2e098756c1717e9e0e735ee7ea77cbaeba463550 (patch)
tree4d7eebaeb90c52738a2ff9a246da9bfdb99aff04
parent59120d8bfd7ec9d6d254065f3de3c9729e3c9a1d (diff)
downloadgtk+-2e098756c1717e9e0e735ee7ea77cbaeba463550.tar.gz
Add check for GNU extensions to ftw()/nftw().
2007-05-14 Emmanuele Bassi <ebassi@gnome.org> * configure.in: Add check for GNU extensions to ftw()/nftw(). * gtk/gtksearchenginesimple.c: Fix compilation on systems with only POSIX-compliant ftw(). (#435797, based on a patch by Richard Hult) svn path=/trunk/; revision=17844
-rw-r--r--ChangeLog8
-rw-r--r--configure.in11
-rw-r--r--gtk/gtksearchenginesimple.c31
3 files changed, 42 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 7c2b50d821..06c4eddf4b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2007-05-14 Emmanuele Bassi <ebassi@gnome.org>
+ * configure.in: Add check for GNU extensions to ftw()/nftw().
+
+ * gtk/gtksearchenginesimple.c: Fix compilation on systems with
+ only POSIX-compliant ftw(). (#435797, based on a patch by
+ Richard Hult)
+
+2007-05-14 Emmanuele Bassi <ebassi@gnome.org>
+
* gtk/gtkfilechooserdefault.c:
Convert the GtkTreeIter inside the sorting functions for the
search and recent modes. This doesn't yet fix the segfault when
diff --git a/configure.in b/configure.in
index 7113cec10d..90acb1c124 100644
--- a/configure.in
+++ b/configure.in
@@ -567,6 +567,17 @@ AC_CHECK_HEADERS(sys/time.h, AC_DEFINE(HAVE_SYS_TIME_H))
AC_CHECK_HEADERS(unistd.h, AC_DEFINE(HAVE_UNISTD_H))
AC_CHECK_HEADERS(ftw.h, AC_DEFINE(HAVE_FTW_H))
+AC_MSG_CHECKING([for GNU ftw extensions])
+AC_TRY_COMPILE([#define _XOPEN_SOURCE 500
+#define _GNU_SOURCE
+#include <ftw.h>], [int flags = FTW_ACTIONRETVAL;], gtk_ok=yes, gtk_ok=no)
+if test $gtk_ok = yes; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_GNU_FTW,1,[Have GNU ftw])
+else
+ AC_MSG_RESULT([no])
+fi
+
saved_cflags="$CFLAGS"
saved_ldflags="$LDFLAGS"
diff --git a/gtk/gtksearchenginesimple.c b/gtk/gtksearchenginesimple.c
index 26768488ee..ede5e85214 100644
--- a/gtk/gtksearchenginesimple.c
+++ b/gtk/gtksearchenginesimple.c
@@ -20,10 +20,17 @@
* Based on nautilus-search-engine-simple.c
*/
+#include <config.h>
+
+#ifdef HAVE_GNU_FTW
#define _XOPEN_SOURCE 500
#define _GNU_SOURCE
+#endif
+
+#ifdef HAVE_FTW_H
+#include <ftw.h>
+#endif
-#include <config.h>
#include "gtksearchenginesimple.h"
#define XDG_PREFIX _gtk_xdg
@@ -31,10 +38,6 @@
#include <string.h>
-#ifdef HAVE_FTW_H
-#include <ftw.h>
-#endif
-
#include <glib/gstrfuncs.h>
#define BATCH_SIZE 500
@@ -205,9 +208,13 @@ search_visit_func (const char *fpath,
gboolean is_hidden;
data = (SearchThreadData*)g_static_private_get (&search_thread_data);
-
+
if (data->cancelled)
+#ifdef HAVE_GNU_FTW
return FTW_STOP;
+#else
+ return 1;
+#endif /* HAVE_GNU_FTW */
name = strrchr (fpath, '/');
if (name)
@@ -262,10 +269,14 @@ search_visit_func (const char *fpath,
if (data->n_processed_files > BATCH_SIZE)
send_batch (data);
+#ifdef HAVE_GNU_FTW
if (is_hidden)
return FTW_SKIP_SUBTREE;
else
return FTW_CONTINUE;
+#else
+ return 0;
+#endif /* HAVE_GNU_FTW */
}
#endif /* HAVE_FTW_H */
@@ -279,12 +290,16 @@ search_thread_func (gpointer user_data)
g_static_private_set (&search_thread_data, data, NULL);
- nftw (data->path, search_visit_func, 20, FTW_ACTIONRETVAL | FTW_PHYS);
+ nftw (data->path, search_visit_func, 20,
+#ifdef HAVE_GNU_FTW
+ FTW_ACTIONRETVAL |
+#endif
+ FTW_PHYS);
send_batch (data);
g_idle_add (search_thread_done_idle, data);
-#endif
+#endif /* HAVE_FTW_H */
return NULL;
}