diff --git a/ppremake/acinclude.m4 b/ppremake/acinclude.m4 index dfaea1f033..c0d0a54311 100644 --- a/ppremake/acinclude.m4 +++ b/ppremake/acinclude.m4 @@ -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, diff --git a/ppremake/config_msvc.h b/ppremake/config_msvc.h index 2126481bcc..4d11866931 100644 --- a/ppremake/config_msvc.h +++ b/ppremake/config_msvc.h @@ -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 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 header file. */ -#define HAVE_IOSTREAM 1 +/* Define if you have the header file. */ +/* #undef HAVE_ALLOCA_H */ -/* Define if you have the header file. */ -#define HAVE_IO_H 1 - -/* Define if you have the header file. */ -#define HAVE_MALLOC_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_MINMAX_H */ - -/* Define if you have the header file. */ +/* Define if you have the header file. */ /* #undef HAVE_DIRENT_H */ -/* Define if you have the header file. */ +/* Define if you have the header file. */ +#define HAVE_IO_H 1 + +/* Define if you have the header file. */ +#define HAVE_IOSTREAM 1 + +/* Define if you have the header file. */ +#define HAVE_MALLOC_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_MINMAX_H */ + +/* Define if you have the header file. */ /* #undef HAVE_REGEX_H */ -/* Define if you have the header file. */ +/* Define if you have the header file. */ +#define HAVE_SSTREAM 1 + +/* Define if you have the header file. */ #define HAVE_STRING_H 1 -/* Define if you have the header file. */ -#define HAVE_STRSTREAM_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_TYPES_H 1 */ - -/* Define if you have the header file. */ +/* Define if you have the header file. */ /* #undef HAVE_SYS_TIME_H 1 */ -/* Define if you have the header file. */ +/* Define if you have the header file. */ +/* #undef HAVE_SYS_TYPES_H 1 */ + +/* Define if you have the header file. */ #define HAVE_SYS_UTIME_H 1 -/* Define if you have the header file. */ +/* Define if you have the header file. */ /* #undef HAVE_SYS_WAIT_H 1 */ -/* Define if you have the header file. */ +/* Define if you have the header file. */ /* #undef HAVE_UNISTD_H 1 */ -/* Define if you have the header file. */ +/* Define if you have the 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. ** diff --git a/ppremake/configure.in b/ppremake/configure.in index 8f1c130784..c697a3c233 100644 --- a/ppremake/configure.in +++ b/ppremake/configure.in @@ -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 diff --git a/ppremake/ppCommandFile.cxx b/ppremake/ppCommandFile.cxx index 839f06a31f..2b465f0e87 100644 --- a/ppremake/ppCommandFile.cxx +++ b/ppremake/ppCommandFile.cxx @@ -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; diff --git a/ppremake/ppCommandFile.h b/ppremake/ppCommandFile.h index 3985497bce..0d78f4f633 100644 --- a/ppremake/ppCommandFile.h +++ b/ppremake/ppCommandFile.h @@ -167,7 +167,11 @@ private: WriteState *_write_state; PPScope *_scope; string _params; +#ifdef HAVE_SSTREAM ostringstream _output; +#else + ostrstream _output; +#endif vector _words; int _flags; BlockNesting *_next; diff --git a/ppremake/ppScope.cxx b/ppremake/ppScope.cxx index 011a9e19c5..2f9a4fde25 100644 --- a/ppremake/ppScope.cxx +++ b/ppremake/ppScope.cxx @@ -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 results; tokenize_whitespace(str, results); string result = repaste(results, " "); - // delete[] str; - return result; } diff --git a/ppremake/ppremake.h b/ppremake/ppremake.h index 09fecb0600..2199bd8920 100644 --- a/ppremake/ppremake.h +++ b/ppremake/ppremake.h @@ -20,12 +20,16 @@ #ifdef HAVE_IOSTREAM #include #include +#ifdef HAVE_SSTREAM #include -#else +#else // HAVE_SSTREAM +#include +#endif // HAVE_SSTREAM +#else // HAVE_IOSTREAM #include #include #include -#endif +#endif // HAVE_IOSTREAM #if defined(HAVE_CYGWIN) || defined(WIN32_VC) // Either Cygwin or Visual C++ is a Win32 environment.