# HG changeset patch # User Thorsten Meyer # Date 1228820651 -3600 # Node ID 1567db1e166cbc99e002243c1dfe5bcef1d220a8 # Parent a5e080076778ad789b1305be4384325f0d609aee make upper and lower aliases of toupper and tolower respectively diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,9 @@ +2008-12-07 Thorsten Meyer + + * strings/lower.m: Remove + * strings/upper.m: Remove + * strings/Makefile.in: Remove lower.m, upper.m + 2008-12-02 Thorsten Meyer * strings/str2mat.m: Make it a simple wrapper around diff --git a/scripts/strings/Makefile.in b/scripts/strings/Makefile.in --- a/scripts/strings/Makefile.in +++ b/scripts/strings/Makefile.in @@ -35,10 +35,10 @@ 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 \ + 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 + substr.m validatestring.m DISTFILES = $(addprefix $(srcdir)/, Makefile.in $(SOURCES)) diff --git a/scripts/strings/lower.m b/scripts/strings/lower.m deleted file mode 100644 --- a/scripts/strings/lower.m +++ /dev/null @@ -1,42 +0,0 @@ -## Copyright (C) 1998, 2000, 2004, 2005, 2006, 2007 John W. Eaton -## -## 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} {} lower (@var{s}) -## Transform all letters in the character string (or cell array of -## character strings) @var{s} to lower case. -## @seealso{upper, tolower, toupper} -## @end deftypefn - -## Author: jwe - -function retval = lower (s) - - if (nargin != 1) - print_usage (); - endif - - if (ischar (s)) - retval = tolower (s); - elseif (iscellstr (s)) - retval = cellfun (@tolower, s, "UniformOutput", false); - else - error ("lower: `s' must be a string or cell array of strings"); - endif - -endfunction diff --git a/scripts/strings/upper.m b/scripts/strings/upper.m deleted file mode 100644 --- a/scripts/strings/upper.m +++ /dev/null @@ -1,42 +0,0 @@ -## Copyright (C) 1998, 2000, 2004, 2005, 2006, 2007 John W. Eaton -## -## 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} {} upper (@var{s}) -## Transform all letters in the character string (or cell array of -## character strings) @var{s} to upper case. -## @seealso{lower, tolower, toupper} -## @end deftypefn - -## Author: jwe - -function retval = upper (s) - - if (nargin != 1) - print_usage (); - endif - - if (ischar (s)) - retval = toupper (s); - elseif (iscellstr (s)) - retval = cellfun (@toupper, s, "UniformOutput", false); - else - error ("upper: `s' must be a string or cell array of strings"); - endif - -endfunction diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-12-07 Thorsten Meyer + + * mappers.cc (Ftolower): Make lower alias of tolower, add tests + * mappers.cc (Ftoupper): Make upper alias of toupper, add tests + 2008-12-09 Jaroslav Hajek * DLD-FUNCTIONS/balance.cc (Fbalance): Exploit the new AEPBAL functionality. diff --git a/src/mappers.cc b/src/mappers.cc --- a/src/mappers.cc +++ b/src/mappers.cc @@ -1569,9 +1569,10 @@ DEFUNX ("tolower", Ftolower, args, , "-*- texinfo -*-\n\ @deftypefn {Mapping Function} {} tolower (@var{s})\n\ -Return a copy of the string @var{s}, with each upper-case character\n\ -replaced by the corresponding lower-case one; nonalphabetic characters\n\ -are left unchanged. For example,\n\ +@deftypefnx {Mapping Function} {} lower (@var{s})\n\ +Return a copy of the string or cell string @var{s}, with each upper-case\n\ +character replaced by the corresponding lower-case one; nonalphabetic\n\ +characters are left unchanged. For example,\n\ \n\ @example\n\ tolower (\"MiXeD cAsE 123\")\n\ @@ -1588,12 +1589,33 @@ return retval; } +DEFALIAS (lower, tolower); + +/* + +%!error tolower(); +%!error lower(); +%!assert(tolower("OCTAVE"), "octave"); +%!assert(tolower("123OCTave!_&"), "123octave!_&"); +%!assert(tolower({"ABC", "DEF", {"GHI", {"JKL"}}}), {"abc", "def", {"ghi", {"jkl"}}}); +%!assert(tolower(["ABC"; "DEF"]), ["abc"; "def"]); +%!assert(tolower({["ABC"; "DEF"]}), {["abc";"def"]}); +%!assert(tolower(68), "d"); +%!assert(tolower({[68, 68; 68, 68]}), {["dd";"dd"]}); +%!test +%! a(3,3,3,3) = "D"; +%! assert(tolower(a)(3,3,3,3), "d"); + +*/ + + DEFUNX ("toupper", Ftoupper, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} toupper (@var{s})\n\ -Return a copy of the string @var{s}, with each lower-case character\n\ -replaced by the corresponding upper-case one; nonalphabetic characters\n\ -are left unchanged. For example,\n\ +@deftypefnx {Built-in Function} {} upper (@var{s})\n\ +Return a copy of the string or cell string @var{s}, with each lower-case\n\ +character replaced by the corresponding upper-case one; nonalphabetic\n\ +characters are left unchanged. For example,\n\ \n\ @example\n\ @group\n\ @@ -1612,6 +1634,25 @@ return retval; } +DEFALIAS (upper, toupper); + +/* + +%!error toupper(); +%!error upper(); +%!assert(toupper("octave"), "OCTAVE"); +%!assert(toupper("123OCTave!_&"), "123OCTAVE!_&"); +%!assert(toupper({"abc", "def", {"ghi", {"jkl"}}}), {"ABC", "DEF", {"GHI", {"JKL"}}}); +%!assert(toupper(["abc"; "def"]), ["ABC"; "DEF"]); +%!assert(toupper({["abc"; "def"]}), {["ABC";"DEF"]}); +%!assert(toupper(100), "D"); +%!assert(toupper({[100, 100; 100, 100]}), {["DD";"DD"]}); +%!test +%! a(3,3,3,3) = "d"; +%! assert(toupper(a)(3,3,3,3), "D"); + +*/ + DEFALIAS (gammaln, lgamma); DEFALIAS (isfinite, finite);