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