From 2e098756c1717e9e0e735ee7ea77cbaeba463550 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 14 May 2007 15:35:37 +0000 Subject: [PATCH] Add check for GNU extensions to ftw()/nftw(). 2007-05-14 Emmanuele Bassi * 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 --- ChangeLog | 8 ++++++++ configure.in | 11 +++++++++++ gtk/gtksearchenginesimple.c | 31 +++++++++++++++++++++++-------- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7c2b50d821..06c4eddf4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-05-14 Emmanuele Bassi + + * 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 * gtk/gtkfilechooserdefault.c: 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 ], [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 + +#ifdef HAVE_GNU_FTW #define _XOPEN_SOURCE 500 #define _GNU_SOURCE +#endif + +#ifdef HAVE_FTW_H +#include +#endif -#include #include "gtksearchenginesimple.h" #define XDG_PREFIX _gtk_xdg @@ -31,10 +38,6 @@ #include -#ifdef HAVE_FTW_H -#include -#endif - #include #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; }