summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2009-07-23 22:51:56 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2009-07-23 22:51:56 +0000
commitf42c5415294d6927ecff1319dd6a6141626f6ff9 (patch)
treeae34e2873d6822ccce327f8b5905f1be20280f30
parenta32ec7f20e1cad1293a0cc8aee1834b1ee67dc80 (diff)
Fixed glibc 2.10 compiler problems (Fedora 11 and others) with scandir()
and strchr() (STR #2222). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6833 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--CHANGES2
-rw-r--r--configh.in4
-rw-r--r--configure.in20
-rw-r--r--src/filename_list.cxx4
-rw-r--r--src/fl_set_fonts_xft.cxx6
5 files changed, 30 insertions, 6 deletions
diff --git a/CHANGES b/CHANGES
index 79a3d0118..d483336ff 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,7 @@
CHANGES IN FLTK 1.3.0
+ - Fixed glibc 2.10 compiler problems (Fedora 11 and others)
+ with scandir() and strchr() (STR #2222)
- Corrected const methods of Fl_Text_{Buffer|Display|Selection}
to be declared const, corrected an Fl_Text_Buffer attrib. typo
- Fixed OpenGL shared context handling (STR #2135)
diff --git a/configh.in b/configh.in
index 1785cf985..35275c379 100644
--- a/configh.in
+++ b/configh.in
@@ -180,7 +180,8 @@
#undef U64
/*
- * HAVE_DIRENT_H, HAVE_SYS_NDIR_H, HAVE_SYS_DIR_H, HAVE_NDIR_H, HAVE_SCANDIR:
+ * HAVE_DIRENT_H, HAVE_SYS_NDIR_H, HAVE_SYS_DIR_H, HAVE_NDIR_H,
+ * HAVE_SCANDIR, HAVE_SCANDIR_POSIX:
*
* Where is <dirent.h> (used only by fl_file_chooser and scandir).
*/
@@ -190,6 +191,7 @@
#undef HAVE_SYS_DIR_H
#undef HAVE_NDIR_H
#undef HAVE_SCANDIR
+#undef HAVE_SCANDIR_POSIX
/*
* Possibly missing sprintf-style functions:
diff --git a/configure.in b/configure.in
index 2da2818e6..bbc178df5 100644
--- a/configure.in
+++ b/configure.in
@@ -449,6 +449,26 @@ AC_CHECK_FUNC(scandir,
else
AC_DEFINE(HAVE_SCANDIR)
fi)
+
+dnl Do we have the POSIX compatible scandir() prototype?
+AC_CACHE_CHECK([whether we have the POSIX compatible scandir() prototype],
+ ac_cv_cxx_scandir_posix,[
+ AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ AC_TRY_COMPILE([
+ #include <dirent.h>
+ int func (const char *d, dirent ***list, void *sort) {
+ int n = scandir(d, list, 0, (int(*)(const dirent **, const dirent **))sort);
+ }
+ ],[
+ ], ac_cv_cxx_scandir_posix=yes, ac_cv_cxx_scandir_posix=no)
+ AC_LANG_RESTORE
+ ])
+
+if test "$ac_cv_cxx_scandir_posix" = yes; then
+ AC_DEFINE(HAVE_SCANDIR_POSIX)
+fi
+
AC_CHECK_FUNC(vsnprintf,[
case "$uname" in
HP-UX*)
diff --git a/src/filename_list.cxx b/src/filename_list.cxx
index 75076a122..e32375557 100644
--- a/src/filename_list.cxx
+++ b/src/filename_list.cxx
@@ -77,8 +77,8 @@ int fl_filename_list(const char *d, dirent ***list,
Fl_File_Sort_F *sort) {
#ifndef HAVE_SCANDIR
int n = scandir(d, list, 0, sort);
-#elif defined(__hpux) || defined(__CYGWIN__)
- // HP-UX, Cygwin define the comparison function like this:
+#elif defined(HAVE_SCANDIR_POSIX)
+ // POSIX (2008) defines the comparison function like this:
int n = scandir(d, list, 0, (int(*)(const dirent **, const dirent **))sort);
#elif defined(__osf__)
// OSF, DU 4.0x
diff --git a/src/fl_set_fonts_xft.cxx b/src/fl_set_fonts_xft.cxx
index b1762ced5..212626333 100644
--- a/src/fl_set_fonts_xft.cxx
+++ b/src/fl_set_fonts_xft.cxx
@@ -271,13 +271,13 @@ Fl_Font Fl::set_fonts(const char* pattern_name)
// So the bit we want is up to the first comma - BUT some strings have
// more than one name, separated by, guess what?, a comma...
stop = start = first = 0;
- stop = strchr((const char *)font, ',');
- start = strchr((const char *)font, ':');
+ stop = strchr((char *)font, ',');
+ start = strchr((char *)font, ':');
if ((stop) && (start) && (stop < start))
{
first = stop + 1; // discard first version of name
// find first comma *after* the end of the name
- stop = strchr((const char *)start, ',');
+ stop = strchr((char *)start, ',');
}
else
{