annotate scripts/miscellaneous/ver.m @ 16033:23a7661e529a ss-3-7-2

snapshot version 3.7.2 * configure.ac (AC_INIT): Set version to 3.7.2. (OCTAVE_RELEASE_DATE): Set to 2013-02-09. (OCTAVE_COPYRIGHT): Update year.
author John W. Eaton <jwe@octave.org>
date Sun, 10 Feb 2013 00:59:19 -0500
parents 5d3a684236b0
children 36dba9be680b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 12681
diff changeset
1 ## Copyright (C) 2005-2012 William Poetra Yoga Hadisoeseno
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
2 ##
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
4 ##
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6615
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6615
diff changeset
8 ## your option) any later version.
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
9 ##
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
14 ##
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6615
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6615
diff changeset
17 ## <http://www.gnu.org/licenses/>.
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
18
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
6615
687ae48b2253 [project @ 2007-05-13 06:24:57 by jwe]
jwe
parents: 6046
diff changeset
20 ## @deftypefn {Function File} {} ver ()
12208
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
21 ## Display a header containing the current Octave version number, license
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
22 ## string and operating system, followed by the installed package names,
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
23 ## versions, and installation directories.
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
24 ##
7499
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
25 ## @deftypefnx {Function File} {v =} ver ()
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
26 ## Return a vector of structures, respecting Octave and each installed package.
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
27 ## The structure includes the following fields.
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
28 ##
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
29 ## @table @code
12208
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
30 ## @item Name
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
31 ## Package name.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 8920
diff changeset
32 ##
12208
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
33 ## @item Version
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
34 ## Version of the package.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 8920
diff changeset
35 ##
12208
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
36 ## @item Revision
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
37 ## Revision of the package.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 8920
diff changeset
38 ##
12208
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
39 ## @item Date
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
40 ## Date respecting the version/revision.
7499
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
41 ## @end table
12208
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
42 ##
12681
c09ed93d1a8b doc: Don't use @code{} within @deftypefn macro
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
43 ## @deftypefnx {Function File} {v =} ver ("Octave")
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
44 ## Return version information for Octave only.
12642
f96b9b9f141b doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 12208
diff changeset
45 ##
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
46 ## @deftypefnx {Function File} {v =} ver (@var{package})
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
47 ## Return version information for @var{package}.
12208
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
48 ##
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
49 ## @seealso{version, octave_config_info}
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
50 ## @end deftypefn
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
51
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
52 ## Author: William Poetra Yoga Hadisoeseno <williampoetra@gmail.com>
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
53
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
54 function varargout = ver (package = "")
7499
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
55
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
56 if (nargin > 1)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5642
diff changeset
57 print_usage ();
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
58 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
59
7499
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
60 ## Start with the version info for Octave
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
61 ret = struct ("Name", "Octave", "Version", version,
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
62 "Release", [], "Date", []);
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
63
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
64 ## Add the installed packages
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
65 lst = pkg ("list");
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
66 for i = 1:length (lst)
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
67 ret(end+1) = struct ("Name", lst{i}.name, "Version", lst{i}.version,
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
68 "Release", [], "Date", lst{i}.date);
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
69 endfor
5548
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
70
7499
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
71 if (nargout == 0)
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
72 octave_license = license ();
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
73
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
74 [unm, status] = uname ();
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
75
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
76 if (status < 0)
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
77 os_string = "unknown";
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
78 else
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
79 os_string = sprintf ("%s %s %s %s", unm.sysname, unm.release,
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
80 unm.version, unm.machine);
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
81 endif
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
82
7499
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
83 hbar(1:70) = "-";
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
84 ver_line1 = "GNU Octave Version ";
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
85 ver_line2 = "GNU Octave License: ";
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
86 ver_line3 = "Operating System: ";
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
87
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
88 ver_desc = sprintf ("%s\n%s%s\n%s%s\n%s%s\n%s\n", hbar, ver_line1, version,
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
89 ver_line2, octave_license, ver_line3, os_string, hbar);
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
90
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
91 puts (ver_desc);
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
92
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
93 pkg ("list");
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
94 else
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
95 if (! isempty (package))
7499
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
96 n = [];
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
97 for r = 1:numel (ret)
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
98 if (strcmpi (ret(r).Name, package))
7499
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
99 n = r;
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
100 break;
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
101 endif
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
102 endfor
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
103 ret = ret(n);
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
104 endif
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
105 varargout{1} = ret;
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
106 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
107
7499
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
108 endfunction
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
109
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
110
7499
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
111 %!test
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
112 %! result = ver;
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
113 %! assert (result(1).Name, "Octave");
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
114 %! assert (result(1).Version, version);
7499
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
115 %! result = ver ("octave");
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
116 %! assert (result(1).Name, "Octave");
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
117 %! assert (result(1).Version, version);
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
118
7499
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
119 %!test
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
120 %! lst = pkg ("list");
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
121 %! for n = 1:numel (lst)
7499
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
122 %! expected = lst{n}.name;
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
123 %! result = ver (expected);
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
124 %! assert (result.Name, expected);
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
125 %! assert (isfield (result, "Version"), true);
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
126 %! assert (isfield (result, "Release"), true);
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
127 %! assert (isfield (result, "Date"), true);
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
128 %! endfor
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
129