~gabriel1984sibiu/octave/octave

« back to all changes in this revision

Viewing changes to scripts/pkg/private/save_order.m

  • Committer: Grevutiu Gabriel
  • Date: 2014-01-02 13:05:54 UTC
  • Revision ID: gabriel1984sibiu@gmail.com-20140102130554-3r7ivdjln1ni6kcg
New version (3.8.0) from upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
## Copyright (C) 2005-2013 Søren Hauberg
 
2
## Copyright (C) 2010 VZLU Prague, a.s.
 
3
##
 
4
## This file is part of Octave.
 
5
##
 
6
## Octave is free software; you can redistribute it and/or modify it
 
7
## under the terms of the GNU General Public License as published by
 
8
## the Free Software Foundation; either version 3 of the License, or (at
 
9
## your option) any later version.
 
10
##
 
11
## Octave is distributed in the hope that it will be useful, but
 
12
## WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
## General Public License for more details.
 
15
##
 
16
## You should have received a copy of the GNU General Public License
 
17
## along with Octave; see the file COPYING.  If not, see
 
18
## <http://www.gnu.org/licenses/>.
 
19
 
 
20
## -*- texinfo -*-
 
21
## @deftypefn {Function File} {@var{newdesc} =} save_order (@var{desc})
 
22
## Undocumented internal function.
 
23
## @end deftypefn
 
24
 
 
25
function newdesc = save_order (desc)
 
26
  newdesc = {};
 
27
  for i = 1 : length (desc)
 
28
    deps = desc{i}.depends;
 
29
    if (isempty (deps)
 
30
        || (length (deps) == 1 && strcmp (deps{1}.package, "octave")))
 
31
      newdesc {end + 1} = desc{i};
 
32
    else
 
33
      tmpdesc = {};
 
34
      for k = 1 : length (deps)
 
35
        for j = 1 : length (desc)
 
36
          if (strcmp (desc{j}.name, deps{k}.package))
 
37
            tmpdesc{end+1} = desc{j};
 
38
            break;
 
39
          endif
 
40
        endfor
 
41
      endfor
 
42
      if (! isempty (tmpdesc))
 
43
        newdesc = {newdesc{:}, save_order(tmpdesc){:}, desc{i}};
 
44
      else
 
45
        newdesc{end+1} = desc{i};
 
46
      endif
 
47
    endif
 
48
  endfor
 
49
  ## Eliminate the duplicates.
 
50
  idx = [];
 
51
  for i = 1 : length (newdesc)
 
52
    for j = (i + 1) : length (newdesc)
 
53
      if (strcmp (newdesc{i}.name, newdesc{j}.name))
 
54
        idx (end + 1) = j;
 
55
      endif
 
56
    endfor
 
57
  endfor
 
58
  newdesc(idx) = [];
 
59
endfunction
 
60