Mercurial > octave
annotate scripts/miscellaneous/version.m @ 21601:25fd18a15a6c
version.m: Use more Octave coding standards.
* version.m: Improve docstring. Match variables in function prototype to those
in documentation. Use parentheses to indicate a function call. Use documented
variable names in error messages. Use semicolons to end assert statements
when they are within a BIST block. Add input validation tests.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 10 Apr 2016 20:18:22 -0700 |
parents | 184b85b31e03 |
children | d7a268e68e69 |
rev | line source |
---|---|
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19187
diff
changeset
|
1 ## Copyright (C) 1994-2015 John W. Eaton |
2313 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
861 | 18 |
3301 | 19 ## -*- texinfo -*- |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
20 ## @deftypefn {} {@var{v} =} version () |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
21 ## @deftypefnx {} {[@var{v}, @var{d}] =} version () |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
22 ## @deftypefnx {} {@var{v} =} version (@var{feature}) |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
23 ## Get version information for Octave. |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
24 ## |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
25 ## If called without input argument, the first return value @var{v} gives the |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
26 ## version number of Octave as a string. The second return value @var{d} holds |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
27 ## the release date as a string. |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
28 ## |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
29 ## The following options can be passed for @var{feature}: |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
30 ## |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
31 ## @table @asis |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
32 ## @item @qcode{"-date"} |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
33 ## for the release date of the running build, |
12208
9611014e7cf1
Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
34 ## |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
35 ## @item @qcode{"-description"} |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
36 ## for a description of the release (always an empty string), |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
37 ## |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
38 ## @item @qcode{"-release"} |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
39 ## for the name of the running build, |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
40 ## |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
41 ## @item @qcode{"-java"} |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
42 ## for version information of the Java VM, |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
43 ## |
21600
184b85b31e03
more updates for version function
mmuetzel <markus.muetzel@gmx.de>
parents:
21597
diff
changeset
|
44 ## @item @qcode{"-fftw"} |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
45 ## for version information for the linked @sc{fftw}, |
21600
184b85b31e03
more updates for version function
mmuetzel <markus.muetzel@gmx.de>
parents:
21597
diff
changeset
|
46 ## |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
47 ## @item @qcode{"-blas"} |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
48 ## for version information for the linked @sc{blas} (not implemented), |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
49 ## |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
50 ## @item @qcode{"-lapack"} |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
51 ## for version information for the linked @sc{lapack} (not implemented). |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
52 ## @end table |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
53 ## |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
54 ## The variant with no input and output argument is an alias for the function |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
55 ## @w{@env{OCTAVE_VERSION}} provided for compatibility. |
19187 | 56 ## @seealso{OCTAVE_VERSION, ver} |
3301 | 57 ## @end deftypefn |
861 | 58 |
2314 | 59 ## Author: jwe |
60 | |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
61 function [v, d] = version (feature) |
861 | 62 |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
63 if (nargin > 1 || ((nargin != 0) && ((nargout > 1) || ! ischar (feature)))) |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
64 print_usage (); |
861 | 65 endif |
66 | |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
67 if (nargin == 0) |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
68 v = OCTAVE_VERSION (); |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
69 |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
70 if (nargout > 1) |
21600
184b85b31e03
more updates for version function
mmuetzel <markus.muetzel@gmx.de>
parents:
21597
diff
changeset
|
71 d = __octave_config_info__ ("release_date"); |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
72 end |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
73 else |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
74 switch (feature) |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
75 case "-date" |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
76 v = __octave_config_info__ ("release_date"); |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
77 case "-description" |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
78 v = ""; |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
79 case "-release" |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
80 v = ""; |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
81 case "-java" |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
82 try |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
83 jversion = javaMethod ("getProperty", "java.lang.System", ... |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
84 "java.runtime.version"); |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
85 jvendor = javaMethod ("getProperty", "java.lang.System", ... |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
86 "java.vendor"); |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
87 jname = javaMethod ("getProperty", "java.lang.System", ... |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
88 "java.vm.name"); |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
89 jjitmode = javaMethod ("getProperty", "java.lang.System", ... |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
90 "java.vm.info"); |
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
91 v = ["Java " jversion " with " jvendor " " jname " " jjitmode]; |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
92 catch |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
93 v = "no java available"; |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
94 end_try_catch |
21600
184b85b31e03
more updates for version function
mmuetzel <markus.muetzel@gmx.de>
parents:
21597
diff
changeset
|
95 case "-fftw" |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
96 v = __octave_config_info__ ("fftw_version"); |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
97 case "-blas" |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
98 v = ""; |
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
99 warning ("version: option '-blas' not implemented"); |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
100 case "-lapack" |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
101 v = ""; |
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
102 warning ("version: option '-lapack' not implemented"); |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
103 otherwise |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
104 error ("version: invalid FEATURE"); |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
105 endswitch |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
106 endif |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
107 |
861 | 108 endfunction |
7411 | 109 |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
110 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
111 %!assert (ischar (version ())) |
7411 | 112 |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
113 %!test |
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
114 %! [v, d] = version (); |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
115 %! assert (v, OCTAVE_VERSION); |
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
116 %! assert (d, __octave_config_info__ ("release_date")); |
7411 | 117 |
21600
184b85b31e03
more updates for version function
mmuetzel <markus.muetzel@gmx.de>
parents:
21597
diff
changeset
|
118 %!assert (version ("-date"), __octave_config_info__ ("release_date")) |
21597
fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
20852
diff
changeset
|
119 |
21601
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
120 ## Test input validation |
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
121 %!error version ("-date", "-release") |
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
122 %!error [v, d] = version ("-date") |
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
123 %!error version (1) |
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
124 %!warning <option '-blas' not implemented> version ("-blas"); |
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
125 %!warning <option '-lapack' not implemented> version ("-lapack"); |
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
126 %!error <invalid FEATURE> version ("-foobar") |
25fd18a15a6c
version.m: Use more Octave coding standards.
Rik <rik@octave.org>
parents:
21600
diff
changeset
|
127 |