# HG changeset patch # User Rik # Date 1411273063 25200 # Node ID f506de9089e868eed33ab31aeb24ce10d2e5d42f # Parent 9c5a17d5fc19723d387dfc9947f688eb9b9c5e26 Deprecate fnmatch function. * NEWS: Announce deprecation. * scripts/deprecated/fnmatch.m: m-file to replace C++ function and issue deprecated warning. * scripts/deprecated/module.mk: Add fnmatch.m to build system. * dirfns.cc: Rename fnmatch to __fnmatch__ internal version. Switch DEFUNX to DEFUN. * test/system.tst: Remove fnmatch tests diff -r 9c5a17d5fc19 -r f506de9089e8 NEWS --- a/NEWS Sat Sep 20 20:31:16 2014 -0700 +++ b/NEWS Sat Sep 20 21:17:43 2014 -0700 @@ -96,6 +96,7 @@ find_dir_in_path | dir_in_loadpath finite | isfinite fmod | rem + fnmatch | glob or regexp nfields | numfields syl | sylvester usage | print_usage diff -r 9c5a17d5fc19 -r f506de9089e8 libinterp/corefcn/dirfns.cc --- a/libinterp/corefcn/dirfns.cc Sat Sep 20 20:31:16 2014 -0700 +++ b/libinterp/corefcn/dirfns.cc Sat Sep 20 21:17:43 2014 -0700 @@ -608,7 +608,7 @@ [2,1] = file2\n\ @}\n\ @end example\n\ -@seealso{ls, dir, readdir, what, fnmatch}\n\ +@seealso{ls, dir, readdir, what}\n\ @end deftypefn") { octave_value retval; @@ -664,7 +664,7 @@ %! assert (result3, {"file1"; "file2"}); */ -DEFUNX ("fnmatch", Ffnmatch, args, , +DEFUN (__fnmatch__, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} fnmatch (@var{pattern}, @var{string})\n\ Return true or false for each element of @var{string} that matches any of\n\ diff -r 9c5a17d5fc19 -r f506de9089e8 scripts/deprecated/fnmatch.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/deprecated/fnmatch.m Sat Sep 20 21:17:43 2014 -0700 @@ -0,0 +1,52 @@ +## Copyright (C) 2014 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 {Built-in Function} {} fnmatch (@var{pattern}, @var{string}) +## +## @code{fnmatch} is deprecated and will be removed in Octave version 4.6. +## Please use @code{glob} or @code{regexp} in all new code. +## +## Return true or false for each element of @var{string} that matches any of +## the elements of the string array @var{pattern}, using the rules of +## filename pattern matching. For example: +## +## @example +## @group +## fnmatch (\"a*b\", @{\"ab\"; \"axyzb\"; \"xyzab\"@}) +## @result{} [ 1; 1; 0 ] +## @end group +## @end example +## @seealso{glob, regexp} +## @end deftypefn + +## Deprecated in version 4.2 + +function retval = fnmatch (varargin) + + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "fnmatch is obsolete and will be removed from a future version of Octave, please use glob or regexp instead"); + endif + + retval = __fnmatch__ (varargin{:}); + +endfunction + diff -r 9c5a17d5fc19 -r f506de9089e8 scripts/deprecated/module.mk --- a/scripts/deprecated/module.mk Sat Sep 20 20:31:16 2014 -0700 +++ b/scripts/deprecated/module.mk Sat Sep 20 21:17:43 2014 -0700 @@ -5,6 +5,7 @@ deprecated/find_dir_in_path.m \ deprecated/finite.m \ deprecated/fmod.m \ + deprecated/fnmatch.m \ deprecated/isstr.m \ deprecated/nfields.m \ deprecated/strmatch.m \ diff -r 9c5a17d5fc19 -r f506de9089e8 test/system.tst --- a/test/system.tst Sat Sep 20 20:31:16 2014 -0700 +++ b/test/system.tst Sat Sep 20 21:17:43 2014 -0700 @@ -185,17 +185,6 @@ %!error glob () %!error glob ("foo", 1) -%!test -%! string_fill_char = char (0); -%! assert ((fnmatch ("a*a", {"aba"; "xxxba"; "aa"}) == [1; 0; 1] -%! && fnmatch ({"a*a"; "b*b"}, "bob") -%! && fnmatch ("x[0-5]*", {"x1"; "x6"}) == [1; 0] -%! && fnmatch ("x[0-5]*", {"x1"; "x6"; "x001"}) == [1; 0; 1] -%! && fnmatch ("x???y", {"xabcy"; "xy"}) == [1; 0])); - -%!error fnmatch () -%!error fnmatch ("foo", "bar", 3) - %!assert (ischar (file_in_path (path (), "date.m"))) %!error file_in_path ("foo", "bar", 1)