1741
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1741
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
4192
|
23 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
1741
|
24 #pragma implementation |
|
25 #endif |
|
26 |
|
27 #ifdef HAVE_CONFIG_H |
|
28 #include <config.h> |
|
29 #endif |
|
30 |
3503
|
31 #include <iostream> |
1741
|
32 |
2172
|
33 #include "defun.h" |
1741
|
34 #include "error.h" |
|
35 #include "oct-obj.h" |
2982
|
36 #include "pt-arg-list.h" |
3770
|
37 #include "pt-bp.h" |
1741
|
38 #include "pt-exp.h" |
|
39 #include "pt-mat.h" |
2124
|
40 #include "pt-walk.h" |
2201
|
41 #include "utils.h" |
2371
|
42 #include "ov.h" |
|
43 #include "variables.h" |
1741
|
44 |
4460
|
45 // If TRUE, print a warning message for empty elements in a matrix list. |
|
46 static bool Vwarn_empty_list_elements; |
2172
|
47 |
2254
|
48 // The character to fill with when creating string arrays. |
3836
|
49 char Vstring_fill_char = ' '; |
2254
|
50 |
1741
|
51 // General matrices. This list type is much more work to handle than |
|
52 // constant matrices, but it allows us to construct matrices from |
|
53 // other matrices, variables, and functions. |
|
54 |
1827
|
55 // But first, some internal classes that make our job much easier. |
1741
|
56 |
1827
|
57 class |
|
58 tm_row_const |
1741
|
59 { |
1827
|
60 private: |
|
61 |
|
62 class |
4219
|
63 tm_row_const_rep : public octave_base_list<octave_value> |
1827
|
64 { |
|
65 public: |
|
66 |
|
67 tm_row_const_rep (void) |
4765
|
68 : count (1), dv (), |
3110
|
69 all_str (false), some_str (false), is_cmplx (false), |
|
70 all_mt (true), ok (false) { } |
1827
|
71 |
2971
|
72 tm_row_const_rep (const tree_argument_list& row) |
4765
|
73 : count (1), dv (), |
3110
|
74 all_str (false), some_str (false), is_cmplx (false), |
|
75 all_mt (true), ok (false) |
|
76 { init (row); } |
1827
|
77 |
|
78 ~tm_row_const_rep (void) { } |
|
79 |
|
80 int count; |
|
81 |
4765
|
82 dim_vector dv; |
1741
|
83 |
1827
|
84 bool all_str; |
3110
|
85 bool some_str; |
1827
|
86 bool is_cmplx; |
2602
|
87 bool all_mt; |
1827
|
88 |
|
89 bool ok; |
|
90 |
4501
|
91 bool do_init_element (tree_expression *, const octave_value&, bool&); |
|
92 |
2971
|
93 void init (const tree_argument_list&); |
1827
|
94 |
|
95 private: |
|
96 |
|
97 tm_row_const_rep (const tm_row_const_rep&); |
|
98 |
2971
|
99 tm_row_const_rep& operator = (const tm_row_const_rep&); |
2419
|
100 |
3661
|
101 void eval_error (const char *msg, int l, int c, |
|
102 int x = -1, int y = -1) const; |
2419
|
103 |
|
104 void eval_warning (const char *msg, int l, int c) const; |
1827
|
105 }; |
|
106 |
|
107 public: |
|
108 |
4219
|
109 typedef tm_row_const_rep::iterator iterator; |
|
110 typedef tm_row_const_rep::const_iterator const_iterator; |
|
111 |
2990
|
112 tm_row_const (void) |
|
113 : rep (0) { } |
1827
|
114 |
2971
|
115 tm_row_const (const tree_argument_list& row) |
|
116 : rep (new tm_row_const_rep (row)) { } |
1827
|
117 |
2990
|
118 tm_row_const (const tm_row_const& x) |
|
119 : rep (x.rep) |
|
120 { |
|
121 if (rep) |
|
122 rep->count++; |
|
123 } |
1827
|
124 |
|
125 tm_row_const& operator = (const tm_row_const& x) |
2990
|
126 { |
|
127 if (this != &x && rep != x.rep) |
|
128 { |
|
129 if (rep && --rep->count == 0) |
|
130 delete rep; |
1741
|
131 |
2990
|
132 rep = x.rep; |
1827
|
133 |
2990
|
134 if (rep) |
|
135 rep->count++; |
|
136 } |
1741
|
137 |
2990
|
138 return *this; |
|
139 } |
1827
|
140 |
|
141 ~tm_row_const (void) |
2990
|
142 { |
|
143 if (rep && --rep->count == 0) |
|
144 delete rep; |
|
145 } |
1741
|
146 |
4765
|
147 int rows (void) |
|
148 { return (rep->dv.length () > 0 ? rep->dv(0) : 0); } |
|
149 |
|
150 int cols (void) |
|
151 { return (rep->dv.length () > 1 ? rep->dv(1) : 0); } |
|
152 |
|
153 dim_vector dims (void) { return rep->dv; } |
1827
|
154 |
2868
|
155 bool all_strings_p (void) const { return rep->all_str; } |
3110
|
156 bool some_strings_p (void) const { return rep->some_str; } |
2868
|
157 bool complex_p (void) const { return rep->is_cmplx; } |
|
158 bool all_empty_p (void) const { return rep->all_mt; } |
1827
|
159 |
4219
|
160 operator bool () const { return (rep && rep->ok); } |
1827
|
161 |
4219
|
162 iterator begin (void) { return rep->begin (); } |
|
163 const_iterator begin (void) const { return rep->begin (); } |
|
164 |
|
165 iterator end (void) { return rep->end (); } |
|
166 const_iterator end (void) const { return rep->end (); } |
1827
|
167 |
|
168 private: |
|
169 |
|
170 tm_row_const_rep *rep; |
|
171 }; |
|
172 |
4501
|
173 bool |
|
174 tm_row_const::tm_row_const_rep::do_init_element (tree_expression *elt, |
|
175 const octave_value& val, |
|
176 bool& first_elem) |
|
177 { |
|
178 int this_elt_nr = val.rows (); |
|
179 int this_elt_nc = val.columns (); |
|
180 |
4765
|
181 dim_vector this_elt_dv = val.dims (); |
|
182 |
|
183 if (!this_elt_dv.all_zero ()) |
4501
|
184 { |
|
185 all_mt = false; |
|
186 |
|
187 if (first_elem) |
|
188 { |
|
189 first_elem = false; |
|
190 |
4765
|
191 dv.resize (this_elt_dv.length ()); |
|
192 for (int i = 2; i < dv.length (); i++) |
|
193 dv.elem (i) = this_elt_dv.elem (i); |
|
194 |
|
195 dv.elem (0) = this_elt_nr; |
|
196 |
|
197 dv.elem (1) = 0; |
4501
|
198 } |
4765
|
199 else |
4501
|
200 { |
5045
|
201 int len = (this_elt_dv.length () < dv.length () |
|
202 ? this_elt_dv.length () : dv.length ()); |
|
203 |
4765
|
204 if (this_elt_nr != dv (0)) |
|
205 { |
|
206 eval_error ("number of rows must match", |
|
207 elt->line (), elt->column (), this_elt_nr, dv (0)); |
|
208 return false; |
|
209 } |
5045
|
210 for (int i = 2; i < len; i++) |
4765
|
211 { |
|
212 if (this_elt_dv (i) != dv (i)) |
|
213 { |
|
214 eval_error ("dimensions mismatch", elt->line (), elt->column (), this_elt_dv (i), dv (i)); |
|
215 return false; |
|
216 } |
|
217 } |
5045
|
218 |
|
219 if (this_elt_dv.length () > len) |
|
220 for (int i = len; i < this_elt_dv.length (); i++) |
|
221 if (this_elt_dv (i) != 1) |
|
222 { |
|
223 eval_error ("dimensions mismatch", elt->line (), elt->column (), this_elt_dv (i), 1); |
|
224 return false; |
|
225 } |
|
226 |
|
227 if (dv.length () > len) |
|
228 for (int i = len; i < dv.length (); i++) |
|
229 if (dv (i) != 1) |
|
230 { |
|
231 eval_error ("dimensions mismatch", elt->line (), elt->column (), 1, dv (i)); |
|
232 return false; |
|
233 } |
4501
|
234 } |
4765
|
235 dv.elem (1) = dv.elem (1) + this_elt_nc; |
4501
|
236 |
|
237 } |
|
238 else if (Vwarn_empty_list_elements) |
|
239 eval_warning ("empty matrix found in matrix list", |
|
240 elt->line (), elt->column ()); |
|
241 |
4915
|
242 append (val); |
|
243 |
4501
|
244 if (all_str && ! val.is_string ()) |
|
245 all_str = false; |
|
246 |
|
247 if (! some_str && val.is_string ()) |
|
248 some_str = true; |
|
249 |
|
250 if (! is_cmplx && val.is_complex_type ()) |
|
251 is_cmplx = true; |
|
252 |
|
253 return true; |
|
254 } |
|
255 |
1827
|
256 void |
2971
|
257 tm_row_const::tm_row_const_rep::init (const tree_argument_list& row) |
1827
|
258 { |
|
259 all_str = true; |
|
260 |
|
261 bool first_elem = true; |
|
262 |
4219
|
263 for (tree_argument_list::const_iterator p = row.begin (); |
|
264 p != row.end (); |
|
265 p++) |
1827
|
266 { |
4219
|
267 tree_expression *elt = *p; |
1827
|
268 |
2971
|
269 octave_value tmp = elt->rvalue (); |
1827
|
270 |
|
271 if (error_state || tmp.is_undefined ()) |
|
272 break; |
|
273 else |
|
274 { |
4501
|
275 if (tmp.is_cs_list ()) |
1827
|
276 { |
4587
|
277 octave_value_list tlst = tmp.list_value (); |
2602
|
278 |
4587
|
279 for (int i = 0; i < tlst.length (); i++) |
1827
|
280 { |
4587
|
281 if (! do_init_element (elt, tlst(i), first_elem)) |
4501
|
282 goto done; |
1827
|
283 } |
|
284 } |
4501
|
285 else |
|
286 { |
|
287 if (! do_init_element (elt, tmp, first_elem)) |
|
288 goto done; |
|
289 } |
1827
|
290 } |
|
291 } |
|
292 |
4501
|
293 done: |
|
294 |
1827
|
295 ok = ! error_state; |
1741
|
296 } |
|
297 |
2419
|
298 void |
|
299 tm_row_const::tm_row_const_rep::eval_error (const char *msg, int l, |
3661
|
300 int c, int x, int y) const |
2419
|
301 { |
|
302 if (l == -1 && c == -1) |
3661
|
303 { |
|
304 if (x == -1 || y == -1) |
|
305 ::error ("%s", msg); |
|
306 else |
|
307 ::error ("%s (%d != %d)", msg, x, y); |
|
308 } |
2419
|
309 else |
3661
|
310 { |
|
311 if (x == -1 || y == -1) |
|
312 ::error ("%s near line %d, column %d", msg, l, c); |
|
313 else |
|
314 ::error ("%s (%d != %d) near line %d, column %d", msg, x, y, l, c); |
|
315 } |
2419
|
316 } |
|
317 |
|
318 void |
|
319 tm_row_const::tm_row_const_rep::eval_warning (const char *msg, int l, |
|
320 int c) const |
|
321 { |
|
322 if (l == -1 && c == -1) |
|
323 ::warning ("%s", msg); |
|
324 else |
|
325 ::warning ("%s near line %d, column %d", msg, l, c); |
|
326 } |
|
327 |
1827
|
328 class |
4219
|
329 tm_const : public octave_base_list<tm_row_const> |
1827
|
330 { |
|
331 public: |
|
332 |
|
333 tm_const (const tree_matrix& tm) |
4765
|
334 : dv (), all_str (false), some_str (false), is_cmplx (false), |
3110
|
335 all_mt (true), ok (false) |
1827
|
336 { init (tm); } |
|
337 |
|
338 ~tm_const (void) { } |
|
339 |
4765
|
340 int rows (void) const { return (dv.length () > 0 ? dv.elem (0) : 0); } |
|
341 int cols (void) const { return (dv.length () > 1 ? dv.elem (1) : 0); } |
|
342 |
|
343 dim_vector dims (void) const { return dv; } |
1827
|
344 |
2868
|
345 bool all_strings_p (void) const { return all_str; } |
3110
|
346 bool some_strings_p (void) const { return some_str; } |
2868
|
347 bool complex_p (void) const { return is_cmplx; } |
|
348 bool all_empty_p (void) const { return all_mt; } |
1827
|
349 |
3145
|
350 operator bool () const { return ok; } |
1827
|
351 |
|
352 private: |
|
353 |
4765
|
354 dim_vector dv; |
1827
|
355 |
|
356 bool all_str; |
3110
|
357 bool some_str; |
1827
|
358 bool is_cmplx; |
2602
|
359 bool all_mt; |
1827
|
360 |
|
361 bool ok; |
|
362 |
|
363 tm_const (void); |
|
364 |
|
365 tm_const (const tm_const&); |
|
366 |
|
367 tm_const& operator = (const tm_const&); |
|
368 |
|
369 void init (const tree_matrix& tm); |
|
370 }; |
|
371 |
|
372 void |
|
373 tm_const::init (const tree_matrix& tm) |
1741
|
374 { |
1827
|
375 all_str = true; |
|
376 |
|
377 bool first_elem = true; |
|
378 |
|
379 // Just eval and figure out if what we have is complex or all |
|
380 // strings. We can't check columns until we know that this is a |
|
381 // numeric matrix -- collections of strings can have elements of |
|
382 // different lengths. |
|
383 |
4219
|
384 for (tree_matrix::const_iterator p = tm.begin (); p != tm.end (); p++) |
1827
|
385 { |
4219
|
386 tree_argument_list *elt = *p; |
1827
|
387 |
|
388 tm_row_const tmp (*elt); |
|
389 |
|
390 if (tmp) |
|
391 { |
2868
|
392 if (all_str && ! tmp.all_strings_p ()) |
1827
|
393 all_str = false; |
|
394 |
3110
|
395 if (! some_str && tmp.some_strings_p ()) |
|
396 some_str = true; |
|
397 |
2868
|
398 if (! is_cmplx && tmp.complex_p ()) |
1827
|
399 is_cmplx = true; |
|
400 |
2868
|
401 if (all_mt && ! tmp.all_empty_p ()) |
2602
|
402 all_mt = false; |
|
403 |
1827
|
404 append (tmp); |
|
405 } |
|
406 else |
|
407 break; |
|
408 } |
|
409 |
|
410 if (! error_state) |
|
411 { |
4219
|
412 for (iterator p = begin (); p != end (); p++) |
1827
|
413 { |
4219
|
414 tm_row_const elt = *p; |
1827
|
415 |
|
416 int this_elt_nr = elt.rows (); |
|
417 int this_elt_nc = elt.cols (); |
|
418 |
4765
|
419 dim_vector this_elt_dv = elt.dims (); |
|
420 |
|
421 if (!this_elt_dv.all_zero ()) |
1827
|
422 { |
2602
|
423 all_mt = false; |
|
424 |
1827
|
425 if (first_elem) |
|
426 { |
|
427 first_elem = false; |
|
428 |
4765
|
429 dv.resize (this_elt_dv.length ()); |
|
430 for (int i = 2; i < dv.length (); i++) |
|
431 dv.elem (i) = this_elt_dv.elem (i); |
|
432 |
|
433 dv.elem (0) = 0; |
|
434 |
|
435 dv.elem (1) = this_elt_nc; |
1827
|
436 } |
|
437 else if (all_str) |
|
438 { |
4765
|
439 if (this_elt_nc > cols ()) |
|
440 dv.elem (1) = this_elt_nc; |
1827
|
441 } |
4765
|
442 else |
1827
|
443 { |
4765
|
444 bool get_out = false; |
5045
|
445 int len = (this_elt_dv.length () < dv.length () |
|
446 ? this_elt_dv.length () : dv.length ()); |
4765
|
447 |
5045
|
448 for (int i = 1; i < len; i++) |
4765
|
449 { |
|
450 if (i == 1 && this_elt_nc != dv (1)) |
|
451 { |
|
452 ::error ("number of columns must match (%d != %d)", |
|
453 this_elt_nc, dv (1)); |
|
454 get_out = true; |
|
455 break; |
|
456 } |
|
457 else if (this_elt_dv (i) != dv (i)) |
|
458 { |
|
459 ::error ("dimensions mismatch (dim = %i, %d != %d)", i+1, this_elt_dv (i), dv (i)); |
|
460 get_out = true; |
|
461 break; |
|
462 } |
|
463 } |
|
464 |
5045
|
465 if (this_elt_dv.length () > len) |
|
466 for (int i = len; i < this_elt_dv.length (); i++) |
|
467 if (this_elt_dv (i) != 1) |
|
468 { |
|
469 ::error ("dimensions mismatch (dim = %i, %d != %d)", i+1, this_elt_dv (i), 1); |
|
470 get_out = true; |
|
471 break; |
|
472 } |
|
473 |
|
474 if (dv.length () > len) |
|
475 for (int i = len; i < dv.length (); i++) |
|
476 if (dv (i) != 1) |
|
477 { |
|
478 ::error ("dimensions mismatch (dim = %i, %d != %d)", i+1, 1, dv(i)); |
|
479 get_out = true; |
|
480 break; |
|
481 } |
|
482 |
4765
|
483 if (get_out) |
|
484 break; |
1827
|
485 } |
4765
|
486 dv.elem (0) = dv.elem (0) + this_elt_nr; |
1827
|
487 } |
4460
|
488 else if (Vwarn_empty_list_elements) |
|
489 warning ("empty matrix found in matrix list"); |
1827
|
490 } |
|
491 } |
|
492 |
|
493 ok = ! error_state; |
1741
|
494 } |
|
495 |
2990
|
496 tree_matrix::~tree_matrix (void) |
|
497 { |
4219
|
498 while (! empty ()) |
2990
|
499 { |
4219
|
500 iterator p = begin (); |
|
501 delete *p; |
|
502 erase (p); |
2990
|
503 } |
|
504 } |
|
505 |
1827
|
506 bool |
4267
|
507 tree_matrix::has_magic_end (void) const |
|
508 { |
|
509 for (const_iterator p = begin (); p != end (); p++) |
|
510 { |
|
511 tree_argument_list *elt = *p; |
|
512 |
|
513 if (elt && elt->has_magic_end ()) |
|
514 return true; |
|
515 } |
|
516 |
|
517 return false; |
|
518 } |
|
519 |
|
520 bool |
2529
|
521 tree_matrix::all_elements_are_constant (void) const |
1827
|
522 { |
4219
|
523 for (const_iterator p = begin (); p != end (); p++) |
1827
|
524 { |
4219
|
525 tree_argument_list *elt = *p; |
1827
|
526 |
2529
|
527 if (! elt->all_elements_are_constant ()) |
1827
|
528 return false; |
|
529 } |
|
530 |
|
531 return true; |
|
532 } |
|
533 |
2971
|
534 octave_value_list |
|
535 tree_matrix::rvalue (int nargout) |
|
536 { |
|
537 octave_value_list retval; |
|
538 |
3770
|
539 MAYBE_DO_BREAKPOINT; |
|
540 |
2971
|
541 if (nargout > 1) |
|
542 error ("invalid number of output arguments for matrix list"); |
|
543 else |
|
544 retval = rvalue (); |
|
545 |
|
546 return retval; |
|
547 } |
|
548 |
2086
|
549 octave_value |
2971
|
550 tree_matrix::rvalue (void) |
1741
|
551 { |
2086
|
552 octave_value retval; |
1741
|
553 |
4915
|
554 bool all_strings_p = false; |
|
555 bool all_empty_p = false; |
|
556 bool frc_str_conv = false; |
1741
|
557 |
4915
|
558 tm_const tmp (*this); |
3110
|
559 |
1827
|
560 if (tmp) |
|
561 { |
4765
|
562 dim_vector dv = tmp.dims (); |
4915
|
563 all_strings_p = tmp.all_strings_p (); |
|
564 all_empty_p = tmp.all_empty_p (); |
|
565 frc_str_conv = tmp.some_strings_p (); |
1741
|
566 |
4915
|
567 // XXX FIXME XX |
|
568 // The previous version of this code obtained the return type and |
|
569 // initialized an array of the correct type. However the return type |
|
570 // is now built-up from the return types of do_cat_op. Should we special |
|
571 // case the situation where there are only NDArray and ComplexNDArray |
|
572 // elements, or things like boolMatrix that widen to them, and do the |
|
573 // correct initialization? How to do this? Will it be faster? Check against |
|
574 // version 2.1.57 |
|
575 |
|
576 |
|
577 // The line below might seem crazy, since we take a copy |
|
578 // of the first argument, resize it to be empty and then resize |
|
579 // it to be full. This is done since it means that there is no |
|
580 // recopying of data, as would happen if we used a single resize. |
|
581 // It should be noted that resize operation is also significantly |
|
582 // slower than the do_cat_op function, so it makes sense to have an |
|
583 // empty matrix and copy all data. |
|
584 // |
|
585 // We might also start with a empty octave_value using |
|
586 // ctmp = octave_value_typeinfo::lookup_type |
|
587 // (tmp.begin() -> begin() -> type_name()); |
|
588 // and then directly resize. However, for some types there might be |
|
589 // some additional setup needed, and so this should be avoided. |
|
590 |
|
591 octave_value ctmp; |
|
592 if (all_strings_p) |
|
593 if (all_empty_p) |
|
594 ctmp = octave_value (charNDArray (), true); |
|
595 else |
|
596 ctmp = octave_value (charNDArray (dv, Vstring_fill_char), true); |
|
597 else |
|
598 { |
|
599 if (all_empty_p) |
|
600 ctmp = (*(tmp.begin() -> begin())); |
|
601 else |
|
602 ctmp = (*(tmp.begin() -> begin())).resize (dim_vector (0,0)).resize (dv); |
|
603 } |
|
604 |
|
605 if (error_state) |
|
606 goto done; |
1741
|
607 |
1827
|
608 // Now, extract the values from the individual elements and |
|
609 // insert them in the result matrix. |
4915
|
610 Array<int> ra_idx (dv.length (), 0); |
4219
|
611 for (tm_const::iterator p = tmp.begin (); p != tmp.end (); p++) |
1827
|
612 { |
4219
|
613 tm_row_const row = *p; |
|
614 for (tm_row_const::iterator q = row.begin (); q != row.end (); q++) |
1827
|
615 { |
4219
|
616 octave_value elt = *q; |
1741
|
617 |
4915
|
618 ctmp = do_cat_op (ctmp, elt, ra_idx); |
|
619 if (error_state) |
|
620 goto done; |
|
621 ra_idx (1) += elt.columns (); |
1741
|
622 } |
4915
|
623 ra_idx (0) += row.rows (); |
|
624 ra_idx (1) = 0; |
1741
|
625 } |
4915
|
626 retval = ctmp; |
|
627 if (frc_str_conv && ! retval.is_string ()) |
|
628 retval = retval.convert_to_str (); |
1741
|
629 } |
|
630 |
1827
|
631 done: |
1741
|
632 return retval; |
|
633 } |
|
634 |
|
635 void |
2124
|
636 tree_matrix::accept (tree_walker& tw) |
1741
|
637 { |
2124
|
638 tw.visit_matrix (*this); |
1741
|
639 } |
|
640 |
2172
|
641 static int |
4460
|
642 warn_empty_list_elements (void) |
2172
|
643 { |
4460
|
644 Vwarn_empty_list_elements = check_preference ("warn_empty_list_elements"); |
2172
|
645 |
|
646 return 0; |
|
647 } |
|
648 |
2254
|
649 static int |
|
650 string_fill_char (void) |
|
651 { |
|
652 int status = 0; |
|
653 |
3523
|
654 std::string s = builtin_string_variable ("string_fill_char"); |
2254
|
655 |
|
656 switch (s.length ()) |
|
657 { |
|
658 case 1: |
|
659 Vstring_fill_char = s[0]; |
|
660 break; |
|
661 |
|
662 case 0: |
|
663 Vstring_fill_char = '\0'; |
|
664 break; |
|
665 |
|
666 default: |
|
667 warning ("string_fill_char must be a single character"); |
|
668 status = -1; |
|
669 break; |
|
670 } |
|
671 |
|
672 return status; |
|
673 } |
|
674 |
2172
|
675 void |
|
676 symbols_of_pt_mat (void) |
|
677 { |
3258
|
678 DEFVAR (string_fill_char, " ", string_fill_char, |
3361
|
679 "-*- texinfo -*-\n\ |
|
680 @defvr {Built-in Variable} string_fill_char\n\ |
|
681 The value of this variable is used to pad all strings in a string matrix\n\ |
|
682 to the same length. It should be a single character. The default value\n\ |
|
683 is @code{\" \"} (a single space). For example,\n\ |
|
684 \n\ |
|
685 @example\n\ |
|
686 @group\n\ |
|
687 string_fill_char = \"X\";\n\ |
|
688 [ \"these\"; \"are\"; \"strings\" ]\n\ |
|
689 @result{} \"theseXX\"\n\ |
|
690 \"areXXXX\"\n\ |
|
691 \"strings\"\n\ |
|
692 @end group\n\ |
|
693 @end example\n\ |
3363
|
694 @end defvr"); |
4460
|
695 |
|
696 DEFVAR (warn_empty_list_elements, false, warn_empty_list_elements, |
|
697 "-*- texinfo -*-\n\ |
|
698 @defvr {Built-in Variable} warn_empty_list_elements\n\ |
|
699 If the value of @code{warn_empty_list_elements} is nonzero, print a\n\ |
|
700 warning when an empty matrix is found in a matrix list. For example,\n\ |
|
701 \n\ |
|
702 @example\n\ |
|
703 a = [1, [], 3, [], 5]\n\ |
|
704 @end example\n\ |
|
705 \n\ |
|
706 @noindent\n\ |
|
707 The default value is 0.\n\ |
|
708 @end defvr"); |
|
709 |
2172
|
710 } |
|
711 |
1741
|
712 /* |
|
713 ;;; Local Variables: *** |
|
714 ;;; mode: C++ *** |
|
715 ;;; End: *** |
|
716 */ |