Mercurial > octave
changeset 27933:863ae57eee69
maint: Use Octave coding conventions in liboctave/
* Array-C.cc, Array-d.cc, Array-f.cc, MSparse.cc, Sparse.cc, dim-vector.h,
xerbla.cc, aepbalance.cc, eigs-base.cc, gepbalance.cc, oct-fftw.cc,
randmtzig.cc, mx-inlines.cc, lo-sysdep.cc, base-list.h, cmd-edit.h,
lo-regexp.cc, oct-atomic.h, oct-binmap.h, oct-inttypes.cc, oct-inttypes.h,
quit.h, url-transfer.cc:
Use Octave coding conventions in liboctave.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 11 Jan 2020 12:53:20 -0800 |
parents | b018f553fd85 |
children | 49a0d90cd2a3 |
files | liboctave/array/Array-C.cc liboctave/array/Array-d.cc liboctave/array/Array-f.cc liboctave/array/MSparse.cc liboctave/array/Sparse.cc liboctave/array/dim-vector.h liboctave/external/blas-xtra/xerbla.cc liboctave/numeric/aepbalance.cc liboctave/numeric/eigs-base.cc liboctave/numeric/gepbalance.cc liboctave/numeric/oct-fftw.cc liboctave/numeric/randmtzig.cc liboctave/operators/mx-inlines.cc liboctave/system/lo-sysdep.cc liboctave/util/base-list.h liboctave/util/cmd-edit.h liboctave/util/lo-regexp.cc liboctave/util/oct-atomic.h liboctave/util/oct-binmap.h liboctave/util/oct-inttypes.cc liboctave/util/oct-inttypes.h liboctave/util/quit.h liboctave/util/url-transfer.cc |
diffstat | 23 files changed, 103 insertions(+), 102 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/array/Array-C.cc Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/array/Array-C.cc Sat Jan 11 12:53:20 2020 -0800 @@ -64,7 +64,7 @@ } Array<Complex>::compare_fcn_type -safe_comparator (sortmode mode, const Array<Complex>& a , bool allow_chk) +safe_comparator (sortmode mode, const Array<Complex>& a, bool allow_chk) { Array<Complex>::compare_fcn_type result = nullptr;
--- a/liboctave/array/Array-d.cc Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/array/Array-d.cc Sat Jan 11 12:53:20 2020 -0800 @@ -64,7 +64,7 @@ } Array<double>::compare_fcn_type -safe_comparator (sortmode mode, const Array<double>& a , bool allow_chk) +safe_comparator (sortmode mode, const Array<double>& a, bool allow_chk) { Array<double>::compare_fcn_type result = nullptr;
--- a/liboctave/array/Array-f.cc Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/array/Array-f.cc Sat Jan 11 12:53:20 2020 -0800 @@ -64,7 +64,7 @@ } Array<float>::compare_fcn_type -safe_comparator (sortmode mode, const Array<float>& a , bool allow_chk) +safe_comparator (sortmode mode, const Array<float>& a, bool allow_chk) { Array<float>::compare_fcn_type result = nullptr;
--- a/liboctave/array/MSparse.cc Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/array/MSparse.cc Sat Jan 11 12:53:20 2020 -0800 @@ -40,7 +40,7 @@ octave_idx_type b_nc = b.cols (); if (a_nr != b_nr || a_nc != b_nc) - octave::err_nonconformant (op_name , a_nr, a_nc, b_nr, b_nc); + octave::err_nonconformant (op_name, a_nr, a_nc, b_nr, b_nc); r = MSparse<T> (a_nr, a_nc, (a.nnz () + b.nnz ()));
--- a/liboctave/array/Sparse.cc Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/array/Sparse.cc Sat Jan 11 12:53:20 2020 -0800 @@ -1235,7 +1235,7 @@ octave_idx_type new_nz = nz - (ubi - lbi); *this = Sparse<T> (1, nc - (ub - lb), new_nz); std::copy_n (tmp.data (), lbi, data ()); - std::copy (tmp.data () + ubi, tmp.data () + nz , xdata () + lbi); + std::copy (tmp.data () + ubi, tmp.data () + nz, xdata () + lbi); std::fill_n (ridx (), new_nz, static_cast<octave_idx_type> (0)); std::copy_n (tmp.cidx () + 1, lb, cidx () + 1); mx_inline_sub (nc - ub, xcidx () + 1, tmp.cidx () + ub + 1,
--- a/liboctave/array/dim-vector.h Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/array/dim-vector.h Sat Jan 11 12:53:20 2020 -0800 @@ -287,7 +287,7 @@ { if (&dv != this) { - if (decrement_count () == 0) + if (decrement_count () == 0) freerep (); rep = dv.rep;
--- a/liboctave/external/blas-xtra/xerbla.cc Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/external/blas-xtra/xerbla.cc Sat Jan 11 12:53:20 2020 -0800 @@ -68,8 +68,8 @@ std::cerr << std::string (s, slen) << ": parameter number " << info << " is invalid" << std::endl; - if (xerbla_handler) - (*xerbla_handler) (); + if (xerbla_handler) + (*xerbla_handler) (); F77_RETURN (0) }
--- a/liboctave/numeric/aepbalance.cc Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/numeric/aepbalance.cc Sat Jan 11 12:53:20 2020 -0800 @@ -130,7 +130,7 @@ FloatMatrix balancing_mat (n, n, 0.0); for (F77_INT i = 0; i < n; i++) - balancing_mat.elem (i ,i) = 1.0; + balancing_mat.elem (i,i) = 1.0; F77_INT info; F77_INT t_ilo = to_f77_int (ilo);
--- a/liboctave/numeric/eigs-base.cc Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/numeric/eigs-base.cc Sat Jan 11 12:53:20 2020 -0800 @@ -448,7 +448,7 @@ tmp.xcidx (n) = n; AminusSigmaB -= sigma * tmp * - b.transpose () * b * tmp.transpose (); + b.transpose () * b * tmp.transpose (); } else AminusSigmaB -= sigma * b.transpose () * b; @@ -629,7 +629,7 @@ tmp.xcidx (n) = n; AminusSigmaB -= tmp * b.hermitian () * b * - tmp.transpose () * sigma; + tmp.transpose () * sigma; } else AminusSigmaB -= sigma * b.hermitian () * b; @@ -1641,7 +1641,7 @@ ip2 = workd + iptr(1) - 1; for (F77_INT i = 0; i < n; i++) *ip2++ = y(i); - } + } } } else @@ -1746,7 +1746,7 @@ } if (note3) eig_vec = utsolve (bt, permB, eig_vec); - } + } } else (*current_liboctave_error_handler) @@ -2577,7 +2577,7 @@ if (have_b) bmat = 'G'; } - } + } else if (! std::abs (sigmar)) { typ = "SM"; @@ -2750,7 +2750,7 @@ ip2 = workd + iptr(1) - 1; for (F77_INT i = 0; i < n; i++) *ip2++ = y(i); - } + } } } else @@ -2905,7 +2905,7 @@ = Complex (octave::numeric_limits<double>::NaN (), 0.); } if (note3) - eig_vec = utsolve (bt, permB, eig_vec); + eig_vec = utsolve (bt, permB, eig_vec); } if (k0 < k) {
--- a/liboctave/numeric/gepbalance.cc Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/numeric/gepbalance.cc Sat Jan 11 12:53:20 2020 -0800 @@ -81,8 +81,8 @@ for (F77_INT i = 0; i < n; i++) { octave_quit (); - balancing_mat.elem (i ,i) = 1.0; - balancing_mat2.elem (i ,i) = 1.0; + balancing_mat.elem (i,i) = 1.0; + balancing_mat2.elem (i,i) = 1.0; } double *p_balancing_mat = balancing_mat.fortran_vec (); @@ -147,8 +147,8 @@ for (F77_INT i = 0; i < n; i++) { octave_quit (); - balancing_mat.elem (i ,i) = 1.0; - balancing_mat2.elem (i ,i) = 1.0; + balancing_mat.elem (i,i) = 1.0; + balancing_mat2.elem (i,i) = 1.0; } float *p_balancing_mat = balancing_mat.fortran_vec (); @@ -215,8 +215,8 @@ for (F77_INT i = 0; i < n; i++) { octave_quit (); - balancing_mat.elem (i ,i) = 1.0; - balancing_mat2.elem (i ,i) = 1.0; + balancing_mat.elem (i,i) = 1.0; + balancing_mat2.elem (i,i) = 1.0; } double *p_balancing_mat = balancing_mat.fortran_vec (); @@ -286,8 +286,8 @@ for (F77_INT i = 0; i < n; i++) { octave_quit (); - balancing_mat.elem (i ,i) = 1.0; - balancing_mat2.elem (i ,i) = 1.0; + balancing_mat.elem (i,i) = 1.0; + balancing_mat2.elem (i,i) = 1.0; } float *p_balancing_mat = balancing_mat.fortran_vec ();
--- a/liboctave/numeric/oct-fftw.cc Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/numeric/oct-fftw.cc Sat Jan 11 12:53:20 2020 -0800 @@ -241,8 +241,8 @@ // Create matrix with the same size and 16-byte alignment as input OCTAVE_LOCAL_BUFFER (Complex, itmp, nn * howmany + 32); itmp = reinterpret_cast<Complex *> - (((reinterpret_cast<ptrdiff_t> (itmp) + 15) & ~ 0xF) + - ((reinterpret_cast<ptrdiff_t> (in)) & 0xF)); + (((reinterpret_cast<ptrdiff_t> (itmp) + 15) & ~ 0xF) + + ((reinterpret_cast<ptrdiff_t> (in)) & 0xF)); *cur_plan_p = fftw_plan_many_dft (rank, tmp, howmany, @@ -360,8 +360,8 @@ // Create matrix with the same size and 16-byte alignment as input OCTAVE_LOCAL_BUFFER (double, itmp, nn + 32); itmp = reinterpret_cast<double *> - (((reinterpret_cast<ptrdiff_t> (itmp) + 15) & ~ 0xF) + - ((reinterpret_cast<ptrdiff_t> (in)) & 0xF)); + (((reinterpret_cast<ptrdiff_t> (itmp) + 15) & ~ 0xF) + + ((reinterpret_cast<ptrdiff_t> (in)) & 0xF)); *cur_plan_p = fftw_plan_many_dft_r2c (rank, tmp, howmany, itmp, @@ -593,8 +593,8 @@ // Create matrix with the same size and 16-byte alignment as input OCTAVE_LOCAL_BUFFER (FloatComplex, itmp, nn * howmany + 32); itmp = reinterpret_cast<FloatComplex *> - (((reinterpret_cast<ptrdiff_t> (itmp) + 15) & ~ 0xF) + - ((reinterpret_cast<ptrdiff_t> (in)) & 0xF)); + (((reinterpret_cast<ptrdiff_t> (itmp) + 15) & ~ 0xF) + + ((reinterpret_cast<ptrdiff_t> (in)) & 0xF)); *cur_plan_p = fftwf_plan_many_dft (rank, tmp, howmany, @@ -712,8 +712,8 @@ // Create matrix with the same size and 16-byte alignment as input OCTAVE_LOCAL_BUFFER (float, itmp, nn + 32); itmp = reinterpret_cast<float *> - (((reinterpret_cast<ptrdiff_t> (itmp) + 15) & ~ 0xF) + - ((reinterpret_cast<ptrdiff_t> (in)) & 0xF)); + (((reinterpret_cast<ptrdiff_t> (itmp) + 15) & ~ 0xF) + + ((reinterpret_cast<ptrdiff_t> (in)) & 0xF)); *cur_plan_p = fftwf_plan_many_dft_r2c (rank, tmp, howmany, itmp,
--- a/liboctave/numeric/randmtzig.cc Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/numeric/randmtzig.cc Sat Jan 11 12:53:20 2020 -0800 @@ -224,7 +224,7 @@ for (; k; k--) { state[i] = (state[i] ^ ((state[i-1] ^ (state[i-1] >> 30)) * 1664525UL)) - + init_key[j] + j; /* non linear */ + + init_key[j] + j; /* non linear */ state[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ i++; j++; @@ -239,7 +239,7 @@ for (k = MT_N - 1; k; k--) { state[i] = (state[i] ^ ((state[i-1] ^ (state[i-1] >> 30)) * 1566083941UL)) - - i; /* non linear */ + - i; /* non linear */ state[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ i++; if (i >= MT_N) @@ -269,7 +269,7 @@ if (std::fread (word, 4, 1, urandom) != 1) break; entropy[n++] = word[0] + (word[1]<<8) + (word[2]<<16) - + (static_cast<uint32_t> (word[3])<<24); + + (static_cast<uint32_t> (word[3])<<24); } std::fclose (urandom); }
--- a/liboctave/operators/mx-inlines.cc Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/operators/mx-inlines.cc Sat Jan 11 12:53:20 2020 -0800 @@ -540,8 +540,8 @@ template <typename R, typename X> inline Array<R>& do_mm_inplace_op (Array<R>& r, const Array<X>& x, - void (*op) (size_t, R *, const X *) , - void (*op1) (size_t, R *, X) , + void (*op) (size_t, R *, const X *), + void (*op1) (size_t, R *, X), const char *opname) { dim_vector dr = r.dims ();
--- a/liboctave/system/lo-sysdep.cc Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/system/lo-sysdep.cc Sat Jan 11 12:53:20 2020 -0800 @@ -84,7 +84,8 @@ } bool - get_dirlist (const std::string& dirname, string_vector& dirlist, std::string& msg) + get_dirlist (const std::string& dirname, string_vector& dirlist, + std::string& msg) { dirlist = ""; msg = ""; @@ -102,17 +103,17 @@ // Find first file in directory. HANDLE hFind = FindFirstFileW (u8_to_wstring (path_name).c_str (), - &ffd); + &ffd); if (INVALID_HANDLE_VALUE == hFind) { DWORD errCode = GetLastError (); char *errorText = nullptr; FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_IGNORE_INSERTS, - nullptr, errCode, - MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - reinterpret_cast <char *> (&errorText), 0, nullptr); + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_IGNORE_INSERTS, + nullptr, errCode, + MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), + reinterpret_cast <char *> (&errorText), 0, nullptr); if (errorText != nullptr) { msg = std::string (errorText); @@ -375,16 +376,16 @@ std::string test_dir = canonicalize_file_name (oct_ascii_dir); if (test_dir.empty ()) - { - std::string msg; - int status = sys::mkdir (oct_ascii_dir, 0777, msg); + { + std::string msg; + int status = sys::mkdir (oct_ascii_dir, 0777, msg); - if (status < 0) - return orig_file_name; + if (status < 0) + return orig_file_name; - // Set hidden property. - SetFileAttributesA (oct_ascii_dir.c_str (), FILE_ATTRIBUTE_HIDDEN); - } + // Set hidden property. + SetFileAttributesA (oct_ascii_dir.c_str (), FILE_ATTRIBUTE_HIDDEN); + } // Create file from hash of full filename. std::string filename_hash
--- a/liboctave/util/base-list.h Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/util/base-list.h Sat Jan 11 12:53:20 2020 -0800 @@ -45,7 +45,7 @@ typedef typename std::list<elt_type>::reverse_iterator reverse_iterator; typedef typename std::list<elt_type>::const_reverse_iterator - const_reverse_iterator; + const_reverse_iterator; bool empty (void) const { return m_lst.empty (); }
--- a/liboctave/util/cmd-edit.h Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/util/cmd-edit.h Sat Jan 11 12:53:20 2020 -0800 @@ -46,7 +46,7 @@ command_editor (void) : m_command_number (1), m_rows (24), m_cols (80), m_interrupted (false), m_interrupt_event_loop (false), m_initial_input () - { } + { } public:
--- a/liboctave/util/lo-regexp.cc Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/util/lo-regexp.cc Sat Jan 11 12:53:20 2020 -0800 @@ -200,7 +200,7 @@ buf << m_pattern.substr (new_pos, tmp_pos3 - new_pos) << '{' << i << '}'; buf << m_pattern.substr (tmp_pos3 + 1, - tmp_pos1 - tmp_pos3 - 1); + tmp_pos1 - tmp_pos3 - 1); if (i != max_length) buf << '|'; } @@ -239,7 +239,7 @@ | PCRE_UTF8); m_data = pcre_compile (buf_str.c_str (), pcre_options, - &err, &erroffset, nullptr); + &err, &erroffset, nullptr); if (! m_data) (*current_liboctave_error_handler)
--- a/liboctave/util/oct-atomic.h Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/util/oct-atomic.h Sat Jan 11 12:53:20 2020 -0800 @@ -32,7 +32,7 @@ extern "C" { #endif -extern octave_idx_type octave_atomic_increment (octave_idx_type *x); + extern octave_idx_type octave_atomic_increment (octave_idx_type *x); extern octave_idx_type octave_atomic_decrement (octave_idx_type *x);
--- a/liboctave/util/oct-binmap.h Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/util/oct-binmap.h Sat Jan 11 12:53:20 2020 -0800 @@ -81,7 +81,7 @@ } static void - op_mm (size_t n, R *r, const X *x , const Y *y) + op_mm (size_t n, R *r, const X *x, const Y *y) { for (size_t i = 0; i < n; i++) r[i] = s_fcn (x[i], y[i]); @@ -95,7 +95,7 @@ } static void - op_ms (size_t n , R *r, const X *x, Y y) + op_ms (size_t n, R *r, const X *x, Y y) { for (size_t i = 0; i < n; i++) r[i] = s_fcn (x[i], y);
--- a/liboctave/util/oct-inttypes.cc Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/util/oct-inttypes.cc Sat Jan 11 12:53:20 2020 -0800 @@ -353,7 +353,7 @@ return res; - overflow: +overflow: return max_val (); } @@ -429,7 +429,7 @@ return -static_cast<int64_t> (res); } - overflow: +overflow: return positive ? max_val () : min_val (); }
--- a/liboctave/util/oct-inttypes.h Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/util/oct-inttypes.h Sat Jan 11 12:53:20 2020 -0800 @@ -648,7 +648,7 @@ ? octave_int_base<T>::max_val () : x - y) : (x < octave_int_base<T>::min_val () + y - ? octave_int_base<T>::min_val () + ? octave_int_base<T>::min_val () : x - y)); }
--- a/liboctave/util/quit.h Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/util/quit.h Sat Jan 11 12:53:20 2020 -0800 @@ -200,9 +200,9 @@ #endif - // The following enum values are deprecated and will eventually be - // removed from Octave, but there seems to be no universally good way - // to tag them with an attribute that will generate a warning. +// The following enum values are deprecated and will eventually be +// removed from Octave, but there seems to be no universally good way +// to tag them with an attribute that will generate a warning. enum octave_exception
--- a/liboctave/util/url-transfer.cc Fri Jan 10 17:25:12 2020 -0800 +++ b/liboctave/util/url-transfer.cc Sat Jan 11 12:53:20 2020 -0800 @@ -94,7 +94,7 @@ { m_ok = false; m_errmsg = "__ftp_mget__: can not create directory '" - + target + sep + directory + "': " + msg; + + target + sep + directory + "': " + msg; return; } } @@ -194,7 +194,7 @@ { m_ok = false; m_errmsg = "__ftp__mput: file '" + realfile - + "' does not exist"; + + "' does not exist"; break; } @@ -217,7 +217,7 @@ { m_ok = false; m_errmsg = "__ftp_mput__: unable to open file '" - + realfile + "'"; + + realfile + "'"; break; } @@ -235,7 +235,7 @@ { m_ok = false; m_errmsg = "__ftp_mput__: can not read the directory '" - + realdir + "'"; + + realdir + "'"; } } @@ -715,16 +715,16 @@ frame.add_fcn (curl_slist_free_all, slist); if (param.numel () >= 2) - { - for (int i = 0; i < param.numel (); i += 2) { - std::string header = param(i) + ": " + param(i+1); + for (int i = 0; i < param.numel (); i += 2) + { + std::string header = param(i) + ": " + param(i+1); - slist = curl_slist_append (slist, header.c_str ()); - } + slist = curl_slist_append (slist, header.c_str ()); + } - SETOPT (CURLOPT_HTTPHEADER, slist); - } + SETOPT (CURLOPT_HTTPHEADER, slist); + } } // Sets and sends the form data associated with a transfer. @@ -743,22 +743,22 @@ frame.add_fcn (curl_formfree, post); if (param.numel () >= 2) - { - for (int i = 0; i < param.numel (); i += 2) - { - std::string name = param(i); - std::string data = param(i+1); + { + for (int i = 0; i < param.numel (); i += 2) + { + std::string name = param(i); + std::string data = param(i+1); - if (name == "file") - curl_formadd (&post, &last, CURLFORM_COPYNAME, name.c_str (), - CURLFORM_FILE, data.c_str (), CURLFORM_END); - else - curl_formadd(&post, &last, CURLFORM_COPYNAME, name.c_str (), - CURLFORM_COPYCONTENTS, data.c_str (), CURLFORM_END); - } + if (name == "file") + curl_formadd (&post, &last, CURLFORM_COPYNAME, name.c_str (), + CURLFORM_FILE, data.c_str (), CURLFORM_END); + else + curl_formadd(&post, &last, CURLFORM_COPYNAME, name.c_str (), + CURLFORM_COPYCONTENTS, data.c_str (), CURLFORM_END); + } - SETOPT (CURLOPT_HTTPPOST, post); - } + SETOPT (CURLOPT_HTTPPOST, post); + } perform (); } @@ -777,18 +777,18 @@ SETOPT (CURLOPT_USERAGENT, options.UserAgent.c_str ()); if (! options.Username.empty ()) - { - if (! options.Password.empty ()) - { - std::string tmp = options.Username + ":" + options.Password; - SETOPT (CURLOPT_USERPWD, tmp.c_str ()); - } - else - { - std::string tmp = options.Username + ":"; - SETOPT (CURLOPT_USERPWD, tmp.c_str ()); - } - } + { + if (! options.Password.empty ()) + { + std::string tmp = options.Username + ":" + options.Password; + SETOPT (CURLOPT_USERPWD, tmp.c_str ()); + } + else + { + std::string tmp = options.Username + ":"; + SETOPT (CURLOPT_USERPWD, tmp.c_str ()); + } + } // Unimplemented. Only for MATLAB compatibility. if (! options.ContentReader.empty ())