7017
|
1 ## Copyright (C) 1996, 2000, 2005, 2007 |
|
2 ## Auburn University. All rights reserved. |
3437
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
7016
|
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. |
3437
|
10 ## |
7016
|
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. |
3437
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
3437
|
19 |
6945
|
20 ## Undocumented internal function. |
|
21 |
3437
|
22 ## -*- texinfo -*- |
3500
|
23 ## @deftypefn {Function File} {} __syschnamesl__ (@var{olist}, @var{old_names}, @var{inames}, @var{listname}) |
3437
|
24 ## used internally in syschnames |
|
25 ## item olist: index list |
|
26 ## old_names: original list names |
|
27 ## inames: new names |
|
28 ## listname: name of index list |
|
29 ## |
|
30 ## combines the two string lists old_names and inames |
|
31 ## @end deftypefn |
|
32 |
3438
|
33 function old_names = __syschnamesl__ (olist, old_names, inames, listname) |
3437
|
34 |
|
35 probstr = []; |
7136
|
36 |
|
37 if (max (olist) > rows (old_names)) |
|
38 probstr = sprintf ("index list value(s) exceed(s) number of signals (%d)", |
|
39 rows (old_names)); |
3437
|
40 |
7136
|
41 elseif (length (olist) > rows (inames)) |
|
42 probstr = sprintf ("index list dimension exceeds number of replacement names (%d)", |
|
43 rows (inames)); |
3437
|
44 |
7136
|
45 elseif (isempty (olist)) |
3437
|
46 probstr = []; # do nothing, no changes |
|
47 |
7136
|
48 elseif (min (size (olist)) != 1) |
3437
|
49 probstr = "index list must be either a vector or an empty matrix"; |
|
50 |
7136
|
51 elseif (max (olist) > rows (old_names)) |
|
52 probstr = sprintf ("max(%s)=%d > %d, too big", listname, |
|
53 max (olist), rows (old_names)); |
3437
|
54 |
7136
|
55 elseif (min (olist) < 1) |
|
56 probstr = sprintf ("min(%s)=%d < 1, too small", listname, min (olist)); |
3437
|
57 |
|
58 else |
7136
|
59 if (length(olist) == 1) |
|
60 len_in = columns (inames); |
|
61 len_out = columns (old_names); |
3437
|
62 |
|
63 if (len_in < len_out) |
7136
|
64 inames(1,(len_in+1):(len_out)) = zeros (1, len_out-len_in); |
3437
|
65 endif |
|
66 |
|
67 old_names(olist,1:length(inames)) = inames; |
7136
|
68 elseif (length(olist) > 1) |
|
69 for ii = 1:length(olist) |
3437
|
70 mystr = inames(ii,:); |
7136
|
71 len_my = columns (mystr); |
|
72 len_out = columns (old_names); |
3437
|
73 |
|
74 if (len_my < len_out) |
7136
|
75 mystr(1,(len_my+1):len_out) = repmat (" ", 1, len_out-len_my); |
3437
|
76 len_my = len_out; |
|
77 endif |
|
78 |
|
79 old_names(olist(ii),1:len_my) = mystr; |
|
80 endfor |
|
81 endif |
|
82 endif |
7136
|
83 if (! isempty (probstr)) |
3437
|
84 ## the following lines are NOT debugging code! |
7136
|
85 disp ("Problem in syschnames: old names are") |
|
86 __outlist__ (old_names," ") |
|
87 disp ("new names are") |
3438
|
88 __outlist__(inames," ") |
7136
|
89 disp ("list indices are") |
|
90 disp (olist) |
|
91 error (sprintf ("syschnames: \"%s\" dim=(%d x %d)--\n\t%s\n", ... |
|
92 listname, rows (olist), columns (olist), probstr)); |
3437
|
93 endif |
|
94 |
|
95 ## change zeros to blanks |
7136
|
96 if (find (old_names == 0)) |
3438
|
97 ## disp("__syschnamesl__: old_names contains zeros ") |
3437
|
98 ## old_names |
3438
|
99 ## disp("/__syschnamesl__"); |
3437
|
100 |
7136
|
101 [ii, jj] = find (old_names == 0); |
|
102 for idx = 1:length(ii) |
3437
|
103 old_names(ii(idx),jj(idx)) = " "; |
|
104 endfor |
|
105 |
3438
|
106 ## disp("__syschnamesl__: old_names fixed zeros ") |
3437
|
107 ## old_names |
3438
|
108 ## disp("/__syschnamesl__"); |
3437
|
109 endif |
|
110 |
|
111 ## just in case it's not a string anymore |
7136
|
112 if (! ischar (old_names)) |
|
113 old_names = char (old_names); |
3437
|
114 endif |
|
115 |
3438
|
116 ## disp("__syschnamesl__: exit, old_names=") |
3437
|
117 ## old_names |
3438
|
118 ## disp("/__syschnamesl__: exiting") |
3437
|
119 |
|
120 endfunction |