Mercurial > hg > octave-lyh
annotate scripts/miscellaneous/ver.m @ 16207:0467d68ca891
move current_input_line to lexical_feedback class
* input.h, input.cc, lex.h, lex.ll (current_input_line): Declare as
member of lexical_feedback class.
(octave_base_reader::octave_gets, octave_terminal_reader::get_input,
octave_file_reader::get_input, octave_eval_string_reader::get_input):
Don't set current_input_line.
(octave_lexer::read): Set current_input_line.
* oct-parse.in.yy (octave_parser::bison_error): Use
curr_lexer->current_input_line.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 06 Mar 2013 19:39:48 -0500 |
parents | 5d3a684236b0 |
children | 36dba9be680b |
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 | 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. | |
5546 | 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/>. | |
5546 | 18 |
19 ## -*- texinfo -*- | |
6615 | 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 | 50 ## @end deftypefn |
51 | |
52 ## Author: William Poetra Yoga Hadisoeseno <williampoetra@gmail.com> | |
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 | 57 print_usage (); |
5546 | 58 endif |
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 | 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 | 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 | 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 | 106 endif |
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 | 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 | 129 |