diff options
Diffstat (limited to 'sys/boot/forth/support.4th')
-rw-r--r-- | sys/boot/forth/support.4th | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/boot/forth/support.4th b/sys/boot/forth/support.4th index 08f5004..9a68872 100644 --- a/sys/boot/forth/support.4th +++ b/sys/boot/forth/support.4th @@ -833,7 +833,7 @@ get-current ( -- wid ) previous definitions >search ( wid -- ) repeat ; -: peek_file +: peek_file ( addr len -- ) 0 to end_of_file? reset_line_reading O_RDONLY fopen fd ! @@ -844,6 +844,7 @@ get-current ( -- wid ) previous definitions >search ( wid -- ) ['] process_assignment catch ['] free_buffers catch fd @ fclose + swap throw throw ; only forth also support-functions definitions @@ -1021,25 +1022,26 @@ string current_file_name_ref \ used to print the file name ; : get_nextboot_conf_file ( -- addr len ) - nextboot_conf_file strget strdup \ XXX is the strdup a leak ? + nextboot_conf_file strget strdup ; : rewrite_nextboot_file ( -- ) get_nextboot_conf_file O_WRONLY fopen fd ! fd @ -1 = if EOPEN throw then - fd @ s' nextboot_enable="NO" ' fwrite + fd @ s' nextboot_enable="NO" ' fwrite ( fd buf len -- nwritten ) drop fd @ fclose ; -: include_nextboot_file +: include_nextboot_file ( -- ) get_nextboot_conf_file - ['] peek_file catch + ['] peek_file catch if 2drop then nextboot? if get_nextboot_conf_file + current_file_name_ref strref ['] load_conf catch process_conf_errors - ['] rewrite_nextboot_file catch + ['] rewrite_nextboot_file catch if 2drop then then ; |