[pan2: 62/68] compatibility with -std=c++0x



commit c1b1f19dd267725d1bee873f7094ce53bfdd9df5
Author: K. Haley <haleykd users sf net>
Date:   Sat Oct 16 14:10:32 2010 -0600

    compatibility with -std=c++0x
    
    Functions strncasecmp & fdopen don't exist with that setting.
    c++0x make use of _close conditional.

 configure.in              |    2 +-
 pan/general/string-view.h |    5 +++--
 pan/gui/post-ui.cc        |   11 +++++++++--
 3 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/configure.in b/configure.in
index 9a412ca..2a2c8f7 100644
--- a/configure.in
+++ b/configure.in
@@ -51,7 +51,7 @@ AC_SUBST(GTKSPELL_REQUIRED)
 AC_PROG_CXX
 AC_HEADER_STDC
 AC_HEADER_TIME
-AC_CHECK_FUNCS([localtime_r])
+AC_CHECK_FUNCS([localtime_r close])
 AC_CXX_HEADER_TR1_UNORDERED_SET
 AC_CXX_HAVE_EXT_HASH_SET
 AC_PROG_AWK
diff --git a/pan/general/string-view.h b/pan/general/string-view.h
index 1ca7066..9b5c2d9 100644
--- a/pan/general/string-view.h
+++ b/pan/general/string-view.h
@@ -23,6 +23,7 @@
 #include <iosfwd>
 #include <string>
 #include <cstring>
+#include <glib.h>
 
 namespace pan
 {
@@ -114,9 +115,9 @@ namespace pan
 
          int strncasecmp (const char * p, unsigned int l) {
            if (len >= l)
-             return ::strncasecmp (str, p, l);
+             return g_ascii_strncasecmp (str, p, l);
            else {
-             int i = ::strncasecmp (str, p, len);
+             int i = g_ascii_strncasecmp (str, p, len);
              if (i)
                return i;
              return -1; // shorter, so less than p
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index bd9622f..2b2affd 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -21,6 +21,7 @@
 #include <fstream>
 #include <iostream>
 #include <sstream>
+#include <unistd.h>
 extern "C" {
   #include <gmime/gmime.h>
   #include <glib/gi18n.h>
@@ -61,6 +62,10 @@ using namespace pan;
 
 namespace
 {
+#ifndef HAVE_CLOSE
+inline int close(int fd) {return _close(fd);}
+#endif
+
   bool remember_charsets (true);
 
   void on_remember_charset_toggled (GtkToggleAction * toggle, gpointer)
@@ -721,8 +726,10 @@ PostUI :: spawn_editor ()
     GError * err = NULL;
     const int fd (g_file_open_tmp ("pan_edit_XXXXXX", &fname, &err));
     if (fd != -1)
-      fp = fdopen (fd, "w");
-    else {
+    {
+      close(fd);
+      fp = g_fopen (fname, "w");
+    } else {
       Log::add_err (err && err->message ? err->message : _("Error opening temporary file"));
       if (err)
         g_clear_error (&err);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]