#! /bin/sh /usr/share/dpatch/dpatch-run
## 20-autoconf-fix-iostream.dpatch by Thomas Girard <thomas.g.girard@free.fr>
##
## DP: fix autotools iostream detection
@DPATCH@
--- ACE_wrappers.orig/configure.ac
+++ ACE_wrappers/configure.ac
@@ -1013,11 +1013,9 @@
 dnl Check for availablity of "new style" C++ stream headers
 AC_CHECK_HEADERS([iomanip ios iostream istream ostream fstream streambuf],
   ,
-  [AC_DEFINE([ACE_USES_OLD_IOSTREAMS])])
-
-AC_CHECK_HEADER([iostream.h],
-  [AC_CHECK_HEADER([fstream.h],,[AC_DEFINE([ACE_LACKS_IOSTREAM_TOTALLY])])],
-  [AC_DEFINE([ACE_LACKS_IOSTREAM_TOTALLY])])
+  [AC_CHECK_HEADERS([iostream.h fstream.h],
+                    [AC_DEFINE([ACE_USES_OLD_IOSTREAMS])],
+                    [AC_DEFINE([ACE_LACKS_IOSTREAM_TOTALLY])])])
 
 dnl Check if platform needs to #include <regexpr.h> for
 dnl regular expression support
@@ -2014,14 +2012,18 @@
   [ace_cv_feature_char_right_shifts],
   [
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef ACE_USES_OLD_IOSTREAM
 #include <iostream.h>
+#else
+#include <iostream>
+#endif
                   ]],[[
 unsigned char a = 0;
-cin >> a;
+std::cin >> a;
 
 #ifndef ACE_LACKS_SIGNED_CHAR
 signed char b = 0;
-cin >> b;
+std::cin >> b;
 #endif
                   ]])],[
                    ace_cv_feature_char_right_shifts=yes
@@ -2036,14 +2038,18 @@
   [ace_cv_feature_char_ptr_right_shifts],
   [
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef ACE_USES_OLD_IOSTREAMS
 #include <iostream.h>
+#else
+#include <iostream>
+#endif
                   ]],[[
 unsigned char * a = 0;
-cin >> a;
+std::cin >> a;
 
 #ifndef ACE_LACKS_SIGNED_CHAR
 signed char * b = 0;
-cin >> b;
+std::cin >> b;
 #endif
                   ]])],[
                    ace_cv_feature_char_ptr_right_shifts=yes
@@ -5823,9 +5829,17 @@
 ACE_CACHE_CHECK([for iostream method ipfx()],
   [ace_cv_feature_has_iostream_ipfx],[
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef ACE_USES_OLD_IOSTREAMS
 #include <iostream.h>
+#else
+#include <iostream>
+#endif
       ]], [[
+#ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB
+       std::cin.ipfx();
+#else
        cin.ipfx();
+#endif
       ]])],[
        ace_cv_feature_has_iostream_ipfx=yes
       ],[
@@ -5837,9 +5851,17 @@
 ACE_CACHE_CHECK([for line-buffered streambufs],
   [ace_cv_feature_has_linebuffered_streambuf],[
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef ACE_USES_OLD_IOSTREAMS
 #include <iostream.h>
+#else
+#include <iostream>
+#endif
       ]], [[
+#ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB
+       std::cin.rdbuf()->linebuffered(1);
+#else
        cin.rdbuf()->linebuffered(1);
+#endif
       ]])],[
        ace_cv_feature_has_linebuffered_streambuf=yes
       ],[
@@ -5851,9 +5873,17 @@
 ACE_CACHE_CHECK([for unbuffered streambufs],
   [ace_cv_feature_has_unbuffered_streambuf],[
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef ACE_USES_OLD_IOSTREAMS
 #include <iostream.h>
+#else
+#include <iostream>
+#endif
       ]], [[
+#ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB
+       std::cin.rdbuf()->unbuffered(1);
+#else
        cin.rdbuf()->unbuffered(1);
+#endif
       ]])],[
        ace_cv_feature_has_unbuffered_streambuf=yes
       ],[
--- ACE_wrappers.orig/m4/aio.m4
+++ ACE_wrappers/m4/aio.m4
@@ -64,7 +64,6 @@
 #include <string.h>
 #include <errno.h>
 #include <stdio.h>
-#include <iostream.h>
 
 #include <aio.h>
 
