File:
[gforth] /
gforth /
kernel /
files.fs
Revision
1.7:
download - view:
text,
annotated -
select for diffs
Tue Mar 23 20:24:24 1999 UTC (23 years, 10 months ago) by
crook
Branches:
MAIN
CVS tags:
HEAD
Makefile.in
-- changes to make documentation build with moofglos.fs
rather than with mini-oof.fs (since the former contains glossary
entries and the latter does not)
assert.fs blocks.fs debug.fs environ.fs errors.fs extend.fs float.fs
glocals.fs moofglos.fs prim search.fs struct.fs stuff.fs vt100.fs
kernel/args.fs kernel/basics.fs kernel/comp.fs kernel/cond.fs
kernel/files.fs kernel/getdoers.fs kernel/int.fs kernel/io.fs
kernel/nio.fs kernel/paths.fs kernel/require.fs kernel/special.fs
kernel/tools.fs kernel/toolsext.fs kernel/vars.fs
-- many small changes to glossary entries.. I think most are done
now, so I hope to change far fewer files next time!
doc/gforth.ds
-- many, many small changes and a few large ones. Moved some sections
around, fixed typos and formatting errors, added new section on
exception handling, rearranged 'files' section.
1: \ File specifiers 11jun93jaw
2:
3: \ Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
4:
5: \ This file is part of Gforth.
6:
7: \ Gforth is free software; you can redistribute it and/or
8: \ modify it under the terms of the GNU General Public License
9: \ as published by the Free Software Foundation; either version 2
10: \ of the License, or (at your option) any later version.
11:
12: \ This program is distributed in the hope that it will be useful,
13: \ but WITHOUT ANY WARRANTY; without even the implied warranty of
14: \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: \ GNU General Public License for more details.
16:
17: \ You should have received a copy of the GNU General Public License
18: \ along with this program; if not, write to the Free Software
19: \ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20:
21: 4 Constant w/o ( -- ntype ) \ file w-o
22: 2 Constant r/w ( -- ntype ) \ file r-w
23: 0 Constant r/o ( -- ntype ) \ file r-o
24:
25: : bin ( ntype1 -- ntype2 ) \ file
26: 1 or ;
27:
28: \ BIN WRITE-LINE 11jun93jaw
29:
30: : write-line ( c-addr u fileid -- ior ) \ file
31: dup >r write-file
32: ?dup IF
33: r> drop EXIT
34: THEN
35: #lf r> emit-file ;
36:
37: \ include-file 07apr93py
38:
39: : push-file ( -- ) r>
40: loadline @ >r
41: loadfile @ >r
42: blk @ >r
43: tibstack @ >r
44: >tib @ >r
45: #tib @ >r
46: >in @ >r >r
47: >tib @ tibstack @ = IF #tib @ tibstack +! THEN
48: tibstack @ >tib ! ;
49:
50: : pop-file ( throw-code -- throw-code )
51: dup IF
52: source >in @ sourceline# sourcefilename
53: error-stack dup @ dup 1+
54: max-errors 1- min error-stack !
55: 6 * cells + cell+
56: 5 cells bounds swap DO
57: I !
58: -1 cells +LOOP
59: THEN
60: r>
61: r> >in !
62: r> #tib !
63: r> >tib !
64: r> tibstack !
65: r> blk !
66: r> loadfile !
67: r> loadline ! >r ;
68:
69: : read-loop ( i*x -- j*x )
70: BEGIN refill WHILE interpret REPEAT ;
71:
72: : include-file ( i*x wfileid -- j*x ) \ file
73: \G Interpret (process using the text interpreter) the contents of
74: \G the file @var{wfileid}.
75: push-file loadfile !
76: 0 loadline ! blk off ['] read-loop catch
77: loadfile @ close-file swap 2dup or
78: pop-file drop throw throw ;
79:
80: \ additional words only needed if there is file support
81:
82: Warnings off
83:
84: : ( ( compilation 'ccc<close-paren>' -- ; run-time -- ) \ core,file paren
85: loadfile @ 0= IF postpone ( EXIT THEN
86: BEGIN
87: >in @
88: [char] ) parse nip
89: >in @ rot - = \ is there no delimter?
90: WHILE
91: refill 0=
92: IF
93: warnings @
94: IF
95: ." warning: ')' missing" cr
96: THEN
97: EXIT
98: THEN
99: REPEAT ; immediate
100:
101: Warnings on
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>