--- gforth/kernel/quotes.fs 2000/09/23 15:06:10 1.2 +++ gforth/kernel/quotes.fs 2001/06/16 22:53:38 1.5 @@ -16,27 +16,36 @@ \ You should have received a copy of the GNU General Public License \ along with this program; if not, write to the Free Software -\ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +\ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. \ this file comes last, because these words override cross' words. require ./vars.fs -create s"-buffer /line chars allot +\ create s"-buffer /line chars allot has? compiler 0= [IF] : s" [ELSE] :noname [THEN] [char] " parse - /line min >r s"-buffer r@ cmove - s"-buffer r> ; +[ has? OS [IF] ] + save-mem +[ [THEN] ] +; +\ /line min >r s"-buffer r@ cmove +\ s"-buffer r> ; has? compiler [IF] :noname [char] " parse postpone SLiteral ; interpret/compile: S" ( compilation 'ccc"' -- ; run-time -- c-addr u ) \ core,file s-quote \G Compilation: Parse a string @i{ccc} delimited by a @code{"} \G (double quote). At run-time, return the length, @i{u}, and the \G start address, @i{c-addr} of the string. Interpretation: parse - \G the string as before, and return @i{c-addr}, @i{u}. The - \G string is stored in a temporary buffer which may be overwritten - \G by subsequent uses of @code{S"}. + \G the string as before, and return @i{c-addr}, @i{u}. Gforth + \G @code{allocate}s the string. The resulting memory leak is usually + \G not a problem; the exception is if you create strings containing + \G @code{S"} and @code{evaluate} them; then the leak is not bounded + \G by the size of the interpreted files and you may want to + \G @code{free} the strings. ANS Forth only guarantees one buffer of + \G 80 characters, so in standard programs you should assume that the + \G string lives only until the next @code{s"}. [THEN] :noname [char] " parse type ;