# HG changeset patch # User John W. Eaton # Date 1272048221 14400 # Node ID c48b7048e720741fc52b2fde7de170b389e9aa64 # Parent 95c3e38098bfbe3752a7477f303b4db338a8d4cc style fixes diff -r 95c3e38098bf -r c48b7048e720 liboctave/CSparse.cc --- a/liboctave/CSparse.cc Fri Apr 23 11:28:50 2010 -0700 +++ b/liboctave/CSparse.cc Fri Apr 23 14:43:41 2010 -0400 @@ -7407,14 +7407,16 @@ // add one to the printed indices to go from // zero-based to one-based arrays - for (octave_idx_type j = 0; j < nc; j++) { - octave_quit (); - for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) { - os << a.ridx(i) + 1 << " " << j + 1 << " "; - octave_write_complex (os, a.data(i)); - os << "\n"; - } - } + for (octave_idx_type j = 0; j < nc; j++) + { + octave_quit (); + for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) + { + os << a.ridx(i) + 1 << " " << j + 1 << " "; + octave_write_complex (os, a.data(i)); + os << "\n"; + } + } return os; } diff -r 95c3e38098bf -r c48b7048e720 liboctave/dSparse.cc --- a/liboctave/dSparse.cc Fri Apr 23 11:28:50 2010 -0700 +++ b/liboctave/dSparse.cc Fri Apr 23 14:43:41 2010 -0400 @@ -7565,14 +7565,16 @@ // add one to the printed indices to go from // zero-based to one-based arrays - for (octave_idx_type j = 0; j < nc; j++) { - octave_quit (); - for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) { - os << a.ridx(i) + 1 << " " << j + 1 << " "; - octave_write_double (os, a.data(i)); - os << "\n"; - } - } + for (octave_idx_type j = 0; j < nc; j++) + { + octave_quit (); + for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) + { + os << a.ridx(i) + 1 << " " << j + 1 << " "; + octave_write_double (os, a.data(i)); + os << "\n"; + } + } return os; } diff -r 95c3e38098bf -r c48b7048e720 src/ChangeLog --- a/src/ChangeLog Fri Apr 23 11:28:50 2010 -0700 +++ b/src/ChangeLog Fri Apr 23 14:43:41 2010 -0400 @@ -1,7 +1,7 @@ 2010-04-23 Rik * DLD-FUNCTIONS/regexp.cc.: eliminate compile warning - warning: suggest explicit braces to avoid ambiguous 'else' + warning: suggest explicit braces to avoid ambiguous 'else'. 2010-04-23 Jaroslav Hajek diff -r 95c3e38098bf -r c48b7048e720 src/DLD-FUNCTIONS/find.cc --- a/src/DLD-FUNCTIONS/find.cc Fri Apr 23 11:28:50 2010 -0700 +++ b/src/DLD-FUNCTIONS/find.cc Fri Apr 23 14:43:41 2010 -0400 @@ -545,12 +545,13 @@ else gripe_wrong_type_arg ("find", arg); } - else if (arg.is_perm_matrix ()) { - PermMatrix P = arg.perm_matrix_value (); + else if (arg.is_perm_matrix ()) + { + PermMatrix P = arg.perm_matrix_value (); - if (! error_state) - retval = find_nonzero_elem_idx (P, nargout, n_to_find, direction); - } + if (! error_state) + retval = find_nonzero_elem_idx (P, nargout, n_to_find, direction); + } else { if (arg.is_single_type ()) diff -r 95c3e38098bf -r c48b7048e720 src/DLD-FUNCTIONS/regexp.cc --- a/src/DLD-FUNCTIONS/regexp.cc Fri Apr 23 11:28:50 2010 -0700 +++ b/src/DLD-FUNCTIONS/regexp.cc Fri Apr 23 14:43:41 2010 -0400 @@ -351,11 +351,12 @@ (freespacing ? PCRE_EXTENDED : 0), &err, &erroffset, 0); - if (re == 0) { - error("%s: %s at position %d of expression", nm.c_str(), - err, erroffset); - return 0; - } + if (re == 0) + { + error("%s: %s at position %d of expression", nm.c_str(), + err, erroffset); + return 0; + } int subpatterns; int namecount; @@ -447,30 +448,32 @@ int status = pcre_get_substring_list(buffer.c_str(), ovector, matches, &listptr); - if (status == PCRE_ERROR_NOMEMORY) { - error("%s: cannot allocate memory in pcre_get_substring_list", - nm.c_str()); - pcre_free(re); - return 0; - } + if (status == PCRE_ERROR_NOMEMORY) + { + error("%s: cannot allocate memory in pcre_get_substring_list", + nm.c_str()); + pcre_free(re); + return 0; + } Cell cell_t (dim_vector(1,pos_match)); string_vector named_tokens(nnames); int pos_offset = 0; pos_match = 0; for (int i = 1; i < matches; i++) - if (ovector[2*i] >= 0 && ovector[2*i+1] > 0) { - if (i == 1 || ovector[2*i] != ovector[2*i-2] - || ovector[2*i-1] != ovector[2*i+1]) - { - if (namecount > 0) - named_tokens(named_idx(i-pos_offset-1)) = - std::string(*(listptr+nidx[i-pos_offset-1])); - cell_t(pos_match++) = - std::string(*(listptr+i)); - } - else - pos_offset++; + if (ovector[2*i] >= 0 && ovector[2*i+1] > 0) + { + if (i == 1 || ovector[2*i] != ovector[2*i-2] + || ovector[2*i-1] != ovector[2*i+1]) + { + if (namecount > 0) + named_tokens(named_idx(i-pos_offset-1)) = + std::string(*(listptr+nidx[i-pos_offset-1])); + cell_t(pos_match++) = + std::string(*(listptr+i)); + } + else + pos_offset++; } m = std::string(*listptr); diff -r 95c3e38098bf -r c48b7048e720 src/DLD-FUNCTIONS/tsearch.cc --- a/src/DLD-FUNCTIONS/tsearch.cc Fri Apr 23 11:28:50 2010 -0700 +++ b/src/DLD-FUNCTIONS/tsearch.cc Fri Apr 23 14:43:41 2010 -0400 @@ -38,20 +38,20 @@ #include "oct-obj.h" #include "parse.h" -inline double max(double a, double b, double c) +inline double max (double a, double b, double c) { if (a < b) - return ( b < c ? c : b ); + return (b < c ? c : b); else - return ( a < c ? c : a ); + return (a < c ? c : a); } -inline double min(double a, double b, double c) +inline double min (double a, double b, double c) { if (a > b) - return ( b > c ? c : b ); + return (b > c ? c : b); else - return ( a > c ? c : a ); + return (a > c ? c : a); } #define REF(x,k,i) x(static_cast(elem((k), (i))) - 1) @@ -78,41 +78,43 @@ octave_value_list retval; const int nargin = args.length (); - if ( nargin != 5 ) { - print_usage (); - return retval; - } + if (nargin != 5) + { + print_usage (); + return retval; + } - const ColumnVector x(args(0).vector_value()); - const ColumnVector y(args(1).vector_value()); - const Matrix elem(args(2).matrix_value()); - const ColumnVector xi(args(3).vector_value()); - const ColumnVector yi(args(4).vector_value()); - - if (error_state) return retval; + const ColumnVector x (args(0).vector_value ()); + const ColumnVector y (args(1).vector_value ()); + const Matrix elem (args(2).matrix_value ()); + const ColumnVector xi (args(3).vector_value ()); + const ColumnVector yi (args(4).vector_value ()); - const octave_idx_type nelem = elem.rows(); + if (error_state) + return retval; + + const octave_idx_type nelem = elem.rows (); - ColumnVector minx(nelem); - ColumnVector maxx(nelem); - ColumnVector miny(nelem); - ColumnVector maxy(nelem); - for(octave_idx_type k = 0; k < nelem; k++) + ColumnVector minx (nelem); + ColumnVector maxx (nelem); + ColumnVector miny (nelem); + ColumnVector maxy (nelem); + for (octave_idx_type k = 0; k < nelem; k++) { - minx(k) = min(REF(x,k,0), REF(x,k,1), REF(x,k,2)) - eps; - maxx(k) = max(REF(x,k,0), REF(x,k,1), REF(x,k,2)) + eps; - miny(k) = min(REF(y,k,0), REF(y,k,1), REF(y,k,2)) - eps; - maxy(k) = max(REF(y,k,0), REF(y,k,1), REF(y,k,2)) + eps; + minx(k) = min (REF (x, k, 0), REF (x, k, 1), REF (x, k, 2)) - eps; + maxx(k) = max (REF (x, k, 0), REF (x, k, 1), REF (x, k, 2)) + eps; + miny(k) = min (REF (y, k, 0), REF (y, k, 1), REF (y, k, 2)) - eps; + maxy(k) = max (REF (y, k, 0), REF (y, k, 1), REF (y, k, 2)) + eps; } - const octave_idx_type np = xi.length(); - ColumnVector values(np); + const octave_idx_type np = xi.length (); + ColumnVector values (np); double x0 = 0.0, y0 = 0.0; double a11 = 0.0, a12 = 0.0, a21 = 0.0, a22 = 0.0, det = 0.0; octave_idx_type k = nelem; // k is a counter of elements - for(octave_idx_type kp = 0; kp < np; kp++) + for (octave_idx_type kp = 0; kp < np; kp++) { const double xt = xi(kp); const double yt = yi(kp); @@ -124,7 +126,7 @@ const double dx2 = yt - y0; const double c1 = (a22 * dx1 - a21 * dx2) / det; const double c2 = (-a12 * dx1 + a11 * dx2) / det; - if ( c1 >= -eps && c2 >= -eps && (c1 + c2) <= (1 + eps)) + if (c1 >= -eps && c2 >= -eps && (c1 + c2) <= (1 + eps)) { values(kp) = double(k+1); continue; @@ -135,16 +137,15 @@ for (k = 0; k < nelem; k++) { OCTAVE_QUIT; - if (xt >= minx(k) && xt <= maxx(k) && - yt >= miny(k) && yt <= maxy(k) ) + if (xt >= minx(k) && xt <= maxx(k) && yt >= miny(k) && yt <= maxy(k)) { // element inside the minimum rectangle: examine it closely - x0 = REF(x,k,0); - y0 = REF(y,k,0); - a11 = REF(x,k,1)-x0; - a12 = REF(y,k,1)-y0; - a21 = REF(x,k,2)-x0; - a22 = REF(y,k,2)-y0; + x0 = REF (x, k, 0); + y0 = REF (y, k, 0); + a11 = REF (x, k, 1) - x0; + a12 = REF (y, k, 1) - y0; + a21 = REF (x, k, 2) - x0; + a22 = REF (y, k, 2) - y0; det = a11 * a22 - a21 * a12; // solve the system