Commit 2e098756 authored by Emmanuele Bassi's avatar Emmanuele Bassi Committed by Emmanuele Bassi

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
parent 59120d8b
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:
......
......@@ -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"
......
......@@ -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;
}
......
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