annotate libinterp/corefcn/sysdep.cc @ 21301:40de9f8f23a6

Use '#include "config.h"' rather than <config.h>. * mk-octave-config-h.sh, mk-opts.pl, Backend.cc, BaseControl.cc, ButtonControl.cc, Canvas.cc, CheckBoxControl.cc, Container.cc, ContextMenu.cc, EditControl.cc, Figure.cc, FigureWindow.cc, GLCanvas.cc, KeyMap.cc, ListBoxControl.cc, Logger.cc, Menu.cc, MouseModeActionGroup.cc, Object.cc, ObjectFactory.cc, ObjectProxy.cc, Panel.cc, PopupMenuControl.cc, PushButtonControl.cc, PushTool.cc, QtHandlesUtils.cc, RadioButtonControl.cc, SliderControl.cc, TextControl.cc, TextEdit.cc, ToggleButtonControl.cc, ToggleTool.cc, ToolBar.cc, ToolBarButton.cc, __init_qt__.cc, annotation-dialog.cc, gl-select.cc, module.mk, kpty.cpp, color-picker.cc, dialog.cc, documentation-dock-widget.cc, files-dock-widget.cc, find-files-dialog.cc, find-files-model.cc, history-dock-widget.cc, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, find-dialog.cc, marker.cc, octave-qscintilla.cc, octave-txt-lexer.cc, main-window.cc, octave-cmd.cc, octave-dock-widget.cc, octave-gui.cc, octave-interpreter.cc, octave-qt-link.cc, parser.cc, webinfo.cc, resource-manager.cc, settings-dialog.cc, shortcut-manager.cc, terminal-dock-widget.cc, thread-manager.cc, welcome-wizard.cc, workspace-model.cc, workspace-view.cc, build-env-features.sh, build-env.in.cc, Cell.cc, __contourc__.cc, __dispatch__.cc, __dsearchn__.cc, __ichol__.cc, __ilu__.cc, __lin_interpn__.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, besselj.cc, betainc.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, cdisplay.c, cellfun.cc, coct-hdf5-types.c, colloc.cc, comment-list.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, debug.cc, defaults.cc, defun.cc, det.cc, dirfns.cc, display.cc, dlmread.cc, dot.cc, dynamic-ld.cc, eig.cc, ellipj.cc, error.cc, errwarn.cc, event-queue.cc, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc, ft-text-renderer.cc, gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, gl-render.cc, gl2ps-print.cc, graphics.cc, gripes.cc, hash.cc, help.cc, hess.cc, hex2num.cc, hook-fcn.cc, input.cc, inv.cc, jit-ir.cc, jit-typeinfo.cc, jit-util.cc, kron.cc, load-path.cc, load-save.cc, lookup.cc, ls-ascii-helper.cc, ls-hdf5.cc, ls-mat-ascii.cc, ls-mat4.cc, ls-mat5.cc, ls-oct-binary.cc, ls-oct-text.cc, ls-utils.cc, lsode.cc, lu.cc, luinc.cc, mappers.cc, matrix_type.cc, max.cc, mex.cc, mgorth.cc, nproc.cc, oct-errno.in.cc, oct-fstrm.cc, oct-hdf5-types.cc, oct-hist.cc, oct-iostrm.cc, oct-lvalue.cc, oct-map.cc, oct-prcstrm.cc, oct-procbuf.cc, oct-stream.cc, oct-strstrm.cc, oct-tex-lexer.in.ll, oct-tex-parser.in.yy, octave-link.cc, ordschur.cc, pager.cc, pinv.cc, pr-output.cc, procstream.cc, profiler.cc, psi.cc, pt-jit.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sighandlers.cc, siglist.c, sparse-xdiv.cc, sparse-xpow.cc, sparse.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symtab.cc, syscalls.cc, sysdep.cc, text-renderer.cc, time.cc, toplev.cc, tril.cc, tsearch.cc, txt-eng.cc, typecast.cc, urlwrite.cc, utils.cc, variables.cc, xdiv.cc, xgl2ps.c, xnorm.cc, xpow.cc, zfstream.cc, __delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __magick_read__.cc, __osmesa_print__.cc, __voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc, colamd.cc, convhulln.cc, dmperm.cc, fftw.cc, qr.cc, symbfact.cc, symrcm.cc, mkbuiltins, mkops, ov-base-diag.cc, ov-base-int.cc, ov-base-mat.cc, ov-base-scalar.cc, ov-base-sparse.cc, ov-base.cc, ov-bool-mat.cc, ov-bool-sparse.cc, ov-bool.cc, ov-builtin.cc, ov-cell.cc, ov-ch-mat.cc, ov-class.cc, ov-classdef.cc, ov-colon.cc, ov-complex.cc, ov-cs-list.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-dld-fcn.cc, ov-fcn-handle.cc, ov-fcn-inline.cc, ov-fcn.cc, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-java.cc, ov-lazy-idx.cc, ov-mex-fcn.cc, ov-null-mat.cc, ov-oncleanup.cc, ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc, ov-struct.cc, ov-typeinfo.cc, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc, ov-usr-fcn.cc, ov.cc, ovl.cc, octave.cc, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc, op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-dm-template.cc, op-dms-template.cc, op-double-conv.cc, op-fcdm-fcdm.cc, op-fcdm-fdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-float-conv.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc, op-int-conv.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc, op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, lex.ll, oct-parse.in.yy, pt-arg-list.cc, pt-array-list.cc, pt-assign.cc, pt-binop.cc, pt-bp.cc, pt-cbinop.cc, pt-cell.cc, pt-check.cc, pt-classdef.cc, pt-cmd.cc, pt-colon.cc, pt-const.cc, pt-decl.cc, pt-eval.cc, pt-except.cc, pt-exp.cc, pt-fcn-handle.cc, pt-funcall.cc, pt-id.cc, pt-idx.cc, pt-jump.cc, pt-loop.cc, pt-mat.cc, pt-misc.cc, pt-pr-code.cc, pt-select.cc, pt-stmt.cc, pt-unop.cc, pt.cc, token.cc, Array-jit.cc, Array-os.cc, Array-sym.cc, Array-tc.cc, version.cc, Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc, Array-fC.cc, Array-i.cc, Array-idx-vec.cc, Array-s.cc, Array-str.cc, Array-util.cc, Array-voidp.cc, Array.cc, CColVector.cc, CDiagMatrix.cc, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc, DiagArray2.cc, MArray-C.cc, MArray-d.cc, MArray-f.cc, MArray-fC.cc, MArray-i.cc, MArray-s.cc, MArray.cc, MDiagArray2.cc, MSparse-C.cc, MSparse-d.cc, MatrixType.cc, PermMatrix.cc, Range.cc, Sparse-C.cc, Sparse-b.cc, Sparse-d.cc, Sparse.cc, boolMatrix.cc, boolNDArray.cc, boolSparse.cc, chMatrix.cc, chNDArray.cc, dColVector.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc, dSparse.cc, dim-vector.cc, fCColVector.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc, fCRowVector.cc, fColVector.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc, fRowVector.cc, idx-vector.cc, int16NDArray.cc, int32NDArray.cc, int64NDArray.cc, int8NDArray.cc, intNDArray.cc, uint16NDArray.cc, uint32NDArray.cc, uint64NDArray.cc, uint8NDArray.cc, blaswrap.c, cquit.c, f77-extern.cc, f77-fcn.c, lo-error.c, quit.cc, CollocWt.cc, DASPK.cc, DASRT.cc, DASSL.cc, EIG.cc, LSODE.cc, ODES.cc, Quad.cc, aepbalance.cc, chol.cc, eigs-base.cc, fEIG.cc, gepbalance.cc, hess.cc, lo-mappers.cc, lo-specfun.cc, lu.cc, oct-convn.cc, oct-fftw.cc, oct-norm.cc, oct-rand.cc, oct-spparms.cc, qr.cc, qrp.cc, randgamma.c, randmtzig.c, randpoisson.c, schur.cc, sparse-chol.cc, sparse-dmsolve.cc, sparse-lu.cc, sparse-qr.cc, svd.cc, mk-ops.awk, dir-ops.cc, file-ops.cc, file-stat.cc, lo-sysdep.cc, mach-info.cc, oct-env.cc, oct-group.cc, oct-passwd.cc, oct-syscalls.cc, oct-time.cc, oct-uname.cc, cmd-edit.cc, cmd-hist.cc, data-conv.cc, f2c-main.c, glob-match.cc, kpse.cc, lo-array-errwarn.cc, lo-array-gripes.cc, lo-cutils.c, lo-ieee.cc, lo-regexp.cc, lo-utils.cc, oct-base64.cc, oct-glob.cc, oct-inttypes.cc, oct-locbuf.cc, oct-mutex.cc, oct-rl-edit.c, oct-rl-hist.c, oct-shlib.cc, oct-sort.cc, pathsearch.cc, singleton-cleanup.cc, sparse-sort.cc, sparse-util.cc, str-vec.cc, unwind-prot.cc, url-transfer.cc, display-available.c, main-cli.cc, main-gui.cc, main.in.cc, mkoctfile.in.cc, octave-config.in.cc: Use '#include "config.h"' rather than <config.h>.
author Rik <rik@octave.org>
date Thu, 18 Feb 2016 13:34:50 -0800
parents fcac5dbbf9ed
children 12f207a534aa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19540
diff changeset
3 Copyright (C) 1993-2015 John W. Eaton
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
4
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6960
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6960
diff changeset
10 option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
11
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6960
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6960
diff changeset
19 <http://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
22
240
a99f28f5e351 [project @ 1993-11-30 20:24:36 by jwe]
jwe
parents: 217
diff changeset
23 #ifdef HAVE_CONFIG_H
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
24 # include "config.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26
1346
9e41dbb74bca [project @ 1995-09-05 06:37:49 by jwe]
jwe
parents: 1343
diff changeset
27 #include <cfloat>
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1318
diff changeset
28 #include <cstddef>
1346
9e41dbb74bca [project @ 1995-09-05 06:37:49 by jwe]
jwe
parents: 1343
diff changeset
29 #include <cstdio>
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1318
diff changeset
30 #include <cstdlib>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1318
diff changeset
31 #include <cstring>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1318
diff changeset
32
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3372
diff changeset
33 #include <iostream>
1728
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1711
diff changeset
34 #include <string>
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1711
diff changeset
35
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
36 #include <sys/types.h>
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
37 #include <unistd.h>
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
38
1430
045e70a15a8f [project @ 1995-09-19 07:05:37 by jwe]
jwe
parents: 1415
diff changeset
39 #if defined (HAVE_TERMIOS_H)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
40 # include <termios.h>
1430
045e70a15a8f [project @ 1995-09-19 07:05:37 by jwe]
jwe
parents: 1415
diff changeset
41 #elif defined (HAVE_TERMIO_H)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
42 # include <termio.h>
1430
045e70a15a8f [project @ 1995-09-19 07:05:37 by jwe]
jwe
parents: 1415
diff changeset
43 #elif defined (HAVE_SGTTY_H)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
44 # include <sgtty.h>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
45 #endif
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
46
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
47 #if defined (HAVE_CONIO_H)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
48 # include <conio.h>
1430
045e70a15a8f [project @ 1995-09-19 07:05:37 by jwe]
jwe
parents: 1415
diff changeset
49 #endif
045e70a15a8f [project @ 1995-09-19 07:05:37 by jwe]
jwe
parents: 1415
diff changeset
50
3248
68259f410026 [project @ 1999-07-13 03:34:54 by jwe]
jwe
parents: 3234
diff changeset
51 #if defined (HAVE_SYS_IOCTL_H)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
52 # include <sys/ioctl.h>
3248
68259f410026 [project @ 1999-07-13 03:34:54 by jwe]
jwe
parents: 3234
diff changeset
53 #endif
68259f410026 [project @ 1999-07-13 03:34:54 by jwe]
jwe
parents: 3234
diff changeset
54
1463
592291d9dfbb [project @ 1995-09-22 07:18:44 by jwe]
jwe
parents: 1430
diff changeset
55 #if defined (HAVE_FLOATINGPOINT_H)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
56 # include <floatingpoint.h>
1463
592291d9dfbb [project @ 1995-09-22 07:18:44 by jwe]
jwe
parents: 1430
diff changeset
57 #endif
592291d9dfbb [project @ 1995-09-22 07:18:44 by jwe]
jwe
parents: 1430
diff changeset
58
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
59 #if defined (HAVE_IEEEFP_H)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
60 # include <ieeefp.h>
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
61 #endif
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
62
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2893
diff changeset
63 #include "cmd-edit.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2893
diff changeset
64 #include "file-ops.h"
2893
9fd1df4b464a [project @ 1997-04-28 02:07:38 by jwe]
jwe
parents: 2847
diff changeset
65 #include "lo-mappers.h"
7231
2eb392d058bb [project @ 2007-11-30 18:53:29 by jwe]
jwe
parents: 7017
diff changeset
66 #include "lo-math.h"
2317
8c09c04f7747 [project @ 1996-07-14 22:30:15 by jwe]
jwe
parents: 2086
diff changeset
67 #include "mach-info.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2893
diff changeset
68 #include "oct-env.h"
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
69 #include "quit.h"
1769
bc7ae9be3378 [project @ 1996-01-23 06:49:08 by jwe]
jwe
parents: 1755
diff changeset
70
6208
323be5eeed1f [project @ 2006-12-06 20:23:18 by jwe]
jwe
parents: 6135
diff changeset
71 #include "Cell.h"
15423
53d073233fa4 call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
72 #include "builtins.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
73 #include "defun.h"
17851
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
74 #include "display.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
75 #include "error.h"
21115
629643522cc0 include errwarn.h in all files that use gripe_disabled_feature
John W. Eaton <jwe@octave.org>
parents: 21109
diff changeset
76 #include "errwarn.h"
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
77 #include "input.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20939
diff changeset
78 #include "ovl.h"
2370
a45c7d64b5e3 [project @ 1996-10-11 23:51:15 by jwe]
jwe
parents: 2317
diff changeset
79 #include "ov.h"
3234
be8e0ba13644 [project @ 1999-01-29 03:52:30 by jwe]
jwe
parents: 3124
diff changeset
80 #include "pager.h"
6419
73fcbac81f33 [project @ 2007-03-20 17:18:24 by jwe]
jwe
parents: 6208
diff changeset
81 #include "parse.h"
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
82 #include "sighandlers.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
83 #include "sysdep.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
84 #include "toplev.h"
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
85 #include "utils.h"
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
86 #include "file-stat.h"
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
87
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
88 #ifndef STDIN_FILENO
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
89 # define STDIN_FILENO 1
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
90 #endif
444
ba637cc5c5f3 [project @ 1994-06-02 17:15:07 by jwe]
jwe
parents: 401
diff changeset
91
9441
160c564d5d25 initialize floating point values properly for NetBSD systems
Aleksej Saushev <asau@inbox.ru>
parents: 9411
diff changeset
92 #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__)
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
93 static void
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
94 BSD_init (void)
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
95 {
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
96 # if defined (HAVE_FLOATINGPOINT_H)
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
97 // Disable trapping on common exceptions.
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
98 # ifndef FP_X_DNML
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
99 # define FP_X_DNML 0
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
100 # endif
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
101 fpsetmask (~(FP_X_OFL|FP_X_INV|FP_X_DZ|FP_X_DNML|FP_X_UFL|FP_X_IMP));
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
102 # endif
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
103 }
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
104 #endif
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
105
6956
cc712c417943 [project @ 2007-10-04 17:51:57 by jwe]
jwe
parents: 6954
diff changeset
106 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
107
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
108 #define WIN32_LEAN_AND_MEAN
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
109 #include <tlhelp32.h>
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
110 #include <windows.h>
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
111
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
112 static void
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
113 w32_set_octave_home (void)
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
114 {
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
115 std::string bin_dir;
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
116
13885
2f42a7b0cf94 Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13771
diff changeset
117 HANDLE h = CreateToolhelp32Snapshot (TH32CS_SNAPMODULE
2f42a7b0cf94 Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13771
diff changeset
118 #ifdef TH32CS_SNAPMODULE32
2f42a7b0cf94 Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13771
diff changeset
119 | TH32CS_SNAPMODULE32
2f42a7b0cf94 Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13771
diff changeset
120 #endif
2f42a7b0cf94 Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13771
diff changeset
121 , 0);
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
122
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
123 if (h != INVALID_HANDLE_VALUE)
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
124 {
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
125 MODULEENTRY32 mod_info;
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
126
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
127 ZeroMemory (&mod_info, sizeof (mod_info));
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
128 mod_info.dwSize = sizeof (mod_info);
13751
be7ff59cbc7a Fix octinterp DLL searching on Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13282
diff changeset
129
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
130 if (Module32First (h, &mod_info))
14445
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
131 {
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
132 do
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
133 {
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
134 std::string mod_name (mod_info.szModule);
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
135
14445
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
136 if (mod_name.find ("octinterp") != std::string::npos)
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
137 {
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
138 bin_dir = mod_info.szExePath;
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
139 if (bin_dir[bin_dir.length () - 1] != '\\')
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
140 bin_dir.append (1, '\\');
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
141 break;
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
142 }
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
143 }
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
144 while (Module32Next (h, &mod_info));
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
145 }
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
146
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
147 CloseHandle (h);
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
148 }
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
149
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
150 if (! bin_dir.empty ())
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
151 {
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
152 size_t pos = bin_dir.rfind ("\\bin\\");
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
153
8021
85184151822e fix typo in NPOS change
John W. Eaton <jwe@octave.org>
parents: 8019
diff changeset
154 if (pos != std::string::npos)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
155 octave_env::putenv ("OCTAVE_HOME", bin_dir.substr (0, pos));
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
156 }
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
157 }
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
158
6960
d5339f9f5f9c [project @ 2007-10-05 15:03:09 by jwe]
jwe
parents: 6956
diff changeset
159 void
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
160 w32_set_quiet_shutdown (void)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
161 {
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
162 // Let the user close the console window or shutdown without the
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
163 // pesky dialog.
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
164 //
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
165 // FIXME: should this be user configurable?
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
166 SetProcessShutdownParameters (0x280, SHUTDOWN_NORETRY);
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
167 }
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
168
6960
d5339f9f5f9c [project @ 2007-10-05 15:03:09 by jwe]
jwe
parents: 6956
diff changeset
169 void
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
170 MINGW_signal_cleanup (void)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
171 {
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5451
diff changeset
172 w32_set_quiet_shutdown ();
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
173 }
19302
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
174
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
175 static void
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
176 w32_init (void)
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
177 {
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
178 w32_set_octave_home ();
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
179
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
180 command_editor::prefer_env_winsize (true);
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
181 }
19774
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
182
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
183 static bool
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
184 w32_shell_execute (const std::string& file)
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
185 {
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
186 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
187 #endif
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
188
19856
5c1a38089f89 Change open_with_system_app to internal function.
Rik <rik@octave.org>
parents: 19849
diff changeset
189 DEFUN (__open_with_system_app__, args, ,
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19857
diff changeset
190 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
191 @deftypefn {} {} __open_with_system_app__ (@var{file})\n\
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
192 Undocumented internal function.\n\
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
193 @end deftypefn")
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
194 {
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
195 if (args.length () != 1)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
196 print_usage ();
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
197
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
198 std::string file = args(0).xstring_value ("__open_with_system_app__: argument must be a filename");
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
199
21078
49852ff04747 maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents: 21017
diff changeset
200 octave_value retval;
49852ff04747 maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents: 21017
diff changeset
201
19774
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
202 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
203 HINSTANCE status = ShellExecute (0, 0, file.c_str (), 0, 0,
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
204 SW_SHOWNORMAL);
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
205
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
206 // ShellExecute returns a value greater than 32 if successful.
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
207 retval = (reinterpret_cast<ptrdiff_t> (status) > 32);
20961
f55251db0833 Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents: 20941
diff changeset
208 #elif defined (__APPLE__)
f55251db0833 Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents: 20941
diff changeset
209 octave_value_list tmp
f55251db0833 Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents: 20941
diff changeset
210 = Fsystem (ovl ("open " + file + " 2> /dev/null",
f55251db0833 Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents: 20941
diff changeset
211 false, "async"),
f55251db0833 Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents: 20941
diff changeset
212 1);
f55251db0833 Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents: 20941
diff changeset
213
f55251db0833 Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents: 20941
diff changeset
214 retval = (tmp(0).double_value () == 0);
19774
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
215 #else
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
216 octave_value_list tmp
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
217 = Fsystem (ovl ("xdg-open " + file + " 2> /dev/null",
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
218 false, "async"),
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
219 1);
19774
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
220
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
221 retval = (tmp(0).double_value () == 0);
19774
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
222 #endif
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
223
19774
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
224 return retval;
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
225 }
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
226
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
227 #if defined (__MINGW32__)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
228 static void
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
229 MINGW_init (void)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
230 {
19302
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
231 w32_init ();
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
232 }
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
233 #endif
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
234
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
235 #if defined (_MSC_VER)
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
236 static void
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
237 MSVC_init (void)
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
238 {
19302
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
239 w32_init ();
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
240 }
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
241 #endif
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
242
4091
575507e27b8b [project @ 2002-10-06 20:50:15 by jwe]
jwe
parents: 4086
diff changeset
243
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
244 // Return TRUE if FILE1 and FILE2 refer to the same (physical) file.
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
245
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
246 bool
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
247 same_file_internal (const std::string& file1, const std::string& file2)
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
248 {
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
249 #ifdef OCTAVE_USE_WINDOWS_API
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
250
6691
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
251 bool retval = false;
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
252
16564
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
253 const char *f1 = file1.c_str ();
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
254 const char *f2 = file2.c_str ();
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
255
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
256 bool f1_is_dir = GetFileAttributes (f1) & FILE_ATTRIBUTE_DIRECTORY;
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
257 bool f2_is_dir = GetFileAttributes (f2) & FILE_ATTRIBUTE_DIRECTORY;
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
258
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
259 // Windows native code
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
260 // Reference: http://msdn2.microsoft.com/en-us/library/aa363788.aspx
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
261
16564
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
262 DWORD share = FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE;
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
263
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
264 HANDLE hfile1
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
265 = CreateFile (f1, 0, share, 0, OPEN_EXISTING,
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
266 f1_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0);
6691
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
267
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
268 if (hfile1 != INVALID_HANDLE_VALUE)
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
269 {
16564
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
270 HANDLE hfile2
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
271 = CreateFile (f2, 0, share, 0, OPEN_EXISTING,
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
272 f2_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0);
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
273
6691
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
274 if (hfile2 != INVALID_HANDLE_VALUE)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
275 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
276 BY_HANDLE_FILE_INFORMATION hfi1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
277 BY_HANDLE_FILE_INFORMATION hfi2;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
278
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
279 if (GetFileInformationByHandle (hfile1, &hfi1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
280 && GetFileInformationByHandle (hfile2, &hfi2))
16564
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
281 {
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
282 retval = (hfi1.dwVolumeSerialNumber == hfi2.dwVolumeSerialNumber
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
283 && hfi1.nFileIndexHigh == hfi2.nFileIndexHigh
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
284 && hfi1.nFileIndexLow == hfi2.nFileIndexLow);
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
285 }
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
286
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
287 CloseHandle (hfile2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
288 }
6691
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
289
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
290 CloseHandle (hfile1);
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
291 }
6691
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
292
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
293 return retval;
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
294
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
295 #else
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
296
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
297 // POSIX Code
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
298
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
299 file_stat fs_file1 (file1);
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
300 file_stat fs_file2 (file2);
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
301
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
302 return (fs_file1 && fs_file2
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
303 && fs_file1.ino () == fs_file2.ino ()
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
304 && fs_file1.dev () == fs_file2.dev ());
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
305
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
306 #endif
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
307 }
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
308
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
309 void
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
310 sysdep_init (void)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
311 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14445
diff changeset
312 #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__)
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
313 BSD_init ();
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
314 #elif defined (__MINGW32__)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
315 MINGW_init ();
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
316 #elif defined (_MSC_VER)
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
317 MSVC_init ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
318 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
319 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
320
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
321 void
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
322 sysdep_cleanup (void)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
323 {
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
324 MINGW_SIGNAL_CLEANUP ();
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
325 }
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
326
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
327 // Set terminal in raw mode. From less-177.
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
328 //
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
329 // Change terminal to "raw mode", or restore to "normal" mode.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
330 // "Raw mode" means
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
331 // 1. An outstanding read will complete on receipt of a single keystroke.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
332 // 2. Input is not echoed.
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
333 // 3. On output, \n is mapped to \r\n.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
334 // 4. \t is NOT expanded into spaces.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
335 // 5. Signal-causing characters such as ctrl-C (interrupt),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
336 // etc. are NOT disabled.
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
337 // It doesn't matter whether an input \n is mapped to \r, or vice versa.
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
338
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
339 void
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
340 raw_mode (bool on, bool wait)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
341 {
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
342 static bool curr_on = false;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
343
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
344 int tty_fd = STDIN_FILENO;
14160
ebcb0f83698f use gnulib::isatty
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
345 if (! gnulib::isatty (tty_fd))
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
346 {
19849
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19774
diff changeset
347 if (interactive && ! forced_interactive)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
348 error ("stdin is not a tty!");
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
349 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
350
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
351 if (on == curr_on)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
352 return;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
353
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
354 #if defined (HAVE_TERMIOS_H)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
355 {
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
356 struct termios s;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
357 static struct termios save_term;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
358
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
359 if (on)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
360 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
361 // Get terminal modes.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
362
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
363 tcgetattr (tty_fd, &s);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
364
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
365 // Save modes and set certain variables dependent on modes.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
366
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
367 save_term = s;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
368 // ospeed = s.c_cflag & CBAUD;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
369 // erase_char = s.c_cc[VERASE];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
370 // kill_char = s.c_cc[VKILL];
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
371
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
372 // Set the modes to the way we want them.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
373
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
374 s.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
375 s.c_oflag |= (OPOST|ONLCR);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
376 #if defined (OCRNL)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
377 s.c_oflag &= ~(OCRNL);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
378 #endif
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
379 #if defined (ONOCR)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
380 s.c_oflag &= ~(ONOCR);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
381 #endif
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
382 #if defined (ONLRET)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
383 s.c_oflag &= ~(ONLRET);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
384 #endif
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
385 s.c_cc[VMIN] = wait ? 1 : 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
386 s.c_cc[VTIME] = 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
387 }
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
388 else
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
389 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
390 // Restore saved modes.
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
391
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
392 s = save_term;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
393 }
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
394
9411
c9636d98e5cd fix kbhit(1) to not discard waiting keystrokes
Joe Rothweiler <octaveuser@sensicomm.com>
parents: 9242
diff changeset
395 tcsetattr (tty_fd, wait ? TCSAFLUSH : TCSADRAIN, &s);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
396 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
397 #elif defined (HAVE_TERMIO_H)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
398 {
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
399 struct termio s;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
400 static struct termio save_term;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
401
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
402 if (on)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
403 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
404 // Get terminal modes.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
405
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
406 ioctl (tty_fd, TCGETA, &s);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
407
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
408 // Save modes and set certain variables dependent on modes.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
409
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
410 save_term = s;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
411 // ospeed = s.c_cflag & CBAUD;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
412 // erase_char = s.c_cc[VERASE];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
413 // kill_char = s.c_cc[VKILL];
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
414
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
415 // Set the modes to the way we want them.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
416
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
417 s.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
418 s.c_oflag |= (OPOST|ONLCR);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
419 #if defined (OCRNL)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
420 s.c_oflag &= ~(OCRNL);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
421 #endif
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
422 #if defined (ONOCR)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
423 s.c_oflag &= ~(ONOCR);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
424 #endif
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
425 #if defined (ONLRET)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
426 s.c_oflag &= ~(ONLRET);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
427 #endif
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
428 s.c_cc[VMIN] = wait ? 1 : 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
429 }
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
430 else
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
431 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
432 // Restore saved modes.
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
433
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
434 s = save_term;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
435 }
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
436
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
437 ioctl (tty_fd, TCSETAW, &s);
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
438 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
439 #elif defined (HAVE_SGTTY_H)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
440 {
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
441 struct sgttyb s;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
442 static struct sgttyb save_term;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
443
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
444 if (on)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
445 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
446 // Get terminal modes.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
447
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
448 ioctl (tty_fd, TIOCGETP, &s);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
449
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
450 // Save modes and set certain variables dependent on modes.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
451
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
452 save_term = s;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
453 // ospeed = s.sg_ospeed;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
454 // erase_char = s.sg_erase;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
455 // kill_char = s.sg_kill;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
456
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
457 // Set the modes to the way we want them.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
458
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
459 s.sg_flags |= CBREAK;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
460 s.sg_flags &= ~(ECHO);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
461 }
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
462 else
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
463 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
464 // Restore saved modes.
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
465
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
466 s = save_term;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
467 }
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
468
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
469 ioctl (tty_fd, TIOCSETN, &s);
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
470 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
471 #else
21109
bd1752782e56 Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents: 21078
diff changeset
472 warn_disabled_feature ("", "raw mode console I/O");
4064
b4fa31442a78 [project @ 2002-09-26 21:10:45 by jwe]
jwe
parents: 3676
diff changeset
473
b4fa31442a78 [project @ 2002-09-26 21:10:45 by jwe]
jwe
parents: 3676
diff changeset
474 // Make sure the current mode doesn't toggle.
b4fa31442a78 [project @ 2002-09-26 21:10:45 by jwe]
jwe
parents: 3676
diff changeset
475 on = curr_on;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
476 #endif
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
477
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
478 curr_on = on;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
479 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
480
6726
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
481 FILE *
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
482 octave_popen (const char *command, const char *mode)
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
483 {
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
484 #if defined (__MINGW32__) || defined (_MSC_VER)
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
485 if (mode && mode[0] && ! mode[1])
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
486 {
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
487 char tmode[3];
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
488 tmode[0] = mode[0];
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
489 tmode[1] = 'b';
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
490 tmode[2] = 0;
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
491
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
492 return _popen (command, tmode);
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
493 }
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
494 else
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
495 return _popen (command, mode);
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
496 #else
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
497 return popen (command, mode);
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
498 #endif
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
499 }
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
500
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
501 int
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
502 octave_pclose (FILE *f)
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
503 {
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
504 #if defined (__MINGW32__) || defined (_MSC_VER)
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
505 return _pclose (f);
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
506 #else
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
507 return pclose (f);
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
508 #endif
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
509 }
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
510
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
511 // Read one character from the terminal.
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
512
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
513 int
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
514 octave_kbhit (bool wait)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
515 {
20788
a2b96b523472 Rewrite a8ee668e7fd7 to use #if defined rather than #ifdef.
Rik <rik@octave.org>
parents: 20786
diff changeset
516 #if defined (HAVE__KBHIT) && defined (HAVE__GETCH)
20786
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
517 // This essentially means we are on a Windows system.
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
518 int c;
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
519
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
520 if (wait)
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
521 c = _getch ();
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
522 else
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
523 c = (! _kbhit ()) ? 0 : _getch ();
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
524
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
525 #else
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
526 raw_mode (true, wait);
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
527
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
528 // Get current handler.
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
529 octave_interrupt_handler saved_interrupt_handler
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
530 = octave_ignore_interrupts ();
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
531
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
532 // Restore it, disabling system call restarts (if possible) so the
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
533 // read can be interrupted.
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
534
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
535 octave_set_interrupt_handler (saved_interrupt_handler, false);
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
536
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
537 int c = std::cin.get ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
538
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
539 if (std::cin.fail () || std::cin.eof ())
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
540 std::cin.clear ();
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
541
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
542 // Restore it, enabling system call restarts (if possible).
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
543 octave_set_interrupt_handler (saved_interrupt_handler, true);
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
544
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
545 raw_mode (false, true);
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
546 #endif
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
547
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
548 return c;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
549 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
550
12228
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
551 std::string
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
552 get_P_tmpdir (void)
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
553 {
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
554 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
555
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
556 std::string retval;
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
557
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
558 #if defined (P_tmpdir)
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
559 retval = P_tmpdir;
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
560 #endif
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
561
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
562 // Apparently some versions of MinGW and MSVC either don't define
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
563 // P_tmpdir, or they define it to a single backslash, neither of which
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
564 // is particularly helpful.
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
565
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
566 if (retval.empty () || retval == "\\")
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
567 {
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
568 retval = octave_env::getenv ("TEMP");
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
569
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
570 if (retval.empty ())
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
571 retval = octave_env::getenv ("TMP");
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
572
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
573 if (retval.empty ())
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
574 retval = "c:\\temp";
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
575 }
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
576
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
577 return retval;
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
578
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
579 #elif defined (P_tmpdir)
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
580
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
581 return P_tmpdir;
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
582
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
583 #else
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
584
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
585 return "/tmp";
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
586
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
587 #endif
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
588 }
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
589
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
590 DEFUN (clc, , ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
591 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
592 @deftypefn {} {} clc ()\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
593 @deftypefnx {} {} home ()\n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3308
diff changeset
594 Clear the terminal screen and move the cursor to the upper left corner.\n\
3333
15cddaacbc2d [project @ 1999-11-03 19:53:59 by jwe]
jwe
parents: 3332
diff changeset
595 @end deftypefn")
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
596 {
16537
106a38d7b396 optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents: 16404
diff changeset
597 bool skip_redisplay = true;
106a38d7b396 optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents: 16404
diff changeset
598
106a38d7b396 optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents: 16404
diff changeset
599 command_editor::clear_screen (skip_redisplay);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
600
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
601 return ovl ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
602 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
603
549
75a371805554 [project @ 1994-07-22 19:44:41 by jwe]
jwe
parents: 545
diff changeset
604 DEFALIAS (home, clc);
75a371805554 [project @ 1994-07-22 19:44:41 by jwe]
jwe
parents: 545
diff changeset
605
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
606 DEFUN (getenv, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
607 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
608 @deftypefn {} {} getenv (@var{var})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
609 Return the value of the environment variable @var{var}.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
610 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
611 For example,\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
612 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
613 @example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
614 getenv (\"PATH\")\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
615 @end example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
616 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
617 @noindent\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
618 returns a string containing the value of your path.\n\
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
619 @seealso{setenv, unsetenv}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
620 @end deftypefn")
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
621 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
622 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
623 print_usage ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
624
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
625 std::string name = args(0).string_value ();
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
626
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
627 return ovl (octave_env::getenv (name));
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
628 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
629
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
630 /*
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
631 %!assert (ischar (getenv ("OCTAVE_HOME")))
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
632 */
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
633
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
634 DEFUN (setenv, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
635 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
636 @deftypefn {} {} setenv (@var{var}, @var{value})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
637 @deftypefnx {} {} setenv (@var{var})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
638 @deftypefnx {} {} putenv (@dots{})\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
639 Set the value of the environment variable @var{var} to @var{value}.\n\
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
640 \n\
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
641 If no @var{value} is specified then the variable will be assigned the null\n\
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
642 string.\n\
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
643 @seealso{unsetenv, getenv}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
644 @end deftypefn")
1706
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
645 {
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
646 int nargin = args.length ();
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
647
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
648 if (nargin < 1 || nargin > 2)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
649 print_usage ();
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
650
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
651 std::string var = args(0).xstring_value ("setenv: VAR must be a string");
1706
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
652
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
653 std::string val = (nargin == 2
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
654 ? args(1).xstring_value ("setenv: VALUE must be a string")
21017
93748bcaec17 maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents: 20990
diff changeset
655 : "");
20582
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
656
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
657 octave_env::putenv (var, val);
1706
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
658
21078
49852ff04747 maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents: 21017
diff changeset
659 return ovl ();
1706
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
660 }
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
661
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
662 DEFALIAS (putenv, setenv);
1706
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
663
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
664 /*
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
665 %!test
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
666 %! setenv ("dummy_variable_that_cannot_matter", "foobar");
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
667 %! assert (getenv ("dummy_variable_that_cannot_matter"), "foobar");
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
668 %! unsetenv ("dummy_variable_that_cannot_matter");
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
669 %! assert (getenv ("dummy_variable_that_cannot_matter"), "");
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
670 */
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
671
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
672 DEFUN (unsetenv, args, ,
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
673 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
674 @deftypefn {} {@var{status} =} unsetenv (@var{var})\n\
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
675 Delete the environment variable @var{var}.\n\
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
676 \n\
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
677 Return 0 if the variable was deleted, or did not exist, and -1 if an error\n\
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
678 occurred.\n\
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
679 @seealso{setenv, getenv}\n\
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
680 @end deftypefn")
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
681 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
682 if (args.length () != 1)
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
683 print_usage ();
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
684
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
685 std::string tmp = args(0).string_value ();
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
686
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
687 return ovl (gnulib::unsetenv (tmp.c_str ()));
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
688 }
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
689
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
690 /*
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
691 ## Test for unsetenv is in setenv test
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
692 */
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
693
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
694 // FIXME: perhaps kbhit should also be able to print a prompt?
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
695
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
696 DEFUN (kbhit, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
697 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
698 @deftypefn {} {} kbhit ()\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
699 @deftypefnx {} {} kbhit (1)\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
700 Read a single keystroke from the keyboard.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
701 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
702 If called with an argument, don't wait for a keypress.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
703 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
704 For example,\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
705 \n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
706 @example\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
707 x = kbhit ();\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
708 @end example\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
709 \n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
710 @noindent\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
711 will set @var{x} to the next character typed at the keyboard as soon as\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
712 it is typed.\n\
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
713 \n\
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
714 @example\n\
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
715 x = kbhit (1);\n\
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
716 @end example\n\
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
717 \n\
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
718 @noindent\n\
16053
119ce9f5e1a3 doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents: 16015
diff changeset
719 is identical to the above example, but doesn't wait for a keypress,\n\
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
720 returning the empty string if no key is available.\n\
18674
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
721 @seealso{input, pause}\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
722 @end deftypefn")
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
723 {
4233
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 4208
diff changeset
724 octave_value retval;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
725
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
726 // FIXME: add timeout and default value args?
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
727
19849
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19774
diff changeset
728 if (interactive)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
729 {
15423
53d073233fa4 call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
730 Fdrawnow ();
6423
a90b54016b12 [project @ 2007-03-21 13:15:03 by jwe]
jwe
parents: 6419
diff changeset
731
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
732 int c = octave_kbhit (args.length () == 0);
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
733
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
734 if (c == -1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
735 c = 0;
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
736
16092
def3b111cff8 avoid gcc warning about int to char conversion
John W. Eaton <jwe@octave.org>
parents: 16053
diff changeset
737 char s[2] = { static_cast<char> (c), '\0' };
16015
d910b9211cca Plug memory leak in kbhit().
Rik <rik@octave.org>
parents: 15423
diff changeset
738
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
739 retval = s;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
740 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
741
21078
49852ff04747 maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents: 21017
diff changeset
742 return retval;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
743 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
744
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
745 DEFUN (pause, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
746 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
747 @deftypefn {} {} pause ()\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
748 @deftypefnx {} {} pause (@var{n})\n\
18674
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
749 Suspend the execution of the program for @var{n} seconds.\n\
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
750 \n\
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
751 If invoked without an input arguments then the program is suspended until a\n\
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
752 character is typed.\n\
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
753 \n\
20923
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
754 @var{n} is a positive real value and may be a fraction of a second,\n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
755 for example:\n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
756 \n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
757 @example\n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
758 @group\n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
759 tic; pause (0.05); toc\n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
760 @print{} Elapsed time is 0.05039 seconds.\n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
761 @end group\n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
762 @end example\n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
763 \n\
18674
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
764 The following example prints a message and then waits 5 seconds before\n\
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
765 clearing the screen.\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
766 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
767 @example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
768 @group\n\
20923
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
769 disp (\"wait please...\");\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
770 pause (5);\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
771 clc;\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
772 @end group\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
773 @end example\n\
20923
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
774 \n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
775 @seealso{kbhit}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
776 @end deftypefn")
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
777 {
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
778 int nargin = args.length ();
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
779
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
780 if (nargin > 1)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
781 print_usage ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
782
1579
972ce8b5a757 [project @ 1995-10-19 06:39:35 by jwe]
jwe
parents: 1488
diff changeset
783 if (nargin == 1)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
784 {
1579
972ce8b5a757 [project @ 1995-10-19 06:39:35 by jwe]
jwe
parents: 1488
diff changeset
785 double dval = args(0).double_value ();
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 610
diff changeset
786
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
787 if (xisnan (dval))
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
788 warning ("pause: NaN is an invalid delay");
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
789 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
790 {
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20181
diff changeset
791 Fdrawnow ();
6419
73fcbac81f33 [project @ 2007-03-20 17:18:24 by jwe]
jwe
parents: 6208
diff changeset
792
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20181
diff changeset
793 if (xisinf (dval))
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20181
diff changeset
794 {
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20181
diff changeset
795 flush_octave_stdout ();
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20181
diff changeset
796 octave_kbhit ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
797 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
798 else
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20181
diff changeset
799 octave_sleep (dval);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
800 }
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
801 }
1579
972ce8b5a757 [project @ 1995-10-19 06:39:35 by jwe]
jwe
parents: 1488
diff changeset
802 else
3234
be8e0ba13644 [project @ 1999-01-29 03:52:30 by jwe]
jwe
parents: 3124
diff changeset
803 {
15423
53d073233fa4 call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
804 Fdrawnow ();
3234
be8e0ba13644 [project @ 1999-01-29 03:52:30 by jwe]
jwe
parents: 3124
diff changeset
805 flush_octave_stdout ();
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
806 octave_kbhit ();
3234
be8e0ba13644 [project @ 1999-01-29 03:52:30 by jwe]
jwe
parents: 3124
diff changeset
807 }
2630
fdee6fe3e73b [project @ 1997-01-27 19:08:47 by jwe]
jwe
parents: 2610
diff changeset
808
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
809 return ovl ();
2630
fdee6fe3e73b [project @ 1997-01-27 19:08:47 by jwe]
jwe
parents: 2610
diff changeset
810 }
fdee6fe3e73b [project @ 1997-01-27 19:08:47 by jwe]
jwe
parents: 2610
diff changeset
811
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
812 /*
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
813 %!test
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
814 %! pause (1);
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
815
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
816 %!error (pause (1, 2))
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
817 */
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
818
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
819 // FIXME: maybe this should only return 1 if IEEE floating
862
61d83ce7368c [project @ 1994-10-31 20:39:30 by jwe]
jwe
parents: 844
diff changeset
820 // point functions really work.
61d83ce7368c [project @ 1994-10-31 20:39:30 by jwe]
jwe
parents: 844
diff changeset
821
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
822 DEFUN (isieee, , ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
823 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
824 @deftypefn {} {} isieee ()\n\
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 11234
diff changeset
825 Return true if your computer @emph{claims} to conform to the IEEE standard\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
826 for floating point calculations.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
827 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
828 No actual tests are performed.\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
829 @end deftypefn")
862
61d83ce7368c [project @ 1994-10-31 20:39:30 by jwe]
jwe
parents: 844
diff changeset
830 {
4600
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
831 oct_mach_info::float_format flt_fmt = oct_mach_info::native_float_format ();
2317
8c09c04f7747 [project @ 1996-07-14 22:30:15 by jwe]
jwe
parents: 2086
diff changeset
832
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
833 return ovl (flt_fmt == oct_mach_info::flt_fmt_ieee_little_endian
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
834 || flt_fmt == oct_mach_info::flt_fmt_ieee_big_endian);
862
61d83ce7368c [project @ 1994-10-31 20:39:30 by jwe]
jwe
parents: 844
diff changeset
835 }
61d83ce7368c [project @ 1994-10-31 20:39:30 by jwe]
jwe
parents: 844
diff changeset
836
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
837 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
838 %!assert (islogical (isieee ()))
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
839 */
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
840
4600
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
841 DEFUN (native_float_format, , ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
842 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
843 @deftypefn {} {} native_float_format ()\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
844 Return the native floating point format as a string.\n\
4600
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
845 @end deftypefn")
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
846 {
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
847 oct_mach_info::float_format flt_fmt = oct_mach_info::native_float_format ();
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
848
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
849 return ovl (oct_mach_info::float_format_as_string (flt_fmt));
4600
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
850 }
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
851
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
852 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
853 %!assert (ischar (native_float_format ()))
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
854 */
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
855
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
856 DEFUN (tilde_expand, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
857 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
858 @deftypefn {} {} tilde_expand (@var{string})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
859 @deftypefnx {} {} tilde_expand (@var{cellstr})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
860 Perform tilde expansion on @var{string}.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
861 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
862 If @var{string} begins with a tilde character, (@samp{~}), all of the\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
863 characters preceding the first slash (or all characters, if there is no\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
864 slash) are treated as a possible user name, and the tilde and the following\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
865 characters up to the slash are replaced by the home directory of the named\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
866 user. If the tilde is followed immediately by a slash, the tilde is\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
867 replaced by the home directory of the user running Octave.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
868 \n\
20711
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20704
diff changeset
869 If the input is a cell array of strings @var{cellstr} then tilde expansion\n\
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20704
diff changeset
870 is performed on each string element.\n\
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20704
diff changeset
871 \n\
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20704
diff changeset
872 Examples:\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
873 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
874 @example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
875 @group\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
876 tilde_expand (\"~joeuser/bin\")\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
877 @result{} \"/home/joeuser/bin\"\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
878 tilde_expand (\"~/bin\")\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
879 @result{} \"/home/jwe/bin\"\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
880 @end group\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
881 @end example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
882 @end deftypefn")
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
883 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
884 if (args.length () != 1)
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
885 print_usage ();
6116
b64fb24bf4a0 [project @ 2006-10-27 18:04:49 by jwe]
jwe
parents: 6086
diff changeset
886
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
887 octave_value arg = args(0);
6116
b64fb24bf4a0 [project @ 2006-10-27 18:04:49 by jwe]
jwe
parents: 6086
diff changeset
888
20990
fc9cca99b2de Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents: 20961
diff changeset
889 string_vector sv = arg.xstring_vector_value ("tilde_expand: argument must be char or cellstr object");
6116
b64fb24bf4a0 [project @ 2006-10-27 18:04:49 by jwe]
jwe
parents: 6086
diff changeset
890
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
891 sv = file_ops::tilde_expand (sv);
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
892
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
893 if (arg.is_cellstr ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
894 return ovl (Cell (arg.dims (), sv));
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
895 else
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
896 return ovl (sv);
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
897 }
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
898
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
899 /*
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
900 %!test
20016
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
901 %! home = get_home_directory ();
20064
ab7582167810 Fix failing BIST test for tilde_expand() on Windows (bug #44796).
Rik <rik@octave.org>
parents: 20024
diff changeset
902 %! assert (tilde_expand ("~/foobar"), [home "/foobar"]);
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
903 %! assert (tilde_expand ("/foo/bar"), "/foo/bar");
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
904 %! assert (tilde_expand ("foo/bar"), "foo/bar");
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
905 */
17851
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
906
20016
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
907 DEFUN (get_home_directory, , ,
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
908 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
909 @deftypefn {} {@var{homedir} =} get_home_directory ()\n\
20024
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
910 Return the current home directory.\n\
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
911 \n\
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
912 On most systems, this is equivalent to @code{getenv (\"HOME\")}. On Windows\n\
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
913 systems, if the environment variable @env{HOME} is not set then it is\n\
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
914 equivalent to\n\
20016
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
915 @code{fullfile (getenv (\"HOMEDRIVE\"), getenv (\"HOMEPATH\"))}\n\
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
916 @seealso{getenv}\n\
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
917 @end deftypefn")
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
918 {
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
919 return ovl (octave_env::get_home_directory ());
20016
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
920 }
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
921
20024
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
922 /*
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
923 %!test
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
924 %! if (! ispc ())
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20172
diff changeset
925 %! assert (get_home_directory (), getenv ("HOME"));
20024
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
926 %! endif
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
927 */
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
928
17851
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
929 // This function really belongs in display.cc, but including defun.h in
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
930 // that file results in conflicts with symbols from headers that are
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
931 // needed for X11 and Carbon functions.
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
932
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
933 DEFUN (have_window_system, , ,
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19857
diff changeset
934 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
935 @deftypefn {} {} have_window_system ()\n\
18674
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
936 Return true if a window system is available (X11, Windows, or Apple OS X)\n\
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
937 and false otherwise.\n\
19857
bf511802add7 doc: Add have_window_system() to documentation.
Rik <rik@octave.org>
parents: 19856
diff changeset
938 @seealso{isguirunning}\n\
17851
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
939 @end deftypefn")
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
940 {
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
941 return ovl (display_info::display_available ());
17851
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
942 }