( Title: Node Space Management for Single and Double Lists with Dynamic Strings File: nodespace-pfe.fs Version: 1.2.3 Author: David N. Williams License: LGPL Last revision: November 30, 2004 ) \ Copyright (C) 2000-2002, 2004 David N. Williams ( This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or at your option any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. Please see the file POLITENESS included with this distribution. ANS Forth compatible except for: - Case sensitivity. - REQUIRED loads Forth source if it's not already loaded. - Assumption that zero does not occur as an address. - 0$UNUSED uses EMPTY$ and $! from our Dynamic-Strings word set. - "LOADM dstrings" loads the dstrings shared library module in pfe. Uses LOCALS| from the Locals extension word set. Please see the file NOTATION. ) s" nodespace.fs" REQUIRED \ Uncomment *one* of the following two lines: LOADM dstrings \ for pfe \ s" dstrings.fs" REQUIRED \ for ANS compatibility \ *** EXTENSION WORDS : 0unused-$nodes ( -- ) ( Assume the data consists of dstrings. Set the data in all unused nodes in the current node space to the empty string. The expected use is just after MAKE-NODES, when all nodes are in the unused chain. Nevertheless, do nothing if the unused chain is empty. ) \ current-nodes IF \ current-nodes >/node-data @ \ current-nodes >/node-header @ \ current-nodes >last-unused @ \ LOCALS| node /node.header /node.data | \ BEGIN node WHILE \ node /node.header + \ begin data \ dup /node.data + \ after data (cell-aligned) \ swap ( after begin) \ DO \ 0 i ! \ null is outside string space, so \ empty$ i $! \ $! writes over it \ 1 cells +LOOP \ node @ to node \ REPEAT \ THEN ; current-nodes IF current-nodes >last-unused @ BEGIN ( node) dup WHILE ( node) dup current-nodes >/node-header @ + \ begin data ( begin) dup current-nodes >/node-data @ + \ after data (cell-aligned) swap ( after begin) DO 0 i ! \ null is outside string space, so empty$ i $! \ $! writes over it 1 cells +LOOP ( node) @ REPEAT ( node) drop THEN ;