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