Diff for /gforth/kernel/require.fs between versions 1.3 and 1.5

version 1.3, 1997/06/01 20:55:22 version 1.5, 1998/12/08 22:03:13
Line 1 Line 1
 \ require.fs  \ require.fs
   
 \ Copyright (C) 1995-1997 Free Software Foundation, Inc.  \ Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
   
 \ This file is part of Gforth.  \ This file is part of Gforth.
   
Line 20 Line 20
   
 \ Now: Kernel Module, Reloadable  \ Now: Kernel Module, Reloadable
   
 \ $Id$  
   
 create included-files 0 , 0 , ( pointer to and count of included files )  create included-files 0 , 0 , ( pointer to and count of included files )
 here ," the terminal" dup c@ swap 1 + swap , A, here 2 cells -  here ," ./the terminal" dup c@ swap 1 + swap , A, here 2 cells -
 create image-included-files  1 , A, ( pointer to and count of included files )  create image-included-files  1 , A, ( pointer to and count of included files )
 \ included-files points to ALLOCATEd space, while image-included-files  \ included-files points to ALLOCATEd space, while image-included-files
 \ points to ALLOTed objects, so it survives a save-system  \ points to ALLOTed objects, so it survives a save-system
Line 79  create image-included-files  1 , A, ( po Line 77  create image-included-files  1 , A, ( po
     throw ;      throw ;
           
 : included ( i*x addr u -- j*x ) \ file  : included ( i*x addr u -- j*x ) \ file
       \G @code{include-file} the file whose name is given by the string
       \G @var{addr u}.
     open-fpath-file throw included1 ;      open-fpath-file throw included1 ;
   
 : required ( i*x addr u -- j*x ) \ gforth  : required ( i*x addr u -- j*x ) \ gforth
     \G include the file with the name given by addr u, if it is not      \G include the file with the name given by @var{addr u}, if it is not
     \G included already. Currently this works by comparing the name of      \G @code{included} (or @code{required}) already. Currently this
     \G the file (with path) against the names of earlier included      \G works by comparing the name of the file (with path) against the
     \G files; however, it would probably be better to fstat the file,      \G names of earlier included files.
     \G and compare the device and inode. The advantages would be: no      \ however, it may be better to fstat the file,
     \G problems with several paths to the same file (e.g., due to      \ and compare the device and inode. The advantages would be: no
     \G links) and we would catch files included with include-file and      \ problems with several paths to the same file (e.g., due to
     \G write a require-file.      \ links) and we would catch files included with include-file and
       \ write a require-file.
     open-fpath-file throw 2dup included?      open-fpath-file throw 2dup included?
     if      if
         2drop close-file throw          2drop close-file throw
Line 99  create image-included-files  1 , A, ( po Line 100  create image-included-files  1 , A, ( po
   
 \ INCLUDE                                               9may93jaw  \ INCLUDE                                               9may93jaw
   
 : include  ( "file" -- ) \ gforth  : include  ( ... "file" -- ... ) \ gforth
 \G includes a file and keeps in mind that this file is loaded  \G includes @var{file}
   name included ;    name included ;
   
 : require  ( "file" -- ) \ gforth  : require  ( ... "file" -- ... ) \ gforth
 \G load a file only when it is not included already  \G includes @var{file} only if it is not included already
   name required ;    name required ;
   
 0 [IF]  0 [IF]

Removed from v.1.3  
changed lines
  Added in v.1.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>