Mercurial > hg > octave-nkf
annotate scripts/pkg/private/installed_packages.m @ 20815:a260a6acb70f
fix test failures introduced by a22d8a2eb0e5
* scripts/ode/private/integrate_adaptive.m: fix stepping backwards, fix
invocation of OutputFcn, fix text of some error messages
* scripts/ode/private/integrate_const.m: remove use of option OutputSave
* scripts/ode/private/integrate_n_steps.m: remove use of option OutputSave
author | Carlo de Falco <carlo.defalco@polimi.it> |
---|---|
date | Sun, 11 Oct 2015 23:09:01 +0200 |
parents | ad7fe3cb6fd2 |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19794
diff
changeset
|
1 ## Copyright (C) 2005-2015 Søren Hauberg |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
2 ## Copyright (C) 2010 VZLU Prague, a.s. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
3 ## |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
4 ## This file is part of Octave. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
5 ## |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
6 ## Octave is free software; you can redistribute it and/or modify it |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
7 ## under the terms of the GNU General Public License as published by |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
9 ## your option) any later version. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
10 ## |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
11 ## Octave is distributed in the hope that it will be useful, but |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
14 ## General Public License for more details. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
15 ## |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
16 ## You should have received a copy of the GNU General Public License |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
17 ## along with Octave; see the file COPYING. If not, see |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
18 ## <http://www.gnu.org/licenses/>. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
19 |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
20 ## -*- texinfo -*- |
14479
05b59be209ed
doc: grammarcheck new pkg/private functions
Rik <octave@nomad.inbox5.com>
parents:
14477
diff
changeset
|
21 ## @deftypefn {Function File} {[@var{out1}, @var{out2}] =} installed_packages (@var{local_list}, @var{global_list}) |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
22 ## Undocumented internal function. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
23 ## @end deftypefn |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
24 |
19379 | 25 function [out1, out2] = installed_packages (local_list, global_list, pkgname = {}) |
26 | |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
27 ## Get the list of installed packages. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
28 try |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
29 local_packages = load (local_list).local_packages; |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
30 catch |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
31 local_packages = {}; |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
32 end_try_catch |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
33 try |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
34 global_packages = load (global_list).global_packages; |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
35 catch |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
36 global_packages = {}; |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
37 end_try_catch |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
38 installed_pkgs_lst = {local_packages{:}, global_packages{:}}; |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
39 |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
40 ## Eliminate duplicates in the installed package list. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
41 ## Locally installed packages take precedence. |
19379 | 42 installed_names = cellfun (@(x) x.name, installed_pkgs_lst, |
43 "uniformoutput", false); | |
44 [~, idx] = unique (installed_names, "first"); | |
45 installed_names = installed_names(idx); | |
46 installed_pkgs_lst = installed_pkgs_lst(idx); | |
47 | |
48 ## Check whether info on a particular package was requested | |
49 if (! isempty (pkgname)) | |
50 idx = find (strcmp (pkgname{1}, installed_names)); | |
51 if (isempty (idx)) | |
52 installed_names = {}; | |
53 installed_pkgs_lst = {}; | |
54 else | |
55 installed_names = installed_names(idx); | |
56 installed_pkgs_lst = installed_pkgs_lst(idx); | |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
57 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
58 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
59 |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
60 ## Now check if the package is loaded. |
19379 | 61 ## FIXME: couldn't dir_in_loadpath() be used here? |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14637
diff
changeset
|
62 tmppath = strrep (path (), "\\", "/"); |
19379 | 63 for i = 1:numel (installed_pkgs_lst) |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
64 if (strfind (tmppath, strrep (installed_pkgs_lst{i}.dir, '\', '/'))) |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
65 installed_pkgs_lst{i}.loaded = true; |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
66 else |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
67 installed_pkgs_lst{i}.loaded = false; |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
68 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
69 endfor |
19379 | 70 for i = 1:numel (local_packages) |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
71 if (strfind (tmppath, strrep (local_packages{i}.dir, '\', '/'))) |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
72 local_packages{i}.loaded = true; |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
73 else |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
74 local_packages{i}.loaded = false; |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
75 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
76 endfor |
19379 | 77 for i = 1:numel (global_packages) |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
78 if (strfind (tmppath, strrep (global_packages{i}.dir, '\', '/'))) |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
79 global_packages{i}.loaded = true; |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
80 else |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
81 global_packages{i}.loaded = false; |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
82 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
83 endfor |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
84 |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
85 ## Should we return something? |
20690
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
86 if (nargout == 1) |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
87 out1 = installed_pkgs_lst; |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
88 elseif (nargout > 1) |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
89 out1 = local_packages; |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
90 out2 = global_packages; |
20690
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
91 else |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
92 ## Don't return anything, instead we'll print something. |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
93 num_packages = numel (installed_pkgs_lst); |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
94 if (num_packages == 0) |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
95 if (isempty (pkgname)) |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
96 printf ("no packages installed.\n"); |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
97 else |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
98 printf ("package %s is not installed.\n", pkgname{1}); |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
99 endif |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
100 return; |
19379 | 101 endif |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
102 |
20690
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
103 ## Compute the maximal lengths of name, version, and dir. |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
104 h1 = "Package Name"; |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
105 h2 = "Version"; |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
106 h3 = "Installation directory"; |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
107 max_name_length = max ([length(h1), cellfun(@length, installed_names)]); |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
108 version_lengths = cellfun (@(x) length (x.version), installed_pkgs_lst); |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
109 max_version_length = max ([length(h2), version_lengths]); |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
110 ncols = terminal_size ()(2); |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
111 max_dir_length = ncols - max_name_length - max_version_length - 7; |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
112 if (max_dir_length < 20) |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
113 max_dir_length = Inf; |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
114 endif |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
115 |
20690
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
116 h1 = postpad (h1, max_name_length + 1, " "); |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
117 h2 = postpad (h2, max_version_length, " ");; |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
118 |
20690
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
119 ## Print a header. |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
120 header = sprintf ("%s | %s | %s\n", h1, h2, h3); |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
121 printf (header); |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
122 tmp = sprintf (repmat ("-", 1, length (header) - 1)); |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
123 tmp(length(h1)+2) = "+"; |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
124 tmp(length(h1)+length(h2)+5) = "+"; |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
125 printf ("%s\n", tmp); |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
126 |
20690
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
127 ## Print the packages. |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
128 format = sprintf ("%%%ds %%1s| %%%ds | %%s\n", |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
129 max_name_length, max_version_length); |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
130 for i = 1:num_packages |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
131 cur_name = installed_pkgs_lst{i}.name; |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
132 cur_version = installed_pkgs_lst{i}.version; |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
133 cur_dir = installed_pkgs_lst{i}.dir; |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
134 if (length (cur_dir) > max_dir_length) |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
135 first_char = length (cur_dir) - max_dir_length + 4; |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
136 first_filesep = strfind (cur_dir(first_char:end), filesep ()); |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
137 if (! isempty (first_filesep)) |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
138 cur_dir = ["..." cur_dir((first_char + first_filesep(1) - 1):end)]; |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
139 else |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
140 cur_dir = ["..." cur_dir(first_char:end)]; |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
141 endif |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
142 endif |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
143 if (installed_pkgs_lst{i}.loaded) |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
144 cur_loaded = "*"; |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
145 else |
20690
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
146 cur_loaded = " "; |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
147 endif |
20690
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
148 printf (format, cur_name, cur_loaded, cur_version, cur_dir); |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
149 endfor |
ad7fe3cb6fd2
pkg: fix regression on output of pkg list (bug #45873)
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
150 endif |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
151 endfunction |