annotate scripts/miscellaneous/license.m @ 30564:796f54d4ddbf stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021. In all .txi and .texi files except gpl.txi and gpl.texi in the doc/liboctave and doc/interpreter directories, change the copyright to "Octave Project Developers", the same as used for other source files. Update copyright notices for 2022 (not done since 2019). For gpl.txi and gpl.texi, change the copyright notice to be "Free Software Foundation, Inc." and leave the date at 2007 only because this file only contains the text of the GPL, not anything created by the Octave Project Developers. Add Paul Thomas to contributors.in.
author John W. Eaton <jwe@octave.org>
date Tue, 28 Dec 2021 18:22:40 -0500
parents 363fb10055df
children 5d3faba0342e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30379
diff changeset
3 ## Copyright (C) 2005-2022 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
7 ##
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
8 ## This file is part of Octave.
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
5546
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 ## 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
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
19 ##
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
20 ## 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: 6555
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
25
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19833
diff changeset
27 ## @deftypefn {} {} license
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19833
diff changeset
28 ## @deftypefnx {} {} license inuse
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19833
diff changeset
29 ## @deftypefnx {} {} license inuse @var{feature}
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19833
diff changeset
30 ## @deftypefnx {} {} license ("inuse")
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19833
diff changeset
31 ## @deftypefnx {} {@var{retval} =} license ("inuse")
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19833
diff changeset
32 ## @deftypefnx {} {@var{retval} =} license ("test", @var{feature})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19833
diff changeset
33 ## @deftypefnx {} {@var{retval} =} license ("checkout", @var{feature})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19833
diff changeset
34 ## @deftypefnx {} {[@var{retval}, @var{errmsg}] =} license ("checkout", @var{feature})
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
35 ## Get license information for Octave and Octave packages.
16491
b10a23fe80bb doc: Tweak docstrings of functions changed for Texinfo 5.0 compatibility.
Rik <rik@octave.org>
parents: 16489
diff changeset
36 ##
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
37 ## GNU Octave is free software distributed under the GNU General Public
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
38 ## License (GPL), and a license manager makes no sense. This function is
19405
cbce5d1bcaf9 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 19222
diff changeset
39 ## provided only for @sc{matlab} compatibility.
16491
b10a23fe80bb doc: Tweak docstrings of functions changed for Texinfo 5.0 compatibility.
Rik <rik@octave.org>
parents: 16489
diff changeset
40 ##
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
41 ## When called with no extra input arguments, it returns the Octave license,
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
42 ## otherwise the first input defines the operation mode and must be one of
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
43 ## the following strings: @code{inuse}, @code{test}, and @code{checkout}.
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
44 ## The optional @var{feature} argument can either be @qcode{"octave"} (core),
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
45 ## or an Octave package.
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
46 ##
11595
5ec6aa05638d Prevent doubled quotes around @table items in Info.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
47 ## @table @asis
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
48 ## @item @qcode{"inuse"}
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
49 ## Returns a list of loaded features, i.e., octave and the list of loaded
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
50 ## packages. If an output is requested, it returns a struct array with
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
51 ## the fields @qcode{"feature"}, and @qcode{"user"}.
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
52 ##
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
53 ## @item @qcode{"test"}
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
54 ## Return true if the specified @var{feature} is installed, false otherwise.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
55 ##
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
56 ## An optional third argument @qcode{"enable"} or @qcode{"disable"} is
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
57 ## accepted but ignored.
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
58 ##
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
59 ## @item @qcode{"checkout"}
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
60 ## Return true if the specified @var{feature} is installed, false otherwise.
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
61 ## An optional second output will have an error message if a package is not
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
62 ## installed.
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
63 ##
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
64 ## @end table
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
65 ##
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
66 ## @seealso{pkg, ver, version}
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
67 ## @end deftypefn
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
68
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
69 function [retval, errmsg] = license (cmd, feature, toggle)
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
70
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
71 if (nargin == 0)
28789
28de41192f3c Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents: 27978
diff changeset
72 ## then only give information about Octave core
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
73 retval = "GNU General Public License";
19222
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
74 return;
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
75 endif
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
76
19222
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
77 [features, loaded] = get_all_features ();
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
78
19222
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
79 switch (tolower (cmd))
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
80 case "inuse"
19222
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
81 features = features(loaded);
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
82
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
83 if (nargin > 1)
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
84 features = features(strcmp (features, feature));
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
85 endif
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
86 if (nargout == 0)
21634
96518f623c91 Backed out changeset dcf8922b724b
Mike Miller <mtmiller@octave.org>
parents: 21633
diff changeset
87 printf ("%s\n", features{:});
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
88 else
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
89 retval = struct ("feature", features, "user", get_username ());
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
90 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
91
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
92 case "test"
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
93 if (nargin < 2)
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
94 print_usage ();
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
95 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
96
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
97 if (nargin > 2)
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
98 ## We ignore the toggle argument because... what's the point? We
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
99 ## don't need a license management system on Octave. This function
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
100 ## will return true, even if anyone tries to disable a license.
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
101 switch (tolower (toggle))
19222
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
102 case "enable" # do nothing
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
103 case "disable" # do nothing
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
104 otherwise error ("license: TOGGLE must be enable or disable");
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
105 endswitch
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
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
108 retval = any (strcmp (features, feature));
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
109
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
110 case "checkout"
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
111 ## I guess we could have the checkout command load packages but it's not
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
112 ## really the same thing. The closest we have is simply to check if
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
113 ## there is a package with the feature name, and give an error if not.
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
114
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
115 if (nargin != 2)
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
116 print_usage ();
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
117 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
118
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
119 retval = any (strcmp (features, feature));
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
120 errmsg = "";
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
121
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
122 if (! retval)
19222
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
123 errmsg = ['No package named "' feature '" installed'];
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
124 endif
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
125
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
126 otherwise
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
127 print_usage ();
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
128 endswitch
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
129
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
130 endfunction
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
131
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
132 function username = get_username ()
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29359
diff changeset
133
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
134 pw = getpwuid (getuid ());
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
135 if (isstruct (pw))
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
136 username = pw.name;
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
137 else
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
138 username = "octave_user";
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
139 endif
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29359
diff changeset
140
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
141 endfunction
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
142
19222
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
143 function [features, loaded] = get_all_features ()
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
144 pkg_list = pkg ("list");
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
145 features = {"octave", ...
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
146 cellfun(@(x) x.name, pkg_list, "uniformoutput", false){:}};
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
147 loaded = [true, cellfun(@(x) x.loaded, pkg_list)];
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
148 endfunction
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
149
19222
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
150
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
151 %!assert (license (), "GNU General Public License")
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
152 %!assert ((license ("inuse", "octave")).feature, "octave")
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
153
19222
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
154 %!shared list
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
155 %!test
19222
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
156 %! list = pkg ("list");
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
157 %! for idx = 1: numel (list)
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
158 %! name = list{idx}.name;
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
159 %! if (list{idx}.loaded);
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
160 %! assert ((license ("inuse", name)).feature, name);
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
161 %! else
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
162 %! rv = license ("inuse", name);
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
163 %! assert (isstruct (rv));
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
164 %! assert (all (isfield (rv, {"feature", "user"})));
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
165 %! endif
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
166 %! endfor
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
167
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
168 %!assert (license ("test", "octave"), true)
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
169 %!assert (license ("test", "not_a_valid package name"), false)
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
170
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
171 %!test
19222
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
172 %! for idx = 1: numel (list)
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 20852
diff changeset
173 %! assert (license ("test", list{idx}.name), true);
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
174 %! endfor
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
175
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
176 %!assert (license ("checkout", "octave"), true)
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
177
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
178 %!test
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
179 %! [s, e] = license ("checkout", "NOT_A_PACKAGE");
19222
672674d5e8d9 license.m: Speed up function by 12X
Rik <rik@octave.org>
parents: 19203
diff changeset
180 %! assert (e, 'No package named "NOT_A_PACKAGE" installed');
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
181
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
182 ## Test input validation
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
183 %!error license ("not_inuse")
19203
6dfce51a7b40 license.m: update to treat packages as features (bug #43154).
Carnë Draug <carandraug@octave.org>
parents: 17744
diff changeset
184 %!error license ("not_test", "octave", "enable")
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
185 %!error <TOGGLE must be enable or disable> license ("test", "octave", "invalid_toggle")