Mercurial > octave
changeset 25012:910804a9d62d stable
tmpnam.m: Deprecate function.
* NEWS: Announce deprecation.
* scripts/deprecated/tmpnam.m: Moved from miscellaneous/. Add deprecation note
to docstring and list replacement tempname. Add deprecation warning to code.
* scripts/deprecated/module.mk, scripts/miscellaneous/module.mk:
Update build system.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 26 Mar 2018 16:38:58 -0700 |
parents | 231847364696 |
children | 485ea63c5082 a281de7620d7 |
files | NEWS scripts/deprecated/module.mk scripts/deprecated/tmpnam.m scripts/miscellaneous/module.mk scripts/miscellaneous/tmpnam.m |
diffstat | 5 files changed, 63 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Mon Mar 26 16:11:33 2018 -0700 +++ b/NEWS Mon Mar 26 16:38:58 2018 -0700 @@ -302,6 +302,7 @@ ---------------------|------------------ chop | sprintf for visual results desktop | isguirunning + tmpnam | tempname toascii | double ** The following functions were deprecated in Octave 4.0 and have been
--- a/scripts/deprecated/module.mk Mon Mar 26 16:11:33 2018 -0700 +++ b/scripts/deprecated/module.mk Mon Mar 26 16:38:58 2018 -0700 @@ -13,6 +13,7 @@ %reldir%/paren.m \ %reldir%/semicolon.m \ %reldir%/sleep.m \ + %reldir%/tmpnam.m \ %reldir%/toascii.m \ %reldir%/usleep.m \ %reldir%/wavread.m \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/deprecated/tmpnam.m Mon Mar 26 16:38:58 2018 -0700 @@ -0,0 +1,61 @@ +## Copyright (C) 2003-2018 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 +## <https://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {} {@var{fname} =} tmpnam () +## @deftypefnx {} {@var{fname} =} tmpnam (@var{dir}) +## @deftypefnx {} {@var{fname} =} tmpnam (@var{dir}, @var{prefix}) +## @code{tmpnam} is deprecated and will be removed in Octave version 4.8. +## Use @code{tempname} instead. +## +## Return a unique temporary filename as a string. +## +## If @var{prefix} is omitted, a value of @qcode{"oct-"} is used. +## +## If @var{dir} is also omitted, the default directory for temporary files +## (@code{P_tmpdir} is used. If @var{dir} is provided, it must exist, +## otherwise the default directory for temporary files is used. +## +## Programming Note: Because the named file is not opened by @code{tmpnam}, +## it is possible, though relatively unlikely, that it will not be available +## by the time your program attempts to open it. If this is a concern, +## see @code{tmpfile}. The functions @code{tmpnam} and @code{tempname} are +## equivalent with the latter provided for @sc{matlab} compatibility. +## +## @strong{Caution}: @code{tmpnam} will be removed in Octave version 4.8, or +## whatever the version number is two releases from 4.4. Use the equivalent +## @code{tempname} in all new code. +## @seealso{tempname, mkstemp, tempdir, P_tmpdir, tmpfile} +## @end deftypefn + +function filename = tmpnam (varargin) + + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "tmpnam is obsolete and will be removed from a future version of Octave, please use tempname instead"); + endif + + filename = tempname (varargin{:}); + +endfunction + + +## No tests needed for alias. +%!assert (1)
--- a/scripts/miscellaneous/module.mk Mon Mar 26 16:11:33 2018 -0700 +++ b/scripts/miscellaneous/module.mk Mon Mar 26 16:38:58 2018 -0700 @@ -71,7 +71,6 @@ %reldir%/symvar.m \ %reldir%/tar.m \ %reldir%/tempdir.m \ - %reldir%/tmpnam.m \ %reldir%/unix.m \ %reldir%/unpack.m \ %reldir%/untar.m \
--- a/scripts/miscellaneous/tmpnam.m Mon Mar 26 16:11:33 2018 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -## Copyright (C) 2003-2017 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 -## <https://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {} {@var{fname} =} tmpnam () -## @deftypefnx {} {@var{fname} =} tmpnam (@var{dir}) -## @deftypefnx {} {@var{fname} =} tmpnam (@var{dir}, @var{prefix}) -## Return a unique temporary filename as a string. -## -## If @var{prefix} is omitted, a value of @qcode{"oct-"} is used. -## -## If @var{dir} is also omitted, the default directory for temporary files -## (@code{P_tmpdir} is used. If @var{dir} is provided, it must exist, -## otherwise the default directory for temporary files is used. -## -## Programming Note: Because the named file is not opened by @code{tmpnam}, -## it is possible, though relatively unlikely, that it will not be available -## by the time your program attempts to open it. If this is a concern, -## see @code{tmpfile}. The functions @code{tmpnam} and @code{tempname} are -## equivalent with the latter provided for @sc{matlab} compatibility. -## -## @strong{Caution}: @code{tmpnam} will be removed in a future version of -## Octave. Use the equivalent @code{tempname} in all new code. -## @seealso{tempname, mkstemp, tempdir, P_tmpdir, tmpfile} -## @end deftypefn - -function filename = tmpnam (varargin) - - filename = tempname (varargin{:}); - -endfunction - - -## No tests needed for alias. -%!assert (1)