diff scripts/strings/validatestring.m @ 17405:3f0ed69d21c6

Replace unnecessary instances of strncmp with strcmp. * scripts/optimization/optimget.m, scripts/plot/__gnuplot_drawnow__.m, scripts/plot/fill.m, scripts/plot/private/__go_draw_axes__.m, scripts/plot/private/__pie__.m, scripts/plot/private/__print_parse_opts__.m, scripts/plot/private/__quiver__.m, scripts/plot/private/__tight_eps_bbox__.m, scripts/plot/stairs.m, scripts/plot/uigetfile.m, scripts/strings/strsplit.m, scripts/strings/validatestring.m: Replace unnecessary instances of strncmp with strcmp.
author Rik <rik@octave.org>
date Tue, 10 Sep 2013 18:31:39 -0700
parents bc924baa2c4e
children d63878346099
line wrap: on
line diff
--- a/scripts/strings/validatestring.m
+++ b/scripts/strings/validatestring.m
@@ -52,7 +52,7 @@
 ##    blue, black
 ## @end group
 ## @end smallexample
-## 
+##
 ## @seealso{strcmp, strcmpi}
 ## @end deftypefn
 
@@ -70,7 +70,7 @@
     position = varargin{end};
     varargin(end) = [];
   endif
-  
+
   funcname = varname = "";
   char_idx = cellfun ("isclass", varargin, "char");
   n_chararg = sum (char_idx);
@@ -112,7 +112,7 @@
     errstr(end:end+1) = ":\n";
   endif
 
-  matches = strncmpi (str, strarray(:), numel (str));
+  matches = strncmpi (str, strarray(:), length (str));
   nmatches = sum (matches);
   if (nmatches == 0)
     error ("validatestring: %s'%s' does not match any of\n%s", errstr, str,
@@ -124,9 +124,9 @@
     ## If true, choose the shortest.  If not, raise an error.
     match_idx = find (matches);
     match_len = cellfun ("length", strarray(match_idx));
-    [min_len, min_idx] = min (match_len); 
+    [min_len, min_idx] = min (match_len);
     short_str = strarray{match_idx(min_idx)};
-    submatch = strncmpi (short_str, strarray(match_idx), min_len);    
+    submatch = strncmpi (short_str, strarray(match_idx), min_len);
     if (all (submatch))
       str = short_str;
     else