changeset 13293:007ebc128ab5

fix input validation for sortrows * sortrows.m: Don't check values of second argument unless nargin is 2.
author John W. Eaton <jwe@octave.org>
date Fri, 07 Oct 2011 23:04:38 -0400
parents 10eba5cdb5d4
children 7dce7e110511
files scripts/general/sortrows.m
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/general/sortrows.m	Fri Oct 07 23:03:36 2011 -0400
+++ b/scripts/general/sortrows.m	Fri Oct 07 23:04:38 2011 -0400
@@ -37,10 +37,12 @@
     print_usage ();
   endif
 
-  if (! (isnumeric (c) && isvector (c))) 
-    error ("sortrows: C must be a numeric vector");
-  elseif (any (c == 0) || any (abs (c) > columns (A)))
-    error ("sortrows: all elements of C must be in the range [1, columns (A)]");
+  if (nargin == 2)
+    if (! (isnumeric (c) && isvector (c))) 
+      error ("sortrows: C must be a numeric vector");
+    elseif (any (c == 0) || any (abs (c) > columns (A)))
+      error ("sortrows: all elements of C must be in the range [1, columns (A)]");
+    endif
   endif
 
   default_mode = "ascend";