Fix REPOSITION-FILE, HISTORY, locked file handle and other problems.
[pforth] / fth / history.fth
index 5e5409e..574d6a6 100644 (file)
@@ -50,6 +50,8 @@ KH-HISTORY kh_history_size erase
 \\r
 \ The most recent entry is put at the beginning,\r
 \ older entries are shifted up.\r
 \\r
 \ The most recent entry is put at the beginning,\r
 \ older entries are shifted up.\r
+
+4 constant KH_LINE_EXTRA_SIZE ( 2 count bytes plus 2 size bytes )
 \r
 : KH-END ( -- addr , end of history buffer )\r
        kh-history kh_history_size +\r
 \r
 : KH-END ( -- addr , end of history buffer )\r
        kh-history kh_history_size +\r
@@ -131,8 +133,10 @@ variable KH-INSIDE        ( true if we are scrolling inside the history buffer )
                ELSE\r
                        >r ( save count )\r
 \ Set look pointer to point to first count byte of last string.\r
                ELSE\r
                        >r ( save count )\r
 \ Set look pointer to point to first count byte of last string.\r
-                       0 kh-look !\r
-                       r@ cell+ kh.make.room\r
+                       0 kh-look !
+\ Make room for this line of text and line header. 
+\ PLB20100823 Was cell+ which broke on 64-bit code.\r
+                       r@ KH_LINE_EXTRA_SIZE + kh.make.room\r
 \ Set count bytes at beginning and end.\r
                        r@ kh-history c!  ( start count )\r
                        r@ kh.endcount.addr c!\r
 \ Set count bytes at beginning and end.\r
                        r@ kh-history c!  ( start count )\r
                        r@ kh.endcount.addr c!\r