<commit_before>: mark ( a1 -- a2 )
   begin cell+ dup 2@ [ hex ] feedbabe.deadbeef [ decimal ]  d= until ;

: 'cold!
   dict0 cell+ cell+ ! ;

\g Deferred word for building the startup execution chain
defer coldchain  ' noop is coldchain

:noname 
   rp0 @ rp!  sp0 @ sp!  coldchain ; 'cold!

: save ( a u -- )
   w/o open-file throw >r   0 arg r/o open-file throw
   dup mmap-file throw
   dup dup mark over - dup pad ! r@ write-file throw 
   dict0 memtop over - dup pad +! r@ write-file throw
   dup pad @ + >r ( handle addr r: start)
   over file-size throw drop + ( handle end r: start )
   r@ - r> swap  r@ write-file throw 
   close-file throw  r> close-file throw ;

: save"
   [char] " parse save ;<commit_msg>Workaround for what I think is a bug in FreeBSD 6.1. The same code ran OK in NetBSD, Linux and Darwin.<commit_after>
: 'cold!
   dict0 cell+ cell+ ! ;

\g Deferred word for building the startup execution chain
defer coldchain  ' noop is coldchain

:noname 
   rp0 @ rp!  sp0 @ sp!  coldchain ; 'cold!

: mark ( a1 -- a2 )
   begin cell+ dup 2@ [ hex ] feedbabe.deadbeef [ decimal ]  d= until ;

: hdrsize ( src -- size )
   dup mark swap - ;

: dictsize ( -- size )
   memtop dict0 - ;

: exesize 322436 exit
   0 arg r/o open-file throw >r
   r@ file-size throw drop
   r> close-file throw ;

: savehdr ( src dstfile )
   >r dup hdrsize r> write-file throw ;

: savedict ( dstfile )
   dict0 dictsize rot write-file throw ;

: saveftr ( src dstfile )
   >r exesize over hdrsize dictsize + /string r> write-file throw ;

: savefile' ( dstfile srcfile -- srcmem dstfile )
   mmap-file throw swap
   2dup savehdr
   dup savedict ;

: savefile ( dstfile -- )
   0 arg r/o open-file throw >r
   r@ ['] savefile' catch
   r> close-file throw 
   throw saveftr ;

: save ( a u -- )
   w/o open-file throw >r   
   r@ ['] savefile catch 
   r> close-file throw throw ;


: save"
   [char] " parse save ;
{'fraction_non_alphanumeric': 0.10809399477806789, 'fraction_numerical': 0.014099216710182768, 'mean_word_length': 2.4836363636363634, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3890920', 'n_tokens_mistral': 709, 'n_tokens_neox': 689, 'n_words': 258}