Call collect_output() before dropping mailbox. Added exception handling. Added user-name variable.
Showing
1 changed file
with
31 additions
and
7 deletions
... | @@ -29,12 +29,33 @@ run_main (int argc, char *argv[]) | ... | @@ -29,12 +29,33 @@ run_main (int argc, char *argv[]) |
29 | } | 29 | } |
30 | 30 | ||
31 | SCM _current_mailbox; | 31 | SCM _current_mailbox; |
32 | SCM _user_name; | ||
33 | |||
34 | static SCM | ||
35 | catch_body (void *data) | ||
36 | { | ||
37 | if (program_file) | ||
38 | scm_primitive_load (scm_makfrom0str (program_file)); | ||
39 | |||
40 | if (program_expr) | ||
41 | scm_eval_0str (program_expr); | ||
42 | |||
43 | return SCM_BOOL_F; | ||
44 | } | ||
45 | |||
46 | static SCM | ||
47 | catch_handler (void *data, SCM tag, SCM throw_args) | ||
48 | { | ||
49 | collect_drop_mailbox (); | ||
50 | return scm_handle_by_message ("guimb", tag, throw_args); | ||
51 | } | ||
32 | 52 | ||
33 | void | 53 | void |
34 | _scheme_main () | 54 | _scheme_main () |
35 | { | 55 | { |
36 | SCM *scm_loc; | 56 | SCM *scm_loc; |
37 | 57 | int rc; | |
58 | |||
38 | if (debug_guile) | 59 | if (debug_guile) |
39 | { | 60 | { |
40 | SCM_DEVAL_P = 1; | 61 | SCM_DEVAL_P = 1; |
... | @@ -43,7 +64,7 @@ _scheme_main () | ... | @@ -43,7 +64,7 @@ _scheme_main () |
43 | SCM_RESET_DEBUG_MODE; | 64 | SCM_RESET_DEBUG_MODE; |
44 | } | 65 | } |
45 | 66 | ||
46 | /* Initialize scheme library */ | 67 | /* Initialize scheme library */ |
47 | mu_scm_init (); | 68 | mu_scm_init (); |
48 | 69 | ||
49 | /* Provide basic primitives */ | 70 | /* Provide basic primitives */ |
... | @@ -53,12 +74,15 @@ _scheme_main () | ... | @@ -53,12 +74,15 @@ _scheme_main () |
53 | scm_loc = SCM_CDRLOC (scm_sysintern ("current-mailbox", SCM_EOL)); | 74 | scm_loc = SCM_CDRLOC (scm_sysintern ("current-mailbox", SCM_EOL)); |
54 | *scm_loc = _current_mailbox; | 75 | *scm_loc = _current_mailbox; |
55 | 76 | ||
56 | if (program_file) | 77 | _user_name = user_name ? scm_makfrom0str (user_name) : SCM_BOOL_F; |
57 | scm_primitive_load (scm_makfrom0str (program_file)); | 78 | scm_loc = SCM_CDRLOC (scm_sysintern ("user-name", SCM_EOL)); |
79 | *scm_loc = _user_name; | ||
58 | 80 | ||
59 | if (program_expr) | 81 | scm_internal_lazy_catch (SCM_BOOL_T, |
60 | scm_eval_0str (program_expr); | 82 | catch_body, NULL, |
83 | catch_handler, NULL); | ||
61 | 84 | ||
85 | rc = collect_output (); | ||
62 | collect_drop_mailbox (); | 86 | collect_drop_mailbox (); |
63 | 87 | exit (rc); | |
64 | } | 88 | } | ... | ... |
-
Please register or sign in to post a comment