# HG changeset patch # User Thorsten Meyer # Date 1228425412 -3600 # Node ID 8dff9cba15feaaa555cbb75295ffebf6a997f988 # Parent c3f7e2549abb438a3a4fbdf2f62a769d94a59947 move str2mat to deprecated and make it a simple wrapper around char diff --git a/doc/ChangeLog b/doc/ChangeLog --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2008-12-02 Thorsten Meyer + + * interpreter/container.txi, interpreter/strings.txi: + Remove reference to str2mat.m + 2008-11-15 Thorsten Meyer * interpreter/strings.txi: Add text around docstrings, change diff --git a/doc/interpreter/container.txi b/doc/interpreter/container.txi --- a/doc/interpreter/container.txi +++ b/doc/interpreter/container.txi @@ -665,7 +665,7 @@ @noindent The following functions for string manipulation support cell arrays of strings, @code{strcmp}, @code{strcmpi}, @code{strncmp}, @code{strncmpi}, -@code{str2double}, @code{str2mat}, @code{strappend}, @code{strtrunc}, +@code{str2double}, @code{char}, @code{strappend}, @code{strtrunc}, @code{strvcat}, @code{strfind}, and @code{strmatch}. @DOCSTRING(cellstr) diff --git a/doc/interpreter/strings.txi b/doc/interpreter/strings.txi --- a/doc/interpreter/strings.txi +++ b/doc/interpreter/strings.txi @@ -224,7 +224,7 @@ It has been shown above that strings can be concatenated using matrix notation (@pxref{Strings}, @ref{Character Arrays}). Apart from that, there are several -functions to concatenate string objects: @code{char}, @code{str2mat}, +functions to concatenate string objects: @code{char}, @code{strvcat}, @code{strcat} and @code{cstrcat}. In addition, the general purpose concatenation functions can be used: see @ref{doc-cat,,cat}, @ref{doc-horzcat,,horzcat} and @ref{doc-vertcat,,vertcat}. @@ -243,7 +243,7 @@ @end example @item -@code{char}, @code{str2mat} and @code{strvcat} +@code{char} and @code{strvcat} concatenate vertically, while @code{strcat} and @code{cstrcat} concatenate horizontally. For example: @@ -262,7 +262,7 @@ @end group @end example -@item @code{char} and @code{str2mat} both generate an empty row in the output +@item @code{char} generates an empty row in the output for each empty string in the input. @code{strvcat}, on the other hand, eliminates empty strings. @@ -286,7 +286,7 @@ @end example @item All string concatenation functions except @code{cstrcat} also accept cell -array data (@pxref{Cell Arrays}). @code{char}, @code{str2mat} and +array data (@pxref{Cell Arrays}). @code{char} and @code{strvcat} convert cell arrays into character arrays, while @code{strcat} concatenates within the cells of the cell arrays: @@ -337,8 +337,6 @@ @DOCSTRING(char) -@DOCSTRING(str2mat) - @DOCSTRING(strvcat) @DOCSTRING(strcat) diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,12 @@ +2008-12-02 Thorsten Meyer + + * strings/str2mat.m: Make it a simple wrapper around + char() and move it to scripts/deprecated/str2mat.m, remove + obsolete tests, move remaining test to src/strfns.cc (Fchar). + * strings/Makefile.in: Remove str2mat.m. + * deprecated/Makefile.in: Add str2mat.m. + * strings/strvcat.m: Remove reference to str2mat. + 2008-11-28 David Bateman * plot/__go_draw_axes__.m: Set two point clipping mode to be on. diff --git a/scripts/deprecated/Makefile.in b/scripts/deprecated/Makefile.in --- a/scripts/deprecated/Makefile.in +++ b/scripts/deprecated/Makefile.in @@ -53,7 +53,7 @@ struct_contains.m struct_elements.m t_cdf.m t_inv.m t_pdf.m \ t_rnd.m uniform_cdf.m uniform_inv.m uniform_pdf.m uniform_rnd.m \ weibcdf.m weibinv.m weibpdf.m weibrnd.m weibull_cdf.m \ - weibull_inv.m weibull_pdf.m weibull_rnd.m wiener_rnd.m + weibull_inv.m weibull_pdf.m weibull_rnd.m wiener_rnd.m str2mat.m DISTFILES = $(addprefix $(srcdir)/, Makefile.in $(SOURCES)) diff --git a/scripts/deprecated/str2mat.m b/scripts/deprecated/str2mat.m new file mode 100644 --- /dev/null +++ b/scripts/deprecated/str2mat.m @@ -0,0 +1,44 @@ +## Copyright (C) 1996, 1998, 1999, 2000, 2002, 2004, 2005, 2006, 2007 +## Kurt Hornik +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {} str2mat (@var{s_1}, @dots{}, @var{s_n}) +## Return a matrix containing the strings @var{s_1}, @dots{}, @var{s_n} as +## its rows. Each string is padded with blanks in order to form a valid +## matrix. +## +## This function is modelled after @sc{Matlab}. In Octave, you can create +## a matrix of strings by @code{[@var{s_1}; @dots{}; @var{s_n}]} even if +## the strings are not all the same length. +## @end deftypefn + +## Author: Kurt Hornik +## Adapted-By: jwe + +function retval = str2mat (varargin) + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "str2mat is obsolete and will be removed from a future version of Octave; please use char instead."); + endif + + retval = char (varargin{:}); + +endfunction diff --git a/scripts/strings/Makefile.in b/scripts/strings/Makefile.in --- a/scripts/strings/Makefile.in +++ b/scripts/strings/Makefile.in @@ -35,7 +35,7 @@ SOURCES = base2dec.m bin2dec.m blanks.m deblank.m dec2base.m \ dec2bin.m dec2hex.m findstr.m hex2dec.m index.m isletter.m isstrprop.m \ - lower.m mat2str.m regexptranslate.m rindex.m split.m str2double.m str2mat.m \ + lower.m mat2str.m regexptranslate.m rindex.m split.m str2double.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 validatestring.m diff --git a/scripts/strings/str2mat.m b/scripts/strings/str2mat.m deleted file mode 100644 --- a/scripts/strings/str2mat.m +++ /dev/null @@ -1,83 +0,0 @@ -## Copyright (C) 1996, 1998, 1999, 2000, 2002, 2004, 2005, 2006, 2007 -## Kurt Hornik -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {} str2mat (@var{s_1}, @dots{}, @var{s_n}) -## Return a matrix containing the strings @var{s_1}, @dots{}, @var{s_n} as -## its rows. Each string is padded with blanks in order to form a valid -## matrix. -## -## This function is modelled after @sc{Matlab}. In Octave, you can create -## a matrix of strings by @code{[@var{s_1}; @dots{}; @var{s_n}]} even if -## the strings are not all the same length. -## @end deftypefn - -## Author: Kurt Hornik -## Adapted-By: jwe - -function retval = str2mat (varargin) - - if (nargin == 0) - print_usage (); - endif - - nc = 0; - nr = 0; - - nr = zeros (nargin, 1); - nc = zeros (nargin, 1); - for k = 1 : nargin - s = varargin{k}; - if (! ischar (s)) - s = char (s); - endif - [nr(k), nc(k)] = size (s); - endfor - - tmp = find (nr == 0); - - if (! isempty (tmp)) - nr(tmp) = 1; - endif - - retval_nr = sum (nr); - retval_nc = max (nc); - - retval = char (ones (retval_nr, retval_nc) * toascii (" ")); - - row_offset = 0; - for k = 1 : nargin - s = varargin{k}; - if (! ischar (s)) - s = char (s); - endif - if (nc(k) > 0) - retval ((row_offset + 1) : (row_offset + nr(k)), 1:nc(k)) = s; - endif - row_offset = row_offset + nr(k); - endfor - -endfunction - -%!assert(strcmp (str2mat ("a", "bb", "ccc"), ["a "; "bb "; "ccc"])); - -%!error str2mat (); - -%!assert(all (str2mat (1, 2, 3) == setstr ([1; 2; 3]))); - diff --git a/scripts/strings/strvcat.m b/scripts/strings/strvcat.m --- a/scripts/strings/strvcat.m +++ b/scripts/strings/strvcat.m @@ -21,8 +21,8 @@ ## Return a matrix containing the strings (and cell-strings) ## @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{cstrcat, str2mat} +## matrix. Unlike @var{char}, empty strings are ignored. +## @seealso{cstrcat, char} ## @end deftypefn ## Author: Kurt Hornik diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2008-12-04 Thorsten Meyer + + * strfns.cc (Fchar): Add test from str2mat.m + 2008-12-04 Jaroslav Hajek * ov.h (octave_value::is_perm_matrix): New method. diff --git a/src/strfns.cc b/src/strfns.cc --- a/src/strfns.cc +++ b/src/strfns.cc @@ -149,6 +149,7 @@ %!assert (all(char ({100, [], 100}) == ["d";" ";"d"])) %!assert (all(char ({100,{100, {""}}}) == ["d";"d";" "])) %!assert (all(char (["a";"be"], {"c", 100}) == ["a";"be";"c";"d"])) +%!assert(strcmp (char ("a", "bb", "ccc"), ["a "; "bb "; "ccc"])); */