Mercurial > hg > octave-lojdl
changeset 3504:5eef8a2294bd
[project @ 2000-02-01 10:06:51 by jwe]
line wrap: on
line diff
--- a/liboctave/Array-str.cc +++ b/liboctave/Array-str.cc @@ -31,7 +31,7 @@ #include <string> -template class Array<string>; +template class Array<std::string>; /* ;;; Local Variables: ***
--- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -46,7 +46,7 @@ template <class T> class Array { -private: +protected: // The real representation of all arrays.
--- a/liboctave/Array2.cc +++ b/liboctave/Array2.cc @@ -122,14 +122,14 @@ if (r == dim1 () && c == dim2 ()) return; - ArrayRep *old_rep = rep; + Array<T>::ArrayRep *old_rep = rep; const T *old_data = data (); int old_d1 = dim1 (); int old_d2 = dim2 (); int old_len = length (); - rep = new ArrayRep (get_size (r, c)); + rep = new Array<T>::ArrayRep (get_size (r, c)); d1 = r; d2 = c; @@ -162,14 +162,14 @@ if (r == dim1 () && c == dim2 ()) return; - ArrayRep *old_rep = rep; + Array<T>::ArrayRep *old_rep = rep; const T *old_data = data (); int old_d1 = dim1 (); int old_d2 = dim2 (); int old_len = length (); - rep = new ArrayRep (get_size (r, c)); + rep = new Array<T>::ArrayRep (get_size (r, c)); d1 = r; d2 = c;
--- a/liboctave/Bounds.cc +++ b/liboctave/Bounds.cc @@ -84,8 +84,8 @@ return *this; } -ostream& -operator << (ostream& os, const Bounds& b) +std::ostream& +operator << (std::ostream& os, const Bounds& b) { for (int i = 0; i < b.size (); i++) os << b.lower_bound (i) << " " << b.upper_bound (i) << "\n";
--- a/liboctave/Bounds.h +++ b/liboctave/Bounds.h @@ -126,7 +126,7 @@ Bounds& set_lower_bounds (const ColumnVector lb); Bounds& set_upper_bounds (const ColumnVector ub); - friend ostream& operator << (ostream& os, const Bounds& b); + friend std::ostream& operator << (std::ostream& os, const Bounds& b); protected:
--- a/liboctave/CColVector.cc +++ b/liboctave/CColVector.cc @@ -802,8 +802,8 @@ // i/o -ostream& -operator << (ostream& os, const ComplexColumnVector& a) +std::ostream& +operator << (std::ostream& os, const ComplexColumnVector& a) { // int field_width = os.precision () + 7; for (int i = 0; i < a.length (); i++) @@ -811,13 +811,13 @@ return os; } -istream& -operator >> (istream& is, ComplexColumnVector& a) +std::istream& +operator >> (std::istream& is, ComplexColumnVector& a) { int len = a.length(); if (len < 1) - is.clear (ios::badbit); + is.clear (std::ios::badbit); else { double tmp;
--- a/liboctave/CColVector.h +++ b/liboctave/CColVector.h @@ -182,8 +182,8 @@ // i/o - friend ostream& operator << (ostream& os, const ComplexColumnVector& a); - friend istream& operator >> (istream& is, ComplexColumnVector& a); + friend std::ostream& operator << (std::ostream& os, const ComplexColumnVector& a); + friend std::istream& operator >> (std::istream& is, ComplexColumnVector& a); private:
--- a/liboctave/CDiagMatrix.cc +++ b/liboctave/CDiagMatrix.cc @@ -282,16 +282,16 @@ ComplexRowVector ComplexDiagMatrix::row (int i) const { - int nr = rows (); - int nc = cols (); - if (i < 0 || i >= nr) + int r = rows (); + int c = cols (); + if (i < 0 || i >= r) { (*current_liboctave_error_handler) ("invalid row selection"); return RowVector (); } - ComplexRowVector retval (nc, 0.0); - if (nr <= nc || (nr > nc && i < nc)) + ComplexRowVector retval (c, 0.0); + if (r <= c || (r > c && i < c)) retval.elem (i) = elem (i, i); return retval; @@ -321,16 +321,16 @@ ComplexColumnVector ComplexDiagMatrix::column (int i) const { - int nr = rows (); - int nc = cols (); - if (i < 0 || i >= nc) + int r = rows (); + int c = cols (); + if (i < 0 || i >= c) { (*current_liboctave_error_handler) ("invalid column selection"); return ColumnVector (); } - ComplexColumnVector retval (nr, 0.0); - if (nr >= nc || (nr < nc && i < nr)) + ComplexColumnVector retval (r, 0.0); + if (r >= c || (r < c && i < r)) retval.elem (i) = elem (i, i); return retval; @@ -367,15 +367,15 @@ ComplexDiagMatrix ComplexDiagMatrix::inverse (int& info) const { - int nr = rows (); - int nc = cols (); - if (nr != nc) + int r = rows (); + int c = cols (); + if (r != c) { (*current_liboctave_error_handler) ("inverse requires square matrix"); return DiagMatrix (); } - ComplexDiagMatrix retval (nr, nc); + ComplexDiagMatrix retval (r, c); info = 0; for (int i = 0; i < length (); i++) @@ -397,19 +397,19 @@ ComplexDiagMatrix& ComplexDiagMatrix::operator += (const DiagMatrix& a) { - int nr = rows (); - int nc = cols (); + int r = rows (); + int c = cols (); int a_nr = a.rows (); int a_nc = a.cols (); - if (nr != a_nr || nc != a_nc) + if (r != a_nr || c != a_nc) { - gripe_nonconformant ("operator +=", nr, nc, a_nr, a_nc); + gripe_nonconformant ("operator +=", r, c, a_nr, a_nc); return *this; } - if (nr == 0 || nc == 0) + if (r == 0 || c == 0) return *this; Complex *d = fortran_vec (); // Ensures only one reference to my privates! @@ -421,19 +421,19 @@ ComplexDiagMatrix& ComplexDiagMatrix::operator -= (const DiagMatrix& a) { - int nr = rows (); - int nc = cols (); + int r = rows (); + int c = cols (); int a_nr = a.rows (); int a_nc = a.cols (); - if (nr != a_nr || nc != a_nc) + if (r != a_nr || c != a_nc) { - gripe_nonconformant ("operator -=", nr, nc, a_nr, a_nc); + gripe_nonconformant ("operator -=", r, c, a_nr, a_nc); return *this; } - if (nr == 0 || nc == 0) + if (r == 0 || c == 0) return *this; Complex *d = fortran_vec (); // Ensures only one reference to my privates! @@ -445,19 +445,19 @@ ComplexDiagMatrix& ComplexDiagMatrix::operator += (const ComplexDiagMatrix& a) { - int nr = rows (); - int nc = cols (); + int r = rows (); + int c = cols (); int a_nr = a.rows (); int a_nc = a.cols (); - if (nr != a_nr || nc != a_nc) + if (r != a_nr || c != a_nc) { - gripe_nonconformant ("operator +=", nr, nc, a_nr, a_nc); + gripe_nonconformant ("operator +=", r, c, a_nr, a_nc); return *this; } - if (nr == 0 || nc == 0) + if (r == 0 || c == 0) return *this; Complex *d = fortran_vec (); // Ensures only one reference to my privates! @@ -469,19 +469,19 @@ ComplexDiagMatrix& ComplexDiagMatrix::operator -= (const ComplexDiagMatrix& a) { - int nr = rows (); - int nc = cols (); + int r = rows (); + int c = cols (); int a_nr = a.rows (); int a_nc = a.cols (); - if (nr != a_nr || nc != a_nc) + if (r != a_nr || c != a_nc) { - gripe_nonconformant ("operator -=", nr, nc, a_nr, a_nc); + gripe_nonconformant ("operator -=", r, c, a_nr, a_nc); return *this; } - if (nr == 0 || nc == 0) + if (r == 0 || c == 0) return *this; Complex *d = fortran_vec (); // Ensures only one reference to my privates! @@ -490,75 +490,29 @@ return *this; } -// diagonal matrix by scalar -> diagonal matrix operations - -ComplexDiagMatrix -operator * (const ComplexDiagMatrix& a, double s) -{ - return ComplexDiagMatrix (multiply (a.data (), a.length (), s), - a.rows (), a.cols ()); -} - -ComplexDiagMatrix -operator / (const ComplexDiagMatrix& a, double s) -{ - return ComplexDiagMatrix (divide (a.data (), a.length (), s), - a.rows (), a.cols ()); -} - -ComplexDiagMatrix -operator * (const DiagMatrix& a, const Complex& s) -{ - return ComplexDiagMatrix (multiply (a.data (), a.length (), s), - a.rows (), a.cols ()); -} - -ComplexDiagMatrix -operator / (const DiagMatrix& a, const Complex& s) -{ - return ComplexDiagMatrix (divide (a.data (), a.length (), s), - a.rows (), a.cols ()); -} - -// scalar by diagonal matrix -> diagonal matrix operations - -ComplexDiagMatrix -operator * (double s, const ComplexDiagMatrix& a) -{ - return ComplexDiagMatrix (multiply (a.data (), a.length (), s), - a.rows (), a.cols ()); -} - -ComplexDiagMatrix -operator * (const Complex& s, const DiagMatrix& a) -{ - return ComplexDiagMatrix (multiply (a.data (), a.length (), s), - a.rows (), a.cols ()); -} - // diagonal matrix by diagonal matrix -> diagonal matrix operations ComplexDiagMatrix operator * (const ComplexDiagMatrix& a, const ComplexDiagMatrix& b) { - int nr_a = a.rows (); - int nc_a = a.cols (); + int a_nr = a.rows (); + int a_nc = a.cols (); - int nr_b = b.rows (); - int nc_b = b.cols (); + int b_nr = b.rows (); + int b_nc = b.cols (); - if (nc_a != nr_b) + if (a_nc != b_nr) { - gripe_nonconformant ("operator *", nr_a, nc_a, nr_b, nc_b); + gripe_nonconformant ("operator *", a_nr, a_nc, b_nr, b_nc); return ComplexDiagMatrix (); } - if (nr_a == 0 || nc_a == 0 || nc_b == 0) - return ComplexDiagMatrix (nr_a, nc_a, 0.0); + if (a_nr == 0 || a_nc == 0 || b_nc == 0) + return ComplexDiagMatrix (a_nr, a_nc, 0.0); - ComplexDiagMatrix c (nr_a, nc_b); + ComplexDiagMatrix c (a_nr, b_nc); - int len = nr_a < nc_b ? nr_a : nc_b; + int len = a_nr < b_nc ? a_nr : b_nc; for (int i = 0; i < len; i++) { @@ -581,24 +535,24 @@ ComplexDiagMatrix operator * (const ComplexDiagMatrix& a, const DiagMatrix& b) { - int nr_a = a.rows (); - int nc_a = a.cols (); + int a_nr = a.rows (); + int a_nc = a.cols (); - int nr_b = b.rows (); - int nc_b = b.cols (); + int b_nr = b.rows (); + int b_nc = b.cols (); - if (nc_a != nr_b) + if (a_nc != b_nr) { - gripe_nonconformant ("operator *", nr_a, nc_a, nr_b, nc_b); + gripe_nonconformant ("operator *", a_nr, a_nc, b_nr, b_nc); return ComplexDiagMatrix (); } - if (nr_a == 0 || nc_a == 0 || nc_b == 0) - return ComplexDiagMatrix (nr_a, nc_a, 0.0); + if (a_nr == 0 || a_nc == 0 || b_nc == 0) + return ComplexDiagMatrix (a_nr, a_nc, 0.0); - ComplexDiagMatrix c (nr_a, nc_b); + ComplexDiagMatrix c (a_nr, b_nc); - int len = nr_a < nc_b ? nr_a : nc_b; + int len = a_nr < b_nc ? a_nr : b_nc; for (int i = 0; i < len; i++) { @@ -621,24 +575,24 @@ ComplexDiagMatrix operator * (const DiagMatrix& a, const ComplexDiagMatrix& b) { - int nr_a = a.rows (); - int nc_a = a.cols (); + int a_nr = a.rows (); + int a_nc = a.cols (); - int nr_b = b.rows (); - int nc_b = b.cols (); + int b_nr = b.rows (); + int b_nc = b.cols (); - if (nc_a != nr_b) + if (a_nc != b_nr) { - gripe_nonconformant ("operator *", nr_a, nc_a, nr_b, nc_b); + gripe_nonconformant ("operator *", a_nr, a_nc, b_nr, b_nc); return ComplexDiagMatrix (); } - if (nr_a == 0 || nc_a == 0 || nc_b == 0) - return ComplexDiagMatrix (nr_a, nc_a, 0.0); + if (a_nr == 0 || a_nc == 0 || b_nc == 0) + return ComplexDiagMatrix (a_nr, a_nc, 0.0); - ComplexDiagMatrix c (nr_a, nc_b); + ComplexDiagMatrix c (a_nr, b_nc); - int len = nr_a < nc_b ? nr_a : nc_b; + int len = a_nr < b_nc ? a_nr : b_nc; for (int i = 0; i < len; i++) { @@ -703,15 +657,15 @@ } } else - cerr << "diag: requested diagonal out of range\n"; + std::cerr << "diag: requested diagonal out of range\n"; return d; } // i/o -ostream& -operator << (ostream& os, const ComplexDiagMatrix& a) +std::ostream& +operator << (std::ostream& os, const ComplexDiagMatrix& a) { Complex ZERO (0.0); // int field_width = os.precision () + 7;
--- a/liboctave/CDiagMatrix.h +++ b/liboctave/CDiagMatrix.h @@ -106,31 +106,6 @@ ComplexDiagMatrix& operator += (const ComplexDiagMatrix& a); ComplexDiagMatrix& operator -= (const ComplexDiagMatrix& a); - // diagonal matrix by scalar -> diagonal matrix operations - - friend ComplexDiagMatrix operator * (const ComplexDiagMatrix& a, double s); - friend ComplexDiagMatrix operator / (const ComplexDiagMatrix& a, double s); - - friend ComplexDiagMatrix operator * (const DiagMatrix& a, const Complex& s); - friend ComplexDiagMatrix operator / (const DiagMatrix& a, const Complex& s); - - // scalar by diagonal matrix -> diagonal matrix operations - - friend ComplexDiagMatrix operator * (double s, const ComplexDiagMatrix& a); - - friend ComplexDiagMatrix operator * (const Complex& s, const DiagMatrix& a); - - // diagonal matrix by diagonal matrix -> diagonal matrix operations - - friend ComplexDiagMatrix operator * (const ComplexDiagMatrix& a, - const ComplexDiagMatrix& b); - - friend ComplexDiagMatrix operator * (const ComplexDiagMatrix& a, - const DiagMatrix& b); - - friend ComplexDiagMatrix operator * (const DiagMatrix& a, - const ComplexDiagMatrix& b); - // other operations ComplexColumnVector diag (void) const; @@ -138,7 +113,7 @@ // i/o - friend ostream& operator << (ostream& os, const ComplexDiagMatrix& a); + friend std::ostream& operator << (std::ostream& os, const ComplexDiagMatrix& a); private: @@ -146,6 +121,17 @@ : MDiagArray2<Complex> (d, nr, nc) { } }; +// diagonal matrix by diagonal matrix -> diagonal matrix operations + +ComplexDiagMatrix +operator * (const ComplexDiagMatrix& a, const ComplexDiagMatrix& b); + +ComplexDiagMatrix +operator * (const ComplexDiagMatrix& a, const DiagMatrix& b); + +ComplexDiagMatrix +operator * (const DiagMatrix& a, const ComplexDiagMatrix& b); + #endif /*
--- a/liboctave/CMatrix.cc +++ b/liboctave/CMatrix.cc @@ -2551,7 +2551,7 @@ } } else - cerr << "diag: requested diagonal out of range\n"; + std::cerr << "diag: requested diagonal out of range\n"; return d; } @@ -2616,16 +2616,16 @@ for (int i = 0; i < nr; i++) { - int idx = 0; - - Complex tmp_min = elem (i, idx); + int idx_j = 0; + + Complex tmp_min = elem (i, idx_j); bool real_only = row_is_real_only (i); double abs_min = real_only ? real (tmp_min) : abs (tmp_min); if (xisnan (tmp_min)) - idx = -1; + idx_j = -1; else { for (int j = 1; j < nc; j++) @@ -2636,19 +2636,19 @@ if (xisnan (tmp)) { - idx = -1; + idx_j = -1; break; } else if (abs_tmp < abs_min) { - idx = j; + idx_j = j; tmp_min = tmp; abs_min = abs_tmp; } } - result.elem (i) = (idx < 0) ? Complex_NaN_result : tmp_min; - index.elem (i) = idx; + result.elem (i) = (idx_j < 0) ? Complex_NaN_result : tmp_min; + index.elem (i) = idx_j; } } } @@ -2678,16 +2678,16 @@ for (int i = 0; i < nr; i++) { - int idx = 0; - - Complex tmp_max = elem (i, idx); + int idx_j = 0; + + Complex tmp_max = elem (i, idx_j); bool real_only = row_is_real_only (i); double abs_max = real_only ? real (tmp_max) : abs (tmp_max); if (xisnan (tmp_max)) - idx = -1; + idx_j = -1; else { for (int j = 1; j < nc; j++) @@ -2698,19 +2698,19 @@ if (xisnan (tmp)) { - idx = -1; + idx_j = -1; break; } else if (abs_tmp > abs_max) { - idx = j; + idx_j = j; tmp_max = tmp; abs_max = abs_tmp; } } - result.elem (i) = (idx < 0) ? Complex_NaN_result : tmp_max; - index.elem (i) = idx; + result.elem (i) = (idx_j < 0) ? Complex_NaN_result : tmp_max; + index.elem (i) = idx_j; } } } @@ -2740,16 +2740,16 @@ for (int j = 0; j < nc; j++) { - int idx = 0; - - Complex tmp_min = elem (idx, j); + int idx_i = 0; + + Complex tmp_min = elem (idx_i, j); bool real_only = column_is_real_only (j); double abs_min = real_only ? real (tmp_min) : abs (tmp_min); if (xisnan (tmp_min)) - idx = -1; + idx_i = -1; else { for (int i = 1; i < nr; i++) @@ -2760,19 +2760,19 @@ if (xisnan (tmp)) { - idx = -1; + idx_i = -1; break; } else if (abs_tmp < abs_min) { - idx = i; + idx_i = i; tmp_min = tmp; abs_min = abs_tmp; } } - result.elem (j) = (idx < 0) ? Complex_NaN_result : tmp_min; - index.elem (j) = idx; + result.elem (j) = (idx_i < 0) ? Complex_NaN_result : tmp_min; + index.elem (j) = idx_i; } } } @@ -2802,16 +2802,16 @@ for (int j = 0; j < nc; j++) { - int idx = 0; - - Complex tmp_max = elem (idx, j); + int idx_i = 0; + + Complex tmp_max = elem (idx_i, j); bool real_only = column_is_real_only (j); double abs_max = real_only ? real (tmp_max) : abs (tmp_max); if (xisnan (tmp_max)) - idx = -1; + idx_i = -1; else { for (int i = 1; i < nr; i++) @@ -2822,19 +2822,19 @@ if (xisnan (tmp)) { - idx = -1; + idx_i = -1; break; } else if (abs_tmp > abs_max) { - idx = i; + idx_i = i; tmp_max = tmp; abs_max = abs_tmp; } } - result.elem (j) = (idx < 0) ? Complex_NaN_result : tmp_max; - index.elem (j) = idx; + result.elem (j) = (idx_i < 0) ? Complex_NaN_result : tmp_max; + index.elem (j) = idx_i; } } } @@ -2844,8 +2844,8 @@ // i/o -ostream& -operator << (ostream& os, const ComplexMatrix& a) +std::ostream& +operator << (std::ostream& os, const ComplexMatrix& a) { // int field_width = os.precision () + 7; for (int i = 0; i < a.rows (); i++) @@ -2857,14 +2857,14 @@ return os; } -istream& -operator >> (istream& is, ComplexMatrix& a) +std::istream& +operator >> (std::istream& is, ComplexMatrix& a) { int nr = a.rows (); int nc = a.cols (); if (nr < 1 || nc < 1) - is.clear (ios::badbit); + is.clear (std::ios::badbit); else { Complex tmp; @@ -3008,13 +3008,13 @@ } MS_CMP_OPS(ComplexMatrix, real, Complex, real) -MS_BOOL_OPS(ComplexMatrix, Complex) +MS_BOOL_OPS(ComplexMatrix, Complex, 0.0) SM_CMP_OPS(Complex, real, ComplexMatrix, real) -SM_BOOL_OPS(Complex, ComplexMatrix) +SM_BOOL_OPS(Complex, ComplexMatrix, 0.0) MM_CMP_OPS(ComplexMatrix, real, ComplexMatrix, real) -MM_BOOL_OPS(ComplexMatrix, ComplexMatrix) +MM_BOOL_OPS(ComplexMatrix, ComplexMatrix, 0.0) /* ;;; Local Variables: ***
--- a/liboctave/CMatrix.h +++ b/liboctave/CMatrix.h @@ -36,15 +36,6 @@ class ComplexMatrix : public MArray2<Complex> { -friend class Matrix; -friend class ComplexCHOL; -friend class ComplexHESS; -friend class ComplexLU; -friend class ComplexQR; -friend class ComplexQRP; -friend class ComplexSCHUR; -friend class ComplexSVD; - public: typedef void (*solve_singularity_handler) (double rcond); @@ -254,8 +245,8 @@ // i/o - friend ostream& operator << (ostream& os, const ComplexMatrix& a); - friend istream& operator >> (istream& is, ComplexMatrix& a); + friend std::ostream& operator << (std::ostream& os, const ComplexMatrix& a); + friend std::istream& operator >> (std::istream& is, ComplexMatrix& a); private:
--- a/liboctave/CRowVector.cc +++ b/liboctave/CRowVector.cc @@ -712,8 +712,8 @@ // i/o -ostream& -operator << (ostream& os, const ComplexRowVector& a) +std::ostream& +operator << (std::ostream& os, const ComplexRowVector& a) { // int field_width = os.precision () + 7; for (int i = 0; i < a.length (); i++) @@ -721,13 +721,13 @@ return os; } -istream& -operator >> (istream& is, ComplexRowVector& a) +std::istream& +operator >> (std::istream& is, ComplexRowVector& a) { int len = a.length(); if (len < 1) - is.clear (ios::badbit); + is.clear (std::ios::badbit); else { Complex tmp;
--- a/liboctave/CRowVector.h +++ b/liboctave/CRowVector.h @@ -149,8 +149,8 @@ // i/o - friend ostream& operator << (ostream& os, const ComplexRowVector& a); - friend istream& operator >> (istream& is, ComplexRowVector& a); + friend std::ostream& operator << (std::ostream& os, const ComplexRowVector& a); + friend std::istream& operator >> (std::istream& is, ComplexRowVector& a); private:
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,11 +1,45 @@ +2000-02-01 John W. Eaton <jwe@bevo.che.wisc.edu> + + * dMatrix.cc (write_int, read_int): No longer declared static. + + * CDiagMatrix.h: Delete decls for friend operators that are + handled by MDiagArray2 class. Move others outside class decl and + strip friend status. + * dDiagMatrix.h: Likewise. + + * MArray.h: Delete decls for friend operators inside class decl. + * MArray2.h: Ditto. + * MDiagArray2.h: Ditto. + + * MArray-defs.h (DO_VS_OP,, DO_SV_OP, DO_VV_OP, NEGV): Pass all + necessary parameters. Don't allocate memory in the macro. Change + all uses. + + * dMatrix.h (class Matrix): Delete `friend class' decls. + * CMatrix.h (class ComplexMatrix): Ditto. + + * mx-op-defs (MS_BOOL_OP, MS_BOOL_OPS, SM_BOOL_OP, SM_BOOL_OPS, + MM_BOOL_OP, MM_BOOL_OPS, MDM_MULTIPLY_OP, MDM_BIN_OPS, + DMM_MULTIPLY_OP, DMM_BIN_OPS): Pass zero constant as final arg, to + avoid type conflicts. Change all uses. + + * strptime.c (__mon_yday): Fix size of array decl. + + * mx-inlines.cc: Use `xnot' instead of `not' for function name. + + * chMatrix.cc (charMatrix::row_as_string): Delete extraneous + default value for second arg. + + * Array2.cc (Array2<T>::resize): Add Array<T>:: qulaifier to + references to ArrayRep. + 2000-01-31 John W. Eaton <jwe@bevo.che.wisc.edu> - * oct-alloc.cc (octave_allocator::grow): Add std:: qualifier for - set_net_handler. + * Array.h (Array::ArrayRep): Now protected, not private. * All source files: Include iostream, fstream, strstream, etc. as needed instead of using forward declarations for these - classes. + classes. Add std:: qualifier as needed. 2000-01-30 John W. Eaton <jwe@bevo.che.wisc.edu>
--- a/liboctave/CmplxAEPBAL.cc +++ b/liboctave/CmplxAEPBAL.cc @@ -47,7 +47,8 @@ } int -ComplexAEPBALANCE::init (const ComplexMatrix& a, const string& balance_job) +ComplexAEPBALANCE::init (const ComplexMatrix& a, + const std::string& balance_job) { int n = a.cols ();
--- a/liboctave/CmplxAEPBAL.h +++ b/liboctave/CmplxAEPBAL.h @@ -39,7 +39,7 @@ ComplexAEPBALANCE (void) : balanced_mat (), balancing_mat () { } - ComplexAEPBALANCE (const ComplexMatrix& a, const string& balance_job) + ComplexAEPBALANCE (const ComplexMatrix& a, const std::string& balance_job) { init (a, balance_job); } @@ -63,14 +63,14 @@ ComplexMatrix balancing_matrix (void) const { return balancing_mat; } - friend ostream& operator << (ostream& os, const ComplexAEPBALANCE& a); + friend std::ostream& operator << (std::ostream& os, const ComplexAEPBALANCE& a); private: ComplexMatrix balanced_mat; ComplexMatrix balancing_mat; - int init (const ComplexMatrix& a, const string& balance_job); + int init (const ComplexMatrix& a, const std::string& balance_job); }; #endif
--- a/liboctave/CmplxCHOL.h +++ b/liboctave/CmplxCHOL.h @@ -61,7 +61,7 @@ return chol_mat; } - friend ostream& operator << (ostream& os, const ComplexCHOL& a); + friend std::ostream& operator << (std::ostream& os, const ComplexCHOL& a); private:
--- a/liboctave/CmplxDET.h +++ b/liboctave/CmplxDET.h @@ -65,7 +65,7 @@ Complex value (void) const; - friend ostream& operator << (ostream& os, const ComplexDET& a); + friend std::ostream& operator << (std::ostream& os, const ComplexDET& a); private:
--- a/liboctave/CmplxHESS.h +++ b/liboctave/CmplxHESS.h @@ -64,7 +64,7 @@ return unitary_hess_mat; } - friend ostream& operator << (ostream& os, const ComplexHESS& a); + friend std::ostream& operator << (std::ostream& os, const ComplexHESS& a); private:
--- a/liboctave/CmplxQR.h +++ b/liboctave/CmplxQR.h @@ -61,7 +61,7 @@ ComplexMatrix R (void) const { return r; } - friend ostream& operator << (ostream&, const ComplexQR&); + friend std::ostream& operator << (std::ostream&, const ComplexQR&); protected:
--- a/liboctave/CmplxQRP.h +++ b/liboctave/CmplxQRP.h @@ -58,7 +58,7 @@ Matrix P (void) const { return p; } - friend ostream& operator << (ostream&, const ComplexQRP&); + friend std::ostream& operator << (std::ostream&, const ComplexQRP&); private:
--- a/liboctave/CmplxSCHUR.cc +++ b/liboctave/CmplxSCHUR.cc @@ -56,7 +56,7 @@ } int -ComplexSCHUR::init (const ComplexMatrix& a, const string& ord) +ComplexSCHUR::init (const ComplexMatrix& a, const std::string& ord) { int a_nr = a.rows (); int a_nc = a.cols ();
--- a/liboctave/CmplxSCHUR.h +++ b/liboctave/CmplxSCHUR.h @@ -40,13 +40,13 @@ ComplexSCHUR (void) : schur_mat (), unitary_mat () { } - ComplexSCHUR (const ComplexMatrix& a, const string& ord) + ComplexSCHUR (const ComplexMatrix& a, const std::string& ord) : schur_mat (), unitary_mat () { init (a, ord); } - ComplexSCHUR (const ComplexMatrix& a, const string& ord, int& info) + ComplexSCHUR (const ComplexMatrix& a, const std::string& ord, int& info) : schur_mat (), unitary_mat () { info = init (a,ord); @@ -71,7 +71,7 @@ ComplexMatrix unitary_matrix (void) const { return unitary_mat; } - friend ostream& operator << (ostream& os, const ComplexSCHUR& a); + friend std::ostream& operator << (std::ostream& os, const ComplexSCHUR& a); typedef int (*select_function) (const Complex&); @@ -82,7 +82,7 @@ select_function selector; - int init (const ComplexMatrix& a, const string& ord); + int init (const ComplexMatrix& a, const std::string& ord); }; #endif
--- a/liboctave/CmplxSVD.h +++ b/liboctave/CmplxSVD.h @@ -73,7 +73,7 @@ ComplexMatrix right_singular_matrix (void) const; - friend ostream& operator << (ostream& os, const ComplexSVD& a); + friend std::ostream& operator << (std::ostream& os, const ComplexSVD& a); private:
--- a/liboctave/CollocWt.cc +++ b/liboctave/CollocWt.cc @@ -163,8 +163,8 @@ initialized = 1; } -ostream& -operator << (ostream& os, const CollocWt& a) +std::ostream& +operator << (std::ostream& os, const CollocWt& a) { if (a.left_included ()) os << "left boundary is included\n";
--- a/liboctave/CollocWt.h +++ b/liboctave/CollocWt.h @@ -160,7 +160,7 @@ Matrix second (void) { if (!initialized) init (); return B; } - friend ostream& operator << (ostream&, const CollocWt&); + friend std::ostream& operator << (std::ostream&, const CollocWt&); protected:
--- a/liboctave/EIG.h +++ b/liboctave/EIG.h @@ -71,7 +71,7 @@ ComplexMatrix eigenvectors (void) const { return v; } - friend ostream& operator << (ostream& os, const EIG& a); + friend std::ostream& operator << (std::ostream& os, const EIG& a); private:
--- a/liboctave/FEGrid.cc +++ b/liboctave/FEGrid.cc @@ -126,8 +126,8 @@ } } -ostream& -operator << (ostream& s, const FEGrid& g) +std::ostream& +operator << (std::ostream& s, const FEGrid& g) { s << g.element_boundaries (); return s;
--- a/liboctave/FEGrid.h +++ b/liboctave/FEGrid.h @@ -69,7 +69,7 @@ ColumnVector element_boundaries (void) const { return elem; } - friend ostream& operator << (ostream&, const FEGrid&); + friend std::ostream& operator << (std::ostream&, const FEGrid&); protected:
--- a/liboctave/LSODE.cc +++ b/liboctave/LSODE.cc @@ -307,7 +307,7 @@ #if 0 void -LSODE::integrate (int nsteps, double tstep, ostream& s) +LSODE::integrate (int nsteps, double tstep, std::ostream& s) { int time_to_quit = 0; double tout = t;
--- a/liboctave/LSODE.h +++ b/liboctave/LSODE.h @@ -150,7 +150,7 @@ Matrix do_integrate (const ColumnVector& tout); #if 0 - void integrate (int nsteps, double tstep, ostream& s); + void integrate (int nsteps, double tstep, std::ostream& s); #endif Matrix integrate (const ColumnVector& tout)
--- a/liboctave/LinConst.cc +++ b/liboctave/LinConst.cc @@ -41,8 +41,8 @@ (*current_liboctave_error_handler) ("fatal LinConst error: %s", msg); } -ostream& -operator << (ostream& os, const LinConst& c) +std::ostream& +operator << (std::ostream& os, const LinConst& c) { for (int i = 0; i < c.size (); i++) os << c.lower_bound (i) << " " << c.upper_bound (i) << "\n";
--- a/liboctave/LinConst.h +++ b/liboctave/LinConst.h @@ -79,7 +79,7 @@ return *this; } - friend ostream& operator << (ostream& os, const LinConst& b); + friend std::ostream& operator << (std::ostream& os, const LinConst& b); protected:
--- a/liboctave/MArray-defs.h +++ b/liboctave/MArray-defs.h @@ -2,48 +2,32 @@ // have been nice to do this with template functions but as of 2.5.x, // g++ seems to fail to resolve them properly. -#define DO_VS_OP(OP) \ - int l = a.length (); \ - T *result = 0; \ +#define DO_VS_OP(r, l, v, OP, s) \ if (l > 0) \ { \ - result = new T [l]; \ - const T *x = a.data (); \ for (int i = 0; i < l; i++) \ - result[i] = x[i] OP s; \ + r[i] = v[i] OP s; \ } -#define DO_SV_OP(OP) \ - int l = a.length (); \ - T *result = 0; \ +#define DO_SV_OP(r, l, s, OP, v) \ if (l > 0) \ { \ - result = new T [l]; \ - const T *x = a.data (); \ for (int i = 0; i < l; i++) \ - result[i] = s OP x[i]; \ + r[i] = s OP v[i]; \ } -#define DO_VV_OP(OP) \ - T *result = 0; \ +#define DO_VV_OP(r, l, x, OP, y) \ if (l > 0) \ { \ - result = new T [l]; \ - const T *x = a.data (); \ - const T *y = b.data (); \ for (int i = 0; i < l; i++) \ - result[i] = x[i] OP y[i]; \ + r[i] = x[i] OP y[i]; \ } -#define NEG_V \ - int l = a.length (); \ - T *result = 0; \ +#define NEG_V(r, l, x) \ if (l > 0) \ { \ - result = new T [l]; \ - const T *x = a.data (); \ for (int i = 0; i < l; i++) \ - result[i] = -x[i]; \ + r[i] = -x[i]; \ } #define DO_VS_OP2(OP) \
--- a/liboctave/MArray.cc +++ b/liboctave/MArray.cc @@ -94,8 +94,12 @@ MArray<T> \ operator OP (const MArray<T>& a, const T& s) \ { \ - DO_VS_OP (OP); \ - return MArray<T> (result, l); \ + MArray<T> result (a.length ()); \ + T *r = result.fortran_vec (); \ + int l = a.length (); \ + const T *v = a.data (); \ + DO_VS_OP (r, l, v, OP, s); \ + return result; \ } MARRAY_AS_OP (+) @@ -110,9 +114,13 @@ MArray<T> \ operator OP (const T& s, const MArray<T>& a) \ { \ - DO_SV_OP (OP); \ - return MArray<T> (result, l); \ - } + MArray<T> result (a.length ()); \ + T *r = result.fortran_vec (); \ + int l = a.length (); \ + const T *v = a.data (); \ + DO_SV_OP (r, l, s, OP, v); \ + return result; \ + } MARRAY_SA_OP(+) MARRAY_SA_OP(-) @@ -135,8 +143,12 @@ } \ if (l == 0) \ return MArray<T> (); \ - DO_VV_OP (OP); \ - return MArray<T> (result, l); \ + MArray<T> result (l); \ + T *r = result.fortran_vec (); \ + const T *x = a.data (); \ + const T *y = b.data (); \ + DO_VV_OP (r, l, x, OP, y); \ + return result; \ } MARRAY_AA_OP (operator +, +) @@ -150,8 +162,12 @@ MArray<T> operator - (const MArray<T>& a) { - NEG_V; - return MArray<T> (result, l); + int l = a.length (); + MArray<T> result (l); + T *r = result.fortran_vec (); + const T *x = a.data (); + NEG_V (r, l, x); + return result; } /*
--- a/liboctave/MArray.h +++ b/liboctave/MArray.h @@ -119,41 +119,6 @@ Array<T>::operator = (a); return *this; } - - // element by element MArray by scalar ops - - friend MArray<T>& operator += LTGT (MArray<T>& a, const T& s); - friend MArray<T>& operator -= LTGT (MArray<T>& a, const T& s); - - // element by element MArray by MArray ops - - friend MArray<T>& operator += LTGT (MArray<T>& a, const MArray<T>& b); - friend MArray<T>& operator -= LTGT (MArray<T>& a, const MArray<T>& b); - - // element by element MArray by scalar ops - - friend MArray<T> operator + LTGT (const MArray<T>& a, const T& s); - friend MArray<T> operator - LTGT (const MArray<T>& a, const T& s); - friend MArray<T> operator * LTGT (const MArray<T>& a, const T& s); - friend MArray<T> operator / LTGT (const MArray<T>& a, const T& s); - - // element by element scalar by MArray ops - - friend MArray<T> operator + LTGT (const T& s, const MArray<T>& a); - friend MArray<T> operator - LTGT (const T& s, const MArray<T>& a); - friend MArray<T> operator * LTGT (const T& s, const MArray<T>& a); - friend MArray<T> operator / LTGT (const T& s, const MArray<T>& a); - - // element by element MArray by MArray ops - - friend MArray<T> operator + LTGT (const MArray<T>& a, const MArray<T>& b); - - friend MArray<T> operator - LTGT (const MArray<T>& a, const MArray<T>& b); - - friend MArray<T> product LTGT (const MArray<T>& a, const MArray<T>& b); - friend MArray<T> quotient LTGT (const MArray<T>& a, const MArray<T>& b); - - friend MArray<T> operator - LTGT (const MArray<T>& a); }; #undef LTGT
--- a/liboctave/MArray2.cc +++ b/liboctave/MArray2.cc @@ -104,8 +104,12 @@ MArray2<T> \ operator OP (const MArray2<T>& a, const T& s) \ { \ - DO_VS_OP (OP); \ - return MArray2<T> (result, a.rows (), a.cols ()); \ + MArray2<T> result (a.rows (), a.cols ()); \ + T *r = result.fortran_vec (); \ + int l = a.length (); \ + const T *v = a.data (); \ + DO_VS_OP (r, l, v, OP, s); \ + return result; \ } MARRAY_A2S_OP (+) @@ -120,8 +124,12 @@ MArray2<T> \ operator OP (const T& s, const MArray2<T>& a) \ { \ - DO_SV_OP (OP); \ - return MArray2<T> (result, a.rows (), a.cols ()); \ + MArray2<T> result (a.rows (), a.cols ()); \ + T *r = result.fortran_vec (); \ + int l = a.length (); \ + const T *v = a.data (); \ + DO_SV_OP (r, l, s, OP, v); \ + return result; \ } MARRAY_SA2_OP (+) @@ -136,20 +144,24 @@ MArray2<T> \ FCN (const MArray2<T>& a, const MArray2<T>& b) \ { \ - int r = a.rows (); \ - int c = a.cols (); \ - int br = b.rows (); \ - int bc = b.cols (); \ - if (r != br || c != bc) \ + int a_nr = a.rows (); \ + int a_nc = a.cols (); \ + int b_nr = b.rows (); \ + int b_nc = b.cols (); \ + if (a_nr != b_nr || a_nc != b_nc) \ { \ - gripe_nonconformant (#FCN, r, c, br, bc); \ + gripe_nonconformant (#FCN, a_nr, a_nc, b_nr, b_nc); \ return MArray2<T> (); \ } \ - if (r == 0 || c == 0) \ - return MArray2<T> (r, c); \ + if (a_nr == 0 || a_nc == 0) \ + return MArray2<T> (a_nr, a_nc); \ int l = a.length (); \ - DO_VV_OP (OP); \ - return MArray2<T> (result, r, c); \ + MArray2<T> result (a_nr, a_nc); \ + T *r = result.fortran_vec (); \ + const T *x = a.data (); \ + const T *y = b.data (); \ + DO_VV_OP (r, l, x, OP, y); \ + return result; \ } MARRAY_A2A2_OP (operator +, +) @@ -163,8 +175,12 @@ MArray2<T> operator - (const MArray2<T>& a) { - NEG_V; - return MArray2<T> (result, a.rows (), a.cols ()); + int l = a.length (); + MArray2<T> result (a.rows (), a.cols ()); + T *r = result.fortran_vec (); + const T *x = a.data (); + NEG_V (r, l, x); + return result; } /*
--- a/liboctave/MArray2.h +++ b/liboctave/MArray2.h @@ -127,40 +127,6 @@ } MArray2<T> transpose (void) const { return Array2<T>::transpose (); } - - // element by element MArray2 by scalar ops - - friend MArray2<T>& operator += LTGT (MArray2<T>& a, const T& s); - friend MArray2<T>& operator -= LTGT (MArray2<T>& a, const T& s); - - // element by element MArray2 by MArray2 ops - - friend MArray2<T>& operator += LTGT (MArray2<T>& a, const MArray2<T>& b); - friend MArray2<T>& operator -= LTGT (MArray2<T>& a, const MArray2<T>& b); - - // element by element MArray2 by scalar ops - - friend MArray2<T> operator + LTGT (const MArray2<T>& a, const T& s); - friend MArray2<T> operator - LTGT (const MArray2<T>& a, const T& s); - friend MArray2<T> operator * LTGT (const MArray2<T>& a, const T& s); - friend MArray2<T> operator / LTGT (const MArray2<T>& a, const T& s); - - // element by element scalar by MArray2 ops - - friend MArray2<T> operator + LTGT (const T& s, const MArray2<T>& a); - friend MArray2<T> operator - LTGT (const T& s, const MArray2<T>& a); - friend MArray2<T> operator * LTGT (const T& s, const MArray2<T>& a); - friend MArray2<T> operator / LTGT (const T& s, const MArray2<T>& a); - - // element by element MArray2 by MArray2 ops - - friend MArray2<T> operator + LTGT (const MArray2<T>& a, const MArray2<T>& b); - friend MArray2<T> operator - LTGT (const MArray2<T>& a, const MArray2<T>& b); - - friend MArray2<T> product LTGT (const MArray2<T>& a, const MArray2<T>& b); - friend MArray2<T> quotient LTGT (const MArray2<T>& a, const MArray2<T>& b); - - friend MArray2<T> operator - LTGT (const MArray2<T>& a); }; #undef LTGT
--- a/liboctave/MDiagArray2.cc +++ b/liboctave/MDiagArray2.cc @@ -92,8 +92,12 @@ MDiagArray2<T> \ operator OP (const MDiagArray2<T>& a, const T& s) \ { \ - DO_VS_OP (OP); \ - return MDiagArray2<T> (result, a.rows (), a.cols ()); \ + MDiagArray2<T> result (a.rows (), a.cols ()); \ + T *r = result.fortran_vec (); \ + int l = a.length (); \ + const T *v = a.data (); \ + DO_VS_OP (r, l, v, OP, s); \ + return result; \ } MARRAY_DAS_OP (*) @@ -105,8 +109,12 @@ MDiagArray2<T> operator * (const T& s, const MDiagArray2<T>& a) { - DO_SV_OP (*); - return MDiagArray2<T> (result, a.rows (), a.cols ()); + MDiagArray2<T> result (a.rows (), a.cols ()); \ + T *r = result.fortran_vec (); \ + int l = a.length (); \ + const T *v = a.data (); \ + DO_SV_OP (r, l, s, *, v); \ + return result; \ } // Element by element MDiagArray2 by MDiagArray2 ops. @@ -116,20 +124,24 @@ MDiagArray2<T> \ FCN (const MDiagArray2<T>& a, const MDiagArray2<T>& b) \ { \ - int r = a.rows (); \ - int c = a.cols (); \ + int a_nr = a.rows (); \ + int a_nc = a.cols (); \ int b_nr = b.rows (); \ int b_nc = b.cols (); \ - if (r != b_nr || c != b_nc) \ + if (a_nr != b_nr || a_nc != b_nc) \ { \ - gripe_nonconformant (#FCN, r, c, b_nr, b_nc); \ + gripe_nonconformant (#FCN, a_nr, a_nc, b_nr, b_nc); \ return MDiagArray2<T> (); \ } \ - if (c == 0 || r == 0) \ + if (a_nc == 0 || a_nr == 0) \ return MDiagArray2<T> (); \ int l = a.length (); \ - DO_VV_OP (OP); \ - return MDiagArray2<T> (result, r, c); \ + MDiagArray2<T> result (a_nr, a_nc); \ + T *r = result.fortran_vec (); \ + const T *x = a.data (); \ + const T *y = b.data (); \ + DO_VV_OP (r, l, x, OP, y); \ + return result; \ } MARRAY_DADA_OP (operator +, +) @@ -142,8 +154,12 @@ MDiagArray2<T> operator - (const MDiagArray2<T>& a) { - NEG_V; - return MDiagArray2<T> (result, a.rows (), a.cols ()); + int l = a.length (); + MDiagArray2<T> result (a.rows (), a.cols ()); + T *r = result.fortran_vec (); + const T *x = a.data (); + NEG_V (r, l, x); + return result; } /*
--- a/liboctave/MDiagArray2.h +++ b/liboctave/MDiagArray2.h @@ -109,36 +109,6 @@ return retval; } - - // element by element MDiagArray2 by MDiagArray2 ops - - friend MDiagArray2<T>& - operator += LTGT (MDiagArray2<T>& a, const MDiagArray2<T>& b); - - friend MDiagArray2<T>& - operator -= LTGT (MDiagArray2<T>& a, const MDiagArray2<T>& b); - - // element by element MDiagArray2 by scalar ops - - friend MDiagArray2<T> operator * LTGT (const MDiagArray2<T>& a, const T& s); - friend MDiagArray2<T> operator / LTGT (const MDiagArray2<T>& a, const T& s); - - // element by element scalar by MDiagArray2 ops - - friend MDiagArray2<T> operator * LTGT (const T& s, const MDiagArray2<T>& a); - - // element by element MDiagArray2 by MDiagArray2 ops - - friend MDiagArray2<T> - operator + LTGT (const MDiagArray2<T>& a, const MDiagArray2<T>& b); - - friend MDiagArray2<T> - operator - LTGT (const MDiagArray2<T>& a, const MDiagArray2<T>& b); - - friend MDiagArray2<T> - product LTGT (const MDiagArray2<T>& a, const MDiagArray2<T>& b); - - friend MDiagArray2<T> operator - LTGT (const MDiagArray2<T>& a); }; #undef LTGT
--- a/liboctave/Range.cc +++ b/liboctave/Range.cc @@ -112,14 +112,14 @@ void Range::print_range (void) { - cerr << "Range: rng_base = " << rng_base - << " rng_limit " << rng_limit - << " rng_inc " << rng_inc - << " rng_nelem " << rng_nelem << "\n"; + std::cerr << "Range: rng_base = " << rng_base + << " rng_limit " << rng_limit + << " rng_inc " << rng_inc + << " rng_nelem " << rng_nelem << "\n"; } -ostream& -operator << (ostream& os, const Range& a) +std::ostream& +operator << (std::ostream& os, const Range& a) { double b = a.base (); double increment = a.inc (); @@ -133,8 +133,8 @@ return os; } -istream& -operator >> (istream& is, Range& a) +std::istream& +operator >> (std::istream& is, Range& a) { is >> a.rng_base; if (is)
--- a/liboctave/Range.h +++ b/liboctave/Range.h @@ -69,8 +69,8 @@ void set_limit (double l) { rng_limit = l; } void set_inc (double i) { rng_inc = i; } - friend ostream& operator << (ostream& os, const Range& r); - friend istream& operator >> (istream& is, Range& r); + friend std::ostream& operator << (std::ostream& os, const Range& r); + friend std::istream& operator >> (std::istream& is, Range& r); void print_range (void);
--- a/liboctave/boolMatrix.h +++ b/liboctave/boolMatrix.h @@ -69,8 +69,8 @@ #if 0 // i/o - friend ostream& operator << (ostream& os, const Matrix& a); - friend istream& operator >> (istream& is, Matrix& a); + friend std::ostream& operator << (std::ostream& os, const Matrix& a); + friend std::istream& operator >> (std::istream& is, Matrix& a); #endif private:
--- a/liboctave/chMatrix.cc +++ b/liboctave/chMatrix.cc @@ -62,7 +62,7 @@ elem (0, i) = s[i]; } -charMatrix::charMatrix (const string& s) +charMatrix::charMatrix (const std::string& s) : MArray2<char> () { int nc = s.length (); @@ -128,10 +128,10 @@ return *this; } -string -charMatrix::row_as_string (int r, bool strip_ws = false) const +std::string +charMatrix::row_as_string (int r, bool strip_ws) const { - string retval; + std::string retval; int nr = rows (); int nc = cols ();
--- a/liboctave/chMatrix.h +++ b/liboctave/chMatrix.h @@ -48,7 +48,7 @@ charMatrix (const charMatrix& a) : MArray2<char> (a) { } charMatrix (char c); charMatrix (const char *s); - charMatrix (const string& s); + charMatrix (const std::string& s); charMatrix (const string_vector& s); charMatrix& operator = (const charMatrix& a) @@ -65,7 +65,7 @@ charMatrix& insert (const char *s, int r, int c); charMatrix& insert (const charMatrix& a, int r, int c); - string row_as_string (int r, bool strip_trailing_whitespace = false) const; + std::string row_as_string (int, bool = false) const; // resize is the destructive equivalent for this one @@ -77,8 +77,8 @@ #if 0 // i/o - friend ostream& operator << (ostream& os, const Matrix& a); - friend istream& operator >> (istream& is, Matrix& a); + friend std::ostream& operator << (std::ostream& os, const Matrix& a); + friend std::istream& operator >> (std::istream& is, Matrix& a); #endif private:
--- a/liboctave/cmd-edit.cc +++ b/liboctave/cmd-edit.cc @@ -73,9 +73,9 @@ ~gnu_readline (void) { } - void do_set_name (const string& n); + void do_set_name (const std::string& n); - string do_readline (const string& prompt, bool& eof); + std::string do_readline (const std::string& prompt, bool& eof); void do_set_input_stream (FILE *f); @@ -93,13 +93,13 @@ void do_resize_terminal (void); - string newline_chars (void); + std::string newline_chars (void); void do_restore_terminal_state (void); void do_blink_matching_paren (bool flag); - void do_set_basic_quote_characters (const string& s); + void do_set_basic_quote_characters (const std::string& s); void do_set_completion_append_character (char c); @@ -107,7 +107,7 @@ completion_fcn do_get_completion_function (void) const; - void do_insert_text (const string& text); + void do_insert_text (const std::string& text); void do_newline (void); @@ -121,7 +121,7 @@ void do_restore_event_hook (void); - void do_read_init_file (const string& file); + void do_read_init_file (const std::string& file); static void operate_and_get_next (int, int); @@ -163,7 +163,7 @@ } void -gnu_readline::do_set_name (const string& n) +gnu_readline::do_set_name (const std::string& n) { static char *nm = 0; @@ -180,10 +180,10 @@ rl_re_read_init_file (); } -string -gnu_readline::do_readline (const string& prompt, bool& eof) +std::string +gnu_readline::do_readline (const std::string& prompt, bool& eof) { - string retval; + std::string retval; eof = false; @@ -255,7 +255,7 @@ rl_resize_terminal (); } -string +std::string gnu_readline::newline_chars (void) { return "\r\n"; @@ -275,7 +275,7 @@ } void -gnu_readline::do_set_basic_quote_characters (const string& s) +gnu_readline::do_set_basic_quote_characters (const std::string& s) { static char *ss = 0; @@ -311,7 +311,7 @@ } void -gnu_readline::do_insert_text (const string& text) +gnu_readline::do_insert_text (const std::string& text) { rl_insert_text (text.c_str ()); } @@ -362,7 +362,7 @@ } void -gnu_readline::do_read_init_file (const string& file) +gnu_readline::do_read_init_file (const std::string& file) { if (file.empty ()) rl_re_read_init_file (); @@ -400,7 +400,7 @@ completion_fcn f = command_editor::get_completion_function (); - string tmp = f (text, state); + std::string tmp = f (text, state); size_t len = tmp.length (); @@ -434,7 +434,7 @@ ~default_command_editor (void) { } - string do_readline (const string& prompt, bool& eof); + std::string do_readline (const std::string& prompt, bool& eof); void do_set_input_stream (FILE *f); @@ -444,7 +444,7 @@ FILE *do_get_output_stream (void); - void do_insert_text (const string&); + void do_insert_text (const std::string&); void do_newline (void); @@ -455,8 +455,8 @@ FILE *output_stream; }; -string -default_command_editor::do_readline (const string& prompt, bool& eof) +std::string +default_command_editor::do_readline (const std::string& prompt, bool& eof) { eof = false; @@ -491,7 +491,7 @@ } void -default_command_editor::do_insert_text (const string&) +default_command_editor::do_insert_text (const std::string&) { // XXX FIXME XXX } @@ -532,25 +532,25 @@ } void -command_editor::set_name (const string& n) +command_editor::set_name (const std::string& n) { if (instance_ok ()) instance->do_set_name (n); } -string -command_editor::readline (const string& prompt) +std::string +command_editor::readline (const std::string& prompt) { bool eof; return readline (prompt, eof); } -string -command_editor::readline (const string& prompt, bool& eof) +std::string +command_editor::readline (const std::string& prompt, bool& eof) { return (instance_ok ()) - ? instance->do_readline (prompt, eof) : string (); + ? instance->do_readline (prompt, eof) : std::string (); } void @@ -609,11 +609,11 @@ instance->do_resize_terminal (); } -string -command_editor::decode_prompt_string (const string& s) +std::string +command_editor::decode_prompt_string (const std::string& s) { return (instance_ok ()) - ? instance->do_decode_prompt_string (s) : string (); + ? instance->do_decode_prompt_string (s) : std::string (); } int @@ -652,7 +652,7 @@ } void -command_editor::set_basic_quote_characters (const string& s) +command_editor::set_basic_quote_characters (const std::string& s) { if (instance_ok ()) instance->do_set_basic_quote_characters (s); @@ -680,7 +680,7 @@ } void -command_editor::insert_text (const string& text) +command_editor::insert_text (const std::string& text) { if (instance_ok ()) instance->do_insert_text (text); @@ -729,7 +729,7 @@ } void -command_editor::read_init_file (const string& file) +command_editor::read_init_file (const std::string& file) { if (instance_ok ()) instance->do_read_init_file (file); @@ -752,11 +752,11 @@ // \<octal> character code in octal // \\ a backslash -string -command_editor::do_decode_prompt_string (const string& s) +std::string +command_editor::do_decode_prompt_string (const std::string& s) { - string result; - string temp; + std::string result; + std::string temp; size_t i = 0; size_t slen = s.length (); int c; @@ -956,7 +956,7 @@ // the string contained a bad number. int -command_editor::read_octal (const string& s) +command_editor::read_octal (const std::string& s) { int result = 0; int digits = 0; @@ -984,7 +984,7 @@ } void -command_editor::error (const string& s) +command_editor::error (const std::string& s) { current_liboctave_error_handler ("%s", s.c_str ()); }
--- a/liboctave/cmd-edit.h +++ b/liboctave/cmd-edit.h @@ -39,15 +39,15 @@ typedef int (*fcn) (...); - typedef string (*completion_fcn) (const string&, int); + typedef std::string (*completion_fcn) (const std::string&, int); virtual ~command_editor (void) { } - static void set_name (const string& n); + static void set_name (const std::string& n); - static string readline (const string& prompt); + static std::string readline (const std::string& prompt); - static string readline (const string& prompt, bool& eof); + static std::string readline (const std::string& prompt, bool& eof); static void set_input_stream (FILE *f); @@ -65,13 +65,13 @@ static void resize_terminal (void); - static string decode_prompt_string (const string& s); + static std::string decode_prompt_string (const std::string& s); static void restore_terminal_state (void); static void blink_matching_paren (bool flag); - static void set_basic_quote_characters (const string& s); + static void set_basic_quote_characters (const std::string& s); static void set_completion_append_character (char c); @@ -79,7 +79,7 @@ static completion_fcn get_completion_function (void); - static void insert_text (const string& text); + static void insert_text (const std::string& text); static void newline (void); @@ -93,7 +93,7 @@ static void restore_event_hook (void); - static void read_init_file (const string& file = string ()); + static void read_init_file (const std::string& file = std::string ()); static int current_command_number (void); @@ -122,16 +122,16 @@ // class from command_editor, overload these functions as // necessary, and make instance point to the new class. - virtual void do_set_name (const string&) { } + virtual void do_set_name (const std::string&) { } - string do_readline (const string& prompt) + std::string do_readline (const std::string& prompt) { bool eof; return do_readline (prompt, eof); } - virtual string do_readline (const string&, bool&) = 0; + virtual std::string do_readline (const std::string&, bool&) = 0; virtual void do_set_input_stream (FILE *) = 0; @@ -149,15 +149,15 @@ virtual void do_resize_terminal (void) { } - virtual string do_decode_prompt_string (const string&); + virtual std::string do_decode_prompt_string (const std::string&); - virtual string newline_chars (void) { return "\n"; } + virtual std::string newline_chars (void) { return "\n"; } virtual void do_restore_terminal_state (void) { } virtual void do_blink_matching_paren (bool) { } - virtual void do_set_basic_quote_characters (const string&) { } + virtual void do_set_basic_quote_characters (const std::string&) { } virtual void do_set_completion_append_character (char) { } @@ -165,7 +165,7 @@ virtual completion_fcn do_get_completion_function (void) const { return 0; } - virtual void do_insert_text (const string&) = 0; + virtual void do_insert_text (const std::string&) = 0; virtual void do_newline (void) = 0; @@ -179,13 +179,13 @@ virtual void do_restore_event_hook (void) { } - virtual void do_read_init_file (const string&) { } + virtual void do_read_init_file (const std::string&) { } - int read_octal (const string& s); + int read_octal (const std::string& s); void error (int); - void error (const string&); + void error (const std::string&); // The current command number. int command_number;
--- a/liboctave/cmd-hist.cc +++ b/liboctave/cmd-hist.cc @@ -26,6 +26,8 @@ #include <cstring> +#include <iostream> +#include <strstream> #include <string> #include "cmd-edit.h" @@ -66,7 +68,7 @@ ~gnu_history (void) { } - void do_add (const string&); + void do_add (const std::string&); void do_remove (int); @@ -90,23 +92,23 @@ void do_goto_mark (void); - void do_read (const string&, bool); + void do_read (const std::string&, bool); - void do_read_range (const string&, int, int, bool); + void do_read_range (const std::string&, int, int, bool); - void do_write (const string&); + void do_write (const std::string&); - void do_append (const string&); + void do_append (const std::string&); - void do_truncate_file (const string&, int); + void do_truncate_file (const std::string&, int); string_vector do_list (int, bool); - string do_get_entry (int); + std::string do_get_entry (int); - void do_replace_entry (int, const string&); + void do_replace_entry (int, const std::string&); - void do_clean_up_and_save (const string&, int); + void do_clean_up_and_save (const std::string&, int); private: @@ -114,7 +116,7 @@ }; void -gnu_history::do_add (const string& s) +gnu_history::do_add (const std::string& s) { if (! do_ignoring_entries ()) { @@ -223,7 +225,7 @@ } void -gnu_history::do_read (const string& f, bool must_exist) +gnu_history::do_read (const std::string& f, bool must_exist) { if (! f.empty ()) { @@ -243,7 +245,7 @@ } void -gnu_history::do_read_range (const string& f, int from, int to, +gnu_history::do_read_range (const std::string& f, int from, int to, bool must_exist) { if (from < 0) @@ -267,9 +269,9 @@ } void -gnu_history::do_write (const string& f_arg) +gnu_history::do_write (const std::string& f_arg) { - string f = f_arg; + std::string f = f_arg; if (f.empty ()) f = xfile; @@ -286,7 +288,7 @@ } void -gnu_history::do_append (const string& f_arg) +gnu_history::do_append (const std::string& f_arg) { if (lines_this_session) { @@ -294,7 +296,7 @@ { // Create file if it doesn't already exist. - string f = f_arg; + std::string f = f_arg; if (f.empty ()) f = xfile; @@ -327,9 +329,9 @@ } void -gnu_history::do_truncate_file (const string& f_arg, int n) +gnu_history::do_truncate_file (const std::string& f_arg, int n) { - string f = f_arg; + std::string f = f_arg; if (f.empty ()) f = xfile; @@ -362,13 +364,13 @@ int k = 0; for (int i = beg; i < end; i++) { - ostrstream output_buf; + std::ostrstream output_buf; if (number_lines) output_buf.form ("%5d%c", i + do_base (), hlist[i]->data ? '*' : ' '); - output_buf << hlist[i]->line << ends; + output_buf << hlist[i]->line << std::ends; const char *tmp = output_buf.str (); @@ -382,10 +384,10 @@ return retval; } -string +std::string gnu_history::do_get_entry (int n) { - string retval; + std::string retval; HIST_ENTRY *entry = ::history_get (do_base () + n); @@ -396,7 +398,7 @@ } void -gnu_history::do_replace_entry (int which, const string& line) +gnu_history::do_replace_entry (int which, const std::string& line) { HIST_ENTRY *discard = ::replace_history_entry (which, line.c_str (), 0); @@ -410,9 +412,9 @@ } void -gnu_history::do_clean_up_and_save (const string& f_arg, int n) +gnu_history::do_clean_up_and_save (const std::string& f_arg, int n) { - string f = f_arg; + std::string f = f_arg; if (f.empty ()) f = xfile; @@ -462,17 +464,17 @@ } void -command_history::set_file (const string& f) +command_history::set_file (const std::string& f) { if (instance_ok ()) instance->do_set_file (f); } -string +std::string command_history::file (void) { return (instance_ok ()) - ? instance->do_file () : string (); + ? instance->do_file () : std::string (); } void @@ -504,7 +506,7 @@ } void -command_history::add (const string& s) +command_history::add (const std::string& s) { if (instance_ok ()) instance->do_add (s); @@ -597,7 +599,7 @@ } void -command_history::read (const string& f, bool must_exist) +command_history::read (const std::string& f, bool must_exist) { if (instance_ok ()) instance->do_read (f, must_exist); @@ -611,7 +613,7 @@ } void -command_history::read_range (const string& f, int from, int to, +command_history::read_range (const std::string& f, int from, int to, bool must_exist) { if (instance_ok ()) @@ -619,21 +621,21 @@ } void -command_history::write (const string& f) +command_history::write (const std::string& f) { if (instance_ok ()) instance->do_write (f); } void -command_history::append (const string& f) +command_history::append (const std::string& f) { if (instance_ok ()) instance->do_append (f); } void -command_history::truncate_file (const string& f, int n) +command_history::truncate_file (const std::string& f, int n) { if (instance_ok ()) instance->do_truncate_file (f, n); @@ -646,34 +648,34 @@ ? instance->do_list (limit, number_lines) : string_vector (); } -string +std::string command_history::get_entry (int n) { return (instance_ok ()) - ? instance->do_get_entry (n) : string (); + ? instance->do_get_entry (n) : std::string (); } void -command_history::replace_entry (int which, const string& line) +command_history::replace_entry (int which, const std::string& line) { if (instance_ok ()) instance->do_replace_entry (which, line); } void -command_history::clean_up_and_save (const string& f, int n) +command_history::clean_up_and_save (const std::string& f, int n) { if (instance_ok ()) instance->do_clean_up_and_save (f, n); } void -command_history::do_set_file (const string& f) +command_history::do_set_file (const std::string& f) { xfile = f; } -string +std::string command_history::do_file (void) { return xfile; @@ -704,7 +706,7 @@ } void -command_history::do_add (const string&) +command_history::do_add (const std::string&) { } @@ -777,7 +779,7 @@ } void -command_history::do_read (const string& f, bool) +command_history::do_read (const std::string& f, bool) { if (f.empty ()) error ("command_history::read: missing file name"); @@ -790,16 +792,16 @@ } void -command_history::do_read_range (const string& f, int, int, bool) +command_history::do_read_range (const std::string& f, int, int, bool) { if (f.empty ()) error ("command_history::read_range: missing file name"); } void -command_history::do_write (const string& f_arg) +command_history::do_write (const std::string& f_arg) { - string f = f_arg; + std::string f = f_arg; if (f.empty ()) f = xfile; @@ -809,7 +811,7 @@ } void -command_history::do_append (const string& f_arg) +command_history::do_append (const std::string& f_arg) { if (lines_this_session) { @@ -817,7 +819,7 @@ { // Create file if it doesn't already exist. - string f = f_arg; + std::string f = f_arg; if (f.empty ()) f = xfile; @@ -829,9 +831,9 @@ } void -command_history::do_truncate_file (const string& f_arg, int) +command_history::do_truncate_file (const std::string& f_arg, int) { - string f = f_arg; + std::string f = f_arg; if (f.empty ()) f = xfile; @@ -846,21 +848,21 @@ return string_vector (); } -string +std::string command_history::do_get_entry (int) { - return string (); + return std::string (); } void -command_history::do_replace_entry (int, const string&) +command_history::do_replace_entry (int, const std::string&) { } void -command_history::do_clean_up_and_save (const string& f_arg, int) +command_history::do_clean_up_and_save (const std::string& f_arg, int) { - string f = f_arg; + std::string f = f_arg; if (f.empty ()) f = xfile; @@ -876,7 +878,7 @@ } void -command_history::error (const string& s) +command_history::error (const std::string& s) { (*current_liboctave_error_handler) ("%s", s.c_str ()); }
--- a/liboctave/cmd-hist.h +++ b/liboctave/cmd-hist.h @@ -40,9 +40,9 @@ virtual ~command_history (void) { } - static void set_file (const string&); + static void set_file (const std::string&); - static string file (void); + static std::string file (void); static void set_size (int); @@ -52,7 +52,7 @@ static bool ignoring_entries (void); - static void add (const string&); + static void add (const std::string&); static void remove (int); @@ -81,26 +81,26 @@ static void read (bool = true); - static void read (const string&, bool = true); + static void read (const std::string&, bool = true); static void read_range (int = -1, int = -1, bool = true); - static void read_range (const string&, int = -1, int = -1, + static void read_range (const std::string&, int = -1, int = -1, bool = true); - static void write (const string& = string ()); + static void write (const std::string& = std::string ()); - static void append (const string& = string ()); + static void append (const std::string& = std::string ()); - static void truncate_file (const string& = string (), int = -1); + static void truncate_file (const std::string& = std::string (), int = -1); static string_vector list (int = -1, bool = false); - static string get_entry (int); + static std::string get_entry (int); - static void replace_entry (int, const string&); + static void replace_entry (int, const std::string&); - static void clean_up_and_save (const string& = string (), int = -1); + static void clean_up_and_save (const std::string& = std::string (), int = -1); private: @@ -123,9 +123,9 @@ // class from command_history, overload these functions as // necessary, and make instance point to the new class. - virtual void do_set_file (const string&); + virtual void do_set_file (const std::string&); - virtual string do_file (void); + virtual std::string do_file (void); virtual void do_set_size (int); @@ -135,7 +135,7 @@ virtual bool do_ignoring_entries (void); - virtual void do_add (const string&); + virtual void do_add (const std::string&); virtual void do_remove (int); @@ -161,29 +161,29 @@ virtual void do_read (bool); - virtual void do_read (const string&, bool); + virtual void do_read (const std::string&, bool); virtual void do_read_range (int, int, bool); - virtual void do_read_range (const string&, int, int, bool); + virtual void do_read_range (const std::string&, int, int, bool); - virtual void do_write (const string&); + virtual void do_write (const std::string&); - virtual void do_append (const string&); + virtual void do_append (const std::string&); - virtual void do_truncate_file (const string&, int); + virtual void do_truncate_file (const std::string&, int); virtual string_vector do_list (int, bool); - virtual string do_get_entry (int); + virtual std::string do_get_entry (int); - virtual void do_replace_entry (int, const string&); + virtual void do_replace_entry (int, const std::string&); - virtual void do_clean_up_and_save (const string&, int); + virtual void do_clean_up_and_save (const std::string&, int); void error (int); - void error (const string&); + void error (const std::string&); // TRUE means we are ignoring new additions. bool ignoring_additions; @@ -195,7 +195,7 @@ int lines_this_session; // The default history file. - string xfile; + std::string xfile; // The number of lines of history to save. int xsize;
--- a/liboctave/dColVector.cc +++ b/liboctave/dColVector.cc @@ -331,8 +331,8 @@ return res; } -ostream& -operator << (ostream& os, const ColumnVector& a) +std::ostream& +operator << (std::ostream& os, const ColumnVector& a) { // int field_width = os.precision () + 7; for (int i = 0; i < a.length (); i++) @@ -340,13 +340,13 @@ return os; } -istream& -operator >> (istream& is, ColumnVector& a) +std::istream& +operator >> (std::istream& is, ColumnVector& a) { int len = a.length(); if (len < 1) - is.clear (ios::badbit); + is.clear (std::ios::badbit); else { double tmp;
--- a/liboctave/dColVector.h +++ b/liboctave/dColVector.h @@ -33,9 +33,6 @@ class ColumnVector : public MArray<double> { -friend class Matrix; -friend class RowVector; - public: ColumnVector (void) : MArray<double> () { } @@ -95,8 +92,8 @@ // i/o - friend ostream& operator << (ostream& os, const ColumnVector& a); - friend istream& operator >> (istream& is, ColumnVector& a); + friend std::ostream& operator << (std::ostream& os, const ColumnVector& a); + friend std::istream& operator >> (std::istream& is, ColumnVector& a); private:
--- a/liboctave/dDiagMatrix.cc +++ b/liboctave/dDiagMatrix.cc @@ -191,16 +191,16 @@ RowVector DiagMatrix::row (int i) const { - int nr = rows (); - int nc = cols (); - if (i < 0 || i >= nr) + int r = rows (); + int c = cols (); + if (i < 0 || i >= r) { (*current_liboctave_error_handler) ("invalid row selection"); return RowVector (); } - RowVector retval (nc, 0.0); - if (nr <= nc || (nr > nc && i < nc)) + RowVector retval (c, 0.0); + if (r <= c || (r > c && i < c)) retval.elem (i) = elem (i, i); return retval; @@ -230,16 +230,16 @@ ColumnVector DiagMatrix::column (int i) const { - int nr = rows (); - int nc = cols (); - if (i < 0 || i >= nc) + int r = rows (); + int c = cols (); + if (i < 0 || i >= c) { (*current_liboctave_error_handler) ("invalid column selection"); return ColumnVector (); } - ColumnVector retval (nr, 0.0); - if (nr >= nc || (nr < nc && i < nr)) + ColumnVector retval (r, 0.0); + if (r >= c || (r < c && i < r)) retval.elem (i) = elem (i, i); return retval; @@ -276,16 +276,16 @@ DiagMatrix DiagMatrix::inverse (int &info) const { - int nr = rows (); - int nc = cols (); + int r = rows (); + int c = cols (); int len = length (); - if (nr != nc) + if (r != c) { (*current_liboctave_error_handler) ("inverse requires square matrix"); return DiagMatrix (); } - DiagMatrix retval (nr, nc); + DiagMatrix retval (r, c); info = 0; for (int i = 0; i < len; i++) @@ -307,19 +307,19 @@ DiagMatrix& DiagMatrix::operator += (const DiagMatrix& a) { - int nr = rows (); - int nc = cols (); + int r = rows (); + int c = cols (); int a_nr = a.rows (); int a_nc = a.cols (); - if (nr != a_nr || nc != a_nc) + if (r != a_nr || c != a_nc) { - gripe_nonconformant ("operator +=", nr, nc, a_nr, a_nc); + gripe_nonconformant ("operator +=", r, c, a_nr, a_nc); return *this; } - if (nc == 0 || nr == 0) + if (c == 0 || r == 0) return *this; double *d = fortran_vec (); // Ensures only one reference to my privates! @@ -331,19 +331,19 @@ DiagMatrix& DiagMatrix::operator -= (const DiagMatrix& a) { - int nr = rows (); - int nc = cols (); + int r = rows (); + int c = cols (); int a_nr = a.rows (); int a_nc = a.cols (); - if (nr != a_nr || nc != a_nc) + if (r != a_nr || c != a_nc) { - gripe_nonconformant ("operator -=", nr, nc, a_nr, a_nc); + gripe_nonconformant ("operator -=", r, c, a_nr, a_nc); return *this; } - if (nr == 0 || nc == 0) + if (r == 0 || c == 0) return *this; double *d = fortran_vec (); // Ensures only one reference to my privates! @@ -357,24 +357,24 @@ DiagMatrix operator * (const DiagMatrix& a, const DiagMatrix& b) { - int nr_a = a.rows (); - int nc_a = a.cols (); + int a_nr = a.rows (); + int a_nc = a.cols (); - int nr_b = b.rows (); - int nc_b = b.cols (); + int b_nr = b.rows (); + int b_nc = b.cols (); - if (nc_a != nr_b) + if (a_nc != b_nr) { - gripe_nonconformant ("operaotr *", nr_a, nc_a, nr_b, nc_b); + gripe_nonconformant ("operaotr *", a_nr, a_nc, b_nr, b_nc); return DiagMatrix (); } - if (nr_a == 0 || nc_a == 0 || nc_b == 0) - return DiagMatrix (nr_a, nc_a, 0.0); + if (a_nr == 0 || a_nc == 0 || b_nc == 0) + return DiagMatrix (a_nr, a_nc, 0.0); - DiagMatrix c (nr_a, nc_b); + DiagMatrix c (a_nr, b_nc); - int len = nr_a < nc_b ? nr_a : nc_b; + int len = a_nr < b_nc ? a_nr : b_nc; for (int i = 0; i < len; i++) { @@ -439,13 +439,13 @@ } } else - cerr << "diag: requested diagonal out of range\n"; + std::cerr << "diag: requested diagonal out of range\n"; return d; } -ostream& -operator << (ostream& os, const DiagMatrix& a) +std::ostream& +operator << (std::ostream& os, const DiagMatrix& a) { // int field_width = os.precision () + 7;
--- a/liboctave/dDiagMatrix.h +++ b/liboctave/dDiagMatrix.h @@ -90,11 +90,6 @@ DiagMatrix& operator += (const DiagMatrix& a); DiagMatrix& operator -= (const DiagMatrix& a); - // diagonal matrix by diagonal matrix -> diagonal matrix operations - - friend DiagMatrix operator * (const DiagMatrix& a, - const DiagMatrix& b); - // other operations ColumnVector diag (void) const; @@ -102,13 +97,18 @@ // i/o - friend ostream& operator << (ostream& os, const DiagMatrix& a); + friend std::ostream& operator << (std::ostream& os, const DiagMatrix& a); private: DiagMatrix (double *d, int nr, int nc) : MDiagArray2<double> (d, nr, nc) { } }; +// diagonal matrix by diagonal matrix -> diagonal matrix operations + +DiagMatrix +operator * (const DiagMatrix& a, const DiagMatrix& b); + #endif /*
--- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -1462,8 +1462,8 @@ int minus_one_j = -1; for (int j = 7; j >= 0; j--) { - npp = m * npp + m * padec[j]; - dpp = m * dpp + m * (minus_one_j * padec[j]); + npp = (m * npp) + (m * padec[j]); + dpp = (m * dpp) + (m * (minus_one_j * padec[j])); minus_one_j *= -1; } @@ -2218,7 +2218,7 @@ } } else - cerr << "diag: requested diagonal out of range\n"; + std::cerr << "diag: requested diagonal out of range\n"; return d; } @@ -2245,12 +2245,12 @@ for (int i = 0; i < nr; i++) { - int idx = 0; - - double tmp_min = elem (i, idx); + int idx_j = 0; + + double tmp_min = elem (i, idx_j); if (xisnan (tmp_min)) - idx = -1; + idx_j = -1; else { for (int j = 1; j < nc; j++) @@ -2259,19 +2259,19 @@ if (xisnan (tmp)) { - idx = -1; + idx_j = -1; break; } else if (tmp < tmp_min) { - idx = j; + idx_j = j; tmp_min = tmp; } } } - result.elem (i) = (idx < 0) ? octave_NaN : tmp_min; - index.elem (i) = idx; + result.elem (i) = (idx_j < 0) ? octave_NaN : tmp_min; + index.elem (i) = idx_j; } } @@ -2300,12 +2300,12 @@ for (int i = 0; i < nr; i++) { - int idx = 0; - - double tmp_max = elem (i, idx); + int idx_j = 0; + + double tmp_max = elem (i, idx_j); if (xisnan (tmp_max)) - idx = -1; + idx_j = -1; else { for (int j = 1; j < nc; j++) @@ -2314,19 +2314,19 @@ if (xisnan (tmp)) { - idx = -1; + idx_j = -1; break; } else if (tmp > tmp_max) { - idx = j; + idx_j = j; tmp_max = tmp; } } } - result.elem (i) = (idx < 0) ? octave_NaN : tmp_max; - index.elem (i) = idx; + result.elem (i) = (idx_j < 0) ? octave_NaN : tmp_max; + index.elem (i) = idx_j; } } @@ -2355,12 +2355,12 @@ for (int j = 0; j < nc; j++) { - int idx = 0; - - double tmp_min = elem (idx, j); + int idx_i = 0; + + double tmp_min = elem (idx_i, j); if (xisnan (tmp_min)) - idx = -1; + idx_i = -1; else { for (int i = 1; i < nr; i++) @@ -2369,19 +2369,19 @@ if (xisnan (tmp)) { - idx = -1; + idx_i = -1; break; } else if (tmp < tmp_min) { - idx = i; + idx_i = i; tmp_min = tmp; } } } - result.elem (j) = (idx < 0) ? octave_NaN : tmp_min; - index.elem (j) = idx; + result.elem (j) = (idx_i < 0) ? octave_NaN : tmp_min; + index.elem (j) = idx_i; } } @@ -2410,12 +2410,12 @@ for (int j = 0; j < nc; j++) { - int idx = 0; - - double tmp_max = elem (idx, j); + int idx_i = 0; + + double tmp_max = elem (idx_i, j); if (xisnan (tmp_max)) - idx = -1; + idx_i = -1; else { for (int i = 1; i < nr; i++) @@ -2424,27 +2424,27 @@ if (xisnan (tmp)) { - idx = -1; + idx_i = -1; break; } else if (tmp > tmp_max) { - idx = i; + idx_i = i; tmp_max = tmp; } } } - result.elem (j) = (idx < 0) ? octave_NaN : tmp_max; - index.elem (j) = idx; + result.elem (j) = (idx_i < 0) ? octave_NaN : tmp_max; + index.elem (j) = idx_i; } } return result; } -ostream& -operator << (ostream& os, const Matrix& a) +std::ostream& +operator << (std::ostream& os, const Matrix& a) { // int field_width = os.precision () + 7; @@ -2457,14 +2457,14 @@ return os; } -istream& -operator >> (istream& is, Matrix& a) +std::istream& +operator >> (std::istream& is, Matrix& a) { int nr = a.rows (); int nc = a.cols (); if (nr < 1 || nc < 1) - is.clear (ios::badbit); + is.clear (std::ios::badbit); else { double tmp; @@ -2485,8 +2485,8 @@ } template <class T> -static void -read_int (istream& is, bool swap_bytes, T& val) +void +read_int (std::istream& is, bool swap_bytes, T& val) { is.read (X_CAST (char *, &val), sizeof (T)); @@ -2516,18 +2516,18 @@ } } -template void read_int (istream&, bool, char&); -template void read_int (istream&, bool, signed char&); -template void read_int (istream&, bool, unsigned char&); -template void read_int (istream&, bool, short&); -template void read_int (istream&, bool, unsigned short&); -template void read_int (istream&, bool, int&); -template void read_int (istream&, bool, unsigned int&); -template void read_int (istream&, bool, long&); -template void read_int (istream&, bool, unsigned long&); +template void read_int (std::istream&, bool, char&); +template void read_int (std::istream&, bool, signed char&); +template void read_int (std::istream&, bool, unsigned char&); +template void read_int (std::istream&, bool, short&); +template void read_int (std::istream&, bool, unsigned short&); +template void read_int (std::istream&, bool, int&); +template void read_int (std::istream&, bool, unsigned int&); +template void read_int (std::istream&, bool, long&); +template void read_int (std::istream&, bool, unsigned long&); static inline bool -do_read (istream& is, oct_data_conv::data_type dt, +do_read (std::istream& is, oct_data_conv::data_type dt, oct_mach_info::float_format flt_fmt, bool swap_bytes, bool do_float_conversion, double& val) { @@ -2640,7 +2640,7 @@ } int -Matrix::read (istream& is, int nr, int nc, +Matrix::read (std::istream& is, int nr, int nc, oct_data_conv::data_type dt, int skip, oct_mach_info::float_format flt_fmt) { @@ -2736,7 +2736,7 @@ } if (ok && skip != 0) - is.seekg (skip, ios::cur); + is.seekg (skip, std::ios::cur); if (! ok || is.eof ()) { @@ -2792,8 +2792,8 @@ } template <class T> -static void -write_int (ostream& os, bool swap_bytes, T val) +void +write_int (std::ostream& os, bool swap_bytes, T val) { if (swap_bytes) { @@ -2823,18 +2823,18 @@ os.write (X_CAST (char *, &val), sizeof (T)); } -template void write_int (ostream&, bool, char); -template void write_int (ostream&, bool, signed char); -template void write_int (ostream&, bool, unsigned char); -template void write_int (ostream&, bool, short); -template void write_int (ostream&, bool, unsigned short); -template void write_int (ostream&, bool, int); -template void write_int (ostream&, bool, unsigned int); -template void write_int (ostream&, bool, long); -template void write_int (ostream&, bool, unsigned long); +template void write_int (std::ostream&, bool, char); +template void write_int (std::ostream&, bool, signed char); +template void write_int (std::ostream&, bool, unsigned char); +template void write_int (std::ostream&, bool, short); +template void write_int (std::ostream&, bool, unsigned short); +template void write_int (std::ostream&, bool, int); +template void write_int (std::ostream&, bool, unsigned int); +template void write_int (std::ostream&, bool, long); +template void write_int (std::ostream&, bool, unsigned long); static inline bool -do_write (ostream& os, double d, oct_data_conv::data_type dt, +do_write (std::ostream& os, double d, oct_data_conv::data_type dt, oct_mach_info::float_format flt_fmt, bool swap_bytes, bool do_float_conversion) { @@ -2909,7 +2909,7 @@ } int -Matrix::write (ostream& os, oct_data_conv::data_type dt, int skip, +Matrix::write (std::ostream& os, oct_data_conv::data_type dt, int skip, oct_mach_info::float_format flt_fmt) { int retval = -1; @@ -2943,7 +2943,7 @@ if (os) { if (skip != 0) - os.seekp (skip, ios::cur); + os.seekp (skip, std::ios::cur); if (os) { @@ -3086,13 +3086,13 @@ } MS_CMP_OPS(Matrix, , double, ) -MS_BOOL_OPS(Matrix, double) +MS_BOOL_OPS(Matrix, double, 0.0) SM_CMP_OPS(double, , Matrix, ) -SM_BOOL_OPS(double, Matrix) +SM_BOOL_OPS(double, Matrix, 0.0) MM_CMP_OPS(Matrix, , Matrix, ) -MM_BOOL_OPS(Matrix, Matrix) +MM_BOOL_OPS(Matrix, Matrix, 0.0) /* ;;; Local Variables: ***
--- a/liboctave/dMatrix.h +++ b/liboctave/dMatrix.h @@ -38,17 +38,6 @@ class Matrix : public MArray2<double> { -friend class ComplexMatrix; -friend class AEPBAL; -friend class CHOL; -friend class GEPBAL; -friend class HESS; -friend class LU; -friend class QR; -friend class QRP; -friend class SCHUR; -friend class SVD; - public: typedef void (*solve_singularity_handler) (double rcond); @@ -230,13 +219,13 @@ // i/o - friend ostream& operator << (ostream& os, const Matrix& a); - friend istream& operator >> (istream& is, Matrix& a); + friend std::ostream& operator << (std::ostream& os, const Matrix& a); + friend std::istream& operator >> (std::istream& is, Matrix& a); - int read (istream& is, int nr, int nc, oct_data_conv::data_type dt, + int read (std::istream& is, int nr, int nc, oct_data_conv::data_type dt, int skip, oct_mach_info::float_format flt_fmt); - int write (ostream& os, oct_data_conv::data_type dt, int skip, + int write (std::ostream& os, oct_data_conv::data_type dt, int skip, oct_mach_info::float_format flt_fmt); private:
--- a/liboctave/dRowVector.cc +++ b/liboctave/dRowVector.cc @@ -304,8 +304,8 @@ return res; } -ostream& -operator << (ostream& os, const RowVector& a) +std::ostream& +operator << (std::ostream& os, const RowVector& a) { // int field_width = os.precision () + 7; @@ -314,13 +314,13 @@ return os; } -istream& -operator >> (istream& is, RowVector& a) +std::istream& +operator >> (std::istream& is, RowVector& a) { int len = a.length(); if (len < 1) - is.clear (ios::badbit); + is.clear (std::ios::badbit); else { double tmp;
--- a/liboctave/dRowVector.h +++ b/liboctave/dRowVector.h @@ -33,8 +33,6 @@ class RowVector : public MArray<double> { -friend class ColumnVector; - public: RowVector (void) : MArray<double> () { } @@ -90,8 +88,8 @@ // i/o - friend ostream& operator << (ostream& os, const RowVector& a); - friend istream& operator >> (istream& is, RowVector& a); + friend std::ostream& operator << (std::ostream& os, const RowVector& a); + friend std::istream& operator >> (std::istream& is, RowVector& a); private:
--- a/liboctave/data-conv.cc +++ b/liboctave/data-conv.cc @@ -102,7 +102,7 @@ } oct_data_conv::data_type -oct_data_conv::string_to_data_type (const string& str) +oct_data_conv::string_to_data_type (const std::string& str) { data_type retval = dt_unknown; @@ -123,7 +123,7 @@ int k = 0; - string s (n, ' '); + std::string s (n, ' '); for (int i = 0; i < n; i++) if (! isspace (str[i])) @@ -685,7 +685,7 @@ } void -read_doubles (istream& is, double *data, save_type type, int len, +read_doubles (std::istream& is, double *data, save_type type, int len, int swap, oct_mach_info::float_format fmt) { switch (type) @@ -732,13 +732,13 @@ break; default: - is.clear (ios::failbit|is.rdstate ()); + is.clear (std::ios::failbit|is.rdstate ()); break; } } void -write_doubles (ostream& os, const double *data, save_type type, int len) +write_doubles (std::ostream& os, const double *data, save_type type, int len) { switch (type) {
--- a/liboctave/data-conv.h +++ b/liboctave/data-conv.h @@ -72,7 +72,7 @@ dt_double_complex }; - static data_type string_to_data_type (const string& s); + static data_type string_to_data_type (const std::string& s); }; enum save_type @@ -96,10 +96,10 @@ oct_mach_info::float_format fmt); extern void -read_doubles (istream& is, double *data, save_type type, int len, +read_doubles (std::istream& is, double *data, save_type type, int len, int swap, oct_mach_info::float_format fmt); extern void -write_doubles (ostream& os, const double *data, save_type type, int len); +write_doubles (std::ostream& os, const double *data, save_type type, int len); #endif
--- a/liboctave/dbleAEPBAL.cc +++ b/liboctave/dbleAEPBAL.cc @@ -46,7 +46,7 @@ } int -AEPBALANCE::init (const Matrix& a, const string& balance_job) +AEPBALANCE::init (const Matrix& a, const std::string& balance_job) { int n = a.cols ();
--- a/liboctave/dbleAEPBAL.h +++ b/liboctave/dbleAEPBAL.h @@ -39,7 +39,7 @@ AEPBALANCE (void) : balanced_mat (), balancing_mat () { } - AEPBALANCE (const Matrix& a,const string& balance_job) + AEPBALANCE (const Matrix& a,const std::string& balance_job) { init (a, balance_job); } @@ -63,14 +63,14 @@ Matrix balancing_matrix (void) const { return balancing_mat; } - friend ostream& operator << (ostream& os, const AEPBALANCE& a); + friend std::ostream& operator << (std::ostream& os, const AEPBALANCE& a); private: Matrix balanced_mat; Matrix balancing_mat; - int init (const Matrix& a, const string& balance_job); + int init (const Matrix& a, const std::string& balance_job); }; #endif
--- a/liboctave/dbleCHOL.h +++ b/liboctave/dbleCHOL.h @@ -54,7 +54,7 @@ Matrix chol_matrix (void) const { return chol_mat; } - friend ostream& operator << (ostream& os, const CHOL& a); + friend std::ostream& operator << (std::ostream& os, const CHOL& a); private:
--- a/liboctave/dbleDET.h +++ b/liboctave/dbleDET.h @@ -63,7 +63,7 @@ double value (void) const; - friend ostream& operator << (ostream& os, const DET& a); + friend std::ostream& operator << (std::ostream& os, const DET& a); private:
--- a/liboctave/dbleHESS.h +++ b/liboctave/dbleHESS.h @@ -61,7 +61,7 @@ Matrix unitary_hess_matrix (void) const { return unitary_hess_mat; } - friend ostream& operator << (ostream& os, const HESS& a); + friend std::ostream& operator << (std::ostream& os, const HESS& a); private:
--- a/liboctave/dbleQR.h +++ b/liboctave/dbleQR.h @@ -67,7 +67,7 @@ Matrix R (void) const { return r; } - friend ostream& operator << (ostream&, const QR&); + friend std::ostream& operator << (std::ostream&, const QR&); protected:
--- a/liboctave/dbleQRP.h +++ b/liboctave/dbleQRP.h @@ -59,7 +59,7 @@ Matrix P (void) const { return p; } - friend ostream& operator << (ostream&, const QRP&); + friend std::ostream& operator << (std::ostream&, const QRP&); protected:
--- a/liboctave/dbleSCHUR.cc +++ b/liboctave/dbleSCHUR.cc @@ -58,7 +58,7 @@ } int -SCHUR::init (const Matrix& a, const string& ord) +SCHUR::init (const Matrix& a, const std::string& ord) { int a_nr = a.rows (); int a_nc = a.cols (); @@ -129,8 +129,8 @@ return info; } -ostream& -operator << (ostream& os, const SCHUR& a) +std::ostream& +operator << (std::ostream& os, const SCHUR& a) { os << a.schur_matrix () << "\n"; os << a.unitary_matrix () << "\n";
--- a/liboctave/dbleSCHUR.h +++ b/liboctave/dbleSCHUR.h @@ -40,13 +40,13 @@ SCHUR (void) : schur_mat (), unitary_mat () { } - SCHUR (const Matrix& a, const string& ord) + SCHUR (const Matrix& a, const std::string& ord) : schur_mat (), unitary_mat () { init (a, ord); } - SCHUR (const Matrix& a, const string& ord, int& info) + SCHUR (const Matrix& a, const std::string& ord, int& info) : schur_mat (), unitary_mat () { info = init (a, ord); @@ -71,7 +71,7 @@ Matrix unitary_matrix (void) const { return unitary_mat; } - friend ostream& operator << (ostream& os, const SCHUR& a); + friend std::ostream& operator << (std::ostream& os, const SCHUR& a); typedef int (*select_function) (const double&, const double&); @@ -82,7 +82,7 @@ select_function selector; - int init (const Matrix& a, const string& ord); + int init (const Matrix& a, const std::string& ord); }; #endif
--- a/liboctave/dbleSVD.cc +++ b/liboctave/dbleSVD.cc @@ -164,8 +164,8 @@ return info; } -ostream& -operator << (ostream& os, const SVD& a) +std::ostream& +operator << (std::ostream& os, const SVD& a) { os << a.left_singular_matrix () << "\n"; os << a.singular_values () << "\n";
--- a/liboctave/dbleSVD.h +++ b/liboctave/dbleSVD.h @@ -76,7 +76,7 @@ Matrix right_singular_matrix (void) const; - friend ostream& operator << (ostream& os, const SVD& a); + friend std::ostream& operator << (std::ostream& os, const SVD& a); private:
--- a/liboctave/dir-ops.cc +++ b/liboctave/dir-ops.cc @@ -36,7 +36,7 @@ #include "str-vec.h" bool -dir_entry::open (const string& n) +dir_entry::open (const std::string& n) { fail = true; @@ -52,7 +52,10 @@ if (dir) fail = false; else - errmsg = strerror (errno); + { + using namespace std; + errmsg = strerror (errno); + } } else errmsg = "dir_entry::open: empty file name";
--- a/liboctave/dir-ops.h +++ b/liboctave/dir-ops.h @@ -32,7 +32,7 @@ { public: - dir_entry (const string& n = string ()) : name (n), dir (0) + dir_entry (const std::string& n = std::string ()) : name (n), dir (0) { if (! name.empty ()) open (); @@ -50,7 +50,7 @@ ~dir_entry (void) { close (); } - bool open (const string& = string ()); + bool open (const std::string& = std::string ()); string_vector read (void); @@ -60,12 +60,12 @@ operator bool () const { return ok (); } - string error (void) const { return ok () ? string () : errmsg; } + std::string error (void) const { return ok () ? std::string () : errmsg; } private: // Name of the directory. - string name; + std::string name; // A pointer to the contents of the directory. We use void here to // avoid possible conflicts with the way some systems declare the @@ -76,7 +76,7 @@ bool fail; // If a failure occurs, this contains the system error text. - string errmsg; + std::string errmsg; void copy (const dir_entry&); };
--- a/liboctave/file-ops.cc +++ b/liboctave/file-ops.cc @@ -51,16 +51,16 @@ // We provide a replacement for mkdir(). int -file_ops::mkdir (const string& name, mode_t mode) +file_ops::mkdir (const std::string& name, mode_t mode) { - string msg; + std::string msg; return mkdir (name, mode, msg); } int -file_ops::mkdir (const string& name, mode_t mode, string& msg) +file_ops::mkdir (const std::string& name, mode_t mode, std::string& msg) { - msg = string (); + msg = std::string (); int status = -1; @@ -68,7 +68,10 @@ status = ::mkdir (name.c_str (), mode); if (status < 0) - msg = ::strerror (errno); + { + using namespace std; + msg = ::strerror (errno); + } #else msg = NOT_SUPPORTED ("mkdir"); #endif @@ -79,16 +82,16 @@ // I don't know how to emulate this on systems that don't provide it. int -file_ops::mkfifo (const string& name, mode_t mode) +file_ops::mkfifo (const std::string& name, mode_t mode) { - string msg; + std::string msg; return mkfifo (name, mode, msg); } int -file_ops::mkfifo (const string& name, mode_t mode, string& msg) +file_ops::mkfifo (const std::string& name, mode_t mode, std::string& msg) { - msg = string (); + msg = std::string (); int status = -1; @@ -96,7 +99,10 @@ status = ::mkfifo (name.c_str (), mode); if (status < 0) - msg = ::strerror (errno); + { + using namespace std; + msg = ::strerror (errno); + } #else msg = NOT_SUPPORTED ("mkfifo"); #endif @@ -107,24 +113,28 @@ // We provide a replacement for rename(). int -file_ops::rename (const string& from, const string& to) +file_ops::rename (const std::string& from, const std::string& to) { - string msg; + std::string msg; return rename (from, to, msg); } int -file_ops::rename (const string& from, const string& to, string& msg) +file_ops::rename (const std::string& from, const std::string& to, + std::string& msg) { int status = -1; - msg = string (); + msg = std::string (); #if defined (HAVE_RENAME) status = ::rename (from.c_str (), to.c_str ()); if (status < 0) - msg = ::strerror (errno); + { + using namespace std; + msg = ::strerror (errno); + } #else msg = NOT_SUPPORTED ("rename"); #endif @@ -135,16 +145,16 @@ // We provide a replacement for rmdir(). int -file_ops::rmdir (const string& name) +file_ops::rmdir (const std::string& name) { - string msg; + std::string msg; return rmdir (name, msg); } int -file_ops::rmdir (const string& name, string& msg) +file_ops::rmdir (const std::string& name, std::string& msg) { - msg = string (); + msg = std::string (); int status = -1; @@ -152,7 +162,10 @@ status = ::rmdir (name.c_str ()); if (status < 0) - msg = ::strerror (errno); + { + using namespace std; + msg = ::strerror (errno); + } #else msg = NOT_SUPPORTED ("rmdir"); #endif @@ -162,19 +175,20 @@ // We provide a replacement for tempnam(). -string -file_ops::tempnam (const string& dir, const string& pfx) +std::string +file_ops::tempnam (const std::string& dir, const std::string& pfx) { - string msg; + std::string msg; return tempnam (dir, pfx, msg); } -string -file_ops::tempnam (const string& dir, const string& pfx, string& msg) +std::string +file_ops::tempnam (const std::string& dir, const std::string& pfx, + std::string& msg) { - msg = string (); + msg = std::string (); - string retval; + std::string retval; const char *pdir = dir.empty () ? 0 : dir.c_str (); @@ -189,7 +203,10 @@ ::free (tmp); } else - msg = ::strerror (errno); + { + using namespace std; + msg = ::strerror (errno); + } return retval; } @@ -240,7 +257,7 @@ // tilde itself. static size_t -tilde_find_prefix (const string& s, size_t& len) +tilde_find_prefix (const std::string& s, size_t& len) { len = 0; @@ -275,7 +292,7 @@ // of the character which ends the tilde definition. static size_t -tilde_find_suffix (const string& s) +tilde_find_suffix (const std::string& s) { size_t s_len = s.length (); @@ -305,8 +322,8 @@ // Take FNAME and return the tilde prefix we want expanded. -static string -isolate_tilde_prefix (const string& fname) +static std::string +isolate_tilde_prefix (const std::string& fname) { size_t f_len = fname.length (); @@ -321,8 +338,8 @@ // Do the work of tilde expansion on FILENAME. FILENAME starts with a // tilde. -static string -tilde_expand_word (const string& filename) +static std::string +tilde_expand_word (const std::string& filename) { size_t f_len = filename.length (); @@ -336,15 +353,15 @@ if (f_len == 1 || filename[1] == DIR_SEP_CHAR) return octave_env::get_home_directory () + filename.substr (1); - string username = isolate_tilde_prefix (filename); + std::string username = isolate_tilde_prefix (filename); size_t user_len = username.length (); - string dirname; + std::string dirname; if (file_ops::tilde_expansion_preexpansion_hook) { - string expansion + std::string expansion = file_ops::tilde_expansion_preexpansion_hook (username); if (! expansion.empty ()) @@ -363,7 +380,7 @@ if (file_ops::tilde_expansion_failure_hook) { - string expansion + std::string expansion = file_ops::tilde_expansion_failure_hook (username); if (! expansion.empty ()) @@ -385,10 +402,10 @@ // If NAME has a leading ~ or ~user, Unix-style, expand it to the // user's home directory. If no ~, or no <pwd.h>, just return NAME. -string -file_ops::tilde_expand (const string& name) +std::string +file_ops::tilde_expand (const std::string& name) { - string result; + std::string result; size_t name_len = name.length (); @@ -425,11 +442,11 @@ // Expand the entire tilde word, and copy it into RESULT. - string tilde_word = name.substr (pos, fini); + std::string tilde_word = name.substr (pos, fini); pos += fini; - string expansion = tilde_expand_word (tilde_word); + std::string expansion = tilde_expand_word (tilde_word); result.append (expansion); } @@ -465,16 +482,16 @@ } int -file_ops::unlink (const string& name) +file_ops::unlink (const std::string& name) { - string msg; + std::string msg; return unlink (name, msg); } int -file_ops::unlink (const string& name, string& msg) +file_ops::unlink (const std::string& name, std::string& msg) { - msg = string (); + msg = std::string (); int status = -1; @@ -482,7 +499,10 @@ status = ::unlink (name.c_str ()); if (status < 0) - msg = ::strerror (errno); + { + using namespace std; + msg = ::strerror (errno); + } #else msg = NOT_SUPPORTED ("unlink"); #endif
--- a/liboctave/file-ops.h +++ b/liboctave/file-ops.h @@ -34,22 +34,22 @@ struct file_ops { - static int mkdir (const string&, mode_t); - static int mkdir (const string&, mode_t, string&); + static int mkdir (const std::string&, mode_t); + static int mkdir (const std::string&, mode_t, std::string&); - static int mkfifo (const string&, mode_t); - static int mkfifo (const string&, mode_t, string&); + static int mkfifo (const std::string&, mode_t); + static int mkfifo (const std::string&, mode_t, std::string&); - static int rename (const string&, const string&); - static int rename (const string&, const string&, string&); + static int rename (const std::string&, const std::string&); + static int rename (const std::string&, const std::string&, std::string&); - static int rmdir (const string&); - static int rmdir (const string&, string&); + static int rmdir (const std::string&); + static int rmdir (const std::string&, std::string&); - static string tempnam (const string&, const string&); - static string tempnam (const string&, const string&, string&); + static std::string tempnam (const std::string&, const std::string&); + static std::string tempnam (const std::string&, const std::string&, std::string&); - typedef string (*tilde_expansion_hook) (const string&); + typedef std::string (*tilde_expansion_hook) (const std::string&); static tilde_expansion_hook tilde_expansion_preexpansion_hook; @@ -59,13 +59,13 @@ static string_vector tilde_additional_suffixes; - static string tilde_expand (const string&); + static std::string tilde_expand (const std::string&); static string_vector tilde_expand (const string_vector&); static int umask (mode_t); - static int unlink (const string&); - static int unlink (const string&, string&); + static int unlink (const std::string&); + static int unlink (const std::string&, std::string&); }; #endif
--- a/liboctave/file-stat.cc +++ b/liboctave/file-stat.cc @@ -119,9 +119,9 @@ #endif } -extern "C" void mode_string (); +extern "C" void mode_string (unsigned short, char *); -string +std::string file_stat::mode_as_string (void) const { char buf[11]; @@ -130,14 +130,14 @@ buf[10] = '\0'; - return string (buf); + return std::string (buf); } // Has FILE been modified since TIME? Returns 1 for yes, 0 for no, // and -1 for any error. int -file_stat::is_newer (const string& file, const octave_time& time) +file_stat::is_newer (const std::string& file, const octave_time& time) { file_stat fs (file); @@ -162,6 +162,8 @@ if (status < 0) { + using namespace std; + fail = true; errmsg = strerror (errno); }
--- a/liboctave/file-stat.h +++ b/liboctave/file-stat.h @@ -36,7 +36,7 @@ { public: - file_stat (const string& n = string (), bool fl = true) + file_stat (const std::string& n = std::string (), bool fl = true) : file_name (n), follow_links (fl), initialized (false) { if (! file_name.empty ()) @@ -61,7 +61,7 @@ update_internal (force); } - void get_stats (const string& n, bool force = false) + void get_stats (const std::string& n, bool force = false) { if (n != file_name || ! initialized || force) { @@ -110,7 +110,7 @@ long blocks (void) const { return fs_blocks; } #endif - string mode_as_string (void) const; + std::string mode_as_string (void) const; bool ok (void) const { return initialized && ! fail; } @@ -118,19 +118,19 @@ bool exists (void) const { return ok (); } - string error (void) const { return ok () ? string () : errmsg; } + std::string error (void) const { return ok () ? std::string () : errmsg; } // Has the file referenced by this object been modified since TIME? bool is_newer (const octave_time& time) const { return fs_mtime > time; } // It's nice to be able to hide the file_stat object if we don't // really care about it. - static int is_newer (const string&, const octave_time&); + static int is_newer (const std::string&, const octave_time&); private: // Name of the file. - string file_name; + std::string file_name; // TRUE means follow symbolic links to the ultimate file (stat). // FALSE means get information about the link itself (lstat). @@ -143,7 +143,7 @@ bool fail; // If a failure occurs, this contains the system error text. - string errmsg; + std::string errmsg; // file type and permissions mode_t fs_mode;
--- a/liboctave/glob-match.cc +++ b/liboctave/glob-match.cc @@ -35,7 +35,7 @@ #include "str-vec.h" bool -glob_match::match (const string& s) +glob_match::match (const std::string& s) { int npat = pat.length (); @@ -73,7 +73,7 @@ } static bool -single_match_exists (const string& file) +single_match_exists (const std::string& file) { file_stat s (file); @@ -91,7 +91,7 @@ for (int i = 0; i < npat; i++) { - string xpat = pat(i); + std::string xpat = pat(i); if (! xpat.empty ()) { @@ -111,7 +111,8 @@ // characters. Hmm. if (n > 1 - || (n == 1 && single_match_exists (string (matches[0])))) + || (n == 1 + && single_match_exists (std::string (matches[0])))) { retval.resize (k+n);
--- a/liboctave/glob-match.h +++ b/liboctave/glob-match.h @@ -40,7 +40,7 @@ period = 4 // Leading `.' is matched only explicitly. }; - glob_match (const string& p = string (), + glob_match (const std::string& p = std::string (), unsigned int f = pathname|noescape|period) : pat (p), flags (f) { } @@ -62,11 +62,11 @@ ~glob_match (void) { } - void set_pattern (const string& p) { pat = p; } + void set_pattern (const std::string& p) { pat = p; } void set_pattern (const string_vector& p) { pat = p; } - bool match (const string&); + bool match (const std::string&); Array<bool> match (const string_vector&);
--- a/liboctave/idx-vector.cc +++ b/liboctave/idx-vector.cc @@ -573,8 +573,8 @@ ("idx_vector::shorten: internal error!"); } -ostream& -IDX_VEC_REP::print (ostream& os) const +std::ostream& +IDX_VEC_REP::print (std::ostream& os) const { for (int ii = 0; ii < len; ii++) os << data[ii] << "\n";
--- a/liboctave/idx-vector.h +++ b/liboctave/idx-vector.h @@ -113,7 +113,7 @@ // i/o - ostream& print (ostream& os) const; + std::ostream& print (std::ostream& os) const; int *data; int len; @@ -252,9 +252,9 @@ int freeze (int z_len, const char *tag, int resize_ok = 0) { return rep->freeze (z_len, tag, resize_ok); } - ostream& print (ostream& os) const { return rep->print (os); } + std::ostream& print (std::ostream& os) const { return rep->print (os); } - friend ostream& operator << (ostream& os, const idx_vector& a) + friend std::ostream& operator << (std::ostream& os, const idx_vector& a) { return a.print (os); } void maybe_convert_one_zero_to_idx (int z_len)
--- a/liboctave/lo-sysdep.cc +++ b/liboctave/lo-sysdep.cc @@ -49,10 +49,10 @@ #include "lo-error.h" #include "pathlen.h" -string +std::string octave_getcwd (void) { - string retval; + std::string retval; char buf[MAXPATHLEN]; @@ -75,7 +75,7 @@ } int -octave_chdir (const string& path) +octave_chdir (const std::string& path) { #if defined (__EMX__) int retval = -1;
--- a/liboctave/lo-sysdep.h +++ b/liboctave/lo-sysdep.h @@ -27,9 +27,9 @@ #include "lo-ieee.h" -extern string octave_getcwd (void); +extern std::string octave_getcwd (void); -extern bool octave_chdir (const string&); +extern bool octave_chdir (const std::string&); #if ! defined (HAVE_GETHOSTNAME) && defined (HAVE_SYS_UTSNAME_H) extern int gethostname (char *, int);
--- a/liboctave/lo-utils.cc +++ b/liboctave/lo-utils.cc @@ -86,7 +86,7 @@ // SMART_PUTENV. void -octave_putenv (const string& name, const string& value) +octave_putenv (const std::string& name, const std::string& value) { int new_len = name.length () + value.length () + 2; @@ -101,10 +101,10 @@ (*current_liboctave_error_handler) ("putenv (%s) failed", new_item); } -string +std::string octave_fgets (FILE *f) { - string retval; + std::string retval; int grow_size = 1024; int max_size = grow_size;
--- a/liboctave/lo-utils.h +++ b/liboctave/lo-utils.h @@ -32,9 +32,9 @@ extern char *strsave (const char *); -extern void octave_putenv (const string&, const string&); +extern void octave_putenv (const std::string&, const std::string&); -extern string octave_fgets (FILE *); +extern std::string octave_fgets (std::FILE *); #endif
--- a/liboctave/mach-info.cc +++ b/liboctave/mach-info.cc @@ -186,7 +186,7 @@ } oct_mach_info::float_format -oct_mach_info::string_to_float_format (const string& s) +oct_mach_info::string_to_float_format (const std::string& s) { oct_mach_info::float_format retval = oct_mach_info::unknown; @@ -211,10 +211,10 @@ return retval; } -string +std::string oct_mach_info::float_format_as_string (float_format flt_fmt) { - string retval = "unknown"; + std::string retval = "unknown"; switch (flt_fmt) {
--- a/liboctave/mach-info.h +++ b/liboctave/mach-info.h @@ -53,9 +53,9 @@ static bool words_little_endian (void); - static float_format string_to_float_format (const string&); + static float_format string_to_float_format (const std::string&); - static string float_format_as_string (float_format); + static std::string float_format_as_string (float_format); private:
--- a/liboctave/mx-cdm-cm.cc +++ b/liboctave/mx-cdm-cm.cc @@ -29,7 +29,7 @@ #include "CMatrix.h" #include "CDiagMatrix.h" -DMM_BIN_OPS (ComplexMatrix, ComplexDiagMatrix, ComplexMatrix) +DMM_BIN_OPS (ComplexMatrix, ComplexDiagMatrix, ComplexMatrix, 0.0) /* ;;; Local Variables: ***
--- a/liboctave/mx-cdm-m.cc +++ b/liboctave/mx-cdm-m.cc @@ -30,7 +30,7 @@ #include "CMatrix.h" #include "CDiagMatrix.h" -DMM_BIN_OPS (ComplexMatrix, ComplexDiagMatrix, Matrix) +DMM_BIN_OPS (ComplexMatrix, ComplexDiagMatrix, Matrix, 0.0) /* ;;; Local Variables: ***
--- a/liboctave/mx-cm-cdm.cc +++ b/liboctave/mx-cm-cdm.cc @@ -29,7 +29,7 @@ #include "CMatrix.h" #include "CDiagMatrix.h" -MDM_BIN_OPS (ComplexMatrix, ComplexMatrix, ComplexDiagMatrix) +MDM_BIN_OPS (ComplexMatrix, ComplexMatrix, ComplexDiagMatrix, 0.0) /* ;;; Local Variables: ***
--- a/liboctave/mx-cm-dm.cc +++ b/liboctave/mx-cm-dm.cc @@ -29,7 +29,7 @@ #include "CMatrix.h" #include "dDiagMatrix.h" -MDM_BIN_OPS (ComplexMatrix, ComplexMatrix, DiagMatrix) +MDM_BIN_OPS (ComplexMatrix, ComplexMatrix, DiagMatrix, 0.0) /* ;;; Local Variables: ***
--- a/liboctave/mx-cm-m.cc +++ b/liboctave/mx-cm-m.cc @@ -34,7 +34,7 @@ MM_CMP_OPS (ComplexMatrix, real, Matrix, ) -MM_BOOL_OPS (ComplexMatrix, Matrix) +MM_BOOL_OPS (ComplexMatrix, Matrix, 0.0) /* ;;; Local Variables: ***
--- a/liboctave/mx-cm-s.cc +++ b/liboctave/mx-cm-s.cc @@ -33,7 +33,7 @@ MS_CMP_OPS (ComplexMatrix, real, double, ) -MS_BOOL_OPS (ComplexMatrix, double) +MS_BOOL_OPS (ComplexMatrix, double, 0.0) /* ;;; Local Variables: ***
--- a/liboctave/mx-cs-m.cc +++ b/liboctave/mx-cs-m.cc @@ -34,7 +34,7 @@ SM_CMP_OPS (Complex, real, Matrix, ) -SM_BOOL_OPS (Complex, Matrix) +SM_BOOL_OPS (Complex, Matrix, 0.0) /* ;;; Local Variables: ***
--- a/liboctave/mx-dm-cm.cc +++ b/liboctave/mx-dm-cm.cc @@ -29,7 +29,7 @@ #include "CMatrix.h" #include "dDiagMatrix.h" -DMM_BIN_OPS (ComplexMatrix, DiagMatrix, ComplexMatrix) +DMM_BIN_OPS (ComplexMatrix, DiagMatrix, ComplexMatrix, 0.0) /* ;;; Local Variables: ***
--- a/liboctave/mx-dm-m.cc +++ b/liboctave/mx-dm-m.cc @@ -29,7 +29,7 @@ #include "dMatrix.h" #include "dDiagMatrix.h" -DMM_BIN_OPS (Matrix, DiagMatrix, Matrix) +DMM_BIN_OPS (Matrix, DiagMatrix, Matrix, 0.0) /* ;;; Local Variables: ***
--- a/liboctave/mx-inlines.cc +++ b/liboctave/mx-inlines.cc @@ -215,8 +215,8 @@ // These should really return a bool *. Also, they should probably be // in with a collection of other element-by-element boolean ops. -OP_DUP_FCN (0.0 ==, not, double, double) -OP_DUP_FCN (0.0 ==, not, double, Complex) +OP_DUP_FCN (0.0 ==, xnot, double, double) +OP_DUP_FCN (0.0 ==, xnot, double, Complex) OP_DUP_FCN (, make_complex, Complex, double)
--- a/liboctave/mx-m-cdm.cc +++ b/liboctave/mx-m-cdm.cc @@ -30,7 +30,7 @@ #include "CMatrix.h" #include "CDiagMatrix.h" -MDM_BIN_OPS (ComplexMatrix, Matrix, ComplexDiagMatrix) +MDM_BIN_OPS (ComplexMatrix, Matrix, ComplexDiagMatrix, 0.0) /* ;;; Local Variables: ***
--- a/liboctave/mx-m-cm.cc +++ b/liboctave/mx-m-cm.cc @@ -34,7 +34,7 @@ MM_CMP_OPS (Matrix, , ComplexMatrix, real) -MM_BOOL_OPS (Matrix, ComplexMatrix) +MM_BOOL_OPS (Matrix, ComplexMatrix, 0.0) /* ;;; Local Variables: ***
--- a/liboctave/mx-m-cs.cc +++ b/liboctave/mx-m-cs.cc @@ -34,7 +34,7 @@ MS_CMP_OPS (Matrix, , Complex, real) -MS_BOOL_OPS (Matrix, Complex) +MS_BOOL_OPS (Matrix, Complex, 0.0) /* ;;; Local Variables: ***
--- a/liboctave/mx-m-dm.cc +++ b/liboctave/mx-m-dm.cc @@ -29,7 +29,7 @@ #include "dMatrix.h" #include "dDiagMatrix.h" -MDM_BIN_OPS (Matrix, Matrix, DiagMatrix) +MDM_BIN_OPS (Matrix, Matrix, DiagMatrix, 0.0) /* ;;; Local Variables: ***
--- a/liboctave/mx-op-defs.h +++ b/liboctave/mx-op-defs.h @@ -206,7 +206,7 @@ BOOL_OP_DECL (mx_el_and, M, S); \ BOOL_OP_DECL (mx_el_or, M, S); \ -#define MS_BOOL_OP(F, OP, M, S) \ +#define MS_BOOL_OP(F, OP, M, S, ZERO) \ boolMatrix \ F (const M& m, const S& s) \ { \ @@ -221,15 +221,15 @@ \ for (int j = 0; j < nc; j++) \ for (int i = 0; i < nr; i++) \ - r.elem(i, j) = (m.elem(i, j) != 0) OP (s != 0); \ + r.elem(i, j) = (m.elem(i, j) != ZERO) OP (s != ZERO); \ } \ \ return r; \ } -#define MS_BOOL_OPS(M, S) \ - MS_BOOL_OP (mx_el_and, &&, M, S) \ - MS_BOOL_OP (mx_el_or, ||, M, S) +#define MS_BOOL_OPS(M, S, ZERO) \ + MS_BOOL_OP (mx_el_and, &&, M, S, ZERO) \ + MS_BOOL_OP (mx_el_or, ||, M, S, ZERO) #define MS_OP_DECLS(R, M, S) \ MS_BIN_OP_DECLS (R, M, S) \ @@ -308,7 +308,7 @@ BOOL_OP_DECL (mx_el_and, S, M); \ BOOL_OP_DECL (mx_el_or, S, M); \ -#define SM_BOOL_OP(F, OP, S, M) \ +#define SM_BOOL_OP(F, OP, S, M, ZERO) \ boolMatrix \ F (const S& s, const M& m) \ { \ @@ -323,15 +323,15 @@ \ for (int j = 0; j < nc; j++) \ for (int i = 0; i < nr; i++) \ - r.elem(i, j) = (s != 0) OP (m.elem(i, j) != 0); \ + r.elem(i, j) = (s != ZERO) OP (m.elem(i, j) != ZERO); \ } \ \ return r; \ } -#define SM_BOOL_OPS(S, M) \ - SM_BOOL_OP (mx_el_and, &&, S, M) \ - SM_BOOL_OP (mx_el_or, ||, S, M) +#define SM_BOOL_OPS(S, M, ZERO) \ + SM_BOOL_OP (mx_el_and, &&, S, M, ZERO) \ + SM_BOOL_OP (mx_el_or, ||, S, M, ZERO) #define SM_OP_DECLS(R, S, M) \ SM_BIN_OP_DECLS (R, S, M) \ @@ -433,7 +433,7 @@ BOOL_OP_DECL (mx_el_and, M1, M2); \ BOOL_OP_DECL (mx_el_or, M1, M2); -#define MM_BOOL_OP(F, OP, M1, M2) \ +#define MM_BOOL_OP(F, OP, M1, M2, ZERO) \ boolMatrix \ F (const M1& m1, const M2& m2) \ { \ @@ -453,7 +453,8 @@ \ for (int j = 0; j < m1_nc; j++) \ for (int i = 0; i < m1_nr; i++) \ - r.elem(i, j) = (m1.elem(i, j) != 0) OP (m2.elem(i, j) != 0); \ + r.elem(i, j) = (m1.elem(i, j) != ZERO) \ + OP (m2.elem(i, j) != ZERO); \ } \ } \ else \ @@ -465,9 +466,9 @@ return r; \ } -#define MM_BOOL_OPS(M1, M2) \ - MM_BOOL_OP (mx_el_and, &&, M1, M2) \ - MM_BOOL_OP (mx_el_or, ||, M1, M2) +#define MM_BOOL_OPS(M1, M2, ZERO) \ + MM_BOOL_OP (mx_el_and, &&, M1, M2, ZERO) \ + MM_BOOL_OP (mx_el_or, ||, M1, M2, ZERO) #define MM_OP_DECLS(R, M1, M2) \ MM_BIN_OP_DECLS (R, M1, M2) \ @@ -573,7 +574,7 @@ return r; \ } -#define MDM_MULTIPLY_OP(R, M, DM) \ +#define MDM_MULTIPLY_OP(R, M, DM, ZERO) \ R \ operator * (const M& m, const DM& dm) \ { \ @@ -589,7 +590,7 @@ gripe_nonconformant ("operator *", m_nr, m_nc, dm_nr, dm_nc); \ else \ { \ - r.resize (m_nr, dm_nc, 0.0); \ + r.resize (m_nr, dm_nc, ZERO); \ \ if (m_nr > 0 && m_nc > 0 && dm_nc > 0) \ { \ @@ -600,7 +601,7 @@ for (int i = 0; i < m_nr; i++) \ r.elem(i, j) = m.elem(i, j); \ } \ - else if (dm.elem(j, j) != 0.0) \ + else if (dm.elem(j, j) != ZERO) \ { \ for (int i = 0; i < m_nr; i++) \ r.elem(i, j) = dm.elem(j, j) * m.elem(i, j); \ @@ -612,10 +613,10 @@ return r; \ } -#define MDM_BIN_OPS(R, M, DM) \ +#define MDM_BIN_OPS(R, M, DM, ZERO) \ MDM_BIN_OP (R, operator +, M, DM, +=) \ MDM_BIN_OP (R, operator -, M, DM, -=) \ - MDM_MULTIPLY_OP (R, M, DM) + MDM_MULTIPLY_OP (R, M, DM, ZERO) #define MDM_OP_DECLS(R, M, DM) \ MDM_BIN_OP_DECLS(R, M, DM) @@ -661,7 +662,7 @@ return r; \ } -#define DMM_MULTIPLY_OP(R, DM, M) \ +#define DMM_MULTIPLY_OP(R, DM, M, ZERO) \ R \ operator * (const DM& dm, const M& m) \ { \ @@ -677,7 +678,7 @@ gripe_nonconformant ("operator *", dm_nr, dm_nc, m_nr, m_nc); \ else \ { \ - r.resize (dm_nr, m_nc, 0.0); \ + r.resize (dm_nr, m_nc, ZERO); \ \ if (dm_nr > 0 && dm_nc > 0 && m_nc > 0) \ { \ @@ -688,7 +689,7 @@ for (int j = 0; j < m_nc; j++) \ r.elem(i, j) = m.elem(i, j); \ } \ - else if (dm.elem(i, i) != 0.0) \ + else if (dm.elem(i, i) != ZERO) \ { \ for (int j = 0; j < m_nc; j++) \ r.elem(i, j) = dm.elem(i, i) * m.elem(i, j); \ @@ -700,10 +701,10 @@ return r; \ } -#define DMM_BIN_OPS(R, DM, M) \ +#define DMM_BIN_OPS(R, DM, M, ZERO) \ DMM_BIN_OP (R, operator +, DM, M, +=) \ DMM_BIN_OP (R, operator -, DM, M, -=) \ - DMM_MULTIPLY_OP(R, DM, M) + DMM_MULTIPLY_OP(R, DM, M, ZERO) #define DMM_OP_DECLS(R, DM, M) \ DMM_BIN_OP_DECLS(R, DM, M)
--- a/liboctave/mx-s-cm.cc +++ b/liboctave/mx-s-cm.cc @@ -33,7 +33,7 @@ SM_CMP_OPS (double, , ComplexMatrix, real) -SM_BOOL_OPS (double, ComplexMatrix) +SM_BOOL_OPS (double, ComplexMatrix, 0.0) /* ;;; Local Variables: ***
--- a/liboctave/oct-cmplx.h +++ b/liboctave/oct-cmplx.h @@ -25,7 +25,7 @@ #include <complex> -typedef complex<double> Complex; +typedef std::complex<double> Complex; #endif
--- a/liboctave/oct-env.cc +++ b/liboctave/oct-env.cc @@ -41,6 +41,7 @@ #endif #include <cstdlib> +#include <string> #ifdef HAVE_UNISTD_H #ifdef HAVE_SYS_TYPES_H @@ -91,109 +92,109 @@ return retval; } -string -octave_env::polite_directory_format (const string& name) +std::string +octave_env::polite_directory_format (const std::string& name) { return (instance_ok ()) - ? instance->do_polite_directory_format (name) : string (); + ? instance->do_polite_directory_format (name) : std::string (); } bool -octave_env::absolute_pathname (const string& s) +octave_env::absolute_pathname (const std::string& s) { return (instance_ok ()) ? instance->do_absolute_pathname (s) : false; } -string -octave_env::base_pathname (const string& s) +std::string +octave_env::base_pathname (const std::string& s) { return (instance_ok ()) - ? instance->do_base_pathname (s) : string (); + ? instance->do_base_pathname (s) : std::string (); } -string -octave_env::make_absolute (const string& s, const string& dot_path) +std::string +octave_env::make_absolute (const std::string& s, const std::string& dot_path) { return (instance_ok ()) - ? instance->do_make_absolute (s, dot_path) : string (); + ? instance->do_make_absolute (s, dot_path) : std::string (); } -string +std::string octave_env::getcwd () { return (instance_ok ()) - ? instance->do_getcwd () : string (); + ? instance->do_getcwd () : std::string (); } -string +std::string octave_env::get_home_directory () { return (instance_ok ()) - ? instance->do_get_home_directory () : string (); + ? instance->do_get_home_directory () : std::string (); } -string +std::string octave_env::get_program_name (void) { return (instance_ok ()) - ? instance->program_name : string (); + ? instance->program_name : std::string (); } -string +std::string octave_env::get_program_invocation_name (void) { return (instance_ok ()) - ? instance->program_invocation_name : string (); + ? instance->program_invocation_name : std::string (); } void -octave_env::set_program_name (const string& s) +octave_env::set_program_name (const std::string& s) { if (instance_ok ()) instance->do_set_program_name (s); } -string +std::string octave_env::get_user_name (void) { return (instance_ok ()) - ? instance->do_get_user_name () : string (); + ? instance->do_get_user_name () : std::string (); } -string +std::string octave_env::get_host_name (void) { return (instance_ok ()) - ? instance->do_get_host_name () : string (); + ? instance->do_get_host_name () : std::string (); } // XXX FIXME XXX -- this leaves no way to distinguish between a // variable that is not set and one that is set to the empty string. // Is this a problem? -string -octave_env::getenv (const string& name) +std::string +octave_env::getenv (const std::string& name) { return (instance_ok ()) - ? instance->do_getenv (name) : string (); + ? instance->do_getenv (name) : std::string (); } void -octave_env::putenv (const string& name, const string& value) +octave_env::putenv (const std::string& name, const std::string& value) { octave_putenv (name, value); } bool -octave_env::chdir (const string& newdir) +octave_env::chdir (const std::string& newdir) { return (instance_ok ()) ? instance->do_chdir (newdir) : false; } void -octave_env::do_set_program_name (const string& s) const +octave_env::do_set_program_name (const std::string& s) const { program_invocation_name = s; @@ -206,12 +207,12 @@ // Return a pretty pathname. If the first part of the pathname is the // same as $HOME, then replace that with `~'. -string -octave_env::do_polite_directory_format (const string& name) const +std::string +octave_env::do_polite_directory_format (const std::string& name) const { - string retval; + std::string retval; - string home_dir = do_get_home_directory (); + std::string home_dir = do_get_home_directory (); size_t len = home_dir.length (); @@ -230,7 +231,7 @@ // Return 1 if STRING contains an absolute pathname, else 0. bool -octave_env::do_absolute_pathname (const string& s) const +octave_env::do_absolute_pathname (const std::string& s) const { if (s.empty ()) return 0; @@ -254,8 +255,8 @@ // Return the `basename' of the pathname in STRING (the stuff after // the last '/'). If STRING is not a full pathname, simply return it. -string -octave_env::do_base_pathname (const string& s) const +std::string +octave_env::do_base_pathname (const std::string& s) const { if (! do_absolute_pathname (s)) return s; @@ -271,8 +272,9 @@ // Turn STRING (a pathname) into an absolute pathname, assuming that // DOT_PATH contains the symbolic location of '.'. -string -octave_env::do_make_absolute (const string& s, const string& dot_path) const +std::string +octave_env::do_make_absolute (const std::string& s, + const std::string& dot_path) const { #if defined (__EMX__) if (s.length () > 1 && s[1] == ':') @@ -282,7 +284,7 @@ if (dot_path.empty () || s[0] == '/' || s.empty ()) return s; - string current_path = dot_path; + std::string current_path = dot_path; if (current_path.empty ()) current_path = "./"; @@ -340,7 +342,7 @@ // Return a consed string which is the current working directory. -string +std::string octave_env::do_getcwd () { if (! follow_symbolic_links) @@ -355,22 +357,22 @@ // This value is not cached because it can change while Octave is // running. -string +std::string octave_env::do_get_home_directory (void) const { - string hd = do_getenv ("HOME"); + std::string hd = do_getenv ("HOME"); if (hd.empty ()) { octave_passwd pw = octave_passwd::getpwuid (octave_syscalls::getuid ()); - hd = pw ? pw.dir () : string ("/"); + hd = pw ? pw.dir () : std::string ("/"); } return hd; } -string +std::string octave_env::do_get_user_name (void) const { // XXX FIXME XXX -- is it possible for this to change while Octave @@ -380,13 +382,13 @@ { octave_passwd pw = octave_passwd::getpwuid (octave_syscalls::getuid ()); - user_name = pw ? pw.name () : string ("unknown"); + user_name = pw ? pw.name () : std::string ("unknown"); } return user_name; } -string +std::string octave_env::do_get_host_name (void) const { // XXX FIXME XXX -- is it possible for this to change while Octave @@ -404,8 +406,8 @@ return host_name; } -string -octave_env::do_getenv (const string& name) const +std::string +octave_env::do_getenv (const std::string& name) const { char *value = ::getenv (name.c_str ()); @@ -416,11 +418,11 @@ // link following, etc. bool -octave_env::do_chdir (const string& newdir) +octave_env::do_chdir (const std::string& newdir) { bool retval = false; - string tmp; + std::string tmp; if (follow_symbolic_links) { @@ -457,7 +459,7 @@ // Remove the last N directories from PATH. void -octave_env::pathname_backup (string& path, int n) const +octave_env::pathname_backup (std::string& path, int n) const { if (path.empty ()) return; @@ -485,7 +487,7 @@ } void -octave_env::error (const string& s) const +octave_env::error (const std::string& s) const { (*current_liboctave_error_handler) ("%s", s.c_str ()); }
--- a/liboctave/oct-env.h +++ b/liboctave/oct-env.h @@ -34,67 +34,67 @@ public: - static string polite_directory_format (const string& name); + static std::string polite_directory_format (const std::string& name); - static bool absolute_pathname (const string& s); + static bool absolute_pathname (const std::string& s); - static string base_pathname (const string& s); + static std::string base_pathname (const std::string& s); - static string make_absolute (const string& s, const string& dot_path); + static std::string make_absolute (const std::string& s, const std::string& dot_path); - static string getcwd (void); + static std::string getcwd (void); - static string get_home_directory (void); + static std::string get_home_directory (void); - static string get_program_name (void); + static std::string get_program_name (void); - static string get_program_invocation_name (void); + static std::string get_program_invocation_name (void); - static string get_user_name (void); + static std::string get_user_name (void); - static string get_host_name (void); + static std::string get_host_name (void); - static string getenv (const string& name); + static std::string getenv (const std::string& name); - static void putenv (const string& name, const string& value); + static void putenv (const std::string& name, const std::string& value); - static bool chdir (const string& newdir); + static bool chdir (const std::string& newdir); - static void set_program_name (const string& s); + static void set_program_name (const std::string& s); private: static bool instance_ok (void); - string do_polite_directory_format (const string& name) const; + std::string do_polite_directory_format (const std::string& name) const; - bool do_absolute_pathname (const string& s) const; + bool do_absolute_pathname (const std::string& s) const; - string do_base_pathname (const string& s) const; + std::string do_base_pathname (const std::string& s) const; - string do_make_absolute (const string& s, const string& dot_path) const; + std::string do_make_absolute (const std::string& s, const std::string& dot_path) const; - string do_getcwd (void); + std::string do_getcwd (void); - string do_get_home_directory (void) const; + std::string do_get_home_directory (void) const; - string do_get_user_name (void) const; + std::string do_get_user_name (void) const; - string do_get_host_name (void) const; + std::string do_get_host_name (void) const; - string do_getenv (const string& name) const; + std::string do_getenv (const std::string& name) const; - void do_putenv (const string& name, const string& value) const; + void do_putenv (const std::string& name, const std::string& value) const; - bool do_chdir (const string& newdir); + bool do_chdir (const std::string& newdir); - void do_set_program_name (const string& s) const; + void do_set_program_name (const std::string& s) const; - void pathname_backup (string& path, int n) const; + void pathname_backup (std::string& path, int n) const; void error (int) const; - void error (const string&) const; + void error (const std::string&) const; // No copying! @@ -114,16 +114,16 @@ bool verbatim_pwd; // Where are we? - string current_directory; + std::string current_directory; // Etc. - mutable string program_name; + mutable std::string program_name; - mutable string program_invocation_name; + mutable std::string program_invocation_name; - mutable string user_name; + mutable std::string user_name; - mutable string host_name; + mutable std::string host_name; }; #endif
--- a/liboctave/oct-group.cc +++ b/liboctave/oct-group.cc @@ -39,7 +39,7 @@ #define NOT_SUPPORTED(nm) \ nm ## ": not supported on this system" -string +std::string octave_group::name (void) const { if (! ok ()) @@ -48,7 +48,7 @@ return gr_name; } -string +std::string octave_group::passwd (void) const { if (! ok ()) @@ -78,15 +78,15 @@ octave_group octave_group::getgrent (void) { - string msg; + std::string msg; return getgrent (msg); } octave_group -octave_group::getgrent (string& msg) +octave_group::getgrent (std::string& msg) { #if defined (HAVE_GETGRENT) - msg = string (); + msg = std::string (); return octave_group (::getgrent (), msg); #else msg = NOT_SUPPORTED ("getgrent"); @@ -97,15 +97,15 @@ octave_group octave_group::getgrgid (gid_t gid) { - string msg; + std::string msg; return getgrgid (gid, msg); } octave_group -octave_group::getgrgid (gid_t gid, string& msg) +octave_group::getgrgid (gid_t gid, std::string& msg) { #if defined (HAVE_GETGRGID) - msg = string (); + msg = std::string (); return octave_group (::getgrgid (gid), msg); #else msg = NOT_SUPPORTED ("getgruid"); @@ -114,17 +114,17 @@ } octave_group -octave_group::getgrnam (const string& nm) +octave_group::getgrnam (const std::string& nm) { - string msg; + std::string msg; return getgrnam (msg); } octave_group -octave_group::getgrnam (const string& nm, string& msg) +octave_group::getgrnam (const std::string& nm, std::string& msg) { #if defined (HAVE_GETGRNAM) - msg = string (); + msg = std::string (); return octave_group (::getgrnam (nm.c_str ()), msg); #else msg = NOT_SUPPORTED ("getgrnam"); @@ -135,15 +135,15 @@ int octave_group::setgrent (void) { - string msg; + std::string msg; return setgrent (msg); } int -octave_group::setgrent (string& msg) +octave_group::setgrent (std::string& msg) { #if defined (HAVE_SETGRENT) - msg = string (); + msg = std::string (); ::setgrent (); return 0; #else @@ -155,15 +155,15 @@ int octave_group::endgrent (void) { - string msg; + std::string msg; return endgrent (msg); } int -octave_group::endgrent (string& msg) +octave_group::endgrent (std::string& msg) { #if defined (HAVE_ENDGRENT) - msg = string (); + msg = std::string (); ::endgrent (); return 0; #else @@ -172,11 +172,11 @@ #endif } -octave_group::octave_group (void *p, string& msg) +octave_group::octave_group (void *p, std::string& msg) : gr_name (), gr_passwd (), gr_gid (0), gr_mem (), valid (false) { #if defined (HAVE_GRP_H) - msg = string (); + msg = std::string (); if (p) {
--- a/liboctave/oct-group.h +++ b/liboctave/oct-group.h @@ -59,9 +59,9 @@ return *this; } - string name (void) const; + std::string name (void) const; - string passwd (void) const; + std::string passwd (void) const; gid_t gid (void) const; @@ -72,27 +72,27 @@ operator bool () const { return ok (); } static octave_group getgrent (void); - static octave_group getgrent (string& msg); + static octave_group getgrent (std::string& msg); static octave_group getgrgid (gid_t gid); - static octave_group getgrgid (gid_t gid, string& msg); + static octave_group getgrgid (gid_t gid, std::string& msg); - static octave_group getgrnam (const string& nm); - static octave_group getgrnam (const string& nm, string& msg); + static octave_group getgrnam (const std::string& nm); + static octave_group getgrnam (const std::string& nm, std::string& msg); static int setgrent (void); - static int setgrent (string& msg); + static int setgrent (std::string& msg); static int endgrent (void); - static int endgrent (string& msg); + static int endgrent (std::string& msg); private: // The group name. - string gr_name; + std::string gr_name; // The group password. - string gr_passwd; + std::string gr_passwd; // The numeric group id. gid_t gr_gid; @@ -105,7 +105,7 @@ // This is how we will create an octave_group object from a pointer // to a struct group. - octave_group (void *p, string& msg); + octave_group (void *p, std::string& msg); void gripe_invalid (void) const; };
--- a/liboctave/oct-passwd.cc +++ b/liboctave/oct-passwd.cc @@ -38,7 +38,7 @@ #define NOT_SUPPORTED(nm) \ nm ## ": not supported on this system" -string +std::string octave_passwd::name (void) const { if (! ok ()) @@ -47,7 +47,7 @@ return pw_name; } -string +std::string octave_passwd::passwd (void) const { if (! ok ()) @@ -74,7 +74,7 @@ return pw_gid; } -string +std::string octave_passwd::gecos (void) const { if (! ok ()) @@ -83,7 +83,7 @@ return pw_gecos; } -string +std::string octave_passwd::dir (void) const { if (! ok ()) @@ -92,7 +92,7 @@ return pw_dir; } -string +std::string octave_passwd::shell (void) const { if (! ok ()) @@ -104,15 +104,15 @@ octave_passwd octave_passwd::getpwent (void) { - string msg; + std::string msg; return getpwent (msg); } octave_passwd -octave_passwd::getpwent (string& msg) +octave_passwd::getpwent (std::string& msg) { #if defined HAVE_GETPWENT - msg = string (); + msg = std::string (); return octave_passwd (::getpwent (), msg); #else msg = NOT_SUPPORTED ("getpwent"); @@ -123,15 +123,15 @@ octave_passwd octave_passwd::getpwuid (uid_t uid) { - string msg; + std::string msg; return getpwuid (uid, msg); } octave_passwd -octave_passwd::getpwuid (uid_t uid, string& msg) +octave_passwd::getpwuid (uid_t uid, std::string& msg) { #if defined (HAVE_GETPWUID) - msg = string (); + msg = std::string (); return octave_passwd (::getpwuid (uid), msg); #else msg = NOT_SUPPORTED ("getpwuid"); @@ -140,17 +140,17 @@ } octave_passwd -octave_passwd::getpwnam (const string& nm) +octave_passwd::getpwnam (const std::string& nm) { - string msg; + std::string msg; return getpwnam (nm, msg); } octave_passwd -octave_passwd::getpwnam (const string& nm, string& msg) +octave_passwd::getpwnam (const std::string& nm, std::string& msg) { #if defined (HAVE_GETPWNAM) - msg = string (); + msg = std::string (); return octave_passwd (::getpwnam (nm.c_str ()), msg); #else msg = NOT_SUPPORTED ("getpwnam"); @@ -161,15 +161,15 @@ int octave_passwd::setpwent (void) { - string msg; + std::string msg; return setpwent (msg); } int -octave_passwd::setpwent (string& msg) +octave_passwd::setpwent (std::string& msg) { #if defined (HAVE_SETPWENT) - msg = string (); + msg = std::string (); ::setpwent (); return 0; #else @@ -181,15 +181,15 @@ int octave_passwd::endpwent (void) { - string msg; + std::string msg; return endpwent (msg); } int -octave_passwd::endpwent (string& msg) +octave_passwd::endpwent (std::string& msg) { #if defined (HAVE_ENDPWENT) - msg = string (); + msg = std::string (); ::endpwent (); return 0; #else @@ -198,12 +198,12 @@ #endif } -octave_passwd::octave_passwd (void *p, string& msg) +octave_passwd::octave_passwd (void *p, std::string& msg) : pw_name (), pw_passwd (), pw_uid (0), pw_gid (0), pw_gecos (), pw_dir (), pw_shell (), valid (false) { #if defined (HAVE_PWD_H) - msg = string (); + msg = std::string (); if (p) {
--- a/liboctave/oct-passwd.h +++ b/liboctave/oct-passwd.h @@ -64,46 +64,46 @@ ~octave_passwd (void) { } - string name (void) const; + std::string name (void) const; - string passwd (void) const; + std::string passwd (void) const; uid_t uid (void) const; gid_t gid (void) const; - string gecos (void) const; + std::string gecos (void) const; - string dir (void) const; + std::string dir (void) const; - string shell (void) const; + std::string shell (void) const; bool ok (void) const { return valid; } operator bool () const { return ok (); } static octave_passwd getpwent (void); - static octave_passwd getpwent (string& msg); + static octave_passwd getpwent (std::string& msg); static octave_passwd getpwuid (uid_t uid); - static octave_passwd getpwuid (uid_t uid, string& msg); + static octave_passwd getpwuid (uid_t uid, std::string& msg); - static octave_passwd getpwnam (const string& nm); - static octave_passwd getpwnam (const string& nm, string& msg); + static octave_passwd getpwnam (const std::string& nm); + static octave_passwd getpwnam (const std::string& nm, std::string& msg); static int setpwent (void); - static int setpwent (string& msg); + static int setpwent (std::string& msg); static int endpwent (void); - static int endpwent (string& msg); + static int endpwent (std::string& msg); private: // User name. - string pw_name; + std::string pw_name; // Encrypted password. - string pw_passwd; + std::string pw_passwd; // Numeric user id. uid_t pw_uid; @@ -112,20 +112,20 @@ gid_t pw_gid; // Miscellaneous junk. - string pw_gecos; + std::string pw_gecos; // Home directory. - string pw_dir; + std::string pw_dir; // Login shell. - string pw_shell; + std::string pw_shell; // Flag that says whether we have been properly initialized. bool valid; // This is how we will create an octave_passwd object from a pointer // to a struct passwd. - octave_passwd (void *p, string& msg); + octave_passwd (void *p, std::string& msg); void gripe_invalid (void) const; };
--- a/liboctave/oct-shlib.cc +++ b/liboctave/oct-shlib.cc @@ -65,20 +65,20 @@ tm_loaded (static_cast<time_t> (0)) { count = 1; } - octave_base_shlib (const string& f) + octave_base_shlib (const std::string& f) : octave_shlib (octave_xshlib ()), file (f), fcn_names (), tm_loaded (static_cast<time_t> (0)) { count = 1; } ~octave_base_shlib (void) { } - void open (const string&, bool = false) { } + void open (const std::string&, bool = false) { } - void *search (const string&, name_mangler = 0) { return 0; } + void *search (const std::string&, name_mangler = 0) { return 0; } void close (octave_shlib::close_hook = 0) { } - bool remove (const string& fcn_name); + bool remove (const std::string& fcn_name); bool is_open (void) const { return false; } @@ -86,13 +86,13 @@ int number_of_functions_loaded (void) const { return fcn_names.length (); } - string file_name (void) const { return file; } + std::string file_name (void) const { return file; } octave_time time_loaded (void) const { return tm_loaded; } protected: - string file; + std::string file; string_vector fcn_names; @@ -100,7 +100,7 @@ void stamp_time (bool warn_future = false); - void add_to_fcn_names (const string& name); + void add_to_fcn_names (const std::string& name); void do_close_hook (octave_shlib::close_hook = 0); @@ -114,7 +114,7 @@ }; bool -octave_base_shlib::remove (const string& fcn_name) +octave_base_shlib::remove (const std::string& fcn_name) { bool retval = false; @@ -163,7 +163,7 @@ } void -octave_base_shlib::add_to_fcn_names (const string& name) +octave_base_shlib::add_to_fcn_names (const std::string& name) { int n = number_of_functions_loaded (); @@ -206,9 +206,9 @@ ~octave_dlopen_shlib (void); - void open (const string& f, bool warn_future = false); + void open (const std::string& f, bool warn_future = false); - void *search (const string& name, name_mangler mangler = 0); + void *search (const std::string& name, name_mangler mangler = 0); void close (octave_shlib::close_hook cl_hook = 0); @@ -236,7 +236,7 @@ } void -octave_dlopen_shlib::open (const string& f, bool warn_future) +octave_dlopen_shlib::open (const std::string& f, bool warn_future) { if (! is_open ()) { @@ -260,14 +260,14 @@ } void * -octave_dlopen_shlib::search (const string& name, +octave_dlopen_shlib::search (const std::string& name, octave_shlib::name_mangler mangler) { void *function = 0; if (is_open ()) { - string sym_name = name; + std::string sym_name = name; if (mangler) sym_name = mangler (name); @@ -310,9 +310,9 @@ ~octave_shl_load_shlib (void); - void open (const string& f, bool warn_future = false); + void open (const std::string& f, bool warn_future = false); - void *search (const string& name, name_mangler mangler = 0); + void *search (const std::string& name, name_mangler mangler = 0); void close (octave_shlib::close_hook cl_hook = 0); @@ -340,7 +340,7 @@ } void -octave_shl_load_shlib::open (const string& f, bool warn_future) +octave_shl_load_shlib::open (const std::string& f, bool warn_future) { if (! is_open ()) { @@ -351,7 +351,10 @@ if (library) stamp_time (warn_future); else - (*current_liboctave_error_handler) ("%s", strerror (errno)); + { + using namespace std; + (*current_liboctave_error_handler) ("%s", strerror (errno)); + } } else (*current_liboctave_error_handler) @@ -359,14 +362,14 @@ } void * -octave_shl_load_shlib::search (const string& name, +octave_shl_load_shlib::search (const std::string& name, octave_shlib::name_mangler mangler) { void *function = 0; if (is_open ()) { - string sym_name = name; + std::string s ym_name = name; if (mangler) sym_name = mangler (name);
--- a/liboctave/oct-shlib.h +++ b/liboctave/oct-shlib.h @@ -43,13 +43,13 @@ { public: - typedef string (*name_mangler) (const string&); + typedef std::string (*name_mangler) (const std::string&); - typedef void (*close_hook) (const string&); + typedef void (*close_hook) (const std::string&); octave_shlib (void) : rep (make_shlib ()) { } - octave_shlib::octave_shlib (const string& f, bool warn_future) + octave_shlib::octave_shlib (const std::string& f, bool warn_future) : rep (make_shlib ()) { open (f, warn_future); @@ -89,16 +89,16 @@ operator bool () const { return is_open (); } - virtual void open (const string& f, bool warn_future = false) + virtual void open (const std::string& f, bool warn_future = false) { rep->open (f, warn_future); } - virtual void *search (const string& nm, name_mangler mangler = 0) + virtual void *search (const std::string& nm, name_mangler mangler = 0) { return rep->search (nm, mangler); } virtual void close (close_hook cl_hook = 0) { rep->close (cl_hook); } - virtual bool remove (const string& fcn_name) + virtual bool remove (const std::string& fcn_name) { return rep->remove (fcn_name); } virtual bool is_out_of_date (void) const @@ -107,7 +107,7 @@ virtual int number_of_functions_loaded (void) const { return rep->number_of_functions_loaded (); } - virtual string file_name (void) const + virtual std::string file_name (void) const { return rep->file_name (); } virtual octave_time time_loaded (void) const
--- a/liboctave/oct-syscalls.cc +++ b/liboctave/oct-syscalls.cc @@ -50,14 +50,14 @@ int octave_syscalls::dup2 (int old_fd, int new_fd) { - string msg; + std::string msg; return dup2 (old_fd, new_fd, msg); } int -octave_syscalls::dup2 (int old_fd, int new_fd, string& msg) +octave_syscalls::dup2 (int old_fd, int new_fd, std::string& msg) { - msg = string (); + msg = std::string (); int status = -1; @@ -65,7 +65,10 @@ status = ::dup2 (old_fd, new_fd); if (status < 0) - msg = ::strerror (errno); + { + using namespace std; + msg = ::strerror (errno); + } #else msg = NOT_SUPPORTED ("dup2"); #endif @@ -74,17 +77,17 @@ } int -octave_syscalls::execvp (const string& file, const string_vector& argv) +octave_syscalls::execvp (const std::string& file, const string_vector& argv) { - string msg; + std::string msg; return execvp (file, argv, msg); } int -octave_syscalls::execvp (const string& file, const string_vector& args, - string& msg) +octave_syscalls::execvp (const std::string& file, const string_vector& args, + std::string& msg) { - msg = string (); + msg = std::string (); int status = -1; @@ -96,7 +99,10 @@ string_vector::delete_c_str_vec (argv); if (status < 0) - msg = ::strerror (errno); + { + using namespace std; + msg = ::strerror (errno); + } #else msg = NOT_SUPPORTED ("execvp"); #endif @@ -107,14 +113,14 @@ int octave_syscalls::fcntl (int fd, int cmd, long arg) { - string msg; + std::string msg; return fcntl (fd, cmd, arg, msg); } int -octave_syscalls::fcntl (int fd, int cmd, long arg, string& msg) +octave_syscalls::fcntl (int fd, int cmd, long arg, std::string& msg) { - msg = string (); + msg = std::string (); int status = -1; @@ -122,7 +128,10 @@ status = ::fcntl (fd, cmd, arg); if (status < 0) - msg = ::strerror (errno); + { + using namespace std; + msg = ::strerror (errno); + } #else msg = NOT_SUPPORTED ("fcntl"); #endif @@ -131,7 +140,7 @@ } pid_t -octave_syscalls::fork (string& msg) +octave_syscalls::fork (std::string& msg) { pid_t status = -1; @@ -139,7 +148,10 @@ status = ::fork (); if (status < 0) - msg = ::strerror (errno); + { + using namespace std; + msg = ::strerror (errno); + } #else msg = NOT_SUPPORTED ("fork"); #endif @@ -148,7 +160,7 @@ } pid_t -octave_syscalls::vfork (string& msg) +octave_syscalls::vfork (std::string& msg) { pid_t status = -1; @@ -160,7 +172,10 @@ #endif if (status < 0) - msg = ::strerror (errno); + { + using namespace std; + msg = ::strerror (errno); + } #else msg = NOT_SUPPORTED ("vfork"); #endif @@ -169,7 +184,7 @@ } pid_t -octave_syscalls::getpgrp (string& msg) +octave_syscalls::getpgrp (std::string& msg) { pid_t status = -1; @@ -177,7 +192,10 @@ status = ::getpgrp (); if (status < 0) - msg = ::strerror (errno); + { + using namespace std; + msg = ::strerror (errno); + } #else msg = NOT_SUPPORTED ("getpgrp"); #endif @@ -248,14 +266,14 @@ int octave_syscalls::pipe (int *fildes) { - string msg; + std::string msg; return pipe (fildes); } int -octave_syscalls::pipe (int *fildes, string& msg) +octave_syscalls::pipe (int *fildes, std::string& msg) { - msg = string (); + msg = std::string (); int status = -1; @@ -263,7 +281,10 @@ status = ::pipe (fildes); if (status < 0) - msg = ::strerror (errno); + { + using namespace std; + msg = ::strerror (errno); + } #else msg = NOT_SUPPORTED ("pipe"); #endif @@ -274,14 +295,14 @@ pid_t octave_syscalls::waitpid (pid_t pid, int options) { - string msg; + std::string msg; return waitpid (pid, options, msg); } pid_t -octave_syscalls::waitpid (pid_t pid, int options, string& msg) +octave_syscalls::waitpid (pid_t pid, int options, std::string& msg) { - msg = string (); + msg = std::string (); int status = -1; @@ -289,7 +310,10 @@ status = ::waitpid (pid, 0, options); if (status < 0) - msg = ::strerror (errno); + { + using namespace std; + msg = ::strerror (errno); + } #else msg = NOT_SUPPORTED ("waitpid"); #endif
--- a/liboctave/oct-syscalls.h +++ b/liboctave/oct-syscalls.h @@ -35,18 +35,18 @@ octave_syscalls { static int dup2 (int, int); - static int dup2 (int, int, string&); + static int dup2 (int, int, std::string&); - static int execvp (const string&, const string_vector&); - static int execvp (const string&, const string_vector&, string&); + static int execvp (const std::string&, const string_vector&); + static int execvp (const std::string&, const string_vector&, std::string&); static int fcntl (int, int, long); - static int fcntl (int, int, long, string&); + static int fcntl (int, int, long, std::string&); - static pid_t fork (string&); - static pid_t vfork (string&); + static pid_t fork (std::string&); + static pid_t vfork (std::string&); - static pid_t getpgrp (string&); + static pid_t getpgrp (std::string&); static pid_t getpid (void); static pid_t getppid (void); @@ -58,10 +58,10 @@ static uid_t geteuid (void); static int pipe (int *); - static int pipe (int *, string&); + static int pipe (int *, std::string&); static pid_t waitpid (pid_t, int); - static pid_t waitpid (pid_t, int, string&); + static pid_t waitpid (pid_t, int, std::string&); }; #endif
--- a/liboctave/oct-time.cc +++ b/liboctave/oct-time.cc @@ -51,7 +51,7 @@ t.tm_isdst = tm.isdst (); #if defined (HAVE_TM_ZONE) - string s = tm.zone (); + std::string s = tm.zone (); char *ps = strsave (s.c_str ()); t.tm_zone = ps; #endif @@ -65,7 +65,7 @@ ot_usec = tm.usec (); } -string +std::string octave_time::ctime (void) const { return octave_localtime (*this) . asctime (); @@ -120,7 +120,7 @@ DEFINE_SET_INT_FIELD_FCN (isdst, 0, 1) octave_base_tm& -octave_base_tm::zone (const string& s) +octave_base_tm::zone (const std::string& s) { tm_zone = s; return *this; @@ -130,10 +130,10 @@ #define STRFTIME_BUF_INITIAL_SIZE 128 #endif -string -octave_base_tm::strftime (const string& fmt) const +std::string +octave_base_tm::strftime (const std::string& fmt) const { - string retval; + std::string retval; struct tm t; @@ -224,7 +224,7 @@ } void -octave_strptime::init (const string& str, const string& fmt) +octave_strptime::init (const std::string& str, const std::string& fmt) { struct tm t;
--- a/liboctave/oct-time.h +++ b/liboctave/oct-time.h @@ -46,7 +46,7 @@ : ot_unix_time (static_cast<time_t> (d)), ot_usec (0) { double ip; - ot_usec = static_cast<int> (modf (d, &ip) * 1e6); + ot_usec = static_cast<int> (std::modf (d, &ip) * 1e6); } octave_time (const octave_base_tm& tm); @@ -77,7 +77,7 @@ int usec (void) const { return ot_usec; } - string ctime (void) const; + std::string ctime (void) const; private: @@ -188,7 +188,7 @@ int wday (void) const { return tm_wday; } int yday (void) const { return tm_yday; } int isdst (void) const { return tm_isdst; } - string zone (void) const { return tm_zone; } + std::string zone (void) const { return tm_zone; } octave_base_tm& usec (int v); octave_base_tm& sec (int v); @@ -200,11 +200,12 @@ octave_base_tm& wday (int v); octave_base_tm& yday (int v); octave_base_tm& isdst (int v); - octave_base_tm& zone (const string& s); + octave_base_tm& zone (const std::string& s); - string strftime (const string& fmt) const; + std::string strftime (const std::string& fmt) const; - string asctime (void) const { return strftime ("%a %b %d %H:%M:%S %Y\n"); } + std::string asctime (void) const + { return strftime ("%a %b %d %H:%M:%S %Y\n"); } protected: @@ -239,7 +240,7 @@ int tm_isdst; // Time zone. - string tm_zone; + std::string tm_zone; void init (void *p); }; @@ -300,7 +301,7 @@ { public: - octave_strptime (const string& str, const string& fmt) + octave_strptime (const std::string& str, const std::string& fmt) : octave_base_tm () { init (str, fmt); } octave_strptime (const octave_strptime& s) @@ -321,7 +322,7 @@ int nchars; - void init (const string& str, const string& fmt); + void init (const std::string& str, const std::string& fmt); }; #endif
--- a/liboctave/pathsearch.cc +++ b/liboctave/pathsearch.cc @@ -102,10 +102,10 @@ return retval; } -string -dir_path::find_first (const string& nm) +std::string +dir_path::find_first (const std::string& nm) { - string retval; + std::string retval; if (initialized) { @@ -121,7 +121,7 @@ } string_vector -dir_path::find_all (const string& nm) +dir_path::find_all (const std::string& nm) { string_vector retval; @@ -147,7 +147,7 @@ } void -dir_path::set_program_name (const string& nm) +dir_path::set_program_name (const std::string& nm) { kpse_set_progname (nm.c_str ()); } @@ -187,7 +187,7 @@ free (t1); } else - p = string (); + p = std::string (); int count = 0; char *path_elt = kpse_path_element (p.c_str ());
--- a/liboctave/pathsearch.h +++ b/liboctave/pathsearch.h @@ -32,7 +32,8 @@ { public: - dir_path (const string& s = string (), const string& d = string ()) + dir_path (const std::string& s = std::string (), + const std::string& d = std::string ()) : p_orig (s), p_default (d), initialized (false) { if (! p_orig.empty ()) @@ -56,7 +57,7 @@ ~dir_path (void) { } - void set (const string& s) + void set (const std::string& s) { initialized = false; p_orig = s; @@ -66,12 +67,12 @@ string_vector elements (void); string_vector all_directories (void); - string find_first (const string&); - string find (const string& nm) { return find_first (nm); } + std::string find_first (const std::string&); + std::string find (const std::string& nm) { return find_first (nm); } - string_vector find_all (const string&); + string_vector find_all (const std::string&); - static void set_program_name (const string&); + static void set_program_name (const std::string&); void rehash (void) { @@ -82,18 +83,18 @@ private: // The colon separated list that we were given. - string p_orig; + std::string p_orig; // The default path. If specified, replaces leading, trailing, or // doubled colons in p_orig. - string p_default; + std::string p_default; // TRUE means we've unpacked p. bool initialized; // A version of the colon separate list on which we have performed // tilde, variable, and possibly default path expansion. - string p; + std::string p; // The elements of the list. string_vector pv;
--- a/liboctave/str-vec.cc +++ b/liboctave/str-vec.cc @@ -42,7 +42,7 @@ // Create a string vector from a NULL terminated list of C strings. string_vector::string_vector (const char * const *s) - : Array<string> () + : Array<std::string> () { int n = 0; @@ -61,7 +61,7 @@ // nonnegative. string_vector::string_vector (const char * const *s, int n) - : Array<string> (n) + : Array<std::string> (n) { for (int i = 0; i < n; i++) elem (i) = s[i]; @@ -114,8 +114,8 @@ // Format a list in neat columns. -ostream& -string_vector::list_in_columns (ostream& os) const +std::ostream& +string_vector::list_in_columns (std::ostream& os) const { // Compute the maximum name length. @@ -159,7 +159,7 @@ while (1) { - string nm = elem (count); + std::string nm = elem (count); os << nm; int name_length = nm.length ();
--- a/liboctave/str-vec.h +++ b/liboctave/str-vec.h @@ -31,26 +31,26 @@ static int str_vec_compare (const void *a_arg, const void *b_arg) { - const string *a = (const string *) a_arg; - const string *b = (const string *) b_arg; + const std::string *a = (const std::string *) a_arg; + const std::string *b = (const std::string *) b_arg; return a->compare (*b); } class -string_vector : public Array<string> +string_vector : public Array<std::string> { public: - string_vector (void) : Array<string> () { } + string_vector (void) : Array<std::string> () { } - string_vector (int n) : Array<string> (n) { } + string_vector (int n) : Array<std::string> (n) { } - string_vector (const char *s) : Array<string> (1, s) { } + string_vector (const char *s) : Array<std::string> (1, s) { } - string_vector (const string& s) : Array<string> (1, s) { } + string_vector (const std::string& s) : Array<std::string> (1, s) { } - string_vector (const string_vector& s) : Array<string> (s) { } + string_vector (const string_vector& s) : Array<std::string> (s) { } string_vector (const char * const *s); @@ -59,7 +59,7 @@ string_vector& operator = (const string_vector& s) { if (this != &s) - Array<string>::operator = (s); + Array<std::string>::operator = (s); return *this; } @@ -84,13 +84,13 @@ return longest; } - string& operator[] (int i) { return Array<string>::elem (i); } + std::string& operator[] (int i) { return Array<std::string>::elem (i); } - string operator[] (int i) const { return Array<string>::elem (i); } + std::string operator[] (int i) const { return Array<std::string>::elem (i); } string_vector& qsort (bool make_unique = false) { - Array<string>::qsort (str_vec_compare); + Array<std::string>::qsort (str_vec_compare); if (make_unique) uniq (); @@ -104,7 +104,7 @@ static void delete_c_str_vec (const char * const*); - ostream& list_in_columns (ostream&) const; + std::ostream& list_in_columns (std::ostream&) const; }; #endif
--- a/liboctave/strptime.c +++ b/liboctave/strptime.c @@ -202,7 +202,7 @@ # define HERE_T_FMT_AMPM "%I:%M:%S %p" # define HERE_T_FMT "%H:%M:%S" -const unsigned short int __mon_yday[1][13] = +const unsigned short int __mon_yday[2][13] = { /* Normal years. */ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },