changeset 8372:8dff9cba15fe

move str2mat to deprecated and make it a simple wrapper around char
author Thorsten Meyer <thorsten.meyier@gmx.de>
date Thu, 04 Dec 2008 22:16:52 +0100
parents c3f7e2549abb
children 63fe023d7898
files doc/ChangeLog doc/interpreter/container.txi doc/interpreter/strings.txi scripts/ChangeLog scripts/deprecated/Makefile.in scripts/deprecated/str2mat.m scripts/strings/Makefile.in scripts/strings/str2mat.m scripts/strings/strvcat.m src/ChangeLog src/strfns.cc
diffstat 11 files changed, 72 insertions(+), 94 deletions(-) [+]
line wrap: on
line diff
--- a/doc/ChangeLog	Thu Dec 04 12:03:45 2008 +0100
+++ b/doc/ChangeLog	Thu Dec 04 22:16:52 2008 +0100
@@ -1,3 +1,8 @@
+2008-12-02  Thorsten Meyer  <thorsten.meyier@gmx.de>
+
+        * interpreter/container.txi, interpreter/strings.txi:
+        Remove reference to str2mat.m
+        
 2008-11-15  Thorsten Meyer  <thorsten.meyier@gmx.de>
 
         * interpreter/strings.txi: Add text around docstrings, change
--- a/doc/interpreter/container.txi	Thu Dec 04 12:03:45 2008 +0100
+++ b/doc/interpreter/container.txi	Thu Dec 04 22:16:52 2008 +0100
@@ -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)
--- a/doc/interpreter/strings.txi	Thu Dec 04 12:03:45 2008 +0100
+++ b/doc/interpreter/strings.txi	Thu Dec 04 22:16:52 2008 +0100
@@ -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)
--- a/scripts/ChangeLog	Thu Dec 04 12:03:45 2008 +0100
+++ b/scripts/ChangeLog	Thu Dec 04 22:16:52 2008 +0100
@@ -1,3 +1,12 @@
+2008-12-02  Thorsten Meyer  <thorsten.meyier@gmx.de>
+
+        * 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  <dbateman@free.fr>
 
 	* plot/__go_draw_axes__.m: Set two point clipping mode to be on.
--- a/scripts/deprecated/Makefile.in	Thu Dec 04 12:03:45 2008 +0100
+++ b/scripts/deprecated/Makefile.in	Thu Dec 04 22:16:52 2008 +0100
@@ -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))
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/deprecated/str2mat.m	Thu Dec 04 22:16:52 2008 +0100
@@ -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
+## <http://www.gnu.org/licenses/>.
+
+## -*- 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 <Kurt.Hornik@wu-wien.ac.at>
+## 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
--- a/scripts/strings/Makefile.in	Thu Dec 04 12:03:45 2008 +0100
+++ b/scripts/strings/Makefile.in	Thu Dec 04 22:16:52 2008 +0100
@@ -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
--- a/scripts/strings/str2mat.m	Thu Dec 04 12:03:45 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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
-## <http://www.gnu.org/licenses/>.
-
-## -*- 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 <Kurt.Hornik@wu-wien.ac.at>
-## 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])));
-
--- a/scripts/strings/strvcat.m	Thu Dec 04 12:03:45 2008 +0100
+++ b/scripts/strings/strvcat.m	Thu Dec 04 22:16:52 2008 +0100
@@ -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 <Kurt.Hornik@ci.tuwien.ac.at>
--- a/src/ChangeLog	Thu Dec 04 12:03:45 2008 +0100
+++ b/src/ChangeLog	Thu Dec 04 22:16:52 2008 +0100
@@ -1,3 +1,7 @@
+2008-12-04  Thorsten Meyer  <thorsten.meyier@gmx.de>
+
+        * strfns.cc (Fchar): Add test from str2mat.m
+        
 2008-12-04  Jaroslav Hajek  <highegg@gmail.com>
 
 	* ov.h (octave_value::is_perm_matrix): New method.
--- a/src/strfns.cc	Thu Dec 04 12:03:45 2008 +0100
+++ b/src/strfns.cc	Thu Dec 04 22:16:52 2008 +0100
@@ -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"]));
 */