1
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1
|
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 |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1
|
20 |
|
21 */ |
|
22 |
240
|
23 #ifdef HAVE_CONFIG_H |
1192
|
24 #include <config.h> |
1
|
25 #endif |
|
26 |
1343
|
27 #include <climits> |
1346
|
28 #include <cstring> |
1343
|
29 |
3503
|
30 #include <fstream> |
|
31 #include <iostream> |
|
32 #include <strstream> |
1728
|
33 #include <string> |
|
34 |
1350
|
35 #ifdef HAVE_UNISTD_H |
2442
|
36 #ifdef HAVE_SYS_TYPES_H |
1
|
37 #include <sys/types.h> |
2442
|
38 #endif |
1
|
39 #include <unistd.h> |
|
40 #endif |
367
|
41 |
3566
|
42 // Include setjmp.h, not csetjmp since the latter might only define |
|
43 // the ANSI standard C interface. |
|
44 |
|
45 #include <setjmp.h> |
|
46 |
138
|
47 #if defined (HAVE_TERMIOS_H) |
|
48 #include <termios.h> |
|
49 #elif defined (HAVE_TERMIO_H) |
1
|
50 #include <termio.h> |
138
|
51 #elif defined (HAVE_SGTTY_H) |
1
|
52 #include <sgtty.h> |
|
53 #else |
|
54 LOSE! LOSE! |
|
55 #endif |
|
56 |
|
57 #include "SLStack.h" |
|
58 |
3040
|
59 #include "dir-ops.h" |
|
60 #include "file-ops.h" |
2926
|
61 #include "file-stat.h" |
1651
|
62 #include "oct-cmplx.h" |
2926
|
63 #include "oct-env.h" |
3040
|
64 #include "pathsearch.h" |
1755
|
65 #include "str-vec.h" |
1651
|
66 |
2492
|
67 #include <defaults.h> |
1352
|
68 #include "defun.h" |
|
69 #include "dirfns.h" |
|
70 #include "error.h" |
|
71 #include "gripes.h" |
|
72 #include "input.h" |
1742
|
73 #include "oct-hist.h" |
1750
|
74 #include "oct-obj.h" |
1352
|
75 #include "pager.h" |
1690
|
76 #include "sysdep.h" |
1750
|
77 #include "toplev.h" |
1
|
78 #include "unwind-prot.h" |
1352
|
79 #include "utils.h" |
|
80 #include "variables.h" |
1
|
81 |
3354
|
82 // Should expressions like ones (-1, 5) result in an empty matrix or |
|
83 // an error? A positive value means yes. A negative value means |
|
84 // yes, but print a warning message. Zero means it should be |
|
85 // considered an error. |
|
86 static int Vtreat_neg_dim_as_zero; |
|
87 |
1
|
88 // Top level context (?) |
|
89 extern jmp_buf toplevel; |
|
90 |
581
|
91 // Return to the main command loop in octave.cc. |
|
92 |
3350
|
93 void |
1
|
94 jump_to_top_level (void) |
|
95 { |
2985
|
96 unwind_protect::run_all (); |
1
|
97 |
|
98 longjmp (toplevel, 1); |
|
99 } |
|
100 |
|
101 int |
3523
|
102 almost_match (const std::string& std, const std::string& s, int min_match_len, |
526
|
103 int case_sens) |
1
|
104 { |
1755
|
105 int stdlen = std.length (); |
|
106 int slen = s.length (); |
1
|
107 |
|
108 return (slen <= stdlen |
|
109 && slen >= min_match_len |
287
|
110 && (case_sens |
1755
|
111 ? (strncmp (std.c_str (), s.c_str (), slen) == 0) |
3350
|
112 : (octave_strncasecmp (std.c_str (), s.c_str (), slen) == 0))); |
287
|
113 } |
|
114 |
581
|
115 // Ugh. |
|
116 |
287
|
117 int |
3523
|
118 keyword_almost_match (const char * const *std, int *min_len, const std::string& s, |
287
|
119 int min_toks_to_match, int max_toks) |
|
120 { |
|
121 int status = 0; |
|
122 int tok_count = 0; |
|
123 int toks_matched = 0; |
|
124 |
1755
|
125 if (s.empty () || max_toks < 1) |
287
|
126 return status; |
|
127 |
1755
|
128 char *kw = strsave (s.c_str ()); |
287
|
129 |
|
130 char *t = kw; |
|
131 while (*t != '\0') |
|
132 { |
|
133 if (*t == '\t') |
|
134 *t = ' '; |
|
135 t++; |
|
136 } |
|
137 |
|
138 char *beg = kw; |
|
139 while (*beg == ' ') |
|
140 beg++; |
|
141 |
|
142 if (*beg == '\0') |
|
143 return status; |
|
144 |
|
145 |
3072
|
146 const char **to_match = new const char * [max_toks + 1]; |
|
147 const char * const *s1 = std; |
|
148 const char **s2 = to_match; |
287
|
149 |
526
|
150 if (! s1 || ! s2) |
287
|
151 goto done; |
|
152 |
|
153 s2[tok_count] = beg; |
|
154 char *end; |
526
|
155 while ((end = strchr (beg, ' ')) != 0) |
287
|
156 { |
|
157 *end = '\0'; |
|
158 beg = end + 1; |
|
159 |
|
160 while (*beg == ' ') |
|
161 beg++; |
|
162 |
|
163 if (*beg == '\0') |
|
164 break; |
|
165 |
|
166 tok_count++; |
|
167 if (tok_count >= max_toks) |
|
168 goto done; |
|
169 |
|
170 s2[tok_count] = beg; |
|
171 } |
526
|
172 s2[tok_count+1] = 0; |
287
|
173 |
|
174 s2 = to_match; |
|
175 |
|
176 for (;;) |
|
177 { |
|
178 if (! almost_match (*s1, *s2, min_len[toks_matched], 0)) |
|
179 goto done; |
|
180 |
|
181 toks_matched++; |
|
182 |
|
183 s1++; |
|
184 s2++; |
|
185 |
|
186 if (! *s2) |
|
187 { |
|
188 status = (toks_matched >= min_toks_to_match); |
|
189 goto done; |
|
190 } |
|
191 |
|
192 if (! *s1) |
|
193 goto done; |
|
194 } |
|
195 |
|
196 done: |
|
197 |
|
198 delete [] kw; |
|
199 delete [] to_match; |
|
200 |
|
201 return status; |
1
|
202 } |
|
203 |
2234
|
204 // Return non-zero if either NR or NC is zero. Return -1 if this |
|
205 // should be considered fatal; return 1 if this is ok. |
|
206 |
|
207 int |
|
208 empty_arg (const char *name, int nr, int nc) |
|
209 { |
|
210 int is_empty = 0; |
|
211 |
|
212 if (nr == 0 || nc == 0) |
|
213 { |
|
214 int flag = Vpropagate_empty_matrices; |
|
215 |
|
216 if (flag < 0) |
|
217 { |
|
218 gripe_empty_arg (name, 0); |
|
219 is_empty = 1; |
|
220 } |
|
221 else if (flag == 0) |
|
222 { |
|
223 gripe_empty_arg (name, 1); |
|
224 is_empty = -1; |
|
225 } |
|
226 else |
|
227 is_empty = 1; |
|
228 } |
|
229 |
|
230 return is_empty; |
|
231 } |
|
232 |
581
|
233 // See if the given file is in the path. |
|
234 |
3536
|
235 std::string |
3523
|
236 search_path_for_file (const std::string& path, const std::string& name) |
686
|
237 { |
3174
|
238 dir_path p (path); |
686
|
239 |
2926
|
240 return octave_env::make_absolute (p.find (name), octave_env::getcwd ()); |
686
|
241 } |
|
242 |
3195
|
243 DEFUN (file_in_loadpath, args, , |
3446
|
244 "-*- texinfo -*-\n\ |
|
245 @deftypefn {Built-in Function} {} file_in_loadpath (@var{name})\n\ |
3195
|
246 \n\ |
3446
|
247 Look up @var{name} in Octave's @code{LOADPATH}.\n\ |
|
248 @end deftypefn\n\ |
|
249 @seealso{file_in_path}") |
3195
|
250 { |
|
251 octave_value_list retval; |
|
252 |
|
253 int argc = args.length () + 1; |
|
254 |
|
255 string_vector argv = args.make_argv ("file_in_loadpath"); |
|
256 |
|
257 if (error_state) |
|
258 return retval; |
|
259 |
3225
|
260 if (argc == 2) |
3195
|
261 retval = octave_env::make_absolute (Vload_path_dir_path.find (argv[1]), |
|
262 octave_env::getcwd ()); |
|
263 else |
|
264 print_usage ("file_in_loadpath"); |
|
265 |
|
266 return retval; |
|
267 } |
|
268 |
1957
|
269 DEFUN (file_in_path, args, , |
3301
|
270 "-*- texinfo -*-\n\ |
|
271 @deftypefn {Built-in Function} {} file_in_path (@var{path}, @var{file})\n\ |
|
272 Return the absolute name name of @var{file} if it can be found in\n\ |
|
273 @var{path}. The value of @var{path} should be a colon-separated list of\n\ |
|
274 directories in the format described for the built-in variable\n\ |
|
275 @code{LOADPATH}.\n\ |
|
276 \n\ |
|
277 If the file cannot be found in the path, an empty matrix is returned.\n\ |
|
278 For example,\n\ |
|
279 \n\ |
|
280 @example\n\ |
|
281 file_in_path (LOADPATH, \"nargchk.m\")\n\ |
|
282 @result{} \"@value{OCTAVEHOME}/share/octave/2.0/m/general/nargchk.m\"\n\ |
|
283 @end example\n\ |
|
284 @end deftypefn") |
686
|
285 { |
2086
|
286 octave_value_list retval; |
686
|
287 |
1755
|
288 int argc = args.length () + 1; |
|
289 |
1968
|
290 string_vector argv = args.make_argv ("file_in_path"); |
1755
|
291 |
|
292 if (error_state) |
|
293 return retval; |
686
|
294 |
|
295 if (argc == 3) |
|
296 { |
3523
|
297 std::string fname = search_path_for_file (argv[1], argv[2]); |
686
|
298 |
1755
|
299 if (fname.empty ()) |
|
300 retval = Matrix (); |
|
301 else |
686
|
302 retval = fname; |
|
303 } |
|
304 else |
|
305 print_usage ("file_in_path"); |
|
306 |
|
307 return retval; |
|
308 } |
|
309 |
3536
|
310 std::string |
3523
|
311 file_in_path (const std::string& name, const std::string& suffix) |
526
|
312 { |
3523
|
313 std::string nm = name; |
526
|
314 |
1755
|
315 if (! suffix.empty ()) |
|
316 nm.append (suffix); |
686
|
317 |
3174
|
318 return octave_env::make_absolute (Vload_path_dir_path.find (nm), |
|
319 octave_env::getcwd ()); |
526
|
320 } |
|
321 |
581
|
322 // See if there is an function file in the path. If so, return the |
|
323 // full path to the file. |
|
324 |
3536
|
325 std::string |
3523
|
326 fcn_file_in_path (const std::string& name) |
526
|
327 { |
3523
|
328 std::string retval; |
908
|
329 |
1755
|
330 int len = name.length (); |
|
331 |
|
332 if (len > 0) |
|
333 { |
|
334 if (len > 2 && name [len - 2] == '.' && name [len - 1] == 'm') |
|
335 retval = file_in_path (name, ""); |
908
|
336 else |
1755
|
337 retval = file_in_path (name, ".m"); |
908
|
338 } |
1755
|
339 |
|
340 return retval; |
526
|
341 } |
|
342 |
581
|
343 // See if there is an octave file in the path. If so, return the |
|
344 // full path to the file. |
|
345 |
3536
|
346 std::string |
3523
|
347 oct_file_in_path (const std::string& name) |
572
|
348 { |
3523
|
349 std::string retval; |
908
|
350 |
1755
|
351 int len = name.length (); |
|
352 |
|
353 if (len > 0) |
|
354 { |
|
355 if (len > 2 && name [len - 4] == '.' && name [len - 3] == 'o' |
908
|
356 && name [len - 2] == 'c' && name [len - 1] == 't') |
1755
|
357 retval = file_in_path (name, ""); |
908
|
358 else |
1755
|
359 retval = file_in_path (name, ".oct"); |
908
|
360 } |
1755
|
361 |
|
362 return retval; |
572
|
363 } |
|
364 |
3103
|
365 // Replace backslash escapes in a string with the real values. |
|
366 |
3536
|
367 std::string |
3523
|
368 do_string_escapes (const std::string& s) |
3103
|
369 { |
3523
|
370 std::string retval; |
3103
|
371 |
|
372 size_t i = 0; |
|
373 size_t j = 0; |
|
374 size_t len = s.length (); |
|
375 |
|
376 retval.resize (len); |
|
377 |
|
378 while (j < len) |
|
379 { |
|
380 if (s[j] == '\\' && j+1 < len) |
|
381 { |
|
382 switch (s[++j]) |
|
383 { |
|
384 case 'a': |
|
385 retval[i] = '\a'; |
|
386 break; |
|
387 |
|
388 case 'b': // backspace |
|
389 retval[i] = '\b'; |
|
390 break; |
|
391 |
|
392 case 'f': // formfeed |
|
393 retval[i] = '\f'; |
|
394 break; |
|
395 |
|
396 case 'n': // newline |
|
397 retval[i] = '\n'; |
|
398 break; |
|
399 |
|
400 case 'r': // carriage return |
|
401 retval[i] = '\r'; |
|
402 break; |
|
403 |
|
404 case 't': // horizontal tab |
|
405 retval[i] = '\t'; |
|
406 break; |
|
407 |
|
408 case 'v': // vertical tab |
|
409 retval[i] = '\v'; |
|
410 break; |
|
411 |
|
412 case '\\': // backslash |
|
413 retval[i] = '\\'; |
|
414 break; |
|
415 |
|
416 case '\'': // quote |
|
417 retval[i] = '\''; |
|
418 break; |
|
419 |
|
420 case '"': // double quote |
|
421 retval[i] = '"'; |
|
422 break; |
|
423 |
|
424 default: |
|
425 warning ("unrecognized escape sequence `\\%c' --\ |
|
426 converting to `%c'", s[j], s[j]); |
|
427 retval[i] = s[j]; |
|
428 break; |
|
429 } |
|
430 } |
|
431 else |
|
432 { |
|
433 retval[i] = s[j]; |
|
434 } |
|
435 |
|
436 i++; |
|
437 j++; |
|
438 } |
|
439 |
3105
|
440 retval.resize (i); |
3103
|
441 |
|
442 return retval; |
|
443 } |
|
444 |
|
445 DEFUN (do_string_escapes, args, , |
3446
|
446 "-*- texinfo -*-\n\ |
|
447 @deftypefn {Built-in Function} {} do_string_escapes (@var{string})\n\ |
|
448 Convert special characters in @var{string} to their escaped forms.\n\ |
|
449 @end deftypefn") |
3103
|
450 { |
|
451 octave_value retval; |
|
452 |
|
453 int nargin = args.length (); |
|
454 |
|
455 if (nargin == 1) |
|
456 { |
|
457 if (args(0).is_string ()) |
|
458 retval = do_string_escapes (args(0).string_value ()); |
|
459 else |
|
460 error ("do_string_escapes: argument must be a string"); |
|
461 } |
|
462 else |
|
463 print_usage ("do_string_escapes"); |
|
464 |
|
465 return retval; |
|
466 } |
|
467 |
1755
|
468 const char * |
801
|
469 undo_string_escape (char c) |
|
470 { |
|
471 if (! c) |
1755
|
472 return ""; |
801
|
473 |
|
474 switch (c) |
|
475 { |
|
476 case '\a': |
|
477 return "\\a"; |
|
478 |
|
479 case '\b': // backspace |
|
480 return "\\b"; |
|
481 |
|
482 case '\f': // formfeed |
|
483 return "\\f"; |
|
484 |
|
485 case '\n': // newline |
|
486 return "\\n"; |
|
487 |
|
488 case '\r': // carriage return |
|
489 return "\\r"; |
|
490 |
|
491 case '\t': // horizontal tab |
|
492 return "\\t"; |
|
493 |
|
494 case '\v': // vertical tab |
|
495 return "\\v"; |
|
496 |
|
497 case '\\': // backslash |
|
498 return "\\\\"; |
|
499 |
|
500 case '"': // double quote |
|
501 return "\\\""; |
|
502 |
|
503 default: |
1755
|
504 { |
|
505 static char retval[2]; |
|
506 retval[0] = c; |
|
507 retval[1] = '\0'; |
|
508 return retval; |
|
509 } |
801
|
510 } |
|
511 } |
|
512 |
3536
|
513 std::string |
3523
|
514 undo_string_escapes (const std::string& s) |
801
|
515 { |
3523
|
516 std::string retval; |
801
|
517 |
1755
|
518 for (size_t i = 0; i < s.length (); i++) |
|
519 retval.append (undo_string_escape (s[i])); |
801
|
520 |
1755
|
521 return retval; |
801
|
522 } |
|
523 |
1957
|
524 DEFUN (undo_string_escapes, args, , |
3361
|
525 "-*- texinfo -*-\n\ |
|
526 @deftypefn {Built-in Function} {} undo_string_escapes (@var{s})\n\ |
|
527 Converts special characters in strings back to their escaped forms. For\n\ |
|
528 example, the expression\n\ |
|
529 \n\ |
|
530 @example\n\ |
|
531 bell = \"\\a\";\n\ |
|
532 @end example\n\ |
|
533 \n\ |
|
534 @noindent\n\ |
|
535 assigns the value of the alert character (control-g, ASCII code 7) to\n\ |
|
536 the string variable @code{bell}. If this string is printed, the\n\ |
|
537 system will ring the terminal bell (if it is possible). This is\n\ |
|
538 normally the desired outcome. However, sometimes it is useful to be\n\ |
|
539 able to print the original representation of the string, with the\n\ |
|
540 special characters replaced by their escape sequences. For example,\n\ |
|
541 \n\ |
|
542 @example\n\ |
|
543 octave:13> undo_string_escapes (bell)\n\ |
|
544 ans = \\a\n\ |
|
545 @end example\n\ |
|
546 \n\ |
|
547 @noindent\n\ |
|
548 replaces the unprintable alert character with its printable\n\ |
|
549 representation.\n\ |
|
550 @end deftypefn") |
801
|
551 { |
2086
|
552 octave_value retval; |
801
|
553 |
|
554 int nargin = args.length (); |
|
555 |
3103
|
556 if (nargin == 1) |
|
557 { |
|
558 if (args(0).is_string ()) |
|
559 retval = undo_string_escapes (args(0).string_value ()); |
|
560 else |
|
561 error ("undo_string_escapes: argument must be a string"); |
|
562 } |
801
|
563 else |
1023
|
564 print_usage ("undo_string_escapes"); |
801
|
565 |
|
566 return retval; |
|
567 } |
|
568 |
2285
|
569 static void |
3523
|
570 warn_old_style_preference (bool val, const std::string& sval) |
2285
|
571 { |
|
572 warning |
|
573 ("preference of \"%s\" is obsolete -- use numeric value of %d instead", |
|
574 sval.c_str (), (val ? 1 : 0)); |
|
575 } |
|
576 |
2204
|
577 // Check the value of a string variable to see if it it's ok to do |
|
578 // something. |
|
579 // |
|
580 // return of 1 => always ok. |
|
581 // return of 0 => never ok. |
|
582 // return of -1 => ok, but give me warning (default). |
|
583 |
|
584 int |
3523
|
585 check_preference (const std::string& var) |
2204
|
586 { |
|
587 int pref = -1; |
|
588 |
3523
|
589 std::string val = builtin_string_variable (var); |
2204
|
590 |
|
591 if (val.empty ()) |
|
592 { |
|
593 double dval = 0; |
|
594 if (builtin_real_scalar_variable (var, dval)) |
|
595 pref = NINT (dval); |
|
596 } |
|
597 else |
|
598 { |
3565
|
599 if (val == "yes" || val == "true") |
2285
|
600 { |
|
601 warn_old_style_preference (true, val); |
|
602 pref = 1; |
|
603 } |
3565
|
604 else if (val == "never" || val == "no" || val == "false") |
2285
|
605 { |
|
606 warn_old_style_preference (false, val); |
|
607 pref = 0; |
|
608 } |
2204
|
609 } |
|
610 |
|
611 return pref; |
|
612 } |
|
613 |
3354
|
614 static void |
|
615 check_dimensions (int& nr, int& nc, const char *warnfor) |
|
616 { |
|
617 if (nr < 0 || nc < 0) |
|
618 { |
|
619 if (Vtreat_neg_dim_as_zero) |
|
620 { |
|
621 nr = (nr < 0) ? 0 : nr; |
|
622 nc = (nc < 0) ? 0 : nc; |
|
623 |
|
624 if (Vtreat_neg_dim_as_zero < 0) |
|
625 warning ("%s: converting negative dimension to zero", |
|
626 warnfor); |
|
627 } |
|
628 else |
|
629 error ("%s: can't create a matrix with negative dimensions", |
|
630 warnfor); |
|
631 } |
|
632 } |
|
633 |
|
634 void |
|
635 get_dimensions (const octave_value& a, const char *warn_for, |
|
636 int& nr, int& nc) |
|
637 { |
|
638 if (a.is_scalar_type ()) |
|
639 { |
|
640 nr = nc = a.nint_value (); |
|
641 } |
|
642 else |
|
643 { |
|
644 nr = a.rows (); |
|
645 nc = a.columns (); |
|
646 |
|
647 if ((nr == 1 && nc == 2) || (nr == 2 && nc == 1)) |
|
648 { |
3419
|
649 Array<double> v = a.vector_value (); |
3354
|
650 |
|
651 if (error_state) |
|
652 return; |
|
653 |
|
654 nr = NINT (v (0)); |
|
655 nc = NINT (v (1)); |
|
656 } |
|
657 else |
|
658 warning ("%s (A): use %s (size (A)) instead", warn_for, warn_for); |
|
659 } |
|
660 |
|
661 check_dimensions (nr, nc, warn_for); // May set error_state. |
|
662 } |
|
663 |
|
664 void |
|
665 get_dimensions (const octave_value& a, const octave_value& b, |
|
666 const char *warn_for, int& nr, int& nc) |
|
667 { |
|
668 nr = a.is_empty () ? 0 : a.nint_value (); |
|
669 nc = b.is_empty () ? 0 : b.nint_value (); |
|
670 |
|
671 if (error_state) |
|
672 error ("%s: expecting two scalar arguments", warn_for); |
|
673 else |
|
674 check_dimensions (nr, nc, warn_for); // May set error_state. |
|
675 } |
|
676 |
3620
|
677 extern int |
3622
|
678 octave_format (std::ostream& os, const char *fmt, ...) |
3620
|
679 { |
|
680 int retval = -1; |
|
681 |
|
682 va_list args; |
|
683 va_start (args, fmt); |
|
684 |
|
685 retval = octave_vformat (os, fmt, args); |
|
686 |
|
687 va_end (args); |
|
688 |
|
689 return retval; |
|
690 } |
|
691 |
|
692 extern int |
3622
|
693 octave_vformat (std::ostream& os, const char *fmt, va_list args) |
3620
|
694 { |
|
695 int retval = -1; |
|
696 |
|
697 #if defined (__GNUG__) |
|
698 |
|
699 ostrstream buf; |
|
700 |
|
701 buf.vform (fmt, args); |
|
702 |
|
703 buf << ends; |
|
704 |
|
705 char *s = buf.str (); |
|
706 |
3621
|
707 os << s; |
|
708 |
3620
|
709 retval = strlen (s); |
|
710 |
3621
|
711 delete [] s; |
3620
|
712 |
|
713 #else |
|
714 |
|
715 char *s = octave_vsnprintf (fmt, args); |
|
716 |
|
717 if (s) |
|
718 { |
|
719 os << s; |
|
720 |
|
721 retval = strlen (s); |
3621
|
722 |
|
723 free (s); |
3620
|
724 } |
|
725 |
|
726 #endif |
|
727 |
|
728 return retval; |
|
729 } |
|
730 |
3354
|
731 static int |
|
732 treat_neg_dim_as_zero (void) |
|
733 { |
|
734 Vtreat_neg_dim_as_zero = check_preference ("treat_neg_dim_as_zero"); |
|
735 |
|
736 return 0; |
|
737 } |
|
738 |
|
739 void |
|
740 symbols_of_utils (void) |
|
741 { |
|
742 DEFVAR (treat_neg_dim_as_zero, 0.0, treat_neg_dim_as_zero, |
3369
|
743 "-*- texinfo -*-\n\ |
|
744 @defvr {Built-in Variable} treat_neg_dim_as_zero\n\ |
|
745 If the value of @code{treat_neg_dim_as_zero} is nonzero, expressions\n\ |
|
746 like\n\ |
|
747 \n\ |
|
748 @example\n\ |
|
749 eye (-1)\n\ |
|
750 @end example\n\ |
|
751 \n\ |
|
752 @noindent\n\ |
|
753 produce an empty matrix (i.e., row and column dimensions are zero).\n\ |
|
754 Otherwise, an error message is printed and control is returned to the\n\ |
|
755 top level. The default value is 0.\n\ |
|
756 @end defvr"); |
3354
|
757 } |
|
758 |
572
|
759 /* |
1
|
760 ;;; Local Variables: *** |
|
761 ;;; mode: C++ *** |
|
762 ;;; End: *** |
|
763 */ |