Merge pull request #33 from ellerh/implement-resize-file
authorPhil Burk <philburk@mobileer.com>
Thu, 5 Jan 2017 02:32:48 +0000 (18:32 -0800)
committerGitHub <noreply@github.com>
Thu, 5 Jan 2017 02:32:48 +0000 (18:32 -0800)
Implement RESIZE-FILE

fth/file.fth
fth/t_file.fth

index b71edc5..8fe0810 100644 (file)
@@ -61,6 +61,15 @@ create (LINE-TERMINATOR) \n c,
     0 2r> + c!        ( )
 ;
 
     0 2r> + c!        ( )
 ;
 
+: MULTI-LINE-COMMENT ( "comment<rparen>" -- )
+    BEGIN
+        >in @ ')' parse         ( >in c-addr len )
+        nip + >in @ =           ( delimiter-not-found? )
+    WHILE                       ( )
+        refill 0= IF EXIT THEN  ( )
+    REPEAT
+;
+
 }private
 
 \ This treats \n, \r\n, and \r as line terminator.  Reading is done
 }private
 
 \ This treats \n, \r\n, and \r as line terminator.  Reading is done
@@ -108,4 +117,14 @@ create (LINE-TERMINATOR) \n c,
     THEN
 ;
 
     THEN
 ;
 
+: (  ( "comment<rparen>"  -- )
+    source-id
+    CASE
+        -1 OF postpone ( ENDOF
+        0  OF postpone ( ENDOF
+        \ for input from files
+        multi-line-comment
+    ENDCASE
+; immediate
+
 privatize
 privatize
index e6ba0bd..388008c 100644 (file)
@@ -214,12 +214,12 @@ T{ FN2 R/W BIN OPEN-FILE SWAP DROP 0= -> FALSE }T
 T{ FN2 DELETE-FILE 0= -> FALSE }T
 
 \ ----------------------------------------------------------------------------
 T{ FN2 DELETE-FILE 0= -> FALSE }T
 
 \ ----------------------------------------------------------------------------
-TESTING multi-line ( comments
-\ 
-T{ ( 1 2 3
-4 5 6
-7 8 9 ) 11 22 33 -> 11 22 33 }T
-\ 
+TESTING multi-line ( comments
+
+T{ ( 1 2 3
+4 5 6
+7 8 9 ) 11 22 33 -> 11 22 33 }T
+
 \ ----------------------------------------------------------------------------
 TESTING SOURCE-ID (can only test it does not return 0 or -1)
 
 \ ----------------------------------------------------------------------------
 TESTING SOURCE-ID (can only test it does not return 0 or -1)