]> www.ginac.de Git - ginac.git/commitdiff
* Remove support for <strstream>. It is too bug-ridden.
authorRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Fri, 26 Oct 2001 17:19:24 +0000 (17:19 +0000)
committerRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Fri, 26 Oct 2001 17:19:24 +0000 (17:19 +0000)
INSTALL
check/check_lsolve.cpp
check/time_dennyfliegner.cpp
check/times.h
configure.in
ginac/numeric.cpp
ginac/tostring.h

diff --git a/INSTALL b/INSTALL
index ee1eb2b078956ad5c5f2cdfe1dfb8922a9d3f96d..721d6a2515f81b555e083bf675b4223adcc1a78c 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -80,13 +80,18 @@ libreadline and maybe libreadline-dev.  If your system's vendor
 doesn't supply such packages, go to <ftp://ftp.gnu.org/gnu/readline/>
 and compile it yourself.
 
-Problems with missing <sstream>
--------------------------------
-
-GCC-2.95.2 and earlier don't have support for this header.  GiNaC can use
-<strstream> instead, but this may cause some trouble later.  GCC-3.0 has a
-completely new implementation of the STL-headers (libstdc++-v3) and there,
-standard-conforming support for <sstream> is present.  If you can't upgrade
-your compiler we recommend using the libstdc++-v2 <sstream> header by
-Magnus Fromreide.  It was posted to the gcc-patches mailing list on
-November 21 2000: <http://gcc.gnu.org/ml/gcc-patches/2000-11/msg01152.html>.
+Problems with missing standard header files
+-------------------------------------------
+
+Building GiNaC requires many standard header files.  If you get a
+configure error complaining about such missing files your compiler and
+library are probably not up to date enough and it's no worth
+continuing.  If the only file missing is <sstream>, however, there is
+a solution.  GCC-2.95.2 and earlier don't ship with this file.  A
+working implementation has been available since GCC-2.95.3.  GCC-3.0
+and later have an even better, fully standard-conforming
+implementation, by default.  If you are stuck with GCC-2.95.2 or
+earliear and you cannot upgrade your compiler we recommend obtaining
+the libstdc++-v2 <sstream> header written by Magnus Fromreide.  It was
+posted to the gcc-patches mailing list on November 21 2000:
+<http://gcc.gnu.org/ml/gcc-patches/2000-11/msg01152.html>.
index 59264d9d1cb4cf23b173d438a72db6dca27529d5..a964c4b305352012393dad56dbe6b9bead9e752b 100644 (file)
  */
 
 #include "checks.h"
-
-#if defined(HAVE_SSTREAM)
-#  include <sstream>
-#else
-#  include <strstream>
-#endif
+#include <sstream>
 
 static unsigned check_matrix_solve(unsigned m, unsigned n, unsigned p,
                                                                   unsigned degree)
@@ -55,15 +50,9 @@ static unsigned check_matrix_solve(unsigned m, unsigned n, unsigned p,
        matrix X(n,p);
        for (unsigned i=0; i<n; ++i) {
                for (unsigned j=0; j<p; ++j) {
-#if defined(HAVE_SSTREAM)
                        ostringstream buf;
                        buf << "x" << i << j << ends;
                        x.push_back(symbol(buf.str()));
-#else
-                       char buf[4];
-                       ostrstream(buf,sizeof(buf)) << i << j << ends;
-                       x.push_back(symbol(string("x")+buf));
-#endif
                        X.set(i,j,x[p*i+j]);
                }
        }
@@ -113,17 +102,10 @@ static unsigned check_inifcns_lsolve(unsigned n)
                vector<symbol> a;
                vector<symbol> x;
                for (unsigned i=0; i<n; ++i) {
-#if defined(HAVE_SSTREAM)
                        ostringstream buf;
                        buf << i << ends;
                        a.push_back(symbol(string("a")+buf.str()));
                        x.push_back(symbol(string("x")+buf.str()));
-#else
-                       char buf[3];
-                       ostrstream(buf,sizeof(buf)) << i << ends;
-                       a.push_back(symbol(string("a")+buf));
-                       x.push_back(symbol(string("x")+buf));
-#endif
                }
                lst eqns;  // equation list
                lst vars;  // variable list
index 4f6b7dc35e522918494266a79eb73b183fae9c83..07ebbe6fa2fdd3084596c0cd0d9b97436858e203 100644 (file)
@@ -33,15 +33,9 @@ static unsigned expand_subs(unsigned size)
        vector<symbol> a;
        ex e;
        for (unsigned i=0; i<size; ++i) {
-#if defined(HAVE_SSTREAM)
                ostringstream buf;
                buf << "a" << i << ends;
                a.push_back(symbol(buf.str()));
-#else
-               char buf[5];  // 'a' + 3 decimal digits + '\n'
-               ostrstream(buf,sizeof(buf)) << "a" << i << ends;
-               a.push_back(symbol(buf));
-#endif
                e += a[i];
        }
        ex aux;
index 9127ca52104edf06eebfaf2b4277979f5bccaad2..d938d0b09eb53083394422be84bd1c10881eb87d 100644 (file)
 
 #include <sys/resource.h>
 #include <stdlib.h>
-#include "config.h"
-#if defined(HAVE_SSTREAM)
-#  include <sstream>
-#else
-#  include <strstream>
-#endif
+#include <sstream>
 #include <vector>
-using namespace std;
-
+#include "config.h"
 #include "ginac.h"
+using namespace std;
 using namespace GiNaC;
 
 class timer {
index aa0d315b86266db3edeafd6aa8f95b8a963f04e7..26627588159ca7a7c4339ca600ac4c3f3ad076e0 100644 (file)
@@ -103,23 +103,17 @@ GINSH_LIBS=$LIBS
 LIBS=$save_LIBS
 AC_SUBST(GINSH_LIBS)
 
-dnl Make sure all the necessary new-style headers are installed on the system.
-dnl If one of them cannot be found the system is probably not ANSI-conform
-dnl enough so trying the .h-style headers is a waste of time.
-AC_CHECK_HEADERS(iostream vector map string list typeinfo iterator stdexcept algorithm, ,
-  AC_MSG_ERROR([need to have ANSI compliant headers]))
-dnl We need the sstream header.  But since g++-2.95.n, n<3  does not provide
-dnl it, we must fall back to strstream, which, however, suffers from fixed
-dnl buffer sizes.  So the fallback may produce a crippled library. NB: this
-dnl fallback will disappear in future versions.
-AC_CHECK_HEADERS(sstream strstream)
-if test "x${ac_cv_header_sstream}" = "xno"; then
-  if test "x${ac_cv_header_strstream}" = "xno"; then
-    AC_MSG_ERROR([I could not find the <sstream> or <strstream> header.])
-  else
-    GINAC_WARNING([I could not find <sstream>.  <strstream> may cause trouble.])
-  fi
-fi
+dnl Make sure all the necessary standard headers are installed on the system.
+AC_CHECK_HEADER(iosfwd, , GINAC_ERROR([The standard <iosfwd> header file could not be found.]))
+AC_CHECK_HEADER(iostream, , GINAC_ERROR([The standard <iostream> header file could not be found.]))
+AC_CHECK_HEADER(vector, , GINAC_ERROR([The standard <vector> header file could not be found.]))
+AC_CHECK_HEADER(list, , GINAC_ERROR([The standard <list> header file could not be found.]))
+AC_CHECK_HEADER(map, , GINAC_ERROR([The standard <map> header file could not be found.]))
+AC_CHECK_HEADER(string, , GINAC_ERROR([The standard <string> header file could not be found.]))
+AC_CHECK_HEADER(sstream, , GINAC_ERROR([The standard <sstream> header file could not be found.]))
+AC_CHECK_HEADER(typeinfo, , GINAC_ERROR([The standard <typeinfo> header file could not be found.]))
+AC_CHECK_HEADER(stdexcept, , GINAC_ERROR([The standard <stdexcept> header file could not be found.]))
+AC_CHECK_HEADER(algorithm, , GINAC_ERROR([The standard <algorithm> header file could not be found.]))
 
 dnl We need to have Bruno Haible's CLN installed.
 dnl (CLN versions >= 1.1.0 must have installed cln.m4 at a visible place,
index b1a4033cd73fe5c57f51dd0cb858bc843b8d2fcc..72668220da202597a09fe11564fdc4517e5a05db 100644 (file)
 #include <vector>
 #include <stdexcept>
 #include <string>
-
-#if defined(HAVE_SSTREAM)
 #include <sstream>
-#elif defined(HAVE_STRSTREAM)
-#include <strstream>
-#else
-#error Need either sstream or strstream
-#endif
 
 #include "numeric.h"
 #include "ex.h"
 #include "print.h"
 #include "archive.h"
 #include "debugmsg.h"
+#include "tostring.h"
 #include "utils.h"
 
 // CLN should pollute the global namespace as little as possible.  Hence, we
@@ -219,15 +213,7 @@ numeric::numeric(const char *s) : basic(TINFO_numeric)
                        // E to lower case
                        term = term.replace(term.find("E"),1,"e");
                        // append _<Digits> to term
-#if defined(HAVE_SSTREAM)
-                       std::ostringstream buf;
-                       buf << unsigned(Digits) << std::ends;
-                       term += "_" + buf.str();
-#else
-                       char buf[14];
-                       std::ostrstream(buf,sizeof(buf)) << unsigned(Digits) << std::ends;
-                       term += "_" + std::string(buf);
-#endif
+                       term += "_" + ToString((unsigned)Digits);
                        // construct float using cln::cl_F(const char *) ctor.
                        if (imaginary)
                                ctorval = ctorval + cln::complex(cln::cl_I(0),cln::cl_F(term.c_str()));
@@ -267,11 +253,7 @@ numeric::numeric(const archive_node &n, const lst &sym_lst) : inherited(n, sym_l
        // Read number as string
        std::string str;
        if (n.find_string("number", str)) {
-#ifdef HAVE_SSTREAM
                std::istringstream s(str);
-#else
-               std::istrstream s(str.c_str(), str.size() + 1);
-#endif
                cln::cl_idecoded_float re, im;
                char c;
                s.get(c);
@@ -301,12 +283,7 @@ void numeric::archive(archive_node &n) const
        inherited::archive(n);
 
        // Write number as string
-#ifdef HAVE_SSTREAM
        std::ostringstream s;
-#else
-       char buf[1024];
-       std::ostrstream s(buf, 1024);
-#endif
        if (this->is_crational())
                s << cln::the<cln::cl_N>(value);
        else {
@@ -324,13 +301,7 @@ void numeric::archive(archive_node &n) const
                        s << im.sign << " " << im.mantissa << " " << im.exponent;
                }
        }
-#ifdef HAVE_SSTREAM
        n.add_string("number", s.str());
-#else
-       s << ends;
-       std::string str(buf);
-       n.add_string("number", str);
-#endif
 }
 
 DEFAULT_UNARCHIVE(numeric)
index c82813bf7807beb369b3da8a764a438f4ed8a8d0..1a403eba9b88a761ec6bbab6c36ae3822ecc9817 100644 (file)
 #ifndef __GINAC_TOSTRING_H__
 #define __GINAC_TOSTRING_H__
 
-#include "config.h"
-
-#if defined(HAVE_SSTREAM)
 #include <sstream>
-#elif defined(HAVE_STRSTREAM)
-#include <strstream>
-#else
-#error Need either sstream or strstream
-#endif
 
 namespace GiNaC {
 
-// This should be obsoleted once <sstream> is widely deployed.
 template<class T>
 std::string ToString(const T & t)
 {
-#if defined(HAVE_SSTREAM)
        std::ostringstream buf;
        buf << t << std::ends;
        return buf.str();
-#else
-       char buf[256];
-       std::ostrstream(buf,sizeof(buf)) << t << std::ends;
-       return buf;
-#endif
 }
 
 } // namespace GiNaC