support for old gcc as well as gcc 3.2

This commit is contained in:
David Rose 2003-01-17 17:31:11 +00:00
parent 3ef2e8416b
commit 24cca694cf
7 changed files with 69 additions and 42 deletions

View File

@ -1,6 +1,9 @@
AC_DEFUN(AC_HEADER_IOSTREAM,
[AC_CHECK_HEADERS(iostream,[have_iostream=yes],[have_iostream=no])])
AC_DEFUN(AC_HEADER_SSTREAM,
[AC_CHECK_HEADERS(sstream,[have_sstream=yes],[have_sstream=no])])
AC_DEFUN(AC_IOS_BINARY,
[AC_CACHE_CHECK([for ios::binary],
ac_cv_ios_binary,

View File

@ -6,12 +6,18 @@
other platforms.
*/
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if the C++ compiler uses namespaces. */
#define HAVE_NAMESPACE 1
/* 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 */
@ -22,60 +28,57 @@
initial setting of the $[PLATFORM] variable. */
#define PLATFORM "Win32"
/* Define if you have the <alloca.h> header file. */
/* #undef HAVE_ALLOCA_H */
/* Define if you have the `getopt' function. */
/* Define if you have the `getopt' function. */
/* #undef HAVE_GETOPT */
/* Define if you have the <iostream> header file. */
#define HAVE_IOSTREAM 1
/* Define if you have the <alloca.h> header file. */
/* #undef HAVE_ALLOCA_H */
/* Define if you have the <io.h> header file. */
#define HAVE_IO_H 1
/* Define if you have the <malloc.h> header file. */
#define HAVE_MALLOC_H 1
/* Define if you have the <minmax.h> header file. */
/* #undef HAVE_MINMAX_H */
/* Define if you have the <dirent.h> header file. */
/* Define if you have the <dirent.h> header file. */
/* #undef HAVE_DIRENT_H */
/* Define if you have the <regex.h> header file. */
/* Define if you have the <io.h> header file. */
#define HAVE_IO_H 1
/* Define if you have the <iostream> header file. */
#define HAVE_IOSTREAM 1
/* Define if you have the <malloc.h> header file. */
#define HAVE_MALLOC_H 1
/* Define if you have the <minmax.h> header file. */
/* #undef HAVE_MINMAX_H */
/* Define if you have the <regex.h> header file. */
/* #undef HAVE_REGEX_H */
/* Define if you have the <string.h> header file. */
/* Define if you have the <sstream> header file. */
#define HAVE_SSTREAM 1
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define if you have the <strstream.h> header file. */
#define HAVE_STRSTREAM_H 1
/* Define if you have the <sys/types.h> header file. */
/* #undef HAVE_SYS_TYPES_H 1 */
/* Define if you have the <sys/time.h> header file. */
/* Define if you have the <sys/time.h> header file. */
/* #undef HAVE_SYS_TIME_H 1 */
/* Define if you have the <sys/utime.h> header file. */
/* Define if you have the <sys/types.h> header file. */
/* #undef HAVE_SYS_TYPES_H 1 */
/* Define if you have the <sys/utime.h> header file. */
#define HAVE_SYS_UTIME_H 1
/* Define if you have the <sys/wait.h> header file. */
/* Define if you have the <sys/wait.h> header file. */
/* #undef HAVE_SYS_WAIT_H 1 */
/* Define if you have the <unistd.h> header file. */
/* Define if you have the <unistd.h> header file. */
/* #undef HAVE_UNISTD_H 1 */
/* Define if you have the <utime.h> header file. */
/* Define if you have the <utime.h> header file. */
/* #undef HAVE_UTIME_H 1 */
/* Name of package */
#define PACKAGE "ppremake"
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/**************** UPDATE VERSION NUMBER HERE ****************
** Also be sure to change the version number **
** at the beginning of configure.in. **

View File

@ -42,7 +42,7 @@ AC_SUBST(libm)
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(malloc.h alloca.h unistd.h utime.h io.h minmax.h dirent.h sys/types.h sys/time.h sys/utime.h sys/wait.h string.h strstream.h regex.h)
AC_CHECK_HEADERS(malloc.h alloca.h unistd.h utime.h io.h minmax.h dirent.h sys/types.h sys/time.h sys/utime.h sys/wait.h string.h regex.h)
dnl Checks for typedefs, structures, and compiler characteristics.
@ -53,6 +53,7 @@ AC_CHECK_FUNCS(getopt)
dnl Now we can test some C++-specific features.
AC_LANG_CPLUSPLUS
AC_HEADER_IOSTREAM
AC_HEADER_SSTREAM
AC_NAMESPACE
AC_IOS_BINARY
AC_OPEN_MASK

View File

@ -1229,8 +1229,15 @@ handle_end_command() {
// Now compare the file we generated to the file that's already
// there, if there is one.
// nest->_output << ends;
#ifdef HAVE_SSTREAM
string generated_file = nest->_output.str();
#else
nest->_output << ends;
char *c_str = nest->_output.str();
string generated_file = c_str;
delete[] c_str;
#endif // HAVE_SSTREAM
if (!compare_output(generated_file, nest->_params,
(nest->_flags & OF_notouch) != 0)) {
return false;

View File

@ -167,7 +167,11 @@ private:
WriteState *_write_state;
PPScope *_scope;
string _params;
#ifdef HAVE_SSTREAM
ostringstream _output;
#else
ostrstream _output;
#endif
vector<string> _words;
int _flags;
BlockNesting *_next;

View File

@ -3128,10 +3128,11 @@ expand_function(const string &funcname,
PPScope nested_scope(_named_scopes);
nested_scope.define_formals(funcname, sub->_formals, params);
// This won't compile older C++ libraries that do not have
// ostrstring. (The earlier interface was ostrstream, which is
// functionally equivalent but slightly different.)
#ifdef HAVE_SSTREAM
ostringstream ostr;
#else
ostrstream ostr;
#endif
PPCommandFile command(&nested_scope);
command.set_output(&ostr);
@ -3151,15 +3152,19 @@ 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;
#ifdef HAVE_SSTREAM
string str = ostr.str();
#else
ostr << ends;
char *c_str = ostr.str();
string str = c_str;
delete[] c_str;
#endif
vector<string> results;
tokenize_whitespace(str, results);
string result = repaste(results, " ");
// delete[] str;
return result;
}

View File

@ -20,12 +20,16 @@
#ifdef HAVE_IOSTREAM
#include <iostream>
#include <fstream>
#ifdef HAVE_SSTREAM
#include <sstream>
#else
#else // HAVE_SSTREAM
#include <strstream>
#endif // HAVE_SSTREAM
#else // HAVE_IOSTREAM
#include <iostream.h>
#include <fstream.h>
#include <strstream.h>
#endif
#endif // HAVE_IOSTREAM
#if defined(HAVE_CYGWIN) || defined(WIN32_VC)
// Either Cygwin or Visual C++ is a Win32 environment.