annotate scripts/miscellaneous/license.m @ 17691:8a54a481ecb5

Massive speed improvement in sparse min/max functions for calls like 'max(s,[],2)' (bug #40268) * dSparse.cc (SparseMatrix SparseMatrix::max (Array<octave_idx-type>&, int)) : Remove triple loop by using a local buffer (SparseMatrix SparseMatrix::min (Array<octave_idx-type>&, int)) : ditto * CSparse.cc (SparseComplexMatrix SparseComplexMatrix::max ( Array<octave_idx-type>&, int)) : Remove triple loop by using a local buffer (SparseComplexMatrix SparseComplexMatrix::min (Array<octave_idx-type>&, int)) : ditto
author David Bateman <dbateman@free.fr>
date Fri, 18 Oct 2013 23:44:44 +0200
parents bc924baa2c4e
children d63878346099
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: 13825
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: 6555
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: 6555
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: 6555
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: 6555
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 -*-
16491
b10a23fe80bb doc: Tweak docstrings of functions changed for Texinfo 5.0 compatibility.
Rik <rik@octave.org>
parents: 16489
diff changeset
20 ## @deftypefn {Command} {} license
16489
36dba9be680b doc: Make documentation compatible with Texinfo 5.0 (bug #38392)
Amod Mulay <amodmulay1@gmail.com>
parents: 15466
diff changeset
21 ## @deftypefnx {Function File} {} license ("inuse")
36dba9be680b doc: Make documentation compatible with Texinfo 5.0 (bug #38392)
Amod Mulay <amodmulay1@gmail.com>
parents: 15466
diff changeset
22 ## @deftypefnx {Function File} {@var{retval} =} license ("inuse")
36dba9be680b doc: Make documentation compatible with Texinfo 5.0 (bug #38392)
Amod Mulay <amodmulay1@gmail.com>
parents: 15466
diff changeset
23 ## @deftypefnx {Function File} {@var{retval} =} license ("test", @var{feature})
36dba9be680b doc: Make documentation compatible with Texinfo 5.0 (bug #38392)
Amod Mulay <amodmulay1@gmail.com>
parents: 15466
diff changeset
24 ## @deftypefnx {Function File} {} license ("test", @var{feature}, @var{toggle})
36dba9be680b doc: Make documentation compatible with Texinfo 5.0 (bug #38392)
Amod Mulay <amodmulay1@gmail.com>
parents: 15466
diff changeset
25 ## @deftypefnx {Function File} {@var{retval} =} license ("checkout", @var{feature})
36dba9be680b doc: Make documentation compatible with Texinfo 5.0 (bug #38392)
Amod Mulay <amodmulay1@gmail.com>
parents: 15466
diff changeset
26 ##
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
27 ## Display the license of Octave.
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
28 ##
16489
36dba9be680b doc: Make documentation compatible with Texinfo 5.0 (bug #38392)
Amod Mulay <amodmulay1@gmail.com>
parents: 15466
diff changeset
29 ## @code{license ("inuse")}
16491
b10a23fe80bb doc: Tweak docstrings of functions changed for Texinfo 5.0 compatibility.
Rik <rik@octave.org>
parents: 16489
diff changeset
30 ##
5548
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
31 ## Display a list of packages currently being used.
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
32 ##
16489
36dba9be680b doc: Make documentation compatible with Texinfo 5.0 (bug #38392)
Amod Mulay <amodmulay1@gmail.com>
parents: 15466
diff changeset
33 ## @code{@var{retval} = license ("inuse")}
16491
b10a23fe80bb doc: Tweak docstrings of functions changed for Texinfo 5.0 compatibility.
Rik <rik@octave.org>
parents: 16489
diff changeset
34 ##
5548
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
35 ## Return a structure containing the fields @code{feature} and @code{user}.
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
36 ##
16489
36dba9be680b doc: Make documentation compatible with Texinfo 5.0 (bug #38392)
Amod Mulay <amodmulay1@gmail.com>
parents: 15466
diff changeset
37 ## @code{@var{retval} = license ("test", @var{feature})}
16491
b10a23fe80bb doc: Tweak docstrings of functions changed for Texinfo 5.0 compatibility.
Rik <rik@octave.org>
parents: 16489
diff changeset
38 ##
5548
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
39 ## Return 1 if a license exists for the product identified by the string
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
40 ## @var{feature} and 0 otherwise. The argument @var{feature} is case
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
41 ## insensitive and only the first 27 characters are checked.
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
42 ##
16489
36dba9be680b doc: Make documentation compatible with Texinfo 5.0 (bug #38392)
Amod Mulay <amodmulay1@gmail.com>
parents: 15466
diff changeset
43 ## @code{license ("test", @var{feature}, @var{toggle})}
16491
b10a23fe80bb doc: Tweak docstrings of functions changed for Texinfo 5.0 compatibility.
Rik <rik@octave.org>
parents: 16489
diff changeset
44 ##
5548
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
45 ## Enable or disable license testing for @var{feature}, depending on
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
46 ## @var{toggle}, which may be one of:
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
47 ##
11595
5ec6aa05638d Prevent doubled quotes around @table items in Info.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
48 ## @table @asis
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16491
diff changeset
49 ## @item @qcode{"enable"}
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
50 ## Future tests for the specified license of @var{feature} are conducted
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
51 ## as usual.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
52 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16491
diff changeset
53 ## @item @qcode{"disable"}
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
54 ## Future tests for the specified license of @var{feature} return 0.
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
55 ## @end table
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
56 ##
16489
36dba9be680b doc: Make documentation compatible with Texinfo 5.0 (bug #38392)
Amod Mulay <amodmulay1@gmail.com>
parents: 15466
diff changeset
57 ## @code{@var{retval} = license ("checkout", @var{feature})}
16491
b10a23fe80bb doc: Tweak docstrings of functions changed for Texinfo 5.0 compatibility.
Rik <rik@octave.org>
parents: 16489
diff changeset
58 ##
5548
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
59 ## Check out a license for @var{feature}, returning 1 on success and 0
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
60 ## on failure.
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
61 ##
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 7017
diff changeset
62 ## This function is provided for compatibility with @sc{matlab}.
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5548
diff changeset
63 ## @seealso{ver, version}
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
64 ## @end deftypefn
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
65
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
66 ## Author: William Poetra Yoga Hadisoeseno <williampoetra@gmail.com>
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
67
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
68 function retval = license (varargin)
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
69
5548
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
70 persistent __octave_licenses__;
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
71
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
72 if (isempty (__octave_licenses__))
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
73 __octave_licenses__ = cell ();
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
74 __octave_licenses__{1,1} = "Octave";
6555
69e864d21c11 [project @ 2007-04-20 18:16:08 by jwe]
jwe
parents: 6547
diff changeset
75 __octave_licenses__{1,2} = "GNU General Public License";
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
76 __octave_licenses__{1,3} = true;
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
77 if (exist ("OCTAVE_FORGE_VERSION"))
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
78 __octave_licenses__{2,1} = "octave-forge";
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
79 __octave_licenses__{2,2} = "<various licenses>";
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
80 __octave_licenses__{2,3} = true;
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
81 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
82 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
83
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
84 nout = nargout;
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
85 nin = nargin;
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
86 nr_licenses = rows (__octave_licenses__);
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
87
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
88 if (nout > 1 || nin > 3)
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
89 print_usage ();
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
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
92 if (nin == 0)
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
93
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
94 found = find (strcmp (__octave_licenses__(:,1), "Octave"), 1);
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
95
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
96 if (! isempty (found))
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
97 result = __octave_licenses__{found,2};
5548
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
98 else
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
99 result = "unknown";
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
100 endif
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
101
5548
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
102 if (nout == 0)
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
103 printf ("%s\n", result);
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
104 else
5548
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
105 retval = result;
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
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
108 elseif (nin == 1)
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
109
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
110 if (nout == 0)
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
111
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
112 if (! strcmp (varargin{1}, "inuse"))
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
113 usage ('license ("inuse")');
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
114 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
115
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
116 printf ("%s\n", __octave_licenses__{:,1});
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
117
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
118 else
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
119
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
120 if (! strcmp (varargin{1}, "inuse"))
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
121 usage ('retval = license ("inuse")');
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
122 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
123
5548
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
124 pw = getpwuid (getuid ());
5cc01ba4c052 [project @ 2005-11-30 03:04:44 by jwe]
jwe
parents: 5546
diff changeset
125 if (isstruct (pw))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
126 username = pw.name;
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
127 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
128 username = "octave_user";
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
129 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
130
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 retval = struct ("feature", __octave_licenses__(:,1), "user", username);
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
132
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
133 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
134
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
135 else
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
136
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
137 feature = varargin{2}(1:(min ([(length (varargin{2})), 27])));
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
138
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
139 if (strcmp (varargin{1}, "test"))
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
140
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
141 found = find (strcmpi (__octave_licenses__(:,1), feature), 1);
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
142
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
143 if (nin == 2)
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
144 retval = ! isempty (found) && __octave_licenses__{found,3};
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
145 else
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
146 if (! isempty (found))
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
147 if (strcmp (varargin{3}, "enable"))
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
148 __octave_licenses__{found,3} = true;
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
149 elseif (strcmp (varargin{3}, "disable"))
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
150 __octave_licenses__{found,3} = false;
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
151 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
152 error ("license: TOGGLE must be either 'enable' or 'disable'");
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
153 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
154 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
155 error ("license: FEATURE '%s' not found", feature);
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
156 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
157 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
158
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
159 elseif (strcmp (varargin{1}, "checkout"))
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
160
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
161 if (nin != 2)
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
162 usage ('retval = license ("checkout", feature)');
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
163 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
164
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
165 found = find (strcmpi (__octave_licenses__(:,1), feature), 1);
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
166
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 retval = ! isempty (found) && __octave_licenses__{found,3};
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
168
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
169 else
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 print_usage ();
5546
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
171 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
172
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
173 endif
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
174
3ebf0e35156c [project @ 2005-11-29 17:30:50 by jwe]
jwe
parents:
diff changeset
175 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
176
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
177
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
178 %!assert (license(), "GNU General Public License")
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
179 %!assert ((license ("inuse")).feature, "Octave")
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
180
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
181 %!test
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
182 %! lstate = license ("test", "Octave");
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
183 %! license ("test", "Octave", "disable");
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
184 %! assert (license ("test", "Octave"), false);
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
185 %! license ("test", "Octave", "enable");
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
186 %! assert (license ("test", "Octave"), true);
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
187 %! if (lstate == false)
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
188 %! license ("test", "Octave", "disable");
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
189 %! endif
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
190
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
191 %!assert (license ("checkout", "Octave"), true)
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
192
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
193 %% Test input validation
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
194 %!error license ("not_inuse")
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
195 %!error <TOGGLE must be either> license ("test", "Octave", "not_enable")
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
196 %!error <FEATURE 'INVALID' not found> license ("test", "INVALID", "enable")
13825
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
197 %!error license ("not_test", "Octave", "enable")
45f4ff9a6247 license.m: Update to modern coding standards. Add functional and input validation tests.
Rik <octave@nomad.inbox5.com>
parents: 12480
diff changeset
198