DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2222
Version: 1.3-current


Please test the patch in scandir_const.diff for FLTK 1.3 (svn). This ought
to fix both the scandir() and the strchr() const issues.

This is not fully tested yet, there's one commented test statement
included, and these maybe obsolete cases "HP-UX, Cygwin" as described
above are not (yet) removed.

Feedback, particularly from Fedora 11 users (but also from other platforms
to confirm that it doesn't break anything) highly appreciated !


Link: http://www.fltk.org/str.php?L2222
Version: 1.3-current
Index: configh.in
===================================================================
--- configh.in  (Revision 6829)
+++ configh.in  (Arbeitskopie)
@@ -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:
Index: src/filename_list.cxx
===================================================================
--- src/filename_list.cxx       (Revision 6829)
+++ src/filename_list.cxx       (Arbeitskopie)
@@ -77,6 +77,9 @@
                      Fl_File_Sort_F *sort) {
 #ifndef HAVE_SCANDIR
   int n = scandir(d, list, 0, sort);
+#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(__hpux) || defined(__CYGWIN__)
   // HP-UX, Cygwin define the comparison function like this:
   int n = scandir(d, list, 0, (int(*)(const dirent **, const dirent **))sort);
Index: src/fl_set_fonts_xft.cxx
===================================================================
--- src/fl_set_fonts_xft.cxx    (Revision 6829)
+++ src/fl_set_fonts_xft.cxx    (Arbeitskopie)
@@ -271,13 +271,13 @@
       // 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
       {
Index: configure.in
===================================================================
--- configure.in        (Revision 6829)
+++ configure.in        (Arbeitskopie)
@@ -449,6 +449,27 @@
     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);
+           // int n = scandir(d, list, 0, (int(*)(const void *, const void 
*))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*)
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to