# HG changeset patch # User Ben Abbott # Date 1204184479 18000 # Node ID 3422f39573b18cbab5d4731a92e7fad3f53d61de # Parent 3e107d73aeb4c9315f487f6396a627e3ecabeccc strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m. diff --git a/doc/ChangeLog b/doc/ChangeLog --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2008-02-25 Ben Abbott + + * interpreter/geometryimages.m, interpreter/interpimages.m, + interpreter/plotimages.m, interpreter/sparseimages.m: + Use cstrcat instead of strcat. + 2008-02-22 David Bateman * interpreter/sparse.txi: Remove refernces to spdiag, spcumprod, diff --git a/doc/interpreter/geometryimages.m b/doc/interpreter/geometryimages.m --- a/doc/interpreter/geometryimages.m +++ b/doc/interpreter/geometryimages.m @@ -44,14 +44,14 @@ plot (xc, yc, "g-", "LineWidth", 3); axis([0, 1, 0, 1]); legend ("Delaunay Triangulation", "Voronoi Diagram"); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) elseif (strcmp (nm, "triplot")) rand ("state", 2) x = rand (20, 1); y = rand (20, 1); tri = delaunay (x, y); triplot (tri, x, y); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) elseif (strcmp (nm, "griddata")) rand("state",1); x=2*rand(1000,1)-1; @@ -59,14 +59,14 @@ z=sin(2*(x.^2+y.^2)); [xx,yy]=meshgrid(linspace(-1,1,32)); griddata(x,y,z,xx,yy); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) elseif (strcmp (nm, "convhull")) x = -3:0.05:3; y = abs (sin (x)); k = convhull (x, y); plot (x(k),y(k),'r-',x,y,'b+'); axis ([-3.05, 3.05, -0.05, 1.05]); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) elseif (strcmp (nm, "delaunay")) rand ("state", 1); x = rand (1, 10); @@ -76,7 +76,7 @@ Y = [ y(T(:,1)); y(T(:,2)); y(T(:,3)); y(T(:,1)) ]; axis ([0, 1, 0, 1]); plot(X, Y, "b", x, y, "r*"); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) elseif (strcmp (nm, "inpolygon")) randn ("state", 2); x = randn (100, 1); @@ -86,7 +86,7 @@ in = inpolygon (x, y, vx, vy); plot(vx, vy, x(in), y(in), "r+", x(!in), y(!in), "bo"); axis ([-2, 2, -2, 2]); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) else error ("unrecognized plot requested"); endif @@ -129,14 +129,14 @@ plot (xc, yc, "g-", "LineWidth", 3); axis([0, 1, 0, 1]); legend ("Delaunay Triangulation", "Voronoi Diagram"); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) elseif (strcmp (nm, "triplot")) rand ("state", 2) x = rand (20, 1); y = rand (20, 1); tri = delaunay (x, y); triplot (tri, x, y); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) elseif (strcmp (nm, "griddata")) rand("state",1); x=2*rand(1000,1)-1; @@ -144,7 +144,7 @@ z=sin(2*(x.^2+y.^2)); [xx,yy]=meshgrid(linspace(-1,1,32)); griddata(x,y,z,xx,yy); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) else error ("unrecognized plot requested"); endif @@ -191,7 +191,7 @@ mesh (x, y, z); title ("Sorry, graphics not available because octave was\\ncompiled without the QHULL library."); unwind_protect_cleanup - print (strcat (nm, ".", typ), strcat ("-d", typ)); + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)); bury_output (); end_unwind_protect endif diff --git a/doc/interpreter/interpimages.m b/doc/interpreter/interpimages.m --- a/doc/interpreter/interpimages.m +++ b/doc/interpreter/interpimages.m @@ -32,7 +32,7 @@ plot (ti, yp, 'g', ti, interp1(t, y, ti, 'spline'), 'b', ... ti, interpft (y, k), 'c', t, y, 'r+'); legend ('sin(4t+0.3)cos(3t-0.1','spline','interpft','data'); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) elseif (strcmp (nm, "interpn")) x = y = z = -1:1; f = @(x,y,z) x.^2 - y - z.^2; @@ -42,7 +42,7 @@ [xxi, yyi, zzi] = ndgrid (xi, yi, zi); vi = interpn(x, y, z, v, xxi, yyi, zzi, 'spline'); mesh (zi, yi, squeeze (vi(1,:,:))); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) elseif (strcmp (nm, "interpderiv1")) t = -2:2; dt = 1; @@ -53,7 +53,7 @@ yp = interp1(t,y,ti,'pchip'); plot (ti, ys,'r-', ti, yp,'g-'); legend('spline','pchip', 4); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) elseif (strcmp (nm, "interpderiv2")) t = -2:2; dt = 1; @@ -64,7 +64,7 @@ ddyp = diff(diff(interp1(t,y,ti,'pchip'))./dti)./dti; plot (ti(2:end-1),ddys,'r*', ti(2:end-1),ddyp,'g+'); legend('spline','pchip'); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) endif bury_output (); endfunction diff --git a/doc/interpreter/plotimages.m b/doc/interpreter/plotimages.m --- a/doc/interpreter/plotimages.m +++ b/doc/interpreter/plotimages.m @@ -26,42 +26,42 @@ elseif (strcmp (nm, "plot")) x = -10:0.1:10; plot (x, sin (x)); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) elseif (strcmp (nm, "hist")) hist (randn (10000, 1), 30); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) elseif (strcmp (nm, "errorbar")) x = 0:0.1:10; y = sin (x); yp = 0.1 .* randn (size (x)); ym = -0.1 .* randn (size (x)); errorbar (x, sin (x), ym, yp); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) elseif (strcmp (nm, "polar")) polar (0:0.1:10*pi, 0:0.1:10*pi); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) elseif (strcmp (nm, "mesh")) tx = ty = linspace (-8, 8, 41)'; [xx, yy] = meshgrid (tx, ty); r = sqrt (xx .^ 2 + yy .^ 2) + eps; tz = sin (r) ./ r; mesh (tx, ty, tz); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) elseif (strcmp (nm, "plot3")) t = 0:0.1:10*pi; r = linspace (0, 1, numel (t)); z = linspace (0, 1, numel (t)); plot3 (r.*sin(t), r.*cos(t), z); - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) elseif (strcmp (nm, "extended")) x = 0:0.01:3; plot(x,erf(x)); hold on; plot(x,x,"r"); axis([0, 3, 0, 1]); - text(0.65, 0.6175, strcat('\leftarrow x = {2/\surd\pi {\fontsize{16}', + text(0.65, 0.6175, cstrcat('\leftarrow x = {2/\surd\pi {\fontsize{16}', '\int_{\fontsize{8}0}^{\fontsize{8}x}} e^{-t^2} dt} = 0.6175')) - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) else error ("unrecognized plot requested"); endif diff --git a/doc/interpreter/sparseimages.m b/doc/interpreter/sparseimages.m --- a/doc/interpreter/sparseimages.m +++ b/doc/interpreter/sparseimages.m @@ -51,7 +51,7 @@ [1,1,2,2,3,3,4,4,5,5,6,6], 1, 6, 6); xy = [0,4,8,6,4,2;5,0,5,7,5,7]'; gplot (A, xy) - print (strcat (nm, ".", typ), strcat ("-d", typ)) + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) bury_output (); endfunction @@ -66,16 +66,16 @@ fputs (fid, "+---------------------------------+\n"); fclose (fid); elseif (strcmp (nm, "spmatrix")) - printsparse(a,strcat("spmatrix.",typ)); + printsparse(a,cstrcat("spmatrix.",typ)); else if (!isempty(findstr(octave_config_info ("DEFS"),"HAVE_COLAMD")) && !isempty(findstr(octave_config_info ("DEFS"),"HAVE_CHOLMOD"))) if (strcmp (nm, "spchol")) r1 = chol(a); - printsparse(r1,strcat("spchol.",typ)); + printsparse(r1,cstrcat("spchol.",typ)); elseif (strcmp (nm, "spcholperm")) [r2,p2,q2]=chol(a); - printsparse(r2,strcat("spcholperm.",typ)); + printsparse(r2,cstrcat("spcholperm.",typ)); endif ## printf("Text NNZ: Matrix %d, Chol %d, PermChol %d\n",nnz(a),nnz(r1),nnz(r2)); endif @@ -89,7 +89,7 @@ if (strcmp (nm, "spmatrix")) spy(a); axis("ij") - print(strcat("spmatrix.",typ),strcat("-d",typ)) + print(cstrcat("spmatrix.",typ),cstrcat("-d",typ)) bury_output (); else if (!isempty(findstr(octave_config_info ("DEFS"),"HAVE_COLAMD")) && @@ -98,13 +98,13 @@ r1 = chol(a); spy(r1); axis("ij") - print(strcat("spchol.",typ),strcat("-d",typ)) + print(cstrcat("spchol.",typ),cstrcat("-d",typ)) bury_output (); elseif (strcmp (nm, "spcholperm")) [r2,p2,q2]=chol(a); spy(r2); axis("ij") - print(strcat("spcholperm.",typ),strcat("-d",typ)) + print(cstrcat("spcholperm.",typ),cstrcat("-d",typ)) bury_output (); endif ## printf("Image NNZ: Matrix %d, Chol %d, PermChol %d\n",nnz(a),nnz(r1),nnz(r2)); @@ -227,7 +227,7 @@ plot3 (xelems, yelems, velems); view (10, 10); - print(strcat(nm,".",typ),strcat("-d",typ)) + print(cstrcat(nm,".",typ),cstrcat("-d",typ)) bury_output (); endif endfunction @@ -257,7 +257,7 @@ mesh (x, y, z); title ("Sorry, graphics not available because octave was\\ncompiled without the sparse matrix implementation."); unwind_protect_cleanup - print (strcat (nm, ".", typ), strcat ("-d", typ)); + print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)); bury_output (); end_unwind_protect endif diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,23 @@ +2008-02-25 Ben Abbott + + * control/system/zpout.m, finance/irr.m, general/int2str.m, + general/num2str.m, miscellaneous/bug_report.m, + miscellaneous/copyfile.m, miscellaneous/dir.m, + miscellaneous/edit.m, miscellaneous/fullfile.m, + miscellaneous/mkoctfile.m, miscellaneous/movefile.m, + miscellaneous/tempdir.m, miscellaneous/unpack.m, + path/__extractpath__.m, pkg/pkg.m, plot/__ezplot__.m, + plot/__go_draw_axes__.m, plot/legend.m, plot/print.m, + signal/spectral_adf.m, signal/spectral_xdf.m, + statistics/tests/z_test.m, statistics/tests/z_test_2.m, + strings/Makefile.in, strings/strcat.m, strings/strvcat.m, + testfun/assert.m, testfun/demo.m, testfun/speed.m, + testfun/test.m: Use cstrcat instead of strcat. + + * strings/strcat.m: New compatible version. + + * strings/cstrcat.m: Rename from strings/strcat.m. + 2008-02-25 John W. Eaton * strings/isstrprop.m: New file. @@ -419,7 +439,7 @@ 2007-12-19 Alexander Barth Peter A. Gustafson - * scripts/contourc.m: Allow usage of irregular spaced x, y data. + * plot/contourc.m: Allow usage of irregular spaced x, y data. 2007-12-19 John W. Eaton diff --git a/scripts/control/system/zpout.m b/scripts/control/system/zpout.m --- a/scripts/control/system/zpout.m +++ b/scripts/control/system/zpout.m @@ -58,7 +58,7 @@ if (nzr > 1) numstring = sprintf ("%s %s^%d", numstring, x, nzr); else - numstring = strcat (numstring, x); + numstring = cstrcat (numstring, x); endif endif zer = sortcom (-zer); diff --git a/scripts/finance/irr.m b/scripts/finance/irr.m --- a/scripts/finance/irr.m +++ b/scripts/finance/irr.m @@ -40,7 +40,7 @@ if (! (isvector (p))) error ("irr: p must be a vector"); else - p_string = strcat ("[", sprintf ("%.15f, ", p), "]"); + p_string = cstrcat ("[", sprintf ("%.15f, ", p), "]"); endif if (! isscalar (i)) diff --git a/scripts/general/int2str.m b/scripts/general/int2str.m --- a/scripts/general/int2str.m +++ b/scripts/general/int2str.m @@ -43,9 +43,9 @@ ifmt = get_fmt (x(idx{:}), 0); idx(2) = 2:sz(2); rfmt = get_fmt (x(idx{:}), 2); - fmt = strcat (ifmt, repmat (rfmt, 1, nc-1), "\n") + fmt = cstrcat (ifmt, repmat (rfmt, 1, nc-1), "\n") else - fmt = strcat (get_fmt (x, 0), "\n"); + fmt = cstrcat (get_fmt (x, 0), "\n"); endif tmp = sprintf (fmt, permute (x, [2, 1, 3 : nd])); tmp(end) = ""; diff --git a/scripts/general/num2str.m b/scripts/general/num2str.m --- a/scripts/general/num2str.m +++ b/scripts/general/num2str.m @@ -42,7 +42,7 @@ elseif (iscomplex (x)) if (nargin == 2) if (ischar (arg)) - fmt = strcat (arg, "%-+", arg(2:end), "i"); + fmt = cstrcat (arg, "%-+", arg(2:end), "i"); else if (isnumeric (x) && round (x) == x && abs (x) < (10 .^ arg)) fmt = sprintf ("%%%dd%%-+%ddi ", arg, arg); @@ -88,7 +88,7 @@ x = horzcat (real (x), imag (x)); x = x(idx{:}); - fmt = strcat (deblank (repmat (fmt, 1, nc)), "\n"); + fmt = cstrcat (deblank (repmat (fmt, 1, nc)), "\n"); tmp = sprintf (fmt, permute (x, [2, 1, 3:nd])); ## Put the "i"'s where they are supposed to be. @@ -140,7 +140,7 @@ fmt = "%11.5g"; endif endif - fmt = strcat (deblank (repmat (fmt, 1, columns (x))), "\n"); + fmt = cstrcat (deblank (repmat (fmt, 1, columns (x))), "\n"); nd = ndims (x); tmp = sprintf (fmt, permute (x, [2, 1, 3:nd])); tmp(length (tmp)) = ""; diff --git a/scripts/miscellaneous/bug_report.m b/scripts/miscellaneous/bug_report.m --- a/scripts/miscellaneous/bug_report.m +++ b/scripts/miscellaneous/bug_report.m @@ -50,7 +50,7 @@ endif endif - cmd = strcat ("octave-bug-", OCTAVE_VERSION); + cmd = cstrcat ("octave-bug-", OCTAVE_VERSION); if (length (subject) > 0) cmd = sprintf ("%s -s \"%s\"", cmd, subject); diff --git a/scripts/miscellaneous/copyfile.m b/scripts/miscellaneous/copyfile.m --- a/scripts/miscellaneous/copyfile.m +++ b/scripts/miscellaneous/copyfile.m @@ -60,7 +60,7 @@ endif if (nargin == 3 && strcmp (force, "f")) - cmd = strcat (cmd, " ", cmd_force_flag); + cmd = cstrcat (cmd, " ", cmd_force_flag); endif ## If f1 isn't a cellstr convert it to one. diff --git a/scripts/miscellaneous/dir.m b/scripts/miscellaneous/dir.m --- a/scripts/miscellaneous/dir.m +++ b/scripts/miscellaneous/dir.m @@ -113,7 +113,7 @@ endif endif [dummy, fn, ext] = fileparts (fn); - fn = strcat (fn, ext); + fn = cstrcat (fn, ext); info(i,1).name = fn; lt = localtime (st.mtime); info(i,1).date = strftime ("%d-%b-%Y %T", lt); diff --git a/scripts/miscellaneous/edit.m b/scripts/miscellaneous/edit.m --- a/scripts/miscellaneous/edit.m +++ b/scripts/miscellaneous/edit.m @@ -140,7 +140,7 @@ ## Pick up globals or default them. - persistent FUNCTION = struct ("EDITOR", strcat (EDITOR (), " %s"), + persistent FUNCTION = struct ("EDITOR", cstrcat (EDITOR (), " %s"), "HOME", fullfile (default_home, "octave"), "AUTHOR", default_user(1), "EMAIL", [], @@ -197,7 +197,7 @@ ## Start the editor without a file if no file is given. if (nargin < 1) if (exist (FUNCTION.HOME, "dir") == 7 && (isunix () || ! ispc ())) - system (strcat ("cd \"", FUNCTION.HOME, "\" ; ", + system (cstrcat ("cd \"", FUNCTION.HOME, "\" ; ", sprintf (FUNCTION.EDITOR, "")), [], FUNCTION.MODE); else @@ -271,7 +271,7 @@ ## If the file exists, then edit it. if (FUNCTION.EDITINPLACE) ## Edit in place even if it is protected. - system (sprintf (FUNCTION.EDITOR, strcat ("\"", fileandpath, "\"")), + system (sprintf (FUNCTION.EDITOR, cstrcat ("\"", fileandpath, "\"")), [], FUNCTION.MODE); return; else @@ -280,7 +280,7 @@ fid = fopen (fileandpath, "r+t"); if (fid < 0) from = fileandpath; - fileandpath = strcat (FUNCTION.HOME, from (rindex (from, filesep):end)); + fileandpath = cstrcat (FUNCTION.HOME, from (rindex (from, filesep):end)); [status, msg] = copyfile (from, fileandpath, 1); if (status == 0) error (msg); @@ -288,7 +288,7 @@ else fclose (fid); endif - system (sprintf (FUNCTION.EDITOR, strcat ("\"", fileandpath, "\"")), + system (sprintf (FUNCTION.EDITOR, cstrcat ("\"", fileandpath, "\"")), [], FUNCTION.MODE); return; endif @@ -304,7 +304,7 @@ case {"cc", "m"} 0; otherwise - system (sprintf (FUNCTION.EDITOR, strcat ("\"", fileandpath, "\"")), + system (sprintf (FUNCTION.EDITOR, cstrcat ("\"", fileandpath, "\"")), [], FUNCTION.MODE); return; endswitch @@ -328,25 +328,25 @@ if (isempty (host)) FUNCTION.EMAIL = " "; else - FUNCTION.EMAIL = strcat ("<", default_user(0), "@", host, ">"); + FUNCTION.EMAIL = cstrcat ("<", default_user(0), "@", host, ">"); endif endif ## Fill in the revision string. now = localtime (time); - revs = strcat ("Created: ", strftime ("%Y-%m-%d", now)); + revs = cstrcat ("Created: ", strftime ("%Y-%m-%d", now)); ## Fill in the copyright string. - copyright = strcat (strftime ("Copyright (C) %Y ", now), FUNCTION.AUTHOR); + copyright = cstrcat (strftime ("Copyright (C) %Y ", now), FUNCTION.AUTHOR); ## Fill in the author tag field. - author = strcat ("Author: ", FUNCTION.AUTHOR, " ", FUNCTION.EMAIL); + author = cstrcat ("Author: ", FUNCTION.AUTHOR, " ", FUNCTION.EMAIL); ## Fill in the header. uclicense = toupper (FUNCTION.LICENSE); switch (uclicense) case "GPL" - head = strcat (copyright, "\n\n", "\ + head = cstrcat (copyright, "\n\n", "\ This program is free software; you can redistribute it and/or modify\n\ it under the terms of the GNU General Public License as published by\n\ the Free Software Foundation; either version 2 of the License, or\n\ @@ -361,10 +361,10 @@ along with Octave; see the file COPYING. If not, see\n\ .\ "); - tail = strcat (author, "\n", revs); + tail = cstrcat (author, "\n", revs); case "BSD" - head = strcat (copyright, "\n\n", "\ + head = cstrcat (copyright, "\n\n", "\ This program is free software; redistribution and use in source and\n\ binary forms, with or without modification, are permitted provided that\n\ the following conditions are met:\n\ @@ -387,16 +387,16 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n\ SUCH DAMAGE.\ "); - tail = strcat (author, "\n", revs); + tail = cstrcat (author, "\n", revs); case "PD" head = ""; - tail = strcat (author, "\n", revs, "\n\n", + tail = cstrcat (author, "\n", revs, "\n\n", "This program is granted to the public domain."); otherwise head = ""; - tail = strcat (copyright, "\n\n", FUNCTION.LICENSE, "\n", + tail = cstrcat (copyright, "\n\n", FUNCTION.LICENSE, "\n", author, "\n", revs); endswitch @@ -405,41 +405,41 @@ switch (ext) case {"cc", "C", "cpp"} if (isempty (head)) - comment = strcat ("/*\n", tail, "\n\n*/\n\n"); + comment = cstrcat ("/*\n", tail, "\n\n*/\n\n"); else - comment = strcat ("/*\n", head, "\n\n", tail, "\n\n*/\n\n"); + comment = cstrcat ("/*\n", head, "\n\n", tail, "\n\n*/\n\n"); endif ## If we are shadowing an m-file, paste the code for the m-file. if (any (exists == [2, 103])) - code = strcat ("\\ ", strrep (type (name), "\n", "\n// ")); + code = cstrcat ("\\ ", strrep (type (name), "\n", "\n// ")); else code = " "; endif - body = strcat ("#include \n\n", + body = cstrcat ("#include \n\n", "DEFUN_DLD(", name, ",args,nargout,\"\\\n", name, "\\n\\\n\")\n{\n", " octave_value_list retval;\n", " int nargin = args.length();\n\n", code, "\n return retval;\n}\n"); - text = strcat (comment, body); + text = cstrcat (comment, body); case "m" ## If we are editing a function defined on the fly, paste the ## code. if (any (exists == [2, 103])) body = type (name); else - body = strcat ("function [ ret ] = ", name, " ()\n\nendfunction\n"); + body = cstrcat ("function [ ret ] = ", name, " ()\n\nendfunction\n"); endif if (isempty (head)) - comment = strcat ("## ", name, "\n\n", + comment = cstrcat ("## ", name, "\n\n", "## ", strrep (tail, "\n", "\n## "), "\n\n"); else - comment = strcat ("## ", strrep(head,"\n","\n## "), "\n\n", ... + comment = cstrcat ("## ", strrep(head,"\n","\n## "), "\n\n", ... "## ", name, "\n\n", ... "## ", strrep (tail, "\n", "\n## "), "\n\n"); endif - text = strcat (comment, body); + text = cstrcat (comment, body); endswitch ## Write the initial file (if there is anything to write) @@ -451,7 +451,7 @@ fclose (fid); ## Finally we are ready to edit it! - system (sprintf (FUNCTION.EDITOR, strcat ("\"", fileandpath, "\"")), + system (sprintf (FUNCTION.EDITOR, cstrcat ("\"", fileandpath, "\"")), [], FUNCTION.MODE); endfunction diff --git a/scripts/miscellaneous/fullfile.m b/scripts/miscellaneous/fullfile.m --- a/scripts/miscellaneous/fullfile.m +++ b/scripts/miscellaneous/fullfile.m @@ -40,7 +40,7 @@ elseif (i == nargs && strcmp (tmp, filesep)) tmp = ""; endif - filename = strcat (filename, filesep, tmp); + filename = cstrcat (filename, filesep, tmp); endfor elseif (nargs == 1) filename = varargin{1}; @@ -55,10 +55,10 @@ %!shared fs, fsx, xfs, fsxfs, xfsy %! fs = filesep (); -%! fsx = strcat (fs, "x"); -%! xfs = strcat ("x", fs); -%! fsxfs = strcat (fs, "x", fs); -%! xfsy = strcat ("x", fs, "y"); +%! fsx = cstrcat (fs, "x"); +%! xfs = cstrcat ("x", fs); +%! fsxfs = cstrcat (fs, "x", fs); +%! xfsy = cstrcat ("x", fs, "y"); %!assert (fullfile (""), "") %!assert (fullfile (fs), fs) %!assert (fullfile ("", fs), fs) diff --git a/scripts/miscellaneous/mkoctfile.m b/scripts/miscellaneous/mkoctfile.m --- a/scripts/miscellaneous/mkoctfile.m +++ b/scripts/miscellaneous/mkoctfile.m @@ -125,9 +125,9 @@ shell_script = fullfile (bindir, sprintf ("mkoctfile-%s", OCTAVE_VERSION)); - cmd = strcat ("\"", shell_script, "\""); + cmd = cstrcat ("\"", shell_script, "\""); for i = 1:nargin - cmd = strcat (cmd, " \"", varargin{i}, "\""); + cmd = cstrcat (cmd, " \"", varargin{i}, "\""); endfor status = system (cmd); diff --git a/scripts/miscellaneous/movefile.m b/scripts/miscellaneous/movefile.m --- a/scripts/miscellaneous/movefile.m +++ b/scripts/miscellaneous/movefile.m @@ -59,7 +59,7 @@ endif if (nargin == 3 && strcmp (force, "f")) - cmd = strcat (cmd, " ", cmd_force_flag); + cmd = cstrcat (cmd, " ", cmd_force_flag); endif ## If f1 isn't a cellstr convert it to one. diff --git a/scripts/miscellaneous/tempdir.m b/scripts/miscellaneous/tempdir.m --- a/scripts/miscellaneous/tempdir.m +++ b/scripts/miscellaneous/tempdir.m @@ -29,7 +29,7 @@ endif if (! strcmp (dirname(end), filesep)) - strcat (dirname, filesep); + cstrcat (dirname, filesep); endif if (! isdir (dirname)) diff --git a/scripts/miscellaneous/unpack.m b/scripts/miscellaneous/unpack.m --- a/scripts/miscellaneous/unpack.m +++ b/scripts/miscellaneous/unpack.m @@ -60,7 +60,7 @@ [tmppathstr, tmpname, tmpext] = fileparts (name); if (strcmpi (tmpext, ".tar")) name = tmpname; - ext = strcat (tmpext, ext); + ext = cstrcat (tmpext, ext); endif endif @@ -71,7 +71,7 @@ urlfile = file; ## FIXME -- should we name the file that we download with the ## same file name as the url requests? - tmpfile = strcat (tmpnam (), ext); + tmpfile = cstrcat (tmpnam (), ext); [file, success, msg] = urlwrite (urlfile, tmpfile); if (! success) error ("unpack: could not get \"%s\": %s", urlfile, msg); @@ -172,7 +172,7 @@ unwind_protect cd (directory); - [status, output] = system (sprintf (strcat (command, " 2>&1"), file)); + [status, output] = system (sprintf (cstrcat (command, " 2>&1"), file)); unwind_protect_cleanup cd (origdir); end_unwind_protect diff --git a/scripts/path/__extractpath__.m b/scripts/path/__extractpath__.m --- a/scripts/path/__extractpath__.m +++ b/scripts/path/__extractpath__.m @@ -84,7 +84,7 @@ error ("savepath: unable to parse file, %s", savefile); elseif (startline > 0) ## Undo doubling of single quote characters performed by savepath. - specifiedpath = strrep (regexprep (strcat (filelines(startline:endline){:}), + specifiedpath = strrep (regexprep (cstrcat (filelines(startline:endline){:}), " *path *\\('(.*)'\\); *", "$1"), "''", "'"); else diff --git a/scripts/pkg/pkg.m b/scripts/pkg/pkg.m --- a/scripts/pkg/pkg.m +++ b/scripts/pkg/pkg.m @@ -431,7 +431,7 @@ wd = pwd (); unwind_protect cd (prefix); - dirlist = glob (cellfun(@(x) strcat(x, '-*'), files, 'UniformOutput', 0)); + dirlist = glob (cellfun(@(x) cstrcat(x, '-*'), files, 'UniformOutput', 0)); unwind_protect_cleanup cd (wd); end_unwind_protect @@ -445,7 +445,7 @@ if (exist (descfile, "file")) desc = get_description (descfile); desc.dir = fullfile (prefix, dirlist{k}); - desc.archprefix = fullfile (archprefix, strcat (desc.name, "-", + desc.archprefix = fullfile (archprefix, cstrcat (desc.name, "-", desc.version)); if (auto != 0) if (exist (fullfile (desc.dir, "packinfo", ".autoload"), "file")) @@ -621,10 +621,10 @@ endif ## Set default installation directory - desc.dir = fullfile (prefix, strcat (desc.name, "-", desc.version)); + desc.dir = fullfile (prefix, cstrcat (desc.name, "-", desc.version)); ## Set default architectire dependent installation directory - desc.archprefix = fullfile (archprefix, strcat (desc.name, "-", + desc.archprefix = fullfile (archprefix, cstrcat (desc.name, "-", desc.version)); ## Save desc @@ -675,7 +675,7 @@ ok = false; for i = 1:length (bad_deps) dep = bad_deps{i}; - error_text = strcat (error_text, " ", desc.name, " needs ", + error_text = cstrcat (error_text, " ", desc.name, " needs ", dep.package, " ", dep.operator, " ", dep.version, "\n"); endfor @@ -883,7 +883,7 @@ if (! isempty (bad_deps)) for i = 1:length (bad_deps) dep = bad_deps{i}; - error_text = strcat (error_text, " ", desc.name, " needs ", + error_text = cstrcat (error_text, " ", desc.name, " needs ", dep.package, " ", dep.operator, " ", dep.version, "\n"); endfor @@ -1113,7 +1113,7 @@ if (exist (fullfile (pack.name, "inst", "bin"), "dir")) movefile (fullfile (pack.name, "inst", "bin"), pack.name); endif - archdir = fullfile (pack.archprefix, strcat (pack.name, "-", + archdir = fullfile (pack.archprefix, cstrcat (pack.name, "-", pack.version), getarch ()); if (exist (archdir, "dir")) if (exist (fullfile (pack.name, "inst", "PKG_ADD"), "file")) @@ -1140,7 +1140,7 @@ fullfile (pack.name, "PKG_DEL")); endif endif - tfile = strcat (pack.name, "-", pack.version, ".tar"); + tfile = cstrcat (pack.name, "-", pack.version, ".tar"); tar (tfile, pack.name); try gzip (tfile); @@ -1205,18 +1205,18 @@ if (exist (fullfile (src, "configure"), "file")) flags = ""; if (isempty (getenv ("CC"))) - flags = strcat (flags, " CC=\"", octave_config_info ("CC"), "\""); + flags = cstrcat (flags, " CC=\"", octave_config_info ("CC"), "\""); endif if (isempty (getenv ("CXX"))) - flags = strcat (flags, " CXX=\"", octave_config_info ("CXX"), "\""); + flags = cstrcat (flags, " CXX=\"", octave_config_info ("CXX"), "\""); endif if (isempty (getenv ("AR"))) - flags = strcat (flags, " AR=\"", octave_config_info ("AR"), "\""); + flags = cstrcat (flags, " AR=\"", octave_config_info ("AR"), "\""); endif if (isempty (getenv ("RANLIB"))) - flags = strcat (flags, " RANLIB=\"", octave_config_info ("RANLIB"), "\""); + flags = cstrcat (flags, " RANLIB=\"", octave_config_info ("RANLIB"), "\""); endif - [status, output] = shell (strcat ("cd ", src, "; ./configure --prefix=\"", + [status, output] = shell (cstrcat ("cd ", src, "; ./configure --prefix=\"", desc.dir, "\"", flags)); if (status != 0) rm_rf (desc.dir); @@ -1229,7 +1229,7 @@ ## make if (exist (fullfile (src, "Makefile"), "file")) - [status, output] = shell (strcat ("export INSTALLDIR=\"", desc.dir, + [status, output] = shell (cstrcat ("export INSTALLDIR=\"", desc.dir, "\"; make -C ", src)); if (status != 0) rm_rf (desc.dir); @@ -1276,11 +1276,11 @@ filenames = sprintf (fullfile (src, "%s "), m.name); endif if (length (oct) > 0) - filenames = strcat (filenames, " ", + filenames = cstrcat (filenames, " ", sprintf (fullfile (src, "%s "), oct.name)); endif if (length (mex) > 0) - filenames = strcat (filenames, " ", + filenames = cstrcat (filenames, " ", sprintf (fullfile (src, "%s "), mex.name)); endif filenames = split_by (filenames, " "); @@ -1340,12 +1340,12 @@ if (ln > 0) t = regexp (ln, pat, "tokens"); if (! isempty (t)) - pkg = strcat (pkg, "\n", t{1}{1}); + pkg = cstrcat (pkg, "\n", t{1}{1}); endif endif endwhile if (! isempty (pkg)) - pkg = strcat (pkg, "\n"); + pkg = cstrcat (pkg, "\n"); endif fclose (fid); endif @@ -1358,7 +1358,7 @@ ## architecture dependent directory so that the autoload/mfilename ## commands work as expected. The only part that doesn't is the ## part in the main directory. - archdir = fullfile (getarchprefix (desc), strcat (desc.name, "-", + archdir = fullfile (getarchprefix (desc), cstrcat (desc.name, "-", desc.version), getarch ()); if (exist (getarchdir (desc, global_install), "dir")) archpkg = fullfile (getarchdir (desc, global_install), nm); @@ -1611,7 +1611,7 @@ elseif (isspace(line(1))) ## Continuation lines if (exist ("keyword", "var") && isfield (desc, keyword)) - desc.(keyword) = strcat (desc.(keyword), " ", rstrip(line)); + desc.(keyword) = cstrcat (desc.(keyword), " ", rstrip(line)); endif else ## Keyword/value pair @@ -1956,10 +1956,10 @@ first_char = length (cur_dir) - max_dir_length + 4; first_filesep = strfind (cur_dir(first_char:end), filesep()); if (! isempty (first_filesep)) - cur_dir = strcat ("...", + cur_dir = cstrcat ("...", cur_dir((first_char + first_filesep(1) - 1):end)); else - cur_dir = strcat ("...", cur_dir(first_char:end)); + cur_dir = cstrcat ("...", cur_dir(first_char:end)); endif endif if (installed_pkgs_lst{idx(i)}.loaded) @@ -2114,7 +2114,7 @@ endfunction function arch = getarch () - persistent _arch = strcat (octave_config_info("canonical_host_type"), ... + persistent _arch = cstrcat (octave_config_info("canonical_host_type"), ... "-", octave_config_info("api_version")); arch = _arch; endfunction @@ -2122,7 +2122,7 @@ function archprefix = getarchprefix (desc, global_install) if ((nargin == 2 && global_install) || (nargin < 2 && issuperuser ())) archprefix = fullfile (octave_config_info ("libexecdir"), "octave", - "packages", strcat(desc.name, "-", desc.version)); + "packages", cstrcat(desc.name, "-", desc.version)); else archprefix = desc.dir; endif @@ -2153,7 +2153,7 @@ endif endif if (have_sh) - [status, output] = system (strcat ("sh.exe -c \"", cmd, "\"")); + [status, output] = system (cstrcat ("sh.exe -c \"", cmd, "\"")); else error ("Can not find the command shell") endif @@ -2207,13 +2207,13 @@ ndir = installed_pkgs_lst{i}.dir; dirs{end+1} = ndir; if (exist (fullfile (dirs{end}, "bin"), "dir")) - execpath = strcat (fullfile (dirs{end}, "bin"), ":", execpath); + execpath = cstrcat (fullfile (dirs{end}, "bin"), ":", execpath); endif tmpdir = getarchdir (installed_pkgs_lst{i}); if (exist (tmpdir, "dir")) dirs{end + 1} = tmpdir; if (exist (fullfile (dirs{end}, "bin"), "dir")) - execpath = strcat (fullfile (dirs{end}, "bin"), ":", execpath); + execpath = cstrcat (fullfile (dirs{end}, "bin"), ":", execpath); endif endif endfor diff --git a/scripts/plot/__ezplot__.m b/scripts/plot/__ezplot__.m --- a/scripts/plot/__ezplot__.m +++ b/scripts/plot/__ezplot__.m @@ -20,7 +20,7 @@ function [h, needusage] = __ezplot__ (pfunc, varargin) - func = strcat ("ez", pfunc); + func = cstrcat ("ez", pfunc); if (strncmp (pfunc, "contour", 7)) iscontour = true; else @@ -254,7 +254,7 @@ '\./', '/'), '[\.]*\*', ''); fstrz = regexprep (regexprep (regexprep (fstrz,'\.\^\s*','^'), '\./', '/'), '[\.]*\*', ''); - fstr = strcat ("[",fstrx,",",fstry,",",fstrz,"]"); + fstr = cstrcat ("[",fstrx,",",fstry,",",fstrz,"]"); else if (isplot3) needusage = true; diff --git a/scripts/plot/__go_draw_axes__.m b/scripts/plot/__go_draw_axes__.m --- a/scripts/plot/__go_draw_axes__.m +++ b/scripts/plot/__go_draw_axes__.m @@ -395,7 +395,7 @@ titlespec{data_idx} = "title \"\""; else tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel", have_newer_gnuplot)); - titlespec{data_idx} = strcat ("title \"", tmp, "\""); + titlespec{data_idx} = cstrcat ("title \"", tmp, "\""); endif usingclause{data_idx} = ""; errbars = ""; @@ -547,7 +547,7 @@ titlespec{data_idx} = "title \"\""; else tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel", have_newer_gnuplot)); - titlespec{data_idx} = strcat ("title \"", tmp, "\""); + titlespec{data_idx} = cstrcat ("title \"", tmp, "\""); endif usingclause{data_idx} = ""; if (isfield (obj, "facecolor")) @@ -849,7 +849,7 @@ titlespec{data_idx} = "title \"\""; else tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel", have_newer_gnuplot)); - titlespec{data_idx} = strcat ("title \"", tmp, "\""); + titlespec{data_idx} = cstrcat ("title \"", tmp, "\""); endif usingclause{data_idx} = ""; if (have_newer_gnuplot || isnan (typ)) @@ -1474,7 +1474,7 @@ if (nd == 2) nan_elts = find (sum (isnan (data))); - fmt = strcat (repmat ("%.15g ", 1, rows (data)), "\n"); + fmt = cstrcat (repmat ("%.15g ", 1, rows (data)), "\n"); if (isempty (nan_elts)) fprintf (plot_stream, fmt, data); else @@ -1654,17 +1654,17 @@ if (! isempty(t.fontangle) && (strcmpi (t.fontangle, "italic") || strcmpi (t.fontangle, "oblique"))) - f = strcat (f, "-bolditalic"); + f = cstrcat (f, "-bolditalic"); it = true; bld = true; else - f = strcat (f, "-bold"); + f = cstrcat (f, "-bold"); bld = true; endif elseif (! isempty(t.fontangle) && (strcmpi (t.fontangle, "italic") || strcmpi (t.fontangle, "oblique"))) - f = strcat (f, "-italic"); + f = cstrcat (f, "-italic"); it = true; endif if (isempty (t.fontsize)) @@ -1694,7 +1694,7 @@ str = __tex2enhanced__ (str, fnt, it, bld); if (! have_newer_gnuplot) ## Set the font to work around gnuplot 4.0 X11 enhanced terminal bug - str = strcat ('{/', f, ' ', str, ' }'); + str = cstrcat ('{/', f, ' ', str, ' }'); endif elseif (strcmp (obj.interpreter, "latex")) if (! warned_latex) @@ -1714,7 +1714,7 @@ for i = length (s) : -1 : 1 ## special case for "\0" and replace with "{/Symbol \306}' if (strncmp (m{i}, '\0', 2)) - str = strcat (str(1:s(i) - 1), '{/Symbol \306}', str(s(i) + 2:end)); + str = cstrcat (str(1:s(i) - 1), '{/Symbol \306}', str(s(i) + 2:end)); else f = m{i}(2:end); if (isfield (sym, f)) @@ -1729,27 +1729,27 @@ ##elseif (it) ## g = regexprep (g, '/Symbol', '/Symbol-italic'); ##endif - str = strcat (str(1:s(i) - 1), g, str(e(i) + 1:end)); + str = cstrcat (str(1:s(i) - 1), g, str(e(i) + 1:end)); elseif (strncmp (f, "rm", 2)) bld = false; it = false; - str = strcat (str(1:s(i) - 1), '/', fnt, ' ', str(s(i) + 3:end)); + str = cstrcat (str(1:s(i) - 1), '/', fnt, ' ', str(s(i) + 3:end)); elseif (strncmp (f, "it", 2) || strncmp (f, "sl", 2)) it = true; if (bld) - str = strcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', + str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', str(s(i) + 3:end)); else - str = strcat (str(1:s(i) - 1), '/', fnt, '-italic ', + str = cstrcat (str(1:s(i) - 1), '/', fnt, '-italic ', str(s(i) + 3:end)); endif elseif (strncmp (f, "bf", 2)) bld = true; if (it) - str = strcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', + str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', str(2(i) + 3:end)); else - str = strcat (str(1:s(i) - 1), '/', fnt, '-bold ', + str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bold ', str(s(i) + 3:end)); endif elseif (strcmp (f, "color")) @@ -1758,7 +1758,7 @@ if (isempty (d)) warning ('syntax error in \color argument'); else - str = strcat (str(1:s(i) - 1), str(e(i) + d + 1:end)); + str = cstrcat (str(1:s(i) - 1), str(e(i) + d + 1:end)); endif elseif(strcmp (f, "fontname")) b1 = strfind(str(e(i) + 1:end),'{'); @@ -1766,7 +1766,7 @@ if (isempty(b1) || isempty(b2)) warning ('syntax error in \fontname argument'); else - str = strcat (str(1:s(i) - 1), '/', + str = cstrcat (str(1:s(i) - 1), '/', str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', str(e(i) + b2(1) + 1:end)); endif @@ -1776,7 +1776,7 @@ if (isempty(b1) || isempty(b2)) warning ('syntax error in \fontname argument'); else - str = strcat (str(1:s(i) - 1), '/=', + str = cstrcat (str(1:s(i) - 1), '/=', str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', str(e(i) + b2(1) + 1:end)); endif @@ -1796,7 +1796,7 @@ ##elseif (it) ## g = regexprep (g, '/Symbol', '/Symbol-italic'); ##endif - str = strcat (str(1:s(i) - 1), g, + str = cstrcat (str(1:s(i) - 1), g, str(s(i) + length (flds{j}) + 1:end)); break; endif @@ -1854,15 +1854,15 @@ if (length_string (str(s(i)+p+2:s(i)+p+l1-1)) <= length_string(str(s(i+1)+p+2:s(i+1)+p+l2-1))) ## shortest already first! - str = strcat (str(1:s(i)+p-1), "@", str(s(i)+p:end)); + str = cstrcat (str(1:s(i)+p-1), "@", str(s(i)+p:end)); else ## Have to swap sub/super-script to get shortest first - str = strcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+l2), + str = cstrcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+l2), str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+l2+1:end)); endif else ## Have to swap sub/super-script to get shortest first - str = strcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+1), + str = cstrcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+1), str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+2:end)); endif i += 2; @@ -1873,7 +1873,7 @@ else if (s(i+1) == s(i) + 2) ## shortest already first! - str = strcat (str(1:s(i)+p-1), "@", str(s(i)+p:end)); + str = cstrcat (str(1:s(i)+p-1), "@", str(s(i)+p:end)); p ++; i += 2; else diff --git a/scripts/plot/legend.m b/scripts/plot/legend.m --- a/scripts/plot/legend.m +++ b/scripts/plot/legend.m @@ -210,7 +210,7 @@ %! labels = {}; %! for i = 1:5 %! plot(1:100, i + rand(100,1)); hold on; -%! labels = {labels{:}, strcat("Signal ", num2str(i))}; +%! labels = {labels{:}, cstrcat("Signal ", num2str(i))}; %! endfor; hold off; %! title("Signals with random offset and uniform noise") %! xlabel("Sample Nr [k]"); ylabel("Amplitude [V]"); diff --git a/scripts/plot/print.m b/scripts/plot/print.m --- a/scripts/plot/print.m +++ b/scripts/plot/print.m @@ -187,9 +187,9 @@ doprint = isempty (name); if (doprint) if (isempty (devopt)) - printname = strcat (tmpnam, ".ps"); + printname = cstrcat (tmpnam, ".ps"); else - printname = strcat (tmpnam, ".", devopt); + printname = cstrcat (tmpnam, ".", devopt); endif name = printname; endif @@ -209,7 +209,7 @@ dev = "epslatex"; ## gnuplot 4.0 wants ".eps" in the output name if (compare_versions (__gnuplot_version__, "4.2", "<")) - name = strcat (name(1:dot), "eps"); + name = cstrcat (name(1:dot), "eps"); endif elseif (strcmp (dev, "ill")) dev = "aifm"; @@ -226,12 +226,12 @@ [idx, errmsg] = cellidx (dev_list, dev); if (! idx) if (! isempty (devopt)) - convertname = strcat (devopt, ":", name); + convertname = cstrcat (devopt, ":", name); else convertname = name; endif dev = "epsc"; - name = strcat (tmpnam, ".eps"); + name = cstrcat (tmpnam, ".eps"); endif if (strcmp (dev, "ps") || strcmp (dev, "ps2") ... @@ -257,33 +257,33 @@ if (dev(1) == "e") options = "eps "; else - options = strcat (orientation, " "); + options = cstrcat (orientation, " "); endif termn = "postscript"; endif if (any (dev == "c") || use_color > 0) if (force_solid < 0) - options = strcat (options, "color dashed "); + options = cstrcat (options, "color dashed "); else - options = strcat (options, "color solid "); + options = cstrcat (options, "color solid "); endif else if (force_solid > 0) - options = strcat (options, "mono solid "); + options = cstrcat (options, "mono solid "); else - options = strcat (options, "mono dashed "); + options = cstrcat (options, "mono dashed "); endif endif if (! isempty (font)) - options = strcat (options, "\"", font, "\" "); + options = cstrcat (options, "\"", font, "\" "); endif if (! isempty (fontsize)) - options = strcat (options, " ", fontsize); + options = cstrcat (options, " ", fontsize); endif - new_terminal = strcat (termn, " ", options); + new_terminal = cstrcat (termn, " ", options); elseif (strcmp (dev, "aifm") || strcmp (dev, "corel")) ## Adobe Illustrator, CorelDraw @@ -293,13 +293,13 @@ options = " mono"; endif if (! isempty (font)) - options = strcat (options, " \"", font, "\""); + options = cstrcat (options, " \"", font, "\""); endif if (! isempty (fontsize)) - options = strcat (options, " ", fontsize); + options = cstrcat (options, " ", fontsize); endif - new_terminal = strcat (dev, " ", options); + new_terminal = cstrcat (dev, " ", options); elseif (strcmp (dev, "fig")) ## XFig @@ -309,12 +309,12 @@ else options = " mono"; endif - options = strcat (options, " ", special_flag); + options = cstrcat (options, " ", special_flag); if (! isempty (fontsize)) - options = strcat (options, " fontsize ", fontsize); + options = cstrcat (options, " fontsize ", fontsize); endif - new_terminal = strcat ("fig ", options); + new_terminal = cstrcat ("fig ", options); elseif (strcmp (dev, "emf")) @@ -326,16 +326,16 @@ options = " mono"; endif if (force_solid >= 0) - options = strcat (options, " solid"); + options = cstrcat (options, " solid"); endif if (! isempty (font)) - options = strcat (options, " \"", font, "\""); + options = cstrcat (options, " \"", font, "\""); endif if (! isempty (fontsize)) - options = strcat (options, " ", fontsize); + options = cstrcat (options, " ", fontsize); endif - new_terminal = strcat ("emf ", options); + new_terminal = cstrcat ("emf ", options); elseif (strcmp (dev, "png") || strcmp (dev, "pbm")) ## Portable network graphics, PBMplus @@ -356,9 +356,9 @@ if (isempty (size)) options = " large"; else - options = strcat (" size ", size); + options = cstrcat (" size ", size); endif - new_terminal = strcat (dev, options); + new_terminal = cstrcat (dev, options); elseif (strcmp (dev, "dxf") || strcmp (dev, "mf") || strcmp (dev, "hpgl")) ## AutoCad DXF, METAFONT, HPGL @@ -368,9 +368,9 @@ ## SVG options = ""; if (! isempty (size)) - options = strcat (" size ", size); + options = cstrcat (" size ", size); endif - new_terminal = strcat ("svg", options); + new_terminal = cstrcat ("svg", options); elseif (strcmp (dev, "pdf")) ## Portable Document format @@ -381,18 +381,18 @@ options = "mono"; endif if (force_solid > 0) - options = strcat (options, " solid"); + options = cstrcat (options, " solid"); elseif (force_solid < 0) - options = strcat (options, " dashed"); + options = cstrcat (options, " dashed"); endif if (! isempty (font)) - options = strcat (options, "\"", font, "\" "); + options = cstrcat (options, "\"", font, "\" "); endif if (! isempty (fontsize)) - options = strcat (options, " ", fontsize); + options = cstrcat (options, " ", fontsize); endif - new_terminal = strcat ("pdf ", options); + new_terminal = cstrcat ("pdf ", options); endif diff --git a/scripts/signal/spectral_adf.m b/scripts/signal/spectral_adf.m --- a/scripts/signal/spectral_adf.m +++ b/scripts/signal/spectral_adf.m @@ -48,7 +48,7 @@ if (nargin == 1) w = triangle_lw (cr, b); else - win = str2func (strcat (win, "_lw")); + win = str2func (cstrcat (win, "_lw")); w = feval (win, cr, b); endif diff --git a/scripts/signal/spectral_xdf.m b/scripts/signal/spectral_xdf.m --- a/scripts/signal/spectral_xdf.m +++ b/scripts/signal/spectral_xdf.m @@ -47,7 +47,7 @@ if (nargin == 1) w = triangle_sw (xr, b); else - win = str2func (strcat (win, "_sw")); + win = str2func (cstrcat (win, "_sw")); w = feval (win, xr, b); endif diff --git a/scripts/statistics/tests/z_test.m b/scripts/statistics/tests/z_test.m --- a/scripts/statistics/tests/z_test.m +++ b/scripts/statistics/tests/z_test.m @@ -79,7 +79,7 @@ endif if (nargout == 0) - s = strcat ("Z-test of mean(x) == %g against mean(x) %s %g,\n", + s = cstrcat ("Z-test of mean(x) == %g against mean(x) %s %g,\n", "with known var(x) == %g:\n", " pval = %g\n"); printf (s, m, alt, m, v, pval); diff --git a/scripts/statistics/tests/z_test_2.m b/scripts/statistics/tests/z_test_2.m --- a/scripts/statistics/tests/z_test_2.m +++ b/scripts/statistics/tests/z_test_2.m @@ -79,7 +79,7 @@ endif if (nargout == 0) - s = strcat ("Two-sample Z-test of mean(x) == mean(y) against ", + s = cstrcat ("Two-sample Z-test of mean(x) == mean(y) against ", "mean(x) %s mean(y),\n", "with known var(x) == %g and var(y) == %g:\n", " pval = %g\n"); diff --git a/scripts/strings/Makefile.in b/scripts/strings/Makefile.in --- a/scripts/strings/Makefile.in +++ b/scripts/strings/Makefile.in @@ -36,7 +36,7 @@ SOURCES = base2dec.m bin2dec.m blanks.m deblank.m dec2base.m \ dec2bin.m dec2hex.m findstr.m hex2dec.m index.m isletter.m \ lower.m mat2str.m rindex.m split.m str2double.m str2mat.m \ - str2num.m strcat.m strcmpi.m strfind.m strjust.m strmatch.m \ + str2num.m strcat.m cstrcat.m strcmpi.m strfind.m strjust.m strmatch.m \ strncmpi.m strrep.m strtok.m strtrim.m strtrunc.m strvcat.m \ substr.m upper.m diff --git a/scripts/strings/strcat.m b/scripts/strings/cstrcat.m copy from scripts/strings/strcat.m copy to scripts/strings/cstrcat.m --- a/scripts/strings/strcat.m +++ b/scripts/strings/cstrcat.m @@ -18,13 +18,13 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {} strcat (@var{s1}, @var{s2}, @dots{}) +## @deftypefn {Function File} {} cstrcat (@var{s1}, @var{s2}, @dots{}) ## Return a string containing all the arguments concatenated. For example, ## ## @example ## @group ## s = [ "ab"; "cde" ]; -## strcat (s, s, s) +## cstrcat (s, s, s) ## @result{} "ab ab ab " ## "cdecdecde" ## @end group @@ -33,7 +33,7 @@ ## Author: jwe -function st = strcat (varargin) +function st = cstrcat (varargin) if (nargin > 0) @@ -47,13 +47,7 @@ warning (tmp.state, "Octave:empty-list-elements"); end_unwind_protect else - for i = 1:nargin - tmp = varargin{i}; - if (! (iscellstr (tmp) || ischar (tmp))) - error ("strcat: all arguments must be strings or cell arrays of strings"); - endif - endfor - st = strcat_cell (varargin); + error ("cstrcat: expecting arguments to character strings"); endif else print_usage (); @@ -61,25 +55,16 @@ endfunction -function st = strcat_cell (varargin) - ## All args must be same size or scalars. - ## See the xtest below for expected behavior. - error ("strcat: concatenating cell arrays of strings not implemented"); -endfunction - ## test the dimensionality ## 1d -%!assert(strcat("ab ", "ab "), "ab ab ") +%!assert(cstrcat("ab ", "ab "), "ab ab ") ## 2d -%!assert(strcat(["ab ";"cde"], ["ab ";"cde"]), ["ab ab ";"cdecde"]) - -%!assert((strcmp (strcat ("foo", "bar"), "foobar") -%! && strcmp (strcat (["a"; "bb"], ["foo"; "bar"]), ["a foo"; "bbbar"]))); +%!assert(cstrcat(["ab ";"cde"], ["ab ";"cde"]), ["ab ab ";"cdecde"]) -%!xtest -%! assert(all (strcmp (strcat ("a", {"bc", "de"}, "f"), {"abcf", "adef"}))) +%!assert((strcmp (cstrcat ("foo", "bar"), "foobar") +%! && strcmp (cstrcat (["a"; "bb"], ["foo"; "bar"]), ["a foo"; "bbbar"]))); -%!error strcat (); +%!error cstrcat (); -%!error strcat (1, 2); +%!error cstrcat (1, 2); diff --git a/scripts/strings/strcat.m b/scripts/strings/strcat.m --- a/scripts/strings/strcat.m +++ b/scripts/strings/strcat.m @@ -36,24 +36,51 @@ function st = strcat (varargin) if (nargin > 0) + if (nargin == 1) + st = varargin{1}; + elseif (nargin > 1) + ## Convert to cells of strings + numstrs(nargin) = 0; + dims{nargin} = []; + allchar = true; + for nv = 1:nargin + if (ischar (varargin{nv})) + varargin{nv} = cellstr (varargin{nv}); + elseif (iscell (varargin{nv})) + allchar = false; + else + error ("strcat: inputs must be strings or cells of strings.") + endif + dims{nv} = size (varargin{nv}); + numstrs(nv) = numel (varargin{nv}); + endfor - if (iscellstr (varargin)) - ## All arguments are character strings. - unwind_protect - tmp = warning ("query", "Octave:empty-list-elements"); - warning ("off", "Octave:empty-list-elements"); - st = [varargin{:}]; - unwind_protect_cleanup - warning (tmp.state, "Octave:empty-list-elements"); - end_unwind_protect - else - for i = 1:nargin - tmp = varargin{i}; - if (! (iscellstr (tmp) || ischar (tmp))) - error ("strcat: all arguments must be strings or cell arrays of strings"); - endif + ## Set all cells to a common size + n = find (numstrs == max (numstrs), 1); + maxstrs = numstrs (n); + dim = dims{n}; + for nv = find (numstrs == 1) + str = varargin{nv}{1}; + varargin{nv} = cell (dim); + varargin{nv}{:} = str; endfor - st = strcat_cell (varargin); + + ## Concatenate the strings + st = varargin{1}; + for ns = 1:maxstrs + for nv = 2:nargin + if (size_equal (st, varargin{nv})) + st{ns} = [st{ns}, varargin{nv}{ns}]; + else + error ("strcat: arguments must be the same size, or be scalars."); + endif + endfor + endfor + + if (allchar) + ## If all inputs were strings, return strings. + st = char (st); + endif endif else print_usage (); @@ -61,23 +88,28 @@ endfunction -function st = strcat_cell (varargin) - ## All args must be same size or scalars. - ## See the xtest below for expected behavior. - error ("strcat: concatenating cell arrays of strings not implemented"); -endfunction - ## test the dimensionality ## 1d -%!assert(strcat("ab ", "ab "), "ab ab ") +%!assert(strcat("ab ", "ab "), "abab") +%!assert(strcat({"ab "}, "ab "), {"ab ab"}) +%!assert(strcat("ab ", {"ab "}), {"abab "}) +%!assert(strcat({"ab "}, {"ab "}), {"ab ab "}) ## 2d -%!assert(strcat(["ab ";"cde"], ["ab ";"cde"]), ["ab ab ";"cdecde"]) +%!assert(strcat(["ab ";"cde"], ["ab ";"cde"]), ["abab ";"cdecde"]) -%!assert((strcmp (strcat ("foo", "bar"), "foobar") -%! && strcmp (strcat (["a"; "bb"], ["foo"; "bar"]), ["a foo"; "bbbar"]))); +## test for deblanking implied trailing spaces of character input +%!assert((strcmp (strcat ("foo", "bar"), "foobar") && +%! strcmp (strcat (["a"; "bb"], ["foo"; "bar"]), ["afoo "; "bbbar"]))); + +## test for mixing character and cell inputs +%!assert(all (strcmp (strcat ("a", {"bc", "de"}, "f"), {"abcf", "adef"}))) -%!xtest -%! assert(all (strcmp (strcat ("a", {"bc", "de"}, "f"), {"abcf", "adef"}))) +## test for scalar strings with vector strings +%!assert(all (strcmp (strcat (["a"; "b"], "c"), ["ac"; "bc"]))) + +## test with cells with strings of differing lengths +%!assert(all (strcmp (strcat ({"a", "bb"}, "ccc"), {"accc", "bbccc"}))) +%!assert(all (strcmp (strcat ("a", {"bb", "ccc"}), {"abb", "accc"}))) %!error strcat (); diff --git a/scripts/strings/strvcat.m b/scripts/strings/strvcat.m --- a/scripts/strings/strvcat.m +++ b/scripts/strings/strvcat.m @@ -22,7 +22,7 @@ ## @var{s_1}, @dots{}, @var{s_n} as ## its rows. Each string is padded with blanks in order to form a valid ## matrix. Unlike @var{str2mat}, empty strings are ignored. -## @seealso{strcat, str2mat} +## @seealso{cstrcat, str2mat} ## @end deftypefn ## Author: Kurt Hornik diff --git a/scripts/testfun/assert.m b/scripts/testfun/assert.m --- a/scripts/testfun/assert.m +++ b/scripts/testfun/assert.m @@ -66,9 +66,9 @@ in = deblank (argn(1,:)); for i = 2:rows (argn) - in = strcat (in, ",", deblank (argn(i,:))); + in = cstrcat (in, ",", deblank (argn(i,:))); endfor - in = strcat ("(", in, ")"); + in = cstrcat ("(", in, ")"); coda = ""; iserror = 0; @@ -140,7 +140,7 @@ elseif (tol == 0 && ! strcmp (typeinfo (cond), typeinfo (expected))) iserror = 1; - coda = strcat ("Type ", typeinfo (cond), " != ", typeinfo (expected)); + coda = cstrcat ("Type ", typeinfo (cond), " != ", typeinfo (expected)); else # numeric A = cond(:); @@ -198,9 +198,9 @@ if (! isempty (idx)) str2 = str2 (idx(1):idx(end)); endif - msg = strcat ("assert ", in, " expected\n", str, "\nbut got\n", str2); + msg = cstrcat ("assert ", in, " expected\n", str, "\nbut got\n", str2); if (! isempty (coda)) - msg = strcat (msg, "\n", coda); + msg = cstrcat (msg, "\n", coda); endif error ("%s", msg); ## disp (msg); diff --git a/scripts/testfun/demo.m b/scripts/testfun/demo.m --- a/scripts/testfun/demo.m +++ b/scripts/testfun/demo.m @@ -111,7 +111,7 @@ try block = code(idx(doidx(i)):idx(doidx(i)+1)-1); ## Use an environment without variables - eval (strcat ("function __demo__()\n", block, "\nendfunction")); + eval (cstrcat ("function __demo__()\n", block, "\nendfunction")); ## Display the code that will be executed before executing it printf ("%s example %d:%s\n\n", name, doidx(i), block); __demo__; diff --git a/scripts/testfun/speed.m b/scripts/testfun/speed.m --- a/scripts/testfun/speed.m +++ b/scripts/testfun/speed.m @@ -187,38 +187,38 @@ __torig = __tnew = zeros (size (__test_n)); - disp (strcat ("testing ", __f1, "\ninit: ", __init)); + disp (cstrcat ("testing ", __f1, "\ninit: ", __init)); ## make sure the functions are freshly loaded by evaluating them at ## test_n(1); first have to initialize the args though. n = 1; k = 0; - eval (strcat (__init, ";")); + eval (cstrcat (__init, ";")); if (! isempty (__f2)) - eval (strcat (__f2, ";")); + eval (cstrcat (__f2, ";")); endif - eval (strcat (__f1, ";")); + eval (cstrcat (__f1, ";")); ## run the tests for k = 1:length (__test_n) n = __test_n(k); - eval (strcat (__init, ";")); + eval (cstrcat (__init, ";")); printf ("n%i=%i ",k, n); fflush (stdout); - eval (strcat ("__t=time();", __f1, "; __v1=ans; __t = time()-__t;")); + eval (cstrcat ("__t=time();", __f1, "; __v1=ans; __t = time()-__t;")); if (__t < 0.25) - eval (strcat ("__t2=time();", __f1, "; __t2 = time()-__t2;")); - eval (strcat ("__t3=time();", __f1, "; __t3 = time()-__t3;")); + eval (cstrcat ("__t2=time();", __f1, "; __t2 = time()-__t2;")); + eval (cstrcat ("__t3=time();", __f1, "; __t3 = time()-__t3;")); __t = min ([__t, __t2, __t3]); endif __tnew(k) = __t; if (! isempty (__f2)) - eval (strcat ("__t=time();", __f2, "; __v2=ans; __t = time()-__t;")); + eval (cstrcat ("__t=time();", __f2, "; __v2=ans; __t = time()-__t;")); if (__t < 0.25) - eval (strcat ("__t2=time();", __f2, "; __t2 = time()-__t2;")); - eval (strcat ("__t3=time();", __f2, "; __t3 = time()-__t3;")); + eval (cstrcat ("__t2=time();", __f2, "; __t2 = time()-__t2;")); + eval (cstrcat ("__t3=time();", __f2, "; __t3 = time()-__t3;")); endif __torig(k) = __t; if (! isinf(__tol)) @@ -257,10 +257,10 @@ if (doplot && ! isempty (__f2)) subplot (1, 2, 1); semilogx (__test_n, __torig./__tnew, - strcat ("-*r;", strrep (__f1, ";", "."), "/", + cstrcat ("-*r;", strrep (__f1, ";", "."), "/", strrep (__f2, ";", "."), ";"), __test_n, __tnew./__torig, - strcat ("-*g;", strrep (__f2, ";", "."), "/", + cstrcat ("-*g;", strrep (__f2, ";", "."), "/", strrep (__f1, ";", "."), ";")); xlabel ("test length"); title (__f1); @@ -268,13 +268,13 @@ subplot (1, 2, 2); loglog (__test_n, __tnew*1000, - strcat ("*-g;", strrep (__f1, ";", "."), ";" ), + cstrcat ("*-g;", strrep (__f1, ";", "."), ";" ), __test_n, __torig*1000, - strcat ("*-r;", strrep (__f2,";","."), ";")); + cstrcat ("*-r;", strrep (__f2,";","."), ";")); xlabel ("test length"); ylabel ("best execution time (ms)"); - title (strcat ("init: ", __init)); + title (cstrcat ("init: ", __init)); ratio = mean (__torig ./ __tnew); printf ("\n\nMean runtime ratio = %.3g for '%s' vs '%s'\n", @@ -285,7 +285,7 @@ loglog (__test_n, __tnew*1000, "*-g;execution time;"); xlabel ("test length"); ylabel ("best execution time (ms)"); - title (strcat (__f1, " init: ", __init)); + title (cstrcat (__f1, " init: ", __init)); endif diff --git a/scripts/testfun/test.m b/scripts/testfun/test.m --- a/scripts/testfun/test.m +++ b/scripts/testfun/test.m @@ -157,10 +157,10 @@ ## locate the file to test __file = file_in_loadpath (__name, "all"); if (isempty (__file)) - __file = file_in_loadpath (strcat (__name, ".m"), "all"); + __file = file_in_loadpath (cstrcat (__name, ".m"), "all"); endif if (isempty (__file)) - __file = file_in_loadpath (strcat (__name, ".cc"), "all"); + __file = file_in_loadpath (cstrcat (__name, ".cc"), "all"); endif if (iscell (__file)) ## If repeats, return first in path. @@ -220,7 +220,7 @@ ## ready to start tests ... if in batch mode, tell us what is happening if (__verbose) - disp (strcat ( __signal_file, __file)); + disp (cstrcat ( __signal_file, __file)); endif ## assume all tests will pass @@ -270,7 +270,7 @@ __demo_code = __code; __demo_idx = [1, length(__demo_code)+1]; else - __demo_code = strcat(__demo_code, __code); + __demo_code = cstrcat(__demo_code, __code); __demo_idx = [__demo_idx, length(__demo_code)+1]; endif @@ -313,9 +313,9 @@ try __vars = deblank (__vars); if (! isempty (__vars)) - eval (strcat (strrep (__vars, ",", "=[];"), "=[];")); + eval (cstrcat (strrep (__vars, ",", "=[];"), "=[];")); __shared = __vars; - __shared_r = strcat ("[ ", __vars, "] = "); + __shared_r = cstrcat ("[ ", __vars, "] = "); else __shared = " "; __shared_r = " "; @@ -574,7 +574,7 @@ ## strip '.*prefix:' from '.*prefix: msg\n' and strip trailing blanks function msg = trimerr (msg, prefix) - idx = index (msg, strcat (prefix, ":")); + idx = index (msg, cstrcat (prefix, ":")); if (idx > 0) msg(1:idx+length(prefix)) = []; endif @@ -607,7 +607,7 @@ if (length (ln) >= 2 && strcmp (ln(1:2), "%!")) body = [body, "\n"]; if (length(ln) > 2) - body = strcat (body, ln(3:end)); + body = cstrcat (body, ln(3:end)); endif endif endwhile diff --git a/test/ChangeLog b/test/ChangeLog --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2008-02-25 Ben Abbott + + * test_eval-catch.m, test_io.m, test_try.m: Use cstrcat instead of + strcat. + 2008-02-22 David Bateman * build_sparse_tests.sh: Replaced removed sparse functions like diff --git a/test/test_eval-catch.m b/test/test_eval-catch.m --- a/test/test_eval-catch.m +++ b/test/test_eval-catch.m @@ -49,7 +49,7 @@ %% test/octave.test/eval-catch/eval-catch-7.m %!function ms = mangle (s) %! ## Wrap angle brackets around S. -%! ms = strcat ("<", s, ">"); +%! ms = cstrcat ("<", s, ">"); %!test %! eval ("clear a; a; str='';", "str = mangle (lasterr);"); %! assert(mangle(lasterr)(1:21),""); +%! ms = cstrcat ("<", s, ">"); %!test %! try %! clear a @@ -133,7 +133,7 @@ %! a; %! error("Shoudn't get here"); %! catch -%! error(strcat("rethrow: ",lasterr)); +%! error(cstrcat("rethrow: ",lasterr)); %! end_try_catch %! catch %! assert(strcmp(lasterr()(1:36), "error: rethrow: error: `a' undefined"))