Mercurial > hg > octave-nkf
annotate scripts/plot/util/hgload.m @ 19470:6ca096827123
Use tempname() rather than tmpnam() in core Octave.
* scripts/miscellaneous/tempname.m: Removed m-file as function is now C++.
* scripts/miscellaneous/tmpnam.m: New m-file is an alias that calls tempname.
* scripts/miscellaneous/module.mk: Add tmpnam.m to build system.
* io.txi: Place tempname, tempdir, P_tmpdir docstrings in section on temporary
files.
* system.txi: Remove tempname, tempdir, P_tmpdir docstrings from generic
system functions section of manual.
* dirfns.cc, dlmread.cc, md5sum.cc, ov-fcn-handle.cc: Replace instances
of tmpnam with tempname in BIST code.
* file-io.cc (Ftempname): Change DEFUNX for tmpnam to DEFUN for tempname.
Remove seealso links to tmpnam.
* ftp.m, playaudio.m, wavwrite.m, imformats.m, imread.m, imwrite.m, imageIO.m,
csvwrite.m, dlmwrite.m, fileread.m, importdata.m, textread.m, textscan.m,
genvarname.m, unpack.m, install.m, legend.m, __gnuplot_drawnow__.m,
copyobj.m, hgsave.m, print.m, __ghostscript__.m, __gnuplot_get_var__.m,
__gnuplot_ginput__.m, __gnuplot_print__.m: Replace tmpnam with tempname in
core code.
* build-sparse-tests.sh, io.tst, prefer.tst, system.tst: Replace tmpnam with
tempname in test code.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 22 Oct 2014 10:41:15 -0700 |
parents | a142f35f3cb6 |
children | db92e7e28e1f |
rev | line source |
---|---|
18715
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
1 ## Copyright (C) 2014 Massimiliano Fasi |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
2 ## |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
4 ## |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
8 ## your option) any later version. |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
9 ## |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
13 ## General Public License for more details. |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
14 ## |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
18 |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
18834
a142f35f3cb6
doc: Fix unbalanced parentheses in documentation.
Rik <rik@octave.org>
parents:
18747
diff
changeset
|
20 ## @deftypefn {Function File} {@var{h} =} hgload (@var{filename}) |
18715
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
21 ## Load the graphics object in @var{filename} into the graphics handle @var{h}. |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
22 ## |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
23 ## If @var{filename} has no extension, Octave will try to find the file with |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
24 ## and without the standard extension of @file{.ofig}. |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
25 ## @seealso{hgsave, struct2hdl} |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
26 ## @end deftypefn |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
27 |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
28 ## Author: Massimiliano Fasi |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
29 |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
30 function h = hgload (filename) |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
31 |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
32 ## Check input arguments |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
33 if (nargin != 1) |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
34 print_usage (); |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
35 endif |
18747
348f67886dc4
hgload.m: Check for file with .ofig extension before bare file name (bug #41978).
Rik <rik@octave.org>
parents:
18744
diff
changeset
|
36 |
18715
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
37 ## Check file existence |
18747
348f67886dc4
hgload.m: Check for file with .ofig extension before bare file name (bug #41978).
Rik <rik@octave.org>
parents:
18744
diff
changeset
|
38 [~, ~, ext] = fileparts (filename); |
348f67886dc4
hgload.m: Check for file with .ofig extension before bare file name (bug #41978).
Rik <rik@octave.org>
parents:
18744
diff
changeset
|
39 if (isempty (ext)) |
348f67886dc4
hgload.m: Check for file with .ofig extension before bare file name (bug #41978).
Rik <rik@octave.org>
parents:
18744
diff
changeset
|
40 if (! isempty (file_in_loadpath ([filename ".ofig"]))) |
18715
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
41 filename = [filename ".ofig"]; |
18747
348f67886dc4
hgload.m: Check for file with .ofig extension before bare file name (bug #41978).
Rik <rik@octave.org>
parents:
18744
diff
changeset
|
42 elseif (isempty (file_in_loadpath (filename))) |
348f67886dc4
hgload.m: Check for file with .ofig extension before bare file name (bug #41978).
Rik <rik@octave.org>
parents:
18744
diff
changeset
|
43 error ("hgload: unable to locate file %s", filename); |
18715
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
44 endif |
18747
348f67886dc4
hgload.m: Check for file with .ofig extension before bare file name (bug #41978).
Rik <rik@octave.org>
parents:
18744
diff
changeset
|
45 else |
18744
70d9db29db6f
hgload.m: Correctly find filenames with .ofig extension.
Rik <rik@octave.org>
parents:
18716
diff
changeset
|
46 if (isempty (file_in_loadpath (filename))) |
18715
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
47 error ("hgload: unable to locate file %s", filename); |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
48 endif |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
49 endif |
18747
348f67886dc4
hgload.m: Check for file with .ofig extension before bare file name (bug #41978).
Rik <rik@octave.org>
parents:
18744
diff
changeset
|
50 |
18715
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
51 ## Load the handle |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
52 try |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
53 stmp = load (filename, "s_oct40"); |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
54 catch |
18716
70cff922a42d
hgload.m: Change wording of error message for more clarity.
Rik <rik@octave.org>
parents:
18715
diff
changeset
|
55 error ("hgload: could not load hgsave-formatted object in file %s", filename); |
18715
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
56 end_try_catch |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
57 |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
58 h = struct2hdl (stmp.s_oct40); |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
59 |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
60 endfunction |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
61 |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
62 |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
63 ## Functional test for hgload/hgsave pair is in hgsave.m |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
64 |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
65 %% Test input validation |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
66 %!error hgload () |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
67 %!error hgload (1, 2) |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
68 %!error <unable to locate file> hgload ("%%_A_REALLY_UNLIKELY_FILENAME_%%") |
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff
changeset
|
69 |