Mercurial > hg > octave-jordi
changeset 5765:7ba9ad1fec11
[project @ 2006-04-17 05:05:15 by jwe]
author | jwe |
---|---|
date | Mon, 17 Apr 2006 05:05:17 +0000 |
parents | 80409c2defcc |
children | f3be83cff153 |
files | ChangeLog liboctave/Array.cc liboctave/ChangeLog liboctave/DASPK.cc liboctave/DASRT.cc liboctave/DASSL.cc liboctave/LSODE.cc liboctave/Makefile.in liboctave/Sparse.cc liboctave/dim-vector.h liboctave/kpse.cc liboctave/lo-sstream.h mk-opts.pl src/ChangeLog src/DLD-FUNCTIONS/fftw_wisdom.cc src/DLD-FUNCTIONS/regexp.cc src/__gnuplot_raw__.l src/defun.cc src/dirfns.cc src/error.cc src/help.cc src/input.cc src/lex.l src/load-save.cc src/ls-hdf5.cc src/ls-mat-ascii.cc src/ls-mat4.cc src/ls-mat5.cc src/ls-oct-ascii.cc src/ls-oct-ascii.h src/ls-oct-binary.cc src/oct-stream.cc src/oct-stream.h src/oct-strstrm.h src/ov-cell.cc src/ov-cs-list.cc src/ov-fcn-handle.cc src/ov-fcn-inline.cc src/ov-list.cc src/pager.h src/parse.y src/pr-output.cc src/pt.cc src/strfns.cc src/symtab.cc src/symtab.h src/toplev.cc src/utils.cc |
diffstat | 48 files changed, 325 insertions(+), 492 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-04-17 John W. Eaton <jwe@octave.org> + + * mk-opts.pl (emit_print_function): Emit code that uses + std::ostringstream directly. + 2006-04-13 John W. Eaton <jwe@octave.org> * configure.in (CONST_CAST, DYNAMIC_CAST, REINTERPRET_CAST,
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -30,6 +30,7 @@ #include <climits> #include <iostream> +#include <sstream> #include <vector> #include "Array.h" @@ -38,7 +39,6 @@ #include "Range.h" #include "idx-vector.h" #include "lo-error.h" -#include "lo-sstream.h" // One dimensional array class. Handles the reference counting for // all the derived classes. @@ -354,7 +354,7 @@ T Array<T>::range_error (const char *fcn, const Array<int>& ra_idx) const { - OSSTREAM buf; + std::ostringstream buf; buf << fcn << " ("; @@ -368,11 +368,9 @@ buf << "): range error"; - buf << OSSTREAM_ENDS; - - (*current_liboctave_error_handler) (OSSTREAM_C_STR (buf)); - - OSSTREAM_FREEZE (buf); + std::string buf_str = buf.str (); + + (*current_liboctave_error_handler) (buf_str.c_str ()); return T (); } @@ -381,7 +379,7 @@ T& Array<T>::range_error (const char *fcn, const Array<int>& ra_idx) { - OSSTREAM buf; + std::ostringstream buf; buf << fcn << " ("; @@ -395,11 +393,9 @@ buf << "): range error"; - buf << OSSTREAM_ENDS; - - (*current_liboctave_error_handler) (OSSTREAM_C_STR (buf)); - - OSSTREAM_FREEZE (buf); + std::string buf_str = buf.str (); + + (*current_liboctave_error_handler) (buf_str.c_str ()); static T foo; return foo;
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,5 +1,16 @@ 2006-04-16 John W. Eaton <jwe@octave.org> + * lo-sstream.h: Delete. + * Makefile.in (INCLUDES): Remove it from the list. + + * dim-vector.h (dim_vector::str): Use std::ostringstream directly. + * Sparse.cc (Sparse::range_error): Likewise. + * DASSL.cc (DASSL::error_message): Likewise. + * LSODE.cc (LSODE::error_message): Likewise. + * DASRT.cc (DASRT::error_message): Likewise. + * DASPK.cc (DASPK::error_message): Likewise. + * Array.cc (Array::range_error): Likewise. + * kpse.cc (kpse_hash): Rename from hash. (hash_lookup): Call kpse_hash instead of hash.
--- a/liboctave/DASPK.cc +++ b/liboctave/DASPK.cc @@ -28,10 +28,11 @@ #include <cfloat> #include <cmath> +#include <sstream> + #include "DASPK.h" #include "f77-fcn.h" #include "lo-error.h" -#include "lo-sstream.h" #include "quit.h" typedef octave_idx_type (*daspk_fcn_ptr) (const double&, const double*, @@ -687,10 +688,9 @@ { std::string retval; - OSSTREAM buf; - buf << t << OSSTREAM_ENDS; - std::string t_curr = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + std::ostringstream buf; + buf << t; + std::string t_curr = buf.str (); switch (istate) {
--- a/liboctave/DASRT.cc +++ b/liboctave/DASRT.cc @@ -28,10 +28,11 @@ #include <cfloat> #include <cmath> +#include <sstream> + #include "DASRT.h" #include "f77-fcn.h" #include "lo-error.h" -#include "lo-sstream.h" #include "quit.h" typedef octave_idx_type (*dasrt_fcn_ptr) (const double&, const double*, const double*, @@ -565,10 +566,9 @@ { std::string retval; - OSSTREAM buf; - buf << t << OSSTREAM_ENDS; - std::string t_curr = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + std::ostringstream buf; + buf << t; + std::string t_curr = buf.str (); switch (istate) {
--- a/liboctave/DASSL.cc +++ b/liboctave/DASSL.cc @@ -28,10 +28,11 @@ #include <cfloat> #include <cmath> +#include <sstream> + #include "DASSL.h" #include "f77-fcn.h" #include "lo-error.h" -#include "lo-sstream.h" #include "quit.h" typedef octave_idx_type (*dassl_fcn_ptr) (const double&, const double*, const double*, @@ -503,10 +504,9 @@ { std::string retval; - OSSTREAM buf; - buf << t << OSSTREAM_ENDS; - std::string t_curr = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + std::ostringstream buf; + buf << t; + std::string t_curr = buf.str (); switch (istate) {
--- a/liboctave/LSODE.cc +++ b/liboctave/LSODE.cc @@ -28,10 +28,11 @@ #include <cfloat> #include <cmath> +#include <sstream> + #include "LSODE.h" #include "f77-fcn.h" #include "lo-error.h" -#include "lo-sstream.h" #include "quit.h" typedef octave_idx_type (*lsode_fcn_ptr) (const octave_idx_type&, const double&, double*, @@ -318,10 +319,9 @@ { std::string retval; - OSSTREAM buf; - buf << t << OSSTREAM_ENDS; - std::string t_curr = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + std::ostringstream buf; + buf << t; + std::string t_curr = buf.str (); switch (istate) {
--- a/liboctave/Makefile.in +++ b/liboctave/Makefile.in @@ -63,7 +63,7 @@ base-de.h base-min.h byte-swap.h cmd-edit.h cmd-hist.h \ data-conv.h dir-ops.h file-ops.h file-stat.h getopt.h \ glob-match.h idx-vector.h kpse-xfns.h \ - lo-ieee.h lo-mappers.h lo-specfun.h lo-sstream.h \ + lo-ieee.h lo-mappers.h lo-specfun.h \ lo-sysdep.h lo-utils.h mach-info.h oct-alloc.h oct-cmplx.h \ oct-env.h oct-fftw.h oct-getopt.h oct-group.h oct-inttypes.h \ oct-passwd.h oct-rand.h oct-rl-edit.h oct-rl-hist.h \
--- a/liboctave/Sparse.cc +++ b/liboctave/Sparse.cc @@ -29,6 +29,7 @@ #include <climits> #include <iostream> +#include <sstream> #include <vector> #include "Array.h" @@ -37,7 +38,6 @@ #include "Range.h" #include "idx-vector.h" #include "lo-error.h" -#include "lo-sstream.h" #include "quit.h" #include "Sparse.h" @@ -679,7 +679,7 @@ T Sparse<T>::range_error (const char *fcn, const Array<octave_idx_type>& ra_idx) const { - OSSTREAM buf; + std::ostringstream buf; buf << fcn << " ("; @@ -692,12 +692,10 @@ buf << ", " << ra_idx(i); buf << "): range error"; - - buf << OSSTREAM_ENDS; - - (*current_liboctave_error_handler) (OSSTREAM_C_STR (buf)); - - OSSTREAM_FREEZE (buf); + + std::string buf_str = buf.str (); + + (*current_liboctave_error_handler) (buf_str.c_str ()); return T (); } @@ -706,7 +704,7 @@ T& Sparse<T>::range_error (const char *fcn, const Array<octave_idx_type>& ra_idx) { - OSSTREAM buf; + std::ostringstream buf; buf << fcn << " ("; @@ -720,11 +718,9 @@ buf << "): range error"; - buf << OSSTREAM_ENDS; - - (*current_liboctave_error_handler) (OSSTREAM_C_STR (buf)); - - OSSTREAM_FREEZE (buf); + std::string buf_str = buf.str (); + + (*current_liboctave_error_handler) (buf_str.c_str ()); static T foo; return foo;
--- a/liboctave/dim-vector.h +++ b/liboctave/dim-vector.h @@ -25,9 +25,9 @@ #define octave_dim_vector_h 1 #include <cassert> +#include <sstream> #include <string> -#include "lo-sstream.h" #include "oct-types.h" class @@ -211,7 +211,7 @@ std::string str (char sep = 'x') const { - OSSTREAM buf; + std::ostringstream buf; for (int i = 0; i < length (); i++) { @@ -221,11 +221,7 @@ buf << sep; } - buf << OSSTREAM_ENDS; - - std::string retval = OSSTREAM_STR (buf); - - OSSTREAM_FREEZE (buf); + std::string retval = buf.str (); return retval; }
--- a/liboctave/kpse.cc +++ b/liboctave/kpse.cc @@ -89,7 +89,6 @@ #include "kpse-xfns.h" #include "lo-error.h" -#include "lo-sstream.h" #include "oct-env.h" #include "oct-passwd.h" #include "str-vec.h"
deleted file mode 100644 --- a/liboctave/lo-sstream.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - -Copyright (C) 2002 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. - -*/ - -#if !defined (octave_liboctave_sstream_h) -#define octave_liboctave_sstream_h 1 - -#if defined (__GNUG__) && __GNUC__ < 3 -#undef HAVE_SSTREAM -#endif - -#ifdef HAVE_SSTREAM - -#include <sstream> - -#define STRINGSTREAMBUF std::stringbuf - -#define ISSTREAM std::istringstream - -#define OSSTREAM std::ostringstream -#define OSSTREAM_STR(os) (os).str () -// XXX FIXME XXX -- how long is the temporary created by the str() -// method guaranteed to exist? -#define OSSTREAM_C_STR(os) (os).str () . c_str () -#define OSSTREAM_ENDS "" -#define OSSTREAM_FREEZE(os) do { } while (0) - -#else - -#include <strstream> - -#define STRINGSTREAMBUF std::strstreambuf - -#define ISSTREAM std::istrstream - -#define OSSTREAM std::ostrstream -#define OSSTREAM_STR(os) std::string ((os).str ()) -#define OSSTREAM_C_STR(os) (os).str () -#define OSSTREAM_ENDS std::ends -#define OSSTREAM_FREEZE(os) do { (os).freeze (false); } while (0) - -#endif - -#endif - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
--- a/mk-opts.pl +++ b/mk-opts.pl @@ -597,7 +597,7 @@ print "static void print_${class_name} (void) { - OSSTREAM buf; + std::ostringstream buf; buf << \"\\n\" << \"Options for $CLASS include:\\n\\n\" @@ -677,11 +677,7 @@ print " }\n\n"; } - print " buf << OSSTREAM_ENDS; - - print_usage (\"$opt_fcn_name\", true, OSSTREAM_STR (buf)); - - OSSTREAM_FREEZE (buf); + print "print_usage (\"$opt_fcn_name\", true, buf.str ()); }\n\n"; }
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,58 @@ +2006-04-16 John W. Eaton <jwe@octave.org> + + * pager.h (octave_diary_buf, octave_pager_buf): Use std:stringbuf + directly. + + * ls-mat-ascii.cc (read_mat_ascii_data): Use std::istringstream + directly. + * load-save.cc (parse_save_options): Likewise. + * ls-mat5.cc (read_mat5_binary_element): Likewise. + * oct-strstrm.h (octave_istrstream::is): Likewise. + + * __gnuplot_raw__.l (printrange, handle_using, gnuplot::do_open, + gnuplot::do_set, gnuplot::do_show, gnuplot::makeplot, + gnuplot::handle_title): Use std::ostringstream directly. + * toplev.cc (run_command_and_return_output): Likewise. + * symtab.h (symbol_table::symbol_table): Likewise. + * strfns.cc (Flist_in_columns): Likewise. + * pt.cc (tree::str_print_code): Likewise. + * parse.y (yyerror, fold, finish_matrix): Likewise. + * pr-output.cc (PRINT_ND_ARRAY, octave_print_internal, Fdisp): + Likewise. + * symtab.cc (symbol_table::print_descriptor): Likewise. + * ov-list.cc (octave_list::print_raw, octave_list::save_ascii, + octave_list::save_binary, octave_list::save_hdf5): Likewise. + * ov-fcn-inline.cc (octave_fcn_inline::octave_fcn_inline, + octave_fcn_inline::load_ascii, octave_fcn_inline::print_raw, + Finline): Likewise. + * ov-fcn-handle.cc (octave_fcn_handle::load_ascii, + octave_fcn_handle::save_binary, octave_fcn_handle::save_hdf5): + Likewise. + * ov-cs-list.cc (octave_cs_list::print_raw): Likewise. + * ov-cell.cc (octave_cell::print_raw, octave_cell::save_hdf5): + Likewise. + * oct-strstrm.h (octave_ostrstream::os, octave_ostrstream::str): + Likewise. + * oct-stream.h (scanf_format_list::buf, printf_format_list::buf): + Likewise. + * oct-stream.cc (scanf_format_list::scanf_format_list, + printf_format_list::printf_format_list, + octave_base_stream::do_gets, BEGIN_CHAR_CLASS_CONVERSION, + octave_stream_list::do_list_open_files): Likewise. + * ls-oct-ascii.h (extract_keyword): Likewise. + * load-save.cc (do_load): Likewise. + * lex.l (have_continuation, handle_string): Likewise. + * input.cc (get_user_input): Likewise. + * dirfns.cc (Fls): Likewise. + * error.cc (error_message_buffer, vwarning, verror, pr_where): + Likewise. + * defun.cc (print_usage): Likewise. + * help.cc (display_help_text, Ftype, first_help_sentence): + Likewise. + * ls-mat5.cc (save_mat5_binary_element): Likewise. + * DLD-FUNCTIONS/regexp.cc (octregexp): Likewise. + * DLD-FUNCTIONS/fftw_wisdom.cc (Ffftw_wisdom): Likewise. + 2006-04-13 John W. Eaton <jwe@octave.org> * Makefile.in (lex.o parse.o __gnuplot_raw__.o, pic/parse.o
--- a/src/DLD-FUNCTIONS/fftw_wisdom.cc +++ b/src/DLD-FUNCTIONS/fftw_wisdom.cc @@ -29,13 +29,14 @@ #include <fftw3.h> #endif +#include <sstream> + #include "defaults.h" #include "defun-dld.h" #include "error.h" #include "file-ops.h" #include "gripes.h" #include "lo-mappers.h" -#include "lo-sstream.h" #include "oct-env.h" #include "oct-obj.h" #include "sighandlers.h" @@ -158,7 +159,7 @@ return retval; } - OSSTREAM cmd_buf; + std::ostringstream cmd_buf; cmd_buf << Vfftw_wisdom_prog << " -n -o \"" << name << "\""; for (octave_idx_type k = 0; k < m.rows (); k++) @@ -179,14 +180,12 @@ } } - cmd_buf << OSSTREAM_ENDS; - volatile octave_interrupt_handler old_interrupt_handler = octave_ignore_interrupts (); - int status = system (OSSTREAM_C_STR (cmd_buf)); + std::string cmd_buf_str = cmd_buf.str (); - OSSTREAM_FREEZE (cmd_buf); + int status = system (cmd_buf_str.c_str ()); octave_set_interrupt_handler (old_interrupt_handler);
--- a/src/DLD-FUNCTIONS/regexp.cc +++ b/src/DLD-FUNCTIONS/regexp.cc @@ -27,6 +27,8 @@ #include <config.h> #endif +#include <sstream> + #include "defun-dld.h" #include "error.h" #include "gripes.h" @@ -127,7 +129,7 @@ string_vector named; int nnames = 0; int inames = 0; - OSSTREAM buf; + std::ostringstream buf; Array<int> named_idx; while ((new_pos = pattern.find ("(?<",pos)) != NPOS) @@ -170,7 +172,7 @@ pos = tmp_pos; } - buf << pattern.substr(pos) << OSSTREAM_ENDS; + buf << pattern.substr(pos); if (error_state) return retval; @@ -179,10 +181,10 @@ pcre *re; const char *err; int erroffset; - re = pcre_compile(OSSTREAM_C_STR(buf), - (case_insensitive ? PCRE_CASELESS : 0), - &err, &erroffset, NULL); - OSSTREAM_FREEZE (buf); + std::string buf_str = buf.str (); + re = pcre_compile (buf_str.c_str (), + (case_insensitive ? PCRE_CASELESS : 0), + &err, &erroffset, NULL); if (re == NULL) { error("%s: %s at position %d of expression", nm.c_str(),
--- a/src/__gnuplot_raw__.l +++ b/src/__gnuplot_raw__.l @@ -42,6 +42,7 @@ #include <string> #include <fstream> #include <iostream> +#include <sstream> #ifdef HAVE_UNISTD_H #ifdef HAVE_SYS_TYPES_H @@ -528,7 +529,7 @@ octave_value startv, endv; int status; std::string s; - OSSTREAM range_buf; + std::ostringstream range_buf; range_buf << "["; @@ -551,9 +552,8 @@ } range_buf << "]"; - range_buf << OSSTREAM_ENDS; - s = OSSTREAM_STR (range_buf); + s = range_buf.str (); return s; } @@ -581,10 +581,9 @@ if (status != 0 || ! tmp_data.is_real_scalar ()) throw gpt_parse_error (); - OSSTREAM tmp_buf; + std::ostringstream tmp_buf; tmp_data.print_raw (tmp_buf); - tmp_buf << OSSTREAM_ENDS; - retstr += OSSTREAM_STR (tmp_buf); + retstr += tmp_buf.str (); if (tok == COLON) retstr += ":"; @@ -965,15 +964,11 @@ if (use_title_option) { - OSSTREAM buf; + std::ostringstream buf; - buf << cmd - << " -title \"Figure " << get_current_figure () << "\"" - << OSSTREAM_ENDS; + buf << cmd << " -title \"Figure " << get_current_figure () << "\""; - cmd = OSSTREAM_STR (buf); - - OSSTREAM_FREEZE (buf); + cmd = buf.str (); } plot_stream = new oprocstream (cmd.c_str ()); @@ -1119,7 +1114,7 @@ { int argc = argv.length (); - OSSTREAM plot_buf; + std::ostringstream plot_buf; if (argc > 1) { @@ -1130,15 +1125,14 @@ else if (almost_match ("term", argv[1], 1)) { gnuplot_terminal_type = ""; - OSSTREAM buf; + std::ostringstream buf; int i; for (i = 2; i < argc-1; i++) buf << argv[i] << " "; if (i < argc) buf << argv[i]; - buf << Vgnuplot_command_end << OSSTREAM_ENDS; - gnuplot_terminal_type = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + buf << Vgnuplot_command_end; + gnuplot_terminal_type = buf.str (); } } @@ -1149,11 +1143,9 @@ if (i < argc) plot_buf << argv[i]; - plot_buf << Vgnuplot_command_end << OSSTREAM_ENDS; + plot_buf << Vgnuplot_command_end; - do_send_raw (OSSTREAM_STR (plot_buf)); - - OSSTREAM_FREEZE (plot_buf); + do_send_raw (plot_buf.str ()); } void @@ -1161,7 +1153,7 @@ { int argc = argv.length (); - OSSTREAM plot_buf; + std::ostringstream plot_buf; int i; for (i = 0; i < argc-1; i++) @@ -1169,11 +1161,9 @@ if (i < argc) plot_buf << argv[i]; - plot_buf << Vgnuplot_command_end << OSSTREAM_ENDS; + plot_buf << Vgnuplot_command_end; - do_send (OSSTREAM_STR (plot_buf)); - - OSSTREAM_FREEZE (plot_buf); + do_send (plot_buf.str ()); } void @@ -1295,9 +1285,8 @@ if (status != 0 || ! tmp_data.is_defined ()) throw gpt_parse_error (); - OSSTREAM tmp_buf; + std::ostringstream tmp_buf; tmp_data.print_raw (tmp_buf); - tmp_buf << OSSTREAM_ENDS; if (tmp_data.is_string ()) { @@ -1385,10 +1374,10 @@ if (! title_set) { - OSSTREAM tmp_buf; + std::ostringstream tmp_buf; tmp_buf << Vgnuplot_command_title << " \"line " - << plot_line_count << "\" " << OSSTREAM_ENDS; - title_str = OSSTREAM_STR (tmp_buf); + << plot_line_count << "\" "; + title_str = tmp_buf.str (); title_set = true; } @@ -1441,12 +1430,12 @@ if (status != 0 || ! tmp_data.is_defined ()) throw gpt_parse_error (); - OSSTREAM tmp_buf; + std::ostringstream tmp_buf; if (tmp_data.is_string ()) { tmp_buf << '"'; tmp_data.print_raw (tmp_buf); - tmp_buf << '"' << OSSTREAM_ENDS; + tmp_buf << '"'; } else { @@ -1454,7 +1443,7 @@ tmp_buf << '"' << "line " << plot_line_count << '"'; } - retstr += OSSTREAM_STR (tmp_buf); + retstr += tmp_buf.str (); lasttok = tok;
--- a/src/defun.cc +++ b/src/defun.cc @@ -25,6 +25,7 @@ #include <config.h> #endif +#include <sstream> #include <iostream> #include <string> @@ -56,7 +57,7 @@ if (h.length () > 0) { - OSSTREAM buf; + std::ostringstream buf; buf << "\nInvalid call to " << nm << ". Correct usage is:\n\n"; @@ -69,11 +70,7 @@ if (! just_usage) additional_help_message (buf); - buf << OSSTREAM_ENDS; - - defun_usage_message (OSSTREAM_STR (buf)); - - OSSTREAM_FREEZE (buf); + defun_usage_message (buf.str ()); } } else
--- a/src/dirfns.cc +++ b/src/dirfns.cc @@ -31,6 +31,7 @@ #include <cstdlib> #include <cstring> +#include <sstream> #include <string> #ifdef HAVE_UNISTD_H @@ -43,7 +44,6 @@ #include "file-ops.h" #include "file-stat.h" #include "glob-match.h" -#include "lo-sstream.h" #include "oct-env.h" #include "str-vec.h" @@ -176,17 +176,13 @@ if (error_state) return retval; - OSSTREAM ls_buf; + std::ostringstream ls_buf; ls_buf << "ls -C "; for (int i = 1; i < argc; i++) ls_buf << file_ops::tilde_expand (argv[i]) << " "; - ls_buf << OSSTREAM_ENDS; - - iprocstream *cmd = new iprocstream (OSSTREAM_STR (ls_buf)); - - OSSTREAM_FREEZE (ls_buf); + iprocstream *cmd = new iprocstream (ls_buf.str ()); unwind_protect::add (cleanup_iprocstream, cmd); @@ -194,7 +190,7 @@ { char ch; - OSSTREAM output_buf; + std::ostringstream output_buf; for (;;) { @@ -204,16 +200,12 @@ break; } - output_buf << OSSTREAM_ENDS; - - std::string output = OSSTREAM_STR (output_buf); + std::string output = output_buf.str (); if (nargout > 0) retval = output; else octave_stdout << output; - - OSSTREAM_FREEZE (output_buf); } else error ("couldn't start process for ls!");
--- a/src/error.cc +++ b/src/error.cc @@ -28,10 +28,9 @@ #include <cstdarg> #include <cstring> +#include <sstream> #include <string> -#include "lo-sstream.h" - #include "defun.h" #include "error.h" #include "input.h" @@ -118,7 +117,7 @@ bool discard_warning_messages = false; // The message buffer. -static OSSTREAM *error_message_buffer = 0; +static std::ostringstream *error_message_buffer = 0; void reset_error_handler (void) @@ -148,22 +147,20 @@ flush_octave_stdout (); - OSSTREAM output_buf; + std::ostringstream output_buf; if (name) output_buf << name << ": "; octave_vformat (output_buf, fmt, args); - output_buf << std::endl << OSSTREAM_ENDS; + output_buf << std::endl; // XXX FIXME XXX -- we really want to capture the message before it // has all the formatting goop attached to it. We probably also // want just the message, not the traceback information. - std::string msg_string = OSSTREAM_STR (output_buf); - - OSSTREAM_FREEZE (output_buf); + std::string msg_string = output_buf.str (); if (! warning_state) { @@ -193,7 +190,7 @@ bool to_beep_or_not_to_beep_p = Vbeep_on_error && ! error_state; - OSSTREAM output_buf; + std::ostringstream output_buf; if (to_beep_or_not_to_beep_p) output_buf << "\a"; @@ -203,15 +200,13 @@ octave_vformat (output_buf, fmt, args); - output_buf << std::endl << OSSTREAM_ENDS; + output_buf << std::endl; // XXX FIXME XXX -- we really want to capture the message before it // has all the formatting goop attached to it. We probably also // want just the message, not the traceback information. - std::string msg_string = OSSTREAM_STR (output_buf); - - OSSTREAM_FREEZE (output_buf); + std::string msg_string = output_buf.str (); if (! error_state && save_last_error) { @@ -227,7 +222,7 @@ if (! error_message_buffer) { - error_message_buffer = new OSSTREAM; + error_message_buffer = new std::ostringstream (); // XXX FIXME XXX -- this is ugly, but it prevents // @@ -417,7 +412,7 @@ // one statement even if there were multiple statements on // the original source line. - OSSTREAM output_buf; + std::ostringstream output_buf; output_buf << std::endl; @@ -425,11 +420,11 @@ curr_statement->accept (tpc); - output_buf << std::endl << OSSTREAM_ENDS; + output_buf << std::endl; - pr_where_1 ("%s", OSSTREAM_C_STR (output_buf)); + std::string msg = output_buf.str (); - OSSTREAM_FREEZE (output_buf); + pr_where_1 ("%s", msg.c_str ()); } } }
--- a/src/help.cc +++ b/src/help.cc @@ -30,6 +30,7 @@ #include <iostream> #include <fstream> +#include <sstream> #include <string> #ifdef HAVE_UNISTD_H @@ -41,7 +42,6 @@ #include "cmd-edit.h" #include "file-ops.h" -#include "lo-sstream.h" #include "oct-env.h" #include "str-vec.h" @@ -644,7 +644,7 @@ if (cols > 80) cols = 72; - OSSTREAM buf; + std::ostringstream buf; buf << "sed -e 's/^[#%][#%]* *//' -e 's/^ *@/@/' | " << "\"" << Vmakeinfo_prog << "\"" @@ -656,12 +656,9 @@ << " --no-validate" << " --no-headers" << " --force" - << " --output \"" << tmp_file_name << "\"" - << OSSTREAM_ENDS; + << " --output \"" << tmp_file_name << "\""; - oprocstream filter (OSSTREAM_STR (buf)); - - OSSTREAM_FREEZE (buf); + oprocstream filter (buf.str ()); if (filter && filter.is_open ()) { @@ -999,7 +996,7 @@ if (idx < argc) { - OSSTREAM output_buf; + std::ostringstream output_buf; for (int i = idx; i < argc; i++) { @@ -1015,13 +1012,7 @@ } if (nargout != 0) - { - output_buf << OSSTREAM_ENDS; - - retval = OSSTREAM_STR (output_buf); - - OSSTREAM_FREEZE (output_buf); - } + retval = output_buf.str (); } else print_usage ("type"); @@ -1131,7 +1122,7 @@ { // Get the parsed help string. pos = 0; - OSSTREAM os; + std::ostringstream os; display_help_text (os, h); std::string h2 = os.str ();
--- a/src/input.cc +++ b/src/input.cc @@ -33,6 +33,7 @@ #include <cassert> #include <iostream> +#include <sstream> #include <string> #ifdef HAVE_UNISTD_H @@ -562,7 +563,7 @@ } } - OSSTREAM buf; + std::ostringstream buf; if (! nm.empty ()) { @@ -571,12 +572,8 @@ if (line > 0) buf << " at line " << line; } - - buf << OSSTREAM_ENDS; - std::string msg = OSSTREAM_STR (buf); - - OSSTREAM_FREEZE (buf); + std::string msg = buf.str (); if (! msg.empty ()) message ("keyboard", msg.c_str ());
--- a/src/lex.l +++ b/src/lex.l @@ -37,6 +37,7 @@ #include <cctype> #include <cstring> +#include <sstream> #include <string> #include <stack> @@ -50,7 +51,6 @@ #include "cmd-edit.h" #include "quit.h" #include "lo-mappers.h" -#include "lo-sstream.h" // These would be alphabetical, but y.tab.h must be included before // oct-gperf.h and y.tab.h must be included after token.h and the tree @@ -1783,7 +1783,7 @@ static bool have_continuation (bool trailing_comments_ok) { - OSSTREAM buf; + std::ostringstream buf; std::string comment_buf; @@ -1876,9 +1876,7 @@ cleanup: - buf << OSSTREAM_ENDS; - std::string s = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + std::string s = buf.str (); int len = s.length (); while (len--) @@ -1936,7 +1934,7 @@ static int handle_string (char delim, int text_style) { - OSSTREAM buf; + std::ostringstream buf; int bos_line = input_line_number; int bos_col = current_input_column; @@ -1994,12 +1992,11 @@ { std::string s; yyunput (c, yytext); - buf << OSSTREAM_ENDS; + if (lexer_flags.doing_rawcommand || delim == '\'') - s = OSSTREAM_STR (buf); + s = buf.str (); else - s = do_string_escapes (OSSTREAM_STR(buf)); - OSSTREAM_FREEZE (buf); + s = do_string_escapes (buf.str ()); if (text_style && lexer_flags.doing_rawcommand) s = std::string (1, delim) + s + std::string (1, delim);
--- a/src/load-save.cc +++ b/src/load-save.cc @@ -36,6 +36,7 @@ #include <fstream> #include <iomanip> #include <iostream> +#include <sstream> #include <string> #ifdef HAVE_HDF5 @@ -47,7 +48,6 @@ #include "file-ops.h" #include "glob-match.h" #include "lo-mappers.h" -#include "lo-sstream.h" #include "mach-info.h" #include "oct-env.h" #include "oct-time.h" @@ -444,7 +444,7 @@ Octave_map retstruct; - OSSTREAM output_buf; + std::ostringstream output_buf; octave_idx_type count = 0; @@ -560,9 +560,7 @@ if (list_only && count) { - output_buf << OSSTREAM_ENDS; - std::string msg = OSSTREAM_STR (output_buf); - OSSTREAM_FREEZE (output_buf); + std::string msg = output_buf.str (); if (nargout > 0) retval = msg; @@ -1183,12 +1181,12 @@ bool &append, bool &save_as_floats, bool &save_builtins, bool &use_zlib, int start_arg) { - ISSTREAM is (arg); + std::istringstream is (arg); std::string str; int argc = 0; string_vector argv; - while (!is.eof ()) + while (! is.eof ()) { is >> str; argv.append (str);
--- a/src/ls-hdf5.cc +++ b/src/ls-hdf5.cc @@ -46,7 +46,6 @@ #include "file-ops.h" #include "glob-match.h" #include "lo-mappers.h" -#include "lo-sstream.h" #include "mach-info.h" #include "oct-env.h" #include "oct-time.h"
--- a/src/ls-mat-ascii.cc +++ b/src/ls-mat-ascii.cc @@ -32,6 +32,7 @@ #include <fstream> #include <iomanip> #include <iostream> +#include <sstream> #include <string> #include "byte-swap.h" @@ -39,7 +40,6 @@ #include "file-ops.h" #include "glob-match.h" #include "lo-mappers.h" -#include "lo-sstream.h" #include "mach-info.h" #include "oct-env.h" #include "oct-time.h" @@ -251,11 +251,7 @@ { std::string buf = get_mat_data_input_line (is); -#ifdef HAVE_SSTREAM std::istringstream tmp_stream (buf); -#else - std::istrstream tmp_stream (buf.c_str ()); -#endif for (octave_idx_type j = 0; j < nc; j++) {
--- a/src/ls-mat4.cc +++ b/src/ls-mat4.cc @@ -40,7 +40,6 @@ #include "file-ops.h" #include "glob-match.h" #include "lo-mappers.h" -#include "lo-sstream.h" #include "mach-info.h" #include "oct-env.h" #include "oct-time.h"
--- a/src/ls-mat5.cc +++ b/src/ls-mat5.cc @@ -34,6 +34,7 @@ #include <fstream> #include <iomanip> #include <iostream> +#include <sstream> #include <string> #include <vector> @@ -42,7 +43,6 @@ #include "file-ops.h" #include "glob-match.h" #include "lo-mappers.h" -#include "lo-sstream.h" #include "mach-info.h" #include "oct-env.h" #include "oct-time.h" @@ -456,7 +456,7 @@ error ("load: error uncompressing data element"); else { - ISSTREAM gz_is (outbuf); + std::istringstream gz_is (outbuf); retval = read_mat5_binary_element (gz_is, filename, swap, global, tc); } @@ -1467,7 +1467,7 @@ { bool ret = false; - OSSTREAM buf; + std::ostringstream buf; // The code seeks backwards in the stream to fix the header. Can't // do this with zlib, so use a stringstream. @@ -1476,16 +1476,15 @@ if (ret) { - OSSTREAM_FREEZE (buf); - // destLen must be at least 0.1% larger than source buffer // + 12 bytes. Reality is it must be larger again than that. - uLongf srcLen = OSSTREAM_STR (buf).length (); + std::string buf_str = buf.str (); + uLongf srcLen = buf_str.length (); uLongf destLen = srcLen * 101 / 100 + 12; OCTAVE_LOCAL_BUFFER (char, out_buf, destLen); if (compress (reinterpret_cast<Bytef *> (out_buf), &destLen, - reinterpret_cast<const Bytef *> (OSSTREAM_C_STR (buf)), srcLen) == Z_OK) + reinterpret_cast<const Bytef *> (buf_str.c_str ()), srcLen) == Z_OK) { write_mat5_tag (os, miCOMPRESSED, static_cast<int> (destLen)); os.write (out_buf, destLen);
--- a/src/ls-oct-ascii.cc +++ b/src/ls-oct-ascii.cc @@ -33,6 +33,7 @@ #include <fstream> #include <iomanip> #include <iostream> +#include <sstream> #include <string> #include "byte-swap.h" @@ -40,7 +41,6 @@ #include "file-ops.h" #include "glob-match.h" #include "lo-mappers.h" -#include "lo-sstream.h" #include "mach-info.h" #include "oct-env.h" #include "oct-time.h" @@ -120,7 +120,7 @@ { if (c == '%' || c == '#') { - OSSTREAM buf; + std::ostringstream buf; while (is.get (c) && (c == ' ' || c == '\t' || c == '%' || c == '#')) ; // Skip whitespace and comment characters. @@ -131,14 +131,12 @@ while (is.get (c) && isalpha (c)) buf << c; - buf << OSSTREAM_ENDS; - std::string tmp = OSSTREAM_STR (buf); + std::string tmp = buf.str (); bool match = (tmp.compare (0, strlen (keyword), keyword) == 0); - OSSTREAM_FREEZE (buf); if (match) { - OSSTREAM value; + std::ostringstream value; while (is.get (c) && (c == ' ' || c == '\t' || c == ':')) ; // Skip whitespace and the colon. @@ -148,9 +146,8 @@ while (is.get (c) && c != '\n') value << c; } - value << OSSTREAM_ENDS; - retval = OSSTREAM_STR (value); - OSSTREAM_FREEZE (value); + + retval = value.str (); break; } else if (next_only)
--- a/src/ls-oct-ascii.h +++ b/src/ls-oct-ascii.h @@ -26,9 +26,9 @@ #include <cfloat> +#include <sstream> #include <string> -#include "lo-sstream.h" #include "str-vec.h" // Flag for cell elements @@ -78,7 +78,7 @@ { if (c == '%' || c == '#') { - OSSTREAM buf; + std::ostringstream buf; while (is.get (c) && (c == ' ' || c == '\t' || c == '%' || c == '#')) ; // Skip whitespace and comment characters. @@ -89,10 +89,8 @@ while (is.get (c) && isalpha (c)) buf << c; - buf << OSSTREAM_ENDS; - std::string tmp = OSSTREAM_STR (buf); + std::string tmp = buf.str (); bool match = (tmp.compare (0, strlen (keyword), keyword) == 0); - OSSTREAM_FREEZE (buf); if (match) { @@ -137,7 +135,7 @@ { if (c == '%' || c == '#') { - OSSTREAM buf; + std::ostringstream buf; while (is.get (c) && (c == ' ' || c == '\t' || c == '%' || c == '#')) ; // Skip whitespace and comment characters. @@ -148,9 +146,7 @@ while (is.get (c) && isalpha (c)) buf << c; - buf << OSSTREAM_ENDS; - std::string tmp = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + std::string tmp = buf.str (); for (int i = 0; i < keywords.length (); i++) {
--- a/src/ls-oct-binary.cc +++ b/src/ls-oct-binary.cc @@ -40,7 +40,6 @@ #include "file-ops.h" #include "glob-match.h" #include "lo-mappers.h" -#include "lo-sstream.h" #include "mach-info.h" #include "oct-env.h" #include "oct-time.h"
--- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -30,6 +30,7 @@ #include <iomanip> #include <fstream> +#include <sstream> #include <string> #include <Array.h> @@ -41,7 +42,6 @@ #include "byte-swap.h" #include "lo-ieee.h" #include "lo-mappers.h" -#include "lo-sstream.h" #include "lo-utils.h" #include "str-vec.h" #include "quit.h" @@ -176,7 +176,7 @@ have_more = true; if (! buf) - buf = new OSSTREAM (); + buf = new std::ostringstream (); if (s[i] == '%') { @@ -251,11 +251,7 @@ { if (buf) { - *buf << OSSTREAM_ENDS; - - std::string text = OSSTREAM_STR (*buf); - - OSSTREAM_FREEZE (*buf); + std::string text = buf->str (); if (! text.empty ()) { @@ -612,7 +608,7 @@ if (! buf) { - buf = new OSSTREAM (); + buf = new std::ostringstream (); empty_buf = true; } @@ -681,11 +677,7 @@ { if (buf) { - *buf << OSSTREAM_ENDS; - - std::string text = OSSTREAM_STR (*buf); - - OSSTREAM_FREEZE (*buf); + std::string text = buf->str (); if (! text.empty ()) { @@ -977,7 +969,7 @@ { std::istream& is = *isp; - OSSTREAM buf; + std::ostringstream buf; int c = 0; int char_count = 0; @@ -1004,11 +996,7 @@ } if (is.good () || (is.eof () && char_count > 0)) - { - buf << OSSTREAM_ENDS; - retval = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); - } + retval = buf.str (); else { err = true; @@ -1538,7 +1526,7 @@ } \ else \ { \ - OSSTREAM buf; \ + std::ostringstream buf; \ \ std::string char_class = elt->char_class; \ \ @@ -1560,9 +1548,7 @@ if (c != EOF) \ is.putback (c); \ \ - buf << OSSTREAM_ENDS; \ - tmp = OSSTREAM_STR (buf); \ - OSSTREAM_FREEZE (buf); \ + tmp = buf.str (); \ \ if (tmp.empty ()) \ is.setstate (std::ios::failbit); \ @@ -4091,7 +4077,7 @@ { std::string retval; - OSSTREAM buf; + std::ostringstream buf; buf << "\n" << " number mode arch name\n" @@ -4114,11 +4100,9 @@ << os.name () << "\n"; } - buf << "\n" << OSSTREAM_ENDS; - - retval = OSSTREAM_STR (buf); - - OSSTREAM_FREEZE (buf); + buf << "\n"; + + retval = buf.str (); return retval; }
--- a/src/oct-stream.h +++ b/src/oct-stream.h @@ -30,11 +30,11 @@ class octave_value_list; #include <iostream> +#include <sstream> #include <string> #include "Array.h" #include "data-conv.h" -#include "lo-sstream.h" #include "lo-utils.h" #include "mach-info.h" @@ -160,7 +160,7 @@ Array<scanf_format_elt*> list; // Temporary buffer. - OSSTREAM *buf; + std::ostringstream *buf; void add_elt_to_list (int width, bool discard, char type, char modifier, int& num_elts, @@ -292,7 +292,7 @@ Array<printf_format_elt*> list; // Temporary buffer. - OSSTREAM *buf; + std::ostringstream *buf; void add_elt_to_list (int args, const std::string& flags, int fw, int prec, char type, char modifier,
--- a/src/oct-strstrm.h +++ b/src/oct-strstrm.h @@ -25,8 +25,7 @@ #define octave_octave_strstream_h 1 #include <string> - -#include "lo-sstream.h" +#include <sstream> #include "oct-stream.h" @@ -118,7 +117,7 @@ private: - ISSTREAM is; + std::istringstream is; // No copying! @@ -150,13 +149,7 @@ std::ostream *output_stream (void) { return &os; } - std::string str (void) - { - os << OSSTREAM_ENDS; - std::string retval = OSSTREAM_STR (os); - OSSTREAM_FREEZE (os); - return retval; - } + std::string str (void) { return os.str (); } std::streambuf *rdbuf (void) { return os ? os.rdbuf () : 0; } @@ -170,7 +163,7 @@ private: - OSSTREAM os; + std::ostringstream os; // No copying!
--- a/src/ov-cell.cc +++ b/src/ov-cell.cc @@ -26,11 +26,11 @@ #endif #include <iostream> +#include <sstream> #include <vector> #include "Array-util.h" #include "byte-swap.h" -#include "lo-sstream.h" #include "lo-utils.h" #include "quit.h" @@ -386,14 +386,12 @@ { OCTAVE_QUIT; - OSSTREAM buf; - buf << "[" << i+1 << "," << j+1 << "]" << OSSTREAM_ENDS; + std::ostringstream buf; + buf << "[" << i+1 << "," << j+1 << "]"; octave_value val = matrix(i,j); - val.print_with_name (os, OSSTREAM_STR (buf)); - - OSSTREAM_FREEZE (buf); + val.print_with_name (os, buf.str ()); } } @@ -785,10 +783,9 @@ for (octave_idx_type i = 0; i < dv.numel (); i++) { - OSSTREAM buf; - buf << "_" << i << OSSTREAM_ENDS; - std::string s = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + std::ostringstream buf; + buf << "_" << i; + std::string s = buf.str (); if (! add_hdf5_data(data_hid, tmp.elem (i), s.c_str (), "", false, save_as_floats))
--- a/src/ov-cs-list.cc +++ b/src/ov-cs-list.cc @@ -26,8 +26,8 @@ #endif #include <iostream> +#include <sstream> -#include "lo-sstream.h" #include "lo-utils.h" #include "defun.h" @@ -73,14 +73,12 @@ for (octave_idx_type i = 0; i < n; i++) { - OSSTREAM buf; - buf << "[" << i+1 << "]" << OSSTREAM_ENDS; + std::ostringstream buf; + buf << "[" << i+1 << "]"; octave_value val = lst(i); - val.print_with_name (os, OSSTREAM_STR (buf)); - - OSSTREAM_FREEZE (buf); + val.print_with_name (os, buf.str ()); } decrement_indent_level ();
--- a/src/ov-fcn-handle.cc +++ b/src/ov-fcn-handle.cc @@ -26,6 +26,7 @@ #endif #include <iostream> +#include <sstream> #include <vector> #include "defun.h" @@ -164,7 +165,7 @@ if (nm == "@<anonymous>") { char c; - OSSTREAM buf; + std::ostringstream buf; // Skip preceeding newline(s). while (is.get (c) && c == '\n') @@ -186,12 +187,9 @@ } } - buf << OSSTREAM_ENDS; - int parse_status; - octave_value anon_fcn_handle = eval_string (OSSTREAM_STR (buf), - true, parse_status); - OSSTREAM_FREEZE (buf); + octave_value anon_fcn_handle = eval_string (buf.str (), true, + parse_status); if (parse_status == 0) { @@ -222,10 +220,9 @@ os.write (nm.c_str (), nm.length ()); if (nm == "@<anonymous>") { - OSSTREAM buf; + std::ostringstream buf; print_raw (buf, true); - std::string stmp = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + std::string stmp = buf.str (); tmp = stmp.length (); os.write (reinterpret_cast<char *> (&tmp), 4); os.write (stmp.c_str (), stmp.length ()); @@ -328,10 +325,9 @@ if (nm == "@<anonymous>") { - OSSTREAM buf; + std::ostringstream buf; print_raw (buf, true); - std::string stmp = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + std::string stmp = buf.str (); // attach the type of the variable H5Tset_size (type_hid, stmp.length () + 1);
--- a/src/ov-fcn-inline.cc +++ b/src/ov-fcn-inline.cc @@ -29,6 +29,7 @@ #include <istream> #include <iostream> +#include <sstream> #include <vector> #include "defun.h" @@ -59,7 +60,7 @@ { // Form a string representing the function. - OSSTREAM buf; + std::ostringstream buf; buf << "@("; @@ -71,13 +72,10 @@ buf << ifargs(i); } - buf << ") " << iftext << OSSTREAM_ENDS; + buf << ") " << iftext; int parse_status; - octave_value anon_fcn_handle = eval_string (OSSTREAM_STR (buf), true, - parse_status); - - OSSTREAM_FREEZE (buf); + octave_value anon_fcn_handle = eval_string (buf.str (), true, parse_status); if (parse_status == 0) { @@ -120,7 +118,7 @@ nm = ""; char c; - OSSTREAM buf; + std::ostringstream buf; // Skip preceeding newline(s) while (is.get (c) && c == '\n'); @@ -140,9 +138,7 @@ } } - buf << OSSTREAM_ENDS; - iftext = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + iftext = buf.str (); octave_fcn_inline tmp (iftext, ifargs, nm); fcn = tmp.fcn; @@ -535,7 +531,7 @@ void octave_fcn_inline::print_raw (std::ostream& os, bool pr_as_read_syntax) const { - OSSTREAM buf; + std::ostringstream buf; if (nm.empty ()) buf << "f("; @@ -550,11 +546,10 @@ buf << ifargs(i); } - buf << ") = " << iftext << OSSTREAM_ENDS; + buf << ") = " << iftext; - octave_print_internal (os, OSSTREAM_STR (buf), pr_as_read_syntax, + octave_print_internal (os, buf.str (), pr_as_read_syntax, current_print_indent_level ()); - OSSTREAM_FREEZE (buf); } octave_value @@ -682,10 +677,9 @@ for (int i = 1; i < n+1; i++) { - OSSTREAM buf; - buf << "P" << i << OSSTREAM_ENDS; - fargs(i) = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + std::ostringstream buf; + buf << "P" << i; + fargs(i) = buf.str (); } } else
--- a/src/ov-list.cc +++ b/src/ov-list.cc @@ -26,8 +26,8 @@ #endif #include <iostream> +#include <sstream> -#include "lo-sstream.h" #include "lo-utils.h" #include "Cell.h" @@ -311,15 +311,13 @@ for (octave_idx_type i = 0; i < n; i++) { - OSSTREAM buf; + std::ostringstream buf; - buf << "[" << i+1 << "]" << OSSTREAM_ENDS; + buf << "[" << i+1 << "]"; octave_value val = data(i); - val.print_with_name (os, OSSTREAM_STR (buf)); - - OSSTREAM_FREEZE (buf); + val.print_with_name (os, buf.str ()); } decrement_indent_level (); @@ -549,10 +547,9 @@ { // should we use lst.name_tags () to label the elements? - OSSTREAM buf; - buf << "_" << i << OSSTREAM_ENDS; - std::string s = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + std::ostringstream buf; + buf << "_" << i; + std::string s = buf.str (); bool b = save_ascii_data (os, lst (i), s.c_str (), infnan_warned, strip_nan_and_inf, 0, 0); @@ -624,10 +621,9 @@ { // should we use lst.name_tags () to label the elements? - OSSTREAM buf; - buf << "_" << i << OSSTREAM_ENDS; - std::string s = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + std::ostringstream buf; + buf << "_" << i; + std::string s = buf.str (); // Recurse to print sub-value. bool b = save_binary_data (os, lst(i), s.c_str (), "", 0, @@ -704,10 +700,9 @@ { // should we use lst.name_tags () to label the elements? - OSSTREAM buf; - buf << "_" << i << OSSTREAM_ENDS; - std::string s = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + std::ostringstream buf; + buf << "_" << i; + std::string s = buf.str (); bool retval2 = add_hdf5_data (data_hid, lst (i), s.c_str (), "", false, save_as_floats);
--- a/src/pager.h +++ b/src/pager.h @@ -25,21 +25,19 @@ #define octave_pager_h 1 #include <iostream> +#include <sstream> #include <string> -#include "lo-sstream.h" - #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> #endif class -octave_pager_buf : public STRINGSTREAMBUF +octave_pager_buf : public std::stringbuf { public: - octave_pager_buf (void) - : STRINGSTREAMBUF (), diary_skip (0) { } + octave_pager_buf (void) : std::stringbuf (), diary_skip (0) { } void flush_current_contents_to_diary (void); @@ -85,11 +83,11 @@ }; class -octave_diary_buf : public STRINGSTREAMBUF +octave_diary_buf : public std::stringbuf { public: - octave_diary_buf (void) : STRINGSTREAMBUF () { } + octave_diary_buf (void) : std::stringbuf () { } protected:
--- a/src/parse.y +++ b/src/parse.y @@ -40,6 +40,7 @@ #endif #include <map> +#include <sstream> #include "Cell.h" #include "Matrix.h" @@ -47,7 +48,6 @@ #include "cmd-hist.h" #include "file-ops.h" #include "file-stat.h" -#include "lo-sstream.h" #include "oct-env.h" #include "oct-time.h" #include "quit.h" @@ -1409,7 +1409,7 @@ { int err_col = current_input_column - 1; - OSSTREAM output_buf; + std::ostringstream output_buf; if (reading_fcn_file || reading_script_file) output_buf << "parse error near line " << input_line_number @@ -1442,11 +1442,11 @@ output_buf << "^"; } - output_buf << "\n" << OSSTREAM_ENDS; - - parse_error ("%s", OSSTREAM_C_STR (output_buf)); - - OSSTREAM_FREEZE (output_buf); + output_buf << "\n"; + + std::string msg = output_buf.str (); + + parse_error ("%s", msg.c_str ()); } // Error mesages for mismatched end tokens. @@ -1612,17 +1612,13 @@ { tree_constant *tc_retval = new tree_constant (tmp); - OSSTREAM buf; + std::ostringstream buf; tree_print_code tpc (buf); e->accept (tpc); - buf << OSSTREAM_ENDS; - - tc_retval->stash_original_text (OSSTREAM_STR (buf)); - - OSSTREAM_FREEZE (buf); + tc_retval->stash_original_text (buf.str ()); delete e; @@ -1661,17 +1657,13 @@ { tree_constant *tc_retval = new tree_constant (tmp); - OSSTREAM buf; + std::ostringstream buf; tree_print_code tpc (buf); e->accept (tpc); - buf << OSSTREAM_ENDS; - - tc_retval->stash_original_text (OSSTREAM_STR (buf)); - - OSSTREAM_FREEZE (buf); + tc_retval->stash_original_text (buf.str ()); delete e; @@ -1719,17 +1711,13 @@ { tree_constant *tc_retval = new tree_constant (tmp); - OSSTREAM buf; + std::ostringstream buf; tree_print_code tpc (buf); e->accept (tpc); - buf << OSSTREAM_ENDS; - - tc_retval->stash_original_text (OSSTREAM_STR (buf)); - - OSSTREAM_FREEZE (buf); + tc_retval->stash_original_text (buf.str ()); delete e; @@ -2818,17 +2806,13 @@ { tree_constant *tc_retval = new tree_constant (tmp); - OSSTREAM buf; + std::ostringstream buf; tree_print_code tpc (buf); m->accept (tpc); - buf << OSSTREAM_ENDS; - - tc_retval->stash_original_text (OSSTREAM_STR (buf)); - - OSSTREAM_FREEZE (buf); + tc_retval->stash_original_text (buf.str ()); delete m;
--- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -32,6 +32,7 @@ #include <iomanip> #include <iostream> +#include <sstream> #include <string> #include "Array-util.h" @@ -40,7 +41,6 @@ #include "cmd-edit.h" #include "dMatrix.h" #include "lo-mappers.h" -#include "lo-sstream.h" #include "mach-info.h" #include "oct-cmplx.h" #include "quit.h" @@ -1546,7 +1546,7 @@ { \ nm += "(:,:,"; \ \ - OSSTREAM buf; \ + std::ostringstream buf; \ \ for (int k = 2; k < ndims; k++) \ { \ @@ -1558,11 +1558,7 @@ buf << ")"; \ } \ \ - buf << OSSTREAM_ENDS; \ - \ - nm += OSSTREAM_STR (buf); \ - \ - OSSTREAM_FREEZE (buf); \ + nm += buf.str (); \ } \ \ Array<idx_vector> idx (ndims); \ @@ -2044,7 +2040,7 @@ { nm += "(:,:,"; - OSSTREAM buf; + std::ostringstream buf; for (int k = 2; k < ndims; k++) { @@ -2056,11 +2052,7 @@ buf << ")"; } - buf << OSSTREAM_ENDS; - - nm += OSSTREAM_STR (buf); - - OSSTREAM_FREEZE (buf); + nm += buf.str (); } Array<idx_vector> idx (ndims); @@ -2219,7 +2211,7 @@ { std::string nm = "ans(:,:,"; - OSSTREAM buf; + std::ostringstream buf; for (int k = 2; k < ndims; k++) { @@ -2231,11 +2223,7 @@ buf << ")"; } - buf << OSSTREAM_ENDS; - - nm += OSSTREAM_STR (buf); - - OSSTREAM_FREEZE (buf); + nm += buf.str (); os << nm << " =\n\n"; } @@ -2328,7 +2316,7 @@ { std::string nm = "ans(:,:,"; - OSSTREAM buf; + std::ostringstream buf; for (int k = 2; k < ndims; k++) { @@ -2340,11 +2328,7 @@ buf << ")"; } - buf << OSSTREAM_ENDS; - - nm += OSSTREAM_STR (buf); - - OSSTREAM_FREEZE (buf); + nm += buf.str (); os << nm << " =\n\n"; } @@ -2552,11 +2536,9 @@ args(0).print (octave_stdout); else { - OSSTREAM buf; + std::ostringstream buf; args(0).print (buf); - buf << OSSTREAM_ENDS; - retval = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + retval = buf.str (); } } else
--- a/src/pt.cc +++ b/src/pt.cc @@ -26,10 +26,9 @@ #endif #include <iostream> +#include <sstream> #include <string> -#include "lo-sstream.h" - #include "ov-fcn.h" #include "pt.h" #include "pt-pr-code.h" @@ -52,17 +51,13 @@ std::string tree::str_print_code (void) { - OSSTREAM buf; + std::ostringstream buf; tree_print_code tpc (buf); accept (tpc); - buf << OSSTREAM_ENDS; - - std::string retval = OSSTREAM_STR (buf); - - OSSTREAM_FREEZE (buf); + std::string retval = buf.str (); return retval; }
--- a/src/strfns.cc +++ b/src/strfns.cc @@ -26,6 +26,7 @@ #endif #include <cctype> +#include <sstream> #include "dMatrix.h" @@ -393,7 +394,7 @@ if (! error_state) { - OSSTREAM buf; + std::ostringstream buf; if (nargin == 1) // Let list_in_columns query terminal width. @@ -408,11 +409,7 @@ error ("list_in_columns: expecting width to be an integer"); } - buf << OSSTREAM_ENDS; - - retval = OSSTREAM_STR (buf); - - OSSTREAM_FREEZE (buf); + retval = buf.str (); } else error ("list_in_columns: expecting cellstr or char array");
--- a/src/symtab.cc +++ b/src/symtab.cc @@ -32,6 +32,7 @@ #include <iomanip> #include <fstream> +#include <sstream> #include "glob-match.h" #include "str-vec.h" @@ -1225,7 +1226,7 @@ { // This method prints a line of information on a given symbol std::list<whos_parameter>::iterator i = params.begin (); - OSSTREAM param_buf; + std::ostringstream param_buf; while (i != params.end ()) { @@ -1302,9 +1303,7 @@ } } - param_buf << OSSTREAM_ENDS; - os << OSSTREAM_C_STR (param_buf); - OSSTREAM_FREEZE (param_buf); + os << param_buf.str (); } std::list<whos_parameter>
--- a/src/symtab.h +++ b/src/symtab.h @@ -28,8 +28,8 @@ #include <string> #include <stack> +#include <sstream> -#include "lo-sstream.h" #include "oct-alloc.h" #include "str-vec.h" @@ -531,10 +531,9 @@ if (table_name.empty ()) { - OSSTREAM buf; - buf << symtab_count++ << OSSTREAM_ENDS; - table_name = OSSTREAM_STR (buf); - OSSTREAM_FREEZE (buf); + std::ostringstream buf; + buf << symtab_count++; + table_name = buf.str (); } }
--- a/src/toplev.cc +++ b/src/toplev.cc @@ -33,6 +33,7 @@ #include <fstream> #include <iostream> +#include <sstream> #include <string> #ifdef HAVE_UNISTD_H @@ -46,7 +47,6 @@ #include "file-ops.h" #include "lo-error.h" #include "lo-mappers.h" -#include "lo-sstream.h" #include "oct-env.h" #include "quit.h" #include "str-vec.h" @@ -410,7 +410,7 @@ if (*cmd) { - OSSTREAM output_buf; + std::ostringstream output_buf; // XXX FIXME XXX -- Perhaps we should read more than one // character at a time and find a way to avoid the call to @@ -446,12 +446,8 @@ else cmd_status = 127; - output_buf << OSSTREAM_ENDS; - retval(0) = (double) cmd_status; - retval(1) = OSSTREAM_STR (output_buf); - - OSSTREAM_FREEZE (output_buf); + retval(1) = output_buf.str (); } unwind_protect::run ();