GForth 0.4.0 under Linux 2.2 kernel: CREATE-FILE bug? 
Author Message
 GForth 0.4.0 under Linux 2.2 kernel: CREATE-FILE bug?

I'm attempting to write a Forth target compiler in GForth for a project I
want to embark on (and currently failing miserably at it; while it does
produce code, the target compiler is **ugly**, and very fragile, and I'm
just plain not happy with it).  After all the compilations are performed, I
have a call to a word I wrote as follows:

\ ----
: FstCreateImageFile ( caddr u -- h )   BIN R/W CREATE-FILE THROW ;
: FstDumpImageFile ( h -- h )
  DUP >R FstTargetBuffer FstImageSize R> WRITE-FILE THROW
;
: FstCloseImageFile ( h -- )   CLOSE-FILE THROW ;

: FstWriteImage ( caddr u -- )
  FstCreateImageFile FstDumpImageFile FstCloseImageFile
;

S" FSForth2.img" FstWriteImage
S" mbchk FSForth2.img" SYSTEM
\ ----

When I execute ``S" FSForth2.img" FstWriteImage'', a file is created with
the filename "FSForth2.imgh" (note the extra 'h').  As a result, mbchk
doesn't find the intended file.  If I change the last line to read:

        S" mbchk FSForth2.imgh" SYSTEM

everything works fine.

The contents of the file are verified to be correct.  For me, the extra 'h'
is repeatable, but I suspect that it's coincidental to what's available in
the dictionary/pad at the time the code is executed.

I'm assuming that something in CREATE-FILE has a fence-post error when
working with the filename.

--
KC5TJA/6, DM13, QRP-L #1447
Samuel A. Falvo II
Oceanside, CA



Thu, 11 Mar 2004 04:34:48 GMT  
 GForth 0.4.0 under Linux 2.2 kernel: CREATE-FILE bug?


Quote:
>: FstCreateImageFile ( caddr u -- h )   BIN R/W CREATE-FILE THROW ;

                                         ^^^^^^^

You use BIN ( fam1 -- fam2 ) incorrectly; you don't pass it a fam, but
the length of the filename.  Write "R/W BIN" instead.

Moral: It's much nicer if a word blows up on wrong input.

- anton
--
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html



Thu, 11 Mar 2004 16:10:23 GMT  
 GForth 0.4.0 under Linux 2.2 kernel: CREATE-FILE bug?

Quote:
>You use BIN ( fam1 -- fam2 ) incorrectly; you don't pass it a fam, but
>the length of the filename.  Write "R/W BIN" instead.

>Moral: It's much nicer if a word blows up on wrong input.

Whoops -- thanks for the observation! :)

--
KC5TJA/6, DM13, QRP-L #1447
Samuel A. Falvo II
Oceanside, CA



Thu, 11 Mar 2004 18:02:31 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. BUG IN GFORTH FOR LINUX?

2. Bug when using Kernel.fork with File.print

3. Python 2.2, creating new types from base types

4. Creating RPM fails on Python 2.2 Release 1 and RPM version 3.0.6

5. creating linux so files instead of dll files

6. Normal vw5i.3 with Linux and glibc 2.2 crashes

7. [Linux] Using glibc 2.2 and VW

8. Eiffel compiler version 2.2 or 3.0 for linux

9. Linux Oberon System 3 Release 2.2 for X Windows

10. Common Recent Updates - ORexx 2.1.2 on Win32 and 2.2 on Linux

11. Fortran plus 2.2 trouble with Linux Mandrake 8.1

12. problem with setrlimit on Linux 2.2?

 

 
Powered by phpBB® Forum Software