changeset 19302:e5a1e7951908

Deprecate octave_tmp_file_name. * NEWS: Announce deprecation. * file-io.cc: Remove DEFALIAS to tmpnam function. * scripts/deprecated/octave_tmp_file_name.m: New m-file to replace DEFALIAS. Issues warning about deprecation and calls tmpnam internally. * scripts/deprecated/module.mk: Add octave_tmp_file_name.m to build system.
author Rik <rik@octave.org>
date Mon, 20 Oct 2014 21:54:59 -0700
parents f32fb4d3fb9e
children 65554f5847ac
files NEWS libinterp/corefcn/file-io.cc scripts/deprecated/module.mk scripts/deprecated/octave_tmp_file_name.m
diffstat 4 files changed, 69 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Mon Oct 20 21:21:27 2014 -0700
+++ b/NEWS	Mon Oct 20 21:54:59 2014 -0700
@@ -125,19 +125,20 @@
     be removed from Octave 4.6 (or whatever version is the second major
     release after 4.2):
 
-      Function           | Replacement
-      -------------------|------------------
-      bicubic            | interp2
-      delaunay3          | delaunay
-      dump_prefs         | individual preference get/set routines
-      find_dir_in_path   | dir_in_loadpath
-      finite             | isfinite
-      fmod               | rem
-      fnmatch            | glob or regexp
-      luinc              | ilu or ichol
-      nfields            | numfields
-      syl                | sylvester
-      usage              | print_usage
+      Function             | Replacement
+      ---------------------|------------------
+      bicubic              | interp2
+      delaunay3            | delaunay
+      dump_prefs           | individual preference get/set routines
+      find_dir_in_path     | dir_in_loadpath
+      finite               | isfinite
+      fmod                 | rem
+      fnmatch              | glob or regexp
+      luinc                | ilu or ichol
+      nfields              | numfields
+      octave_tmp_file_name | tempname
+      syl                  | sylvester
+      usage                | print_usage
 
     The following functions were deprecated in Octave 3.8 and have been
     removed from Octave 4.2.
--- a/libinterp/corefcn/file-io.cc	Mon Oct 20 21:21:27 2014 -0700
+++ b/libinterp/corefcn/file-io.cc	Mon Oct 20 21:54:59 2014 -0700
@@ -1932,9 +1932,6 @@
 
 DEFUNX ("tmpnam", Ftmpnam, args, ,
         "-*- texinfo -*-\n\
-@c List other forms of function in documentation index\n\
-@findex octave_tmp_file_name\n\
-\n\
 @deftypefn  {Built-in Function} {@var{fname} =} tmpnam ()\n\
 @deftypefnx {Built-in Function} {@var{fname} =} tmpnam (@var{dir})\n\
 @deftypefnx {Built-in Function} {@var{fname} =} tmpnam (@var{dir}, @var{prefix})\n\
@@ -1980,8 +1977,6 @@
   return retval;
 }
 
-DEFALIAS (octave_tmp_file_name, tmpnam);
-
 DEFUN (tmpfile, args, ,
        "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {[@var{fid}, @var{msg}] =} tmpfile ()\n\
--- a/scripts/deprecated/module.mk	Mon Oct 20 21:21:27 2014 -0700
+++ b/scripts/deprecated/module.mk	Mon Oct 20 21:54:59 2014 -0700
@@ -10,6 +10,7 @@
   deprecated/fnmatch.m \
   deprecated/isstr.m \
   deprecated/luinc.m \
+  deprecated/octave_tmp_file_name.m \
   deprecated/nfields.m \
   deprecated/strmatch.m \
   deprecated/syl.m \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/deprecated/octave_tmp_file_name.m	Mon Oct 20 21:54:59 2014 -0700
@@ -0,0 +1,54 @@
+## 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
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn  {Built-in Function} {@var{fname} =} octave_tmp_file_name ()
+## @deftypefnx {Built-in Function} {@var{fname} =} octave_tmp_file_name (@var{dir})
+## @deftypefnx {Built-in Function} {@var{fname} =} octave_tmp_file_name (@var{dir}, @var{prefix})
+##
+## @code{octave_tmp_file_name} is deprecated and will be removed in Octave
+## version 4.6.  Use @code{tempname} for equivalent functionality.
+##
+## Return a unique temporary file name 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.
+## @seealso{tempname, tmpnam, mkstemp, tempdir, P_tmpdir, tmpfile}
+## @end deftypefn
+
+## Deprecated in version 4.2
+
+
+function filename = octave_tmp_file_name (varargin)
+
+  persistent warned = false;
+  if (! warned)
+    warned = true;
+    warning ("Octave:deprecated-function",
+             "octave_tmp_file_name is obsolete and will be removed from a future version of Octave, please use tempname instead");
+  endif
+
+  filename = tmpnam (varargin{:});
+
+endfunction
+
+
+%!assert (1)
+