compile on gcc 3.2

This commit is contained in:
David Rose
2003-01-16 18:21:48 +00:00
parent 2df4152de6
commit 225727773c
8 changed files with 56 additions and 27 deletions

View File

@@ -20,6 +20,9 @@
/* Define if the C++ iostream library supports ios::binary. */
#undef HAVE_IOS_BINARY
/* Define if fstream::open() accepts a third parameter for umask. */
#undef HAVE_OPEN_MASK
/* Define if we're compiling with Cygwin. */
#undef HAVE_CYGWIN

View File

@@ -9,7 +9,7 @@ if test $have_iostream = yes; then
AC_TRY_COMPILE([
#include <iostream>
],[
int x; x = ios::binary;
int x; x = std::ios::binary;
], ac_cv_ios_binary=yes, ac_cv_ios_binary=no)
else
AC_TRY_COMPILE([
@@ -25,6 +25,30 @@ if test $ac_cv_ios_binary = yes; then
fi
])
AC_DEFUN(AC_OPEN_MASK,
[AC_CACHE_CHECK([for third umask parameter to open],
ac_cv_open_mask,
[
if test $have_iostream = yes; then
AC_TRY_COMPILE([
#include <fstream>
],[
std::ofstream x; x.open("foo", std::ios::out, 0666);
], ac_cv_open_mask=yes, ac_cv_open_mask=no)
else
AC_TRY_COMPILE([
#include <fstream.h>
],[
ofstream x; x.open("foo", ios::out, 0666);
], ac_cv_open_mask=yes, ac_cv_open_mask=no)
fi
])
if test $ac_cv_open_mask = yes; then
AC_DEFINE(HAVE_OPEN_MASK)
fi
])
AC_DEFUN(AC_NAMESPACE,
[AC_CACHE_CHECK([for compiler namespace support],

View File

@@ -54,6 +54,8 @@ dnl Now we can test some C++-specific features.
AC_LANG_CPLUSPLUS
AC_HEADER_IOSTREAM
AC_NAMESPACE
AC_IOS_BINARY
AC_OPEN_MASK
AC_LANG_C

View File

@@ -1158,7 +1158,7 @@ bool Filename::
open_read(ifstream &stream) const {
assert(is_text() || is_binary());
int open_mode = ios::in;
ios::openmode open_mode = ios::in;
#ifdef HAVE_IOS_BINARY
// For some reason, some systems (like Irix) don't define
@@ -1189,7 +1189,7 @@ bool Filename::
open_write(ofstream &stream) const {
assert(is_text() || is_binary());
int open_mode = ios::out;
ios::openmode open_mode = ios::out;
#ifdef HAVE_IOS_BINARY
// For some reason, some systems (like Irix) don't define
@@ -1201,10 +1201,10 @@ open_write(ofstream &stream) const {
stream.clear();
string os_specific = to_os_specific();
#ifdef WIN32_VC
stream.open(os_specific.c_str(), open_mode);
#else
#ifdef HAVE_OPEN_MASK
stream.open(os_specific.c_str(), open_mode, 0666);
#else
stream.open(os_specific.c_str(), open_mode);
#endif
return (!stream.fail());
@@ -1225,7 +1225,7 @@ bool Filename::
open_append(ofstream &stream) const {
assert(is_text() || is_binary());
int open_mode = ios::app;
ios::openmode open_mode = ios::app;
#ifdef HAVE_IOS_BINARY
// For some reason, some systems (like Irix) don't define
@@ -1237,10 +1237,10 @@ open_append(ofstream &stream) const {
stream.clear();
string os_specific = to_os_specific();
#ifdef WIN32_VC
stream.open(os_specific.c_str(), open_mode);
#else
#ifdef HAVE_OPEN_MASK
stream.open(os_specific.c_str(), open_mode, 0666);
#else
stream.open(os_specific.c_str(), open_mode);
#endif
return (!stream.fail());
@@ -1261,7 +1261,7 @@ bool Filename::
open_read_write(fstream &stream) const {
assert(is_text() || is_binary());
int open_mode = ios::in | ios::out;
ios::openmode open_mode = ios::in | ios::out;
#ifdef HAVE_IOS_BINARY
// For some reason, some systems (like Irix) don't define
@@ -1273,10 +1273,10 @@ open_read_write(fstream &stream) const {
stream.clear();
string os_specific = to_os_specific();
#ifdef WIN32_VC
stream.open(os_specific.c_str(), open_mode);
#else
#ifdef HAVE_OPEN_MASK
stream.open(os_specific.c_str(), open_mode, 0666);
#else
stream.open(os_specific.c_str(), open_mode);
#endif
return (!stream.fail());

View File

@@ -1230,7 +1230,7 @@ handle_end_command() {
// there, if there is one.
nest->_output << ends;
const char *generated_file = nest->_output.str();
string generated_file = nest->_output.str();
if (!compare_output(generated_file, nest->_params,
(nest->_flags & OF_notouch) != 0)) {
return false;

View File

@@ -167,7 +167,7 @@ private:
WriteState *_write_state;
PPScope *_scope;
string _params;
ostrstream _output;
ostringstream _output;
vector<string> _words;
int _flags;
BlockNesting *_next;
@@ -185,9 +185,9 @@ private:
vector<string> _saved_lines;
friend PPCommandFile::IfNesting;
friend PPCommandFile::WriteState;
friend PPCommandFile::BlockNesting;
friend class PPCommandFile::IfNesting;
friend class PPCommandFile::WriteState;
friend class PPCommandFile::BlockNesting;
};

View File

@@ -3128,10 +3128,10 @@ expand_function(const string &funcname,
PPScope nested_scope(_named_scopes);
nested_scope.define_formals(funcname, sub->_formals, params);
// This won't compile on VC++ with the new iostream library. It has
// only ostringstream, which is functionally equivalent but has a
// slightly different interface.
ostrstream ostr;
// This won't compile older C++ libraries that do not have
// ostrstring. (The earlier interface was ostrstream, which is
// functionally equivalent but slightly different.)
ostringstream ostr;
PPCommandFile command(&nested_scope);
command.set_output(&ostr);
@@ -3151,14 +3151,14 @@ expand_function(const string &funcname,
// Now get the output. We split it into words and then reconnect
// it, to replace all whitespace with spaces.
ostr << ends;
char *str = ostr.str();
// ostr << ends;
string str = ostr.str();
vector<string> results;
tokenize_whitespace(str, results);
string result = repaste(results, " ");
delete[] str;
// delete[] str;
return result;
}

View File

@@ -20,7 +20,7 @@
#ifdef HAVE_IOSTREAM
#include <iostream>
#include <fstream>
#include <strstream>
#include <sstream>
#else
#include <iostream.h>
#include <fstream.h>