annotate scripts/miscellaneous/ver.m @ 12312:b10ea6efdc58 release-3-4-x ss-3-3-91

version is now 3.3.91
author John W. Eaton <jwe@octave.org>
date Mon, 31 Jan 2011 08:36:58 -0500
parents f07e6b4d34c7
children f96b9b9f141b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11469
diff changeset
1 ## Copyright (C) 2005-2011 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 ()
12288
f07e6b4d34c7 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
f07e6b4d34c7 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,
f07e6b4d34c7 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
23 ## versions, and installation directories.
f07e6b4d34c7 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
12288
f07e6b4d34c7 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
30 ## @item Name
f07e6b4d34c7 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 ##
12288
f07e6b4d34c7 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
33 ## @item Version
f07e6b4d34c7 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 ##
12288
f07e6b4d34c7 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
36 ## @item Revision
f07e6b4d34c7 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 ##
12288
f07e6b4d34c7 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
39 ## @item Date
f07e6b4d34c7 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
12288
f07e6b4d34c7 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
42 ##
7499
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
43 ## @deftypefnx {Function File} {v =} ver (@code{"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.
12288
f07e6b4d34c7 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
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}.
12288
f07e6b4d34c7 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
48 ##
f07e6b4d34c7 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 = [];
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
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
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
110 %!test
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
111 %! result = ver;
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
112 %! assert (result(1).Name, "Octave")
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
113 %! assert (result(1).Version, version)
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
114 %! result = ver ("octave");
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
115 %! assert (result(1).Name, "Octave")
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
116 %! assert (result(1).Version, version)
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
117
7499
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
118 %!test
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
119 %! lst = pkg ("list");
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
120 %! for n=1:numel(lst)
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
121 %! expected = lst{n}.name;
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
122 %! result = ver (expected);
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
123 %! assert (result.Name, expected);
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
124 %! assert (isfield (result, "Version"), true);
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
125 %! assert (isfield (result, "Release"), true);
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
126 %! assert (isfield (result, "Date"), true);
94d0cdd60dda Added pkg version info and matlab compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
127 %! endfor
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
128