# HG changeset patch # User Rik # Date 1326950142 28800 # Node ID 2fe0f5fa8cc359893f6fe85227aedb053d91d5e2 # Parent a022c04f68cc5f2aa1c8708c2d3c02a1872f0bd5 Replace to-be-deprecated findstr occurrences with strfind. * help.m, textread.m, textscan.m, pkg.m, legend.m, __ezplot__.m, __go_draw_axes__.m, rundemos.m: Replace to-be-deprecated findstr occurrences with strfind. diff --git a/scripts/help/help.m b/scripts/help/help.m --- a/scripts/help/help.m +++ b/scripts/help/help.m @@ -181,5 +181,6 @@ endfunction -%!assert (! isempty (findstr (help ("ls"), "List directory contents"))) +%!assert (! isempty (strfind (help ("ls"), "List directory contents"))) %!error help (42) + diff --git a/scripts/io/textread.m b/scripts/io/textread.m --- a/scripts/io/textread.m +++ b/scripts/io/textread.m @@ -106,10 +106,10 @@ ## Determine EOL from file. Search for EOL candidates in first 3000 chars eol_srch_len = min (length (str), 3000); ## First try DOS (CRLF) - if (! isempty (findstr ("\r\n", str(1 : eol_srch_len)))) + if (! isempty (strfind ("\r\n", str(1 : eol_srch_len)))) eol_char = "\r\n"; ## Perhaps old Macintosh? (CR) - elseif (! isempty (findstr ("\r", str(1 : eol_srch_len)))) + elseif (! isempty (strfind ("\r", str(1 : eol_srch_len)))) eol_char = "\r"; ## Otherwise, use plain UNIX (LF) else diff --git a/scripts/io/textscan.m b/scripts/io/textscan.m --- a/scripts/io/textscan.m +++ b/scripts/io/textscan.m @@ -192,10 +192,10 @@ ## Determine EOL from file. Search for EOL candidates in first 3000 chars eol_srch_len = min (length (str), 3000); ## First try DOS (CRLF) - if (! isempty (findstr ("\r\n", str(1 : eol_srch_len)))) + if (! isempty (strfind ("\r\n", str(1 : eol_srch_len)))) eol_char = "\r\n"; ## Perhaps old Macintosh? (CR) - elseif (! isempty (findstr ("\r", str(1 : eol_srch_len)))) + elseif (! isempty (strfind ("\r", str(1 : eol_srch_len)))) eol_char = "\r"; ## Otherwise, use plain UNIX (LF) else diff --git a/scripts/pkg/pkg.m b/scripts/pkg/pkg.m --- a/scripts/pkg/pkg.m +++ b/scripts/pkg/pkg.m @@ -2006,21 +2006,21 @@ ## Now check if the package is loaded. tmppath = strrep (path(), "\\", "/"); for i = 1:length (installed_pkgs_lst) - if (findstr (tmppath, strrep (installed_pkgs_lst{i}.dir, "\\", "/"))) + if (strfind (tmppath, strrep (installed_pkgs_lst{i}.dir, '\', '/'))) installed_pkgs_lst{i}.loaded = true; else installed_pkgs_lst{i}.loaded = false; endif endfor for i = 1:length (local_packages) - if (findstr (tmppath, strrep (local_packages{i}.dir, "\\", "/"))) + if (strfind (tmppath, strrep (local_packages{i}.dir, '\', '/'))) local_packages{i}.loaded = true; else local_packages{i}.loaded = false; endif endfor for i = 1:length (global_packages) - if (findstr (tmppath, strrep (global_packages{i}.dir, "\\", "/"))) + if (strfind (tmppath, strrep (global_packages{i}.dir, '\', '/'))) global_packages{i}.loaded = true; else global_packages{i}.loaded = false; @@ -2398,7 +2398,7 @@ else isglob = false; endif - pos = findstr (nm, ext); + pos = strfind (nm, ext); if (pos) if (! isglob && (length(nm) - pos(end) != length(ext) - 1)) continue; diff --git a/scripts/plot/legend.m b/scripts/plot/legend.m --- a/scripts/plot/legend.m +++ b/scripts/plot/legend.m @@ -195,7 +195,7 @@ ## Validate the position type is valid outside = false; - inout = findstr (position, "outside"); + inout = strfind (position, "outside"); if (! isempty (inout)) outside = true; position = position(1:inout-1); @@ -442,7 +442,7 @@ endif if (strcmp (position, "default")) position = get (hlegend, "location"); - inout = findstr (position, "outside"); + inout = strfind (position, "outside"); if (! isempty (inout)) outside = true; position = position(1:inout-1); diff --git a/scripts/plot/private/__ezplot__.m b/scripts/plot/private/__ezplot__.m --- a/scripts/plot/private/__ezplot__.m +++ b/scripts/plot/private/__ezplot__.m @@ -117,10 +117,10 @@ endif elseif (isa (fun, "function_handle")) fstr = func2str (fun); - if (length (findstr (fstr, ")")) != 0) - args = regexp (substr (fstr, 3, findstr (fstr, ")")(1) - 3), + if (! isempty (strfind (fstr, ')'))) + args = regexp (substr (fstr, 3, strfind (fstr, ')')(1) - 3), '(\w+)', 'tokens'); - fstr = substr (fstr, findstr (fstr, ")")(1) + 1); + fstr = substr (fstr, strfind (fstr, ')')(1) + 1); else args = {{"x"}}; endif @@ -175,10 +175,10 @@ elseif (isa (funy, "function_handle")) parametric = true; fstry = func2str (funy); - if (length (findstr (fstry, ")")) != 0) - args = regexp (substr (fstry, 3, findstr (fstry, ")")(1) - 3), + if (! isempty (strfind (fstry, ')'))) + args = regexp (substr (fstry, 3, strfind (fstry, ')')(1) - 3), '(\w+)', 'tokens'); - fstry = substr (fstry, findstr (fstry, ")")(1) + 1); + fstry = substr (fstry, strfind (fstry, ')')(1) + 1); else args = {{"y"}}; endif @@ -216,12 +216,12 @@ fstrz = formula (funz); elseif (isa (funz, "function_handle")) fstrz = func2str (funz); - args = regexp (substr (fstrz, 3, findstr (fstrz, ")")(1) - 3), + args = regexp (substr (fstrz, 3, strfind (fstrz, ')')(1) - 3), '(\w+)', 'tokens'); if (length (args) != nargs) error ("%s: excepting a function of %d arguments", func, nargs); endif - fstrz = substr (fstrz, findstr (fstrz, ")")(1) + 1); + fstrz = substr (fstrz, strfind (fstrz, ')')(1) + 1); else error ("%s: parametric plots expect 3 functions", func); endif diff --git a/scripts/plot/private/__go_draw_axes__.m b/scripts/plot/private/__go_draw_axes__.m --- a/scripts/plot/private/__go_draw_axes__.m +++ b/scripts/plot/private/__go_draw_axes__.m @@ -1544,7 +1544,7 @@ keypos = hlgnd.location; if (ischar (keypos)) keypos = lower (keypos); - keyout = findstr (keypos, "outside"); + keyout = strfind (keypos, "outside"); if (! isempty (keyout)) inout = "outside"; keypos = keypos(1:keyout-1); @@ -2206,7 +2206,6 @@ endif if (ischar (ticklabel)) if (size (ticklabel, 1) == 1 && any (ticklabel == "|")) - n = setdiff (findstr (ticklabel, "|"), findstr (ticklabel, '\|')); ticklabel = strsplit (ticklabel, "|"); else ticklabel = cellstr (ticklabel); diff --git a/scripts/testfun/rundemos.m b/scripts/testfun/rundemos.m --- a/scripts/testfun/rundemos.m +++ b/scripts/testfun/rundemos.m @@ -82,8 +82,9 @@ else str = fscanf (fid, "%s"); fclose (fid); - retval = findstr (str, "%!demo"); + retval = strfind (str, "%!demo"); endif endfunction + %!error rundemos ("foo", 1);