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 |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
1
|
21 |
|
22 */ |
|
23 |
240
|
24 #ifdef HAVE_CONFIG_H |
1192
|
25 #include <config.h> |
1
|
26 #endif |
|
27 |
1346
|
28 #include <cfloat> |
3124
|
29 #include <cmath> |
1343
|
30 #include <cstddef> |
1346
|
31 #include <cstdio> |
1343
|
32 #include <cstdlib> |
|
33 #include <cstring> |
|
34 |
3503
|
35 #include <iostream> |
1728
|
36 #include <string> |
|
37 |
1350
|
38 #ifdef HAVE_UNISTD_H |
2442
|
39 #ifdef HAVE_SYS_TYPES_H |
529
|
40 #include <sys/types.h> |
2442
|
41 #endif |
529
|
42 #include <unistd.h> |
|
43 #endif |
1
|
44 |
1430
|
45 #if defined (HAVE_TERMIOS_H) |
|
46 #include <termios.h> |
|
47 #elif defined (HAVE_TERMIO_H) |
|
48 #include <termio.h> |
|
49 #elif defined (HAVE_SGTTY_H) |
|
50 #include <sgtty.h> |
4067
|
51 #endif |
|
52 |
|
53 #if defined (HAVE_CONIO_H) |
|
54 #include <conio.h> |
1430
|
55 #endif |
|
56 |
3248
|
57 #if defined (HAVE_SYS_IOCTL_H) |
|
58 #include <sys/ioctl.h> |
|
59 #endif |
|
60 |
1463
|
61 #if defined (HAVE_FLOATINGPOINT_H) |
|
62 #include <floatingpoint.h> |
|
63 #endif |
|
64 |
2508
|
65 #if defined (HAVE_IEEEFP_H) |
|
66 #include <ieeefp.h> |
|
67 #endif |
|
68 |
1463
|
69 #if !defined (HAVE_GETHOSTNAME) && defined (HAVE_SYS_UTSNAME_H) |
|
70 #include <sys/utsname.h> |
|
71 #endif |
|
72 |
2926
|
73 #include "cmd-edit.h" |
|
74 #include "file-ops.h" |
2893
|
75 #include "lo-mappers.h" |
2317
|
76 #include "mach-info.h" |
2926
|
77 #include "oct-env.h" |
1769
|
78 |
1352
|
79 #include "defun.h" |
|
80 #include "error.h" |
529
|
81 #include "input.h" |
1755
|
82 #include "oct-obj.h" |
2370
|
83 #include "ov.h" |
3234
|
84 #include "pager.h" |
1352
|
85 #include "sysdep.h" |
1755
|
86 #include "toplev.h" |
529
|
87 #include "utils.h" |
|
88 |
|
89 #ifndef STDIN_FILENO |
|
90 #define STDIN_FILENO 1 |
|
91 #endif |
444
|
92 |
2508
|
93 #if defined (__386BSD__) || defined (__FreeBSD__) |
|
94 static void |
|
95 BSD_init (void) |
|
96 { |
|
97 #if defined (HAVE_FLOATINGPOINT_H) |
|
98 // Disable trapping on common exceptions. |
4164
|
99 #ifndef FP_X_DNML |
|
100 #define FP_X_DNML 0 |
|
101 #endif |
2508
|
102 fpsetmask (~(FP_X_OFL|FP_X_INV|FP_X_DZ|FP_X_DNML|FP_X_UFL|FP_X_IMP)); |
|
103 #endif |
|
104 } |
|
105 #endif |
|
106 |
4091
|
107 #if defined (__CYGWIN__) |
|
108 |
|
109 #include <limits.h> |
|
110 #include <sys/cygwin.h> |
|
111 |
|
112 static void |
|
113 CYGWIN_init (void) |
|
114 { |
4470
|
115 // Make sure TMPDIR contains an absolute windows path. Use '/' |
|
116 // rather than '\\' so that sh expansion won't mess file names. |
|
117 |
4091
|
118 std::string tmpdir = octave_env::getenv ("TMPDIR"); |
|
119 |
|
120 if (tmpdir.empty ()) |
4470
|
121 tmpdir = "/tmp"; |
|
122 |
|
123 char buf [PATH_MAX]; |
4091
|
124 |
4470
|
125 if (cygwin32_conv_to_full_win32_path (tmpdir.c_str (), buf) < 0) |
|
126 panic ("CYGWIN_init: unable to convert TMPDIR (= \"%s\") to Windows directory name", |
|
127 tmpdir.c_str ()); |
|
128 else |
|
129 { |
|
130 tmpdir = buf; |
4091
|
131 |
4470
|
132 for (size_t i = 0; i < tmpdir.length (); i++) |
|
133 if (tmpdir[i] == '\\') |
|
134 tmpdir[i] = '/'; |
4091
|
135 } |
4470
|
136 |
|
137 octave_env::putenv ("TMPDIR", tmpdir); |
4091
|
138 } |
|
139 #endif |
|
140 |
4284
|
141 #if defined (__DECCXX) |
|
142 |
|
143 // These don't seem to be instantiated automatically... |
|
144 |
|
145 template std::istream& |
|
146 std::operator >> (std::istream&, std::complex<double>&); |
|
147 |
|
148 template std::string& |
|
149 std::string::append (const std::string&, size_t, size_t); |
|
150 |
|
151 #endif |
|
152 |
2610
|
153 #if defined (NeXT) |
1
|
154 extern "C" |
|
155 { |
|
156 typedef void (*_cplus_fcn_int) (int); |
|
157 extern void (*malloc_error (_cplus_fcn_int)) (int); |
|
158 } |
|
159 |
|
160 static void |
|
161 malloc_handler (int code) |
|
162 { |
|
163 if (code == 5) |
217
|
164 warning ("hopefully recoverable malloc error: freeing wild pointer"); |
1
|
165 else |
2926
|
166 panic ("probably irrecoverable malloc error: code %d", code); |
1
|
167 } |
|
168 |
|
169 static void |
|
170 NeXT_init (void) |
|
171 { |
|
172 malloc_error (malloc_handler); |
|
173 } |
3333
|
174 #endif |
1
|
175 |
2546
|
176 #if defined (__EMX__) |
|
177 OS2_init (void) |
|
178 { |
|
179 _control87 ((EM_INVALID | EM_DENORMAL | EM_ZERODIVIDE | EM_OVERFLOW |
|
180 | EM_UNDERFLOW | EM_INEXACT), MCW_EM); |
|
181 } |
|
182 #endif |
|
183 |
2508
|
184 #if defined (SCO) |
|
185 static void |
|
186 SCO_init (void) |
|
187 { |
|
188 #if defined (HAVE_IEEEFP_H) |
|
189 // Disable trapping on common exceptions. |
|
190 fpsetmask (~(FP_X_OFL|FP_X_INV|FP_X_DZ|FP_X_DNML|FP_X_UFL|FP_X_IMP)); |
|
191 #endif |
|
192 } |
|
193 #endif |
|
194 |
1
|
195 void |
|
196 sysdep_init (void) |
|
197 { |
959
|
198 #if defined (__386BSD__) || defined (__FreeBSD__) |
2508
|
199 BSD_init (); |
4091
|
200 #elif defined (__CYGWIN__) |
|
201 CYGWIN_init (); |
2610
|
202 #elif defined (NeXT) |
1
|
203 NeXT_init (); |
2610
|
204 #elif defined (__EMX__) |
2546
|
205 OS2_init (); |
2508
|
206 #elif defined (SCO) |
|
207 SCO_init (); |
1
|
208 #endif |
444
|
209 |
|
210 octave_ieee_init (); |
1
|
211 } |
|
212 |
767
|
213 // Set terminal in raw mode. From less-177. |
|
214 // |
|
215 // Change terminal to "raw mode", or restore to "normal" mode. |
|
216 // "Raw mode" means |
|
217 // 1. An outstanding read will complete on receipt of a single keystroke. |
|
218 // 2. Input is not echoed. |
|
219 // 3. On output, \n is mapped to \r\n. |
|
220 // 4. \t is NOT expanded into spaces. |
|
221 // 5. Signal-causing characters such as ctrl-C (interrupt), |
|
222 // etc. are NOT disabled. |
|
223 // It doesn't matter whether an input \n is mapped to \r, or vice versa. |
|
224 |
529
|
225 void |
3657
|
226 raw_mode (bool on, bool wait) |
529
|
227 { |
3657
|
228 static bool curr_on = false; |
529
|
229 |
|
230 int tty_fd = STDIN_FILENO; |
|
231 if (! isatty (tty_fd)) |
|
232 { |
|
233 if (interactive) |
|
234 error ("stdin is not a tty!"); |
|
235 return; |
|
236 } |
|
237 |
|
238 if (on == curr_on) |
|
239 return; |
|
240 |
|
241 #if defined (HAVE_TERMIOS_H) |
|
242 { |
|
243 struct termios s; |
|
244 static struct termios save_term; |
|
245 |
|
246 if (on) |
|
247 { |
1358
|
248 // Get terminal modes. |
529
|
249 |
|
250 tcgetattr (tty_fd, &s); |
|
251 |
1358
|
252 // Save modes and set certain variables dependent on modes. |
529
|
253 |
|
254 save_term = s; |
|
255 // ospeed = s.c_cflag & CBAUD; |
|
256 // erase_char = s.c_cc[VERASE]; |
|
257 // kill_char = s.c_cc[VKILL]; |
|
258 |
1358
|
259 // Set the modes to the way we want them. |
529
|
260 |
|
261 s.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL); |
|
262 s.c_oflag |= (OPOST|ONLCR); |
|
263 #if defined (OCRNL) |
|
264 s.c_oflag &= ~(OCRNL); |
|
265 #endif |
|
266 #if defined (ONOCR) |
|
267 s.c_oflag &= ~(ONOCR); |
|
268 #endif |
|
269 #if defined (ONLRET) |
|
270 s.c_oflag &= ~(ONLRET); |
|
271 #endif |
3658
|
272 s.c_cc[VMIN] = wait ? 1 : 0; |
529
|
273 s.c_cc[VTIME] = 0; |
|
274 } |
|
275 else |
|
276 { |
1358
|
277 // Restore saved modes. |
|
278 |
529
|
279 s = save_term; |
|
280 } |
3658
|
281 |
529
|
282 tcsetattr (tty_fd, TCSAFLUSH, &s); |
|
283 } |
|
284 #elif defined (HAVE_TERMIO_H) |
|
285 { |
|
286 struct termio s; |
|
287 static struct termio save_term; |
|
288 |
|
289 if (on) |
|
290 { |
1358
|
291 // Get terminal modes. |
529
|
292 |
|
293 ioctl (tty_fd, TCGETA, &s); |
|
294 |
1358
|
295 // Save modes and set certain variables dependent on modes. |
529
|
296 |
|
297 save_term = s; |
|
298 // ospeed = s.c_cflag & CBAUD; |
|
299 // erase_char = s.c_cc[VERASE]; |
|
300 // kill_char = s.c_cc[VKILL]; |
|
301 |
1358
|
302 // Set the modes to the way we want them. |
529
|
303 |
|
304 s.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL); |
|
305 s.c_oflag |= (OPOST|ONLCR); |
|
306 #if defined (OCRNL) |
|
307 s.c_oflag &= ~(OCRNL); |
|
308 #endif |
|
309 #if defined (ONOCR) |
|
310 s.c_oflag &= ~(ONOCR); |
|
311 #endif |
|
312 #if defined (ONLRET) |
|
313 s.c_oflag &= ~(ONLRET); |
|
314 #endif |
3658
|
315 s.c_cc[VMIN] = wait ? 1 : 0; |
529
|
316 } |
|
317 else |
|
318 { |
1358
|
319 // Restore saved modes. |
|
320 |
529
|
321 s = save_term; |
|
322 } |
3658
|
323 |
529
|
324 ioctl (tty_fd, TCSETAW, &s); |
|
325 } |
|
326 #elif defined (HAVE_SGTTY_H) |
|
327 { |
|
328 struct sgttyb s; |
|
329 static struct sgttyb save_term; |
|
330 |
|
331 if (on) |
|
332 { |
1358
|
333 // Get terminal modes. |
529
|
334 |
|
335 ioctl (tty_fd, TIOCGETP, &s); |
|
336 |
1358
|
337 // Save modes and set certain variables dependent on modes. |
529
|
338 |
|
339 save_term = s; |
|
340 // ospeed = s.sg_ospeed; |
|
341 // erase_char = s.sg_erase; |
|
342 // kill_char = s.sg_kill; |
|
343 |
1358
|
344 // Set the modes to the way we want them. |
529
|
345 |
|
346 s.sg_flags |= CBREAK; |
|
347 s.sg_flags &= ~(ECHO); |
|
348 } |
|
349 else |
|
350 { |
1358
|
351 // Restore saved modes. |
|
352 |
529
|
353 s = save_term; |
|
354 } |
3658
|
355 |
529
|
356 ioctl (tty_fd, TIOCSETN, &s); |
|
357 } |
|
358 #else |
4064
|
359 warning ("no support for raw mode console I/O on this system"); |
|
360 |
|
361 // Make sure the current mode doesn't toggle. |
|
362 on = curr_on; |
529
|
363 #endif |
|
364 |
|
365 curr_on = on; |
|
366 } |
|
367 |
767
|
368 // Read one character from the terminal. |
|
369 |
529
|
370 int |
4067
|
371 octave_kbhit (bool wait) |
529
|
372 { |
4067
|
373 #ifdef HAVE__KBHIT |
4081
|
374 int c = (! wait && ! _kbhit ()) ? 0 : std::cin.get (); |
4067
|
375 #else |
3658
|
376 raw_mode (true, wait); |
|
377 |
|
378 int c = std::cin.get (); |
|
379 |
|
380 if (std::cin.fail () || std::cin.eof ()) |
|
381 std::cin.clear (); |
|
382 |
|
383 raw_mode (false, true); |
4067
|
384 #endif |
3658
|
385 |
529
|
386 return c; |
|
387 } |
|
388 |
1957
|
389 DEFUN (clc, , , |
3332
|
390 "-*- texinfo -*-\n\ |
|
391 @deftypefn {Built-in Function} {} clc ()\n\ |
|
392 @deftypefnx {Built-in Function} {} home ()\n\ |
|
393 Clear the terminal screen and move the cursor to the upper left corner.\n\ |
3333
|
394 @end deftypefn") |
529
|
395 { |
2926
|
396 command_editor::clear_screen (); |
529
|
397 |
2926
|
398 return octave_value_list (); |
529
|
399 } |
|
400 |
549
|
401 DEFALIAS (home, clc); |
|
402 |
1957
|
403 DEFUN (getenv, args, , |
3301
|
404 "-*- texinfo -*-\n\ |
|
405 @deftypefn {Built-in Function} {} getenv (@var{var})\n\ |
|
406 Return the value of the environment variable @var{var}. For example,\n\ |
|
407 \n\ |
|
408 @example\n\ |
|
409 getenv (\"PATH\")\n\ |
|
410 @end example\n\ |
|
411 \n\ |
|
412 @noindent\n\ |
|
413 returns a string containing the value of your path.\n\ |
|
414 @end deftypefn") |
529
|
415 { |
4233
|
416 octave_value retval; |
529
|
417 |
|
418 int nargin = args.length (); |
|
419 |
712
|
420 if (nargin == 1) |
529
|
421 { |
3523
|
422 std::string name = args(0).string_value (); |
636
|
423 |
|
424 if (! error_state) |
2926
|
425 retval = octave_env::getenv (name); |
529
|
426 } |
|
427 else |
|
428 print_usage ("getenv"); |
|
429 |
|
430 return retval; |
|
431 } |
|
432 |
1957
|
433 DEFUN (putenv, args, , |
3301
|
434 "-*- texinfo -*-\n\ |
|
435 @deftypefn {Built-in Function} {} putenv (@var{var}, @var{value})\n\ |
|
436 Set the value of the environment variable @var{var} to @var{value}.\n\ |
|
437 @end deftypefn") |
1706
|
438 { |
2086
|
439 octave_value_list retval; |
1706
|
440 |
|
441 int nargin = args.length (); |
|
442 |
|
443 if (nargin == 2) |
|
444 { |
3523
|
445 std::string var = args(0).string_value (); |
1706
|
446 |
|
447 if (! error_state) |
|
448 { |
3523
|
449 std::string val = args(1).string_value (); |
1706
|
450 |
|
451 if (! error_state) |
2926
|
452 octave_env::putenv (var, val); |
1706
|
453 else |
|
454 error ("putenv: second argument should be a string"); |
|
455 } |
|
456 else |
|
457 error ("putenv: first argument should be a string"); |
|
458 } |
|
459 else |
|
460 print_usage ("putenv"); |
|
461 |
|
462 return retval; |
|
463 } |
|
464 |
3372
|
465 // XXX FIXME XXX -- perhaps kbhit should also be able to print a prompt? |
|
466 |
3657
|
467 DEFUN (kbhit, args, , |
3372
|
468 "-*- texinfo -*-\n\ |
|
469 @deftypefn {Built-in Function} {} kbhit ()\n\ |
3657
|
470 Read a single keystroke from the keyboard. If called with one\n\ |
|
471 argument, don't wait for a keypress. For example,\n\ |
3372
|
472 \n\ |
|
473 @example\n\ |
|
474 x = kbhit ();\n\ |
|
475 @end example\n\ |
|
476 \n\ |
|
477 @noindent\n\ |
|
478 will set @var{x} to the next character typed at the keyboard as soon as\n\ |
|
479 it is typed.\n\ |
3657
|
480 \n\ |
|
481 @example\n\ |
|
482 x = kbhit (1);\n\ |
|
483 @end example\n\ |
|
484 \n\ |
|
485 @noindent\n\ |
|
486 identical to the above example, but don't wait for a keypress,\n\ |
|
487 returning the empty string if no key is available.\n\ |
3372
|
488 @end deftypefn") |
529
|
489 { |
4233
|
490 octave_value retval; |
529
|
491 |
1358
|
492 // XXX FIXME XXX -- add timeout and default value args? |
529
|
493 |
3676
|
494 if (interactive || forced_interactive) |
529
|
495 { |
4067
|
496 int c = octave_kbhit (args.length () == 0); |
3657
|
497 |
3658
|
498 if (c == -1) |
|
499 c = 0; |
3657
|
500 |
529
|
501 char *s = new char [2]; |
|
502 s[0] = c; |
|
503 s[1] = '\0'; |
|
504 retval = s; |
|
505 } |
|
506 |
|
507 return retval; |
|
508 } |
|
509 |
1957
|
510 DEFUN (pause, args, , |
3301
|
511 "-*- texinfo -*-\n\ |
|
512 @deftypefn {Built-in Function} {} pause (@var{seconds})\n\ |
|
513 Suspend the execution of the program. If invoked without any arguments,\n\ |
|
514 Octave waits until you type a character. With a numeric argument, it\n\ |
|
515 pauses for the given number of seconds. For example, the following\n\ |
|
516 statement prints a message and then waits 5 seconds before clearing the\n\ |
|
517 screen.\n\ |
|
518 \n\ |
|
519 @example\n\ |
|
520 @group\n\ |
|
521 fprintf (stderr, \"wait please...\n\");\n\ |
|
522 pause (5);\n\ |
|
523 clc;\n\ |
|
524 @end group\n\ |
|
525 @end example\n\ |
|
526 @end deftypefn") |
529
|
527 { |
2086
|
528 octave_value_list retval; |
529
|
529 |
|
530 int nargin = args.length (); |
|
531 |
712
|
532 if (! (nargin == 0 || nargin == 1)) |
529
|
533 { |
|
534 print_usage ("pause"); |
|
535 return retval; |
|
536 } |
|
537 |
1579
|
538 if (nargin == 1) |
529
|
539 { |
1579
|
540 double dval = args(0).double_value (); |
636
|
541 |
1579
|
542 if (! error_state) |
|
543 { |
|
544 if (xisnan (dval)) |
|
545 warning ("pause: NaN is an invalid delay"); |
2630
|
546 else if (xisinf (dval)) |
3234
|
547 { |
|
548 flush_octave_stdout (); |
4067
|
549 octave_kbhit (); |
3234
|
550 } |
1579
|
551 else |
4086
|
552 octave_sleep (dval); |
529
|
553 } |
|
554 } |
1579
|
555 else |
3234
|
556 { |
|
557 flush_octave_stdout (); |
4067
|
558 octave_kbhit (); |
3234
|
559 } |
2630
|
560 |
|
561 return retval; |
|
562 } |
|
563 |
|
564 DEFUN (sleep, args, , |
3301
|
565 "-*- texinfo -*-\n\ |
|
566 @deftypefn {Built-in Function} {} sleep (@var{seconds})\n\ |
|
567 Suspend the execution of the program for the given number of seconds.\n\ |
|
568 @end deftypefn") |
2630
|
569 { |
|
570 octave_value_list retval; |
|
571 |
|
572 if (args.length () == 1) |
1579
|
573 { |
2630
|
574 double dval = args(0).double_value (); |
|
575 |
|
576 if (! error_state) |
|
577 { |
|
578 if (xisnan (dval)) |
|
579 warning ("sleep: NaN is an invalid delay"); |
|
580 else |
4086
|
581 octave_sleep (dval); |
2630
|
582 } |
1579
|
583 } |
2630
|
584 else |
|
585 print_usage ("sleep"); |
|
586 |
|
587 return retval; |
|
588 } |
|
589 |
|
590 DEFUN (usleep, args, , |
3301
|
591 "-*- texinfo -*-\n\ |
|
592 @deftypefn {Built-in Function} {} usleep (@var{microseconds})\n\ |
|
593 Suspend the execution of the program for the given number of\n\ |
|
594 microseconds. On systems where it is not possible to sleep for periods\n\ |
|
595 of time less than one second, @code{usleep} will pause the execution for\n\ |
|
596 @code{round (@var{microseconds} / 1e6)} seconds.\n\ |
|
597 @end deftypefn") |
2630
|
598 { |
|
599 octave_value_list retval; |
|
600 |
|
601 if (args.length () == 1) |
|
602 { |
|
603 double dval = args(0).double_value (); |
|
604 |
|
605 if (! error_state) |
|
606 { |
|
607 if (xisnan (dval)) |
|
608 warning ("usleep: NaN is an invalid delay"); |
|
609 else |
|
610 { |
|
611 int delay = NINT (dval); |
2631
|
612 |
2630
|
613 if (delay > 0) |
3308
|
614 octave_usleep (delay); |
2630
|
615 } |
|
616 } |
|
617 } |
|
618 else |
|
619 print_usage ("usleep"); |
529
|
620 |
|
621 return retval; |
|
622 } |
|
623 |
862
|
624 // XXX FIXME XXX -- maybe this should only return 1 if IEEE floating |
|
625 // point functions really work. |
|
626 |
1957
|
627 DEFUN (isieee, , , |
3301
|
628 "-*- texinfo -*-\n\ |
|
629 @deftypefn {Built-in Function} {} isieee ()\n\ |
|
630 Return 1 if your computer claims to conform to the IEEE standard for\n\ |
|
631 floating point calculations.\n\ |
|
632 @end deftypefn") |
862
|
633 { |
4600
|
634 oct_mach_info::float_format flt_fmt = oct_mach_info::native_float_format (); |
2317
|
635 |
4574
|
636 return octave_value (flt_fmt == oct_mach_info::flt_fmt_ieee_little_endian |
|
637 || flt_fmt == oct_mach_info::flt_fmt_ieee_big_endian); |
862
|
638 } |
|
639 |
4600
|
640 DEFUN (native_float_format, , , |
|
641 "-*- texinfo -*-\n\ |
|
642 @deftypefn {Built-in Function} {} native_float_format ()\n\ |
|
643 Return the native floating point format as a string\n\ |
|
644 @end deftypefn") |
|
645 { |
|
646 oct_mach_info::float_format flt_fmt = oct_mach_info::native_float_format (); |
|
647 |
|
648 return octave_value (oct_mach_info::float_format_as_string (flt_fmt)); |
|
649 } |
|
650 |
1957
|
651 DEFUN (tilde_expand, args, , |
3301
|
652 "-*- texinfo -*-\n\ |
|
653 @deftypefn {Built-in Function} {} tilde_expand (@var{string})\n\ |
|
654 Performs tilde expansion on @var{string}. If @var{string} begins with a\n\ |
|
655 tilde character, (@samp{~}), all of the characters preceding the first\n\ |
|
656 slash (or all characters, if there is no slash) are treated as a\n\ |
|
657 possible user name, and the tilde and the following characters up to the\n\ |
|
658 slash are replaced by the home directory of the named user. If the\n\ |
|
659 tilde is followed immediately by a slash, the tilde is replaced by the\n\ |
|
660 home directory of the user running Octave. For example,\n\ |
|
661 \n\ |
|
662 @example\n\ |
|
663 @group\n\ |
|
664 tilde_expand (\"~joeuser/bin\")\n\ |
|
665 @result{} \"/home/joeuser/bin\"\n\ |
|
666 tilde_expand (\"~/bin\")\n\ |
|
667 @result{} \"/home/jwe/bin\"\n\ |
|
668 @end group\n\ |
|
669 @end example\n\ |
|
670 @end deftypefn") |
1750
|
671 { |
4233
|
672 octave_value retval; |
1750
|
673 |
|
674 int nargin = args.length (); |
|
675 |
|
676 if (nargin == 1) |
2926
|
677 retval = file_ops::tilde_expand (args(0).all_strings ()); |
1750
|
678 else |
|
679 print_usage ("tilde_expand"); |
|
680 |
|
681 return retval; |
|
682 } |
|
683 |
2552
|
684 #if defined (__EMX__) && defined (OS2) |
|
685 |
4208
|
686 DEFCMD (extproc, , , |
2926
|
687 "extproc: ignored by Octave") |
2552
|
688 { |
|
689 return octave_value_list (); |
|
690 } |
|
691 |
|
692 DEFALIAS (EXTPROC, extproc); |
|
693 |
|
694 #endif |
|
695 |
529
|
696 /* |
1
|
697 ;;; Local Variables: *** |
|
698 ;;; mode: C++ *** |
|
699 ;;; End: *** |
|
700 */ |