1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2009 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
// Internal function
// Return the sorted version list of the package entered as input argument
function versions = atomsGetVersions(name,min_version,max_version,min_version_included,max_version_included)
// Initialize
// =========================================================================
versions = [];
// Check input parameters
// =========================================================================
rhs = argn(2);
if rhs < 1 | rhs > 5 then
error(msprintf(gettext("%s: Wrong number of input argument: %d to %d expected.\n"),"atomsGetVersions",1,5));
end
if type(name) <> 10 then
error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"atomsGetVersions",1));
end
if (rhs>1) & (type(min_version)<>10) then
error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"atomsGetVersions",2));
end
if (rhs>2) & (type(max_version)<>10) then
error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"atomsGetVersions",3));
end
if (rhs>3) & (type(min_version_included)<>4) then
error(msprintf(gettext("%s: Wrong type for input argument #%d: Boolean expected.\n"),"atomsGetVersions",4));
end
if (rhs>4) & (type(max_version_included)<>4) then
error(msprintf(gettext("%s: Wrong type for input argument #%d: Boolean expected.\n"),"atomsGetVersions",5));
end
// Default values
// =========================================================================
if (rhs<2) | ( (rhs>=2) & (min_version=="") ) then
min_version = "0";
end
if (rhs<3) | ( (rhs>=3) & (max_version=="") ) then
max_version = "9999999";
end
if rhs<4 then
min_version_included = %T;
end
if rhs<5 then
max_version_included = %T;
end
// Get all package description
// =========================================================================
allpackages = atomsDESCRIPTIONget();
// Check if it's a Atoms package
// =========================================================================
if ~isfield(allpackages, name) then
error(msprintf(gettext("%s: Wrong value for input argument #%d: ""%s"" must be an available atoms package name.\n"), "atomsGetVersions",1, name));
end
// Get versions
// =========================================================================
package_versions = allpackages(name);
package_versions_tab = getfield(1,package_versions);
package_versions_tab(1:2) = [];
package_versions_tab = package_versions_tab';
without_packaging_ver = [];
for i=1:size(package_versions_tab,"*")
if ~ isempty(strindex(package_versions_tab(i),"-")) then
without_packaging_ver = [ without_packaging_ver ; part(package_versions_tab(i),1:strindex(package_versions_tab(i),"-")-1) ];
else
without_packaging_ver = [ without_packaging_ver ; package_versions_tab(i) ];
end
end
// Delete out of bounds versions
// =========================================================================
if isempty(strindex(max_version,"-")) then
// max_version doesn't contain a packaging version
if max_version_included then
indexToDel = find(atomsVersionCompare(without_packaging_ver,max_version) > 0);
else
indexToDel = find(atomsVersionCompare(without_packaging_ver,max_version) >= 0);
end
else
// max_version contains a packaging version
if max_version_included then
indexToDel = find(atomsVersionCompare(package_versions_tab,max_version) > 0);
else
indexToDel = find(atomsVersionCompare(package_versions_tab,max_version) >= 0);
end
end
package_versions_tab(indexToDel,:) = [];
without_packaging_ver(indexToDel) = [];
if isempty(strindex(min_version,"-")) then
// min_version doesn't contain a packaging version
if min_version_included then
indexToDel = find(atomsVersionCompare(without_packaging_ver,min_version) < 0)
else
indexToDel = find(atomsVersionCompare(without_packaging_ver,min_version) <= 0)
end
else
// min_version contains a packaging version
if min_version_included then
indexToDel = find(atomsVersionCompare(package_versions_tab,min_version) < 0)
else
indexToDel = find(atomsVersionCompare(package_versions_tab,min_version) <= 0)
end
end
package_versions_tab(indexToDel,:) = [];
without_packaging_ver(indexToDel) = [];
// Sort the version matrix
// =========================================================================
versions = atomsVersionSort(package_versions_tab,"DESC");
endfunction
|