# HG changeset patch # User John W. Eaton # Date 1424974420 18000 # Node ID e9f89866074ca4c6737caea1972aa8cb18c7f5ab # Parent 17d647821d6124f7ae022a12197dcd38059ea1d7 maint: Cleanup some .m files to follow Octave coding conventions. * accumarray.m, validateattributes.m, iscolormap.m, __imread__.m, __imwrite__.m, imwrite_filename.m, strread.m, getappdata.m, appearance/annotation.m, shrinkfaces.m, rundemos.m, runtests.m, datenum.m, datestr.m: Break long lines before && and ||. diff -r 17d647821d61 -r e9f89866074c scripts/general/accumarray.m --- a/scripts/general/accumarray.m Thu Feb 26 13:07:04 2015 -0500 +++ b/scripts/general/accumarray.m Thu Feb 26 13:13:40 2015 -0500 @@ -142,8 +142,7 @@ lensubs = cellfun (@length, subs); - if (any (lensubs != lensubs(1)) || - (lenvals > 1 && lenvals != lensubs(1))) + if (any (lensubs != lensubs(1)) || (lenvals > 1 && lenvals != lensubs(1))) error ("accumarray: dimension mismatch"); endif diff -r 17d647821d61 -r e9f89866074c scripts/general/validateattributes.m --- a/scripts/general/validateattributes.m Thu Feb 26 13:07:04 2015 -0500 +++ b/scripts/general/validateattributes.m Thu Feb 26 13:13:40 2015 -0500 @@ -265,14 +265,14 @@ case "nonnegative", problem = any (A(:) < 0); case "nonzero", problem = any (A(:) == 0); case "positive", problem = any (A(:) <= 0); - case "decreasing", problem = (any (isnan (A(:))) || - any (diff (A(:)) >= 0)); - case "increasing", problem = (any (isnan (A(:))) || - any (diff (A(:)) <= 0)); - case "nondecreasing", problem = (any (isnan (A(:))) || - any (diff (A(:)) < 0)); - case "nonincreasing", problem = (any (isnan (A(:))) || - any (diff (A(:)) > 0)); + case "decreasing", problem = (any (isnan (A(:))) + || any (diff (A(:)) >= 0)); + case "increasing", problem = (any (isnan (A(:))) + || any (diff (A(:)) <= 0)); + case "nondecreasing", problem = (any (isnan (A(:))) + || any (diff (A(:)) < 0)); + case "nonincreasing", problem = (any (isnan (A(:))) + || any (diff (A(:)) > 0)); case "size", A_size = size (A); w_size = attr{idx++}; diff -r 17d647821d61 -r e9f89866074c scripts/image/iscolormap.m --- a/scripts/image/iscolormap.m Thu Feb 26 13:07:04 2015 -0500 +++ b/scripts/image/iscolormap.m Thu Feb 26 13:13:40 2015 -0500 @@ -35,9 +35,9 @@ print_usage; endif - retval = (isnumeric (cmap) && isreal (cmap) && - ndims (cmap) == 2 && columns (cmap) == 3 && isa (cmap, "double") && - min (cmap(:)) >= 0 && max (cmap(:)) <= 1); + retval = (isnumeric (cmap) && isreal (cmap) && ndims (cmap) == 2 + && columns (cmap) == 3 && isa (cmap, "double") + && min (cmap(:)) >= 0 && max (cmap(:)) <= 1); endfunction diff -r 17d647821d61 -r e9f89866074c scripts/image/private/__imread__.m --- a/scripts/image/private/__imread__.m Thu Feb 26 13:07:04 2015 -0500 +++ b/scripts/image/private/__imread__.m Thu Feb 26 13:13:40 2015 -0500 @@ -73,8 +73,8 @@ indexes = find (indexes); if (indexes) options.index = varargin{indexes+1}; - if (! is_valid_index_option (options.index) && - ! (ischar (options.index) && strcmpi (options.index, "all"))) + if (! is_valid_index_option (options.index) + && ! (ischar (options.index) && strcmpi (options.index, "all"))) error ("imread: value for %s must be a vector or the string `all'"); endif endif diff -r 17d647821d61 -r e9f89866074c scripts/image/private/__imwrite__.m --- a/scripts/image/private/__imwrite__.m Thu Feb 26 13:07:04 2015 -0500 +++ b/scripts/image/private/__imwrite__.m Thu Feb 26 13:13:40 2015 -0500 @@ -60,9 +60,9 @@ elseif (size (options.alpha, 3) != 1) error ("imwrite: 3rd dimension of matrix for %s must be singleton", param_list{idx}); - elseif (ndims (options.alpha) > 4 || - any (size (options.alpha)([1 2]) != size (img)([1 2])) || - size (options.alpha, 4) != size (img, 4)) + elseif (ndims (options.alpha) > 4 + || any (size (options.alpha)([1 2]) != size (img)([1 2])) + || size (options.alpha, 4) != size (img, 4)) error ("imwrite: matrix for %s must have same dimension as image", param_list{idx}); endif @@ -88,8 +88,8 @@ case "disposalmethod" options.disposalmethod = param_list{idx+1}; - if (! ischar (options.disposalmethod) && - ! iscellstr (options.disposalmethod)) + if (! ischar (options.disposalmethod) + && ! iscellstr (options.disposalmethod)) error ("imwrite: value for %s must be a string or cell array of strings", param_list{idx}); elseif (! iscell (options.disposalmethod)) @@ -115,8 +115,8 @@ case "loopcount" options.loopcount = param_list{idx+1}; if (! isscalar (options.loopcount) || ! isnumeric (options.loopcount) - || (! isinf (options.loopcount) && (options.loopcount < 0 || - options.loopcount > 65535))) + || (! isinf (options.loopcount) + && (options.loopcount < 0 || options.loopcount > 65535))) error ("imwrite: value for %s must be Inf or between 0 and 65535", param_list{idx}); endif diff -r 17d647821d61 -r e9f89866074c scripts/image/private/imwrite_filename.m --- a/scripts/image/private/imwrite_filename.m Thu Feb 26 13:07:04 2015 -0500 +++ b/scripts/image/private/imwrite_filename.m Thu Feb 26 13:13:40 2015 -0500 @@ -48,9 +48,9 @@ ## is a string, we consider it the file extension. Otherwise we will ## extract what we can from the previously found filename. options_idx = filename_idx + 1; - if (numel (varargin) > filename_idx && - rem (length (varargin) - filename_idx, 2) != 0 && - ischar (varargin{filename_idx + 1})) + if (numel (varargin) > filename_idx + && rem (length (varargin) - filename_idx, 2) != 0 + && ischar (varargin{filename_idx + 1})) ext = varargin{filename_idx + 1}; options_idx++; else diff -r 17d647821d61 -r e9f89866074c scripts/io/strread.m --- a/scripts/io/strread.m Thu Feb 26 13:07:04 2015 -0500 +++ b/scripts/io/strread.m Thu Feb 26 13:13:40 2015 -0500 @@ -245,8 +245,8 @@ case "matlab" [comment_start, comment_end] = deal ("%" , "eol_char"); otherwise - if (ischar (varargin{n+1}) || - (numel (varargin{n+1}) == 1 && iscellstr (varargin{n+1}))) + if (ischar (varargin{n+1}) + || (numel (varargin{n+1}) == 1 && iscellstr (varargin{n+1}))) [comment_start, comment_end] = deal (char (varargin{n+1}), "eol_char"); elseif (iscellstr (varargin{n+1}) && numel (varargin{n+1}) == 2) [comment_start, comment_end] = deal (varargin{n+1}{:}); diff -r 17d647821d61 -r e9f89866074c scripts/miscellaneous/getappdata.m --- a/scripts/miscellaneous/getappdata.m Thu Feb 26 13:07:04 2015 -0500 +++ b/scripts/miscellaneous/getappdata.m Thu Feb 26 13:13:40 2015 -0500 @@ -52,8 +52,7 @@ for i = 1:numel (h) value{i} = []; pval = get (h(i)); - if (isfield (pval, "__appdata__") && - isfield (pval.__appdata__, name)) + if (isfield (pval, "__appdata__") && isfield (pval.__appdata__, name)) value{i} = pval.__appdata__.(name); endif endfor diff -r 17d647821d61 -r e9f89866074c scripts/plot/appearance/annotation.m --- a/scripts/plot/appearance/annotation.m Thu Feb 26 13:07:04 2015 -0500 +++ b/scripts/plot/appearance/annotation.m Thu Feb 26 13:13:40 2015 -0500 @@ -190,8 +190,8 @@ y = varargin{2}; varargin(1:2) = []; - if (isnumeric (x) && isnumeric (y) && - length (x) == 2 && length (y) == 2) + if (isnumeric (x) && isnumeric (y) + && length (x) == 2 && length (y) == 2) lims = [x(1) y(1) diff(x) diff(y)]; else error ("annotation: expect 2 elements vectors for X and Y"); diff -r 17d647821d61 -r e9f89866074c scripts/plot/draw/shrinkfaces.m --- a/scripts/plot/draw/shrinkfaces.m Thu Feb 26 13:07:04 2015 -0500 +++ b/scripts/plot/draw/shrinkfaces.m Thu Feb 26 13:13:40 2015 -0500 @@ -76,8 +76,8 @@ colors = []; p = varargin{1}; - if (isscalar (p) && ishandle (p) && nargin < 3 && - strcmp (get (p, "type"), "patch")) + if (isscalar (p) && ishandle (p) && nargin < 3 + && strcmp (get (p, "type"), "patch")) faces = get (p, "Faces"); vertices = get (p, "Vertices"); colors = get (p, "FaceVertexCData"); diff -r 17d647821d61 -r e9f89866074c scripts/testfun/rundemos.m --- a/scripts/testfun/rundemos.m Thu Feb 26 13:07:04 2015 -0500 +++ b/scripts/testfun/rundemos.m Thu Feb 26 13:13:40 2015 -0500 @@ -66,8 +66,8 @@ dirs = {}; for i = 1:numel (flist) f = flist{i}; - if ((length (f) > 2 && strcmpi (f((end-1):end), ".m")) || - (length (f) > 3 && strcmpi (f((end-2):end), ".cc"))) + if ((length (f) > 2 && strcmpi (f((end-1):end), ".m")) + || (length (f) > 3 && strcmpi (f((end-2):end), ".cc"))) f = fullfile (directory, f); if (has_demos (f)) try diff -r 17d647821d61 -r e9f89866074c scripts/testfun/runtests.m --- a/scripts/testfun/runtests.m Thu Feb 26 13:07:04 2015 -0500 +++ b/scripts/testfun/runtests.m Thu Feb 26 13:13:40 2015 -0500 @@ -69,8 +69,8 @@ fflush (stdout); for i = 1:numel (flist) f = flist{i}; - if ((length (f) > 2 && strcmpi (f((end-1):end), ".m")) || - (length (f) > 3 && strcmpi (f((end-2):end), ".cc"))) + if ((length (f) > 2 && strcmpi (f((end-1):end), ".m")) + || (length (f) > 3 && strcmpi (f((end-2):end), ".cc"))) ff = fullfile (directory, f); if (has_tests (ff)) print_test_file_name (f); diff -r 17d647821d61 -r e9f89866074c scripts/time/datenum.m --- a/scripts/time/datenum.m Thu Feb 26 13:07:04 2015 -0500 +++ b/scripts/time/datenum.m Thu Feb 26 13:13:40 2015 -0500 @@ -96,8 +96,8 @@ persistent monthstart = [306; 337; 0; 31; 61; 92; 122; 153; 184; 214; 245; 275]; persistent monthlength = [31; 28; 31; 30; 31; 30; 31; 31; 30; 31; 30; 31]; - if (nargin == 0 || nargin > 6 || - (nargin > 2 && (ischar (year) || iscellstr (year)))) + if (nargin == 0 || nargin > 6 + || (nargin > 2 && (ischar (year) || iscellstr (year)))) print_usage (); endif @@ -130,8 +130,8 @@ if (floor (month) != month) fracmonth = month - floor (month); month = floor (month); - if ((mod (month-1,12) + 1) == 2 && - (floor (year/4) - floor (year/100) + floor (year/400)) != 0) + if ((mod (month-1,12) + 1) == 2 + && (floor (year/4) - floor (year/100) + floor (year/400)) != 0) ## leap year day += fracmonth * 29; else diff -r 17d647821d61 -r e9f89866074c scripts/time/datestr.m --- a/scripts/time/datestr.m Thu Feb 26 13:07:04 2015 -0500 +++ b/scripts/time/datestr.m Thu Feb 26 13:13:40 2015 -0500 @@ -183,8 +183,8 @@ if (columns (date) == 6) ## Make sure that the input really is a datevec. maxdatevec = [Inf, 12, 31, 23, 59, 60]; - if (any (max (date, 1) > maxdatevec) || - any (date(:,1:5) != floor (date(:,1:5)))) + if (any (max (date, 1) > maxdatevec) + || any (date(:,1:5) != floor (date(:,1:5)))) v = datevec (date, p); endif endif