* arbiters.c, async.c, regex-posix.c: Use new smob interface.
[bpt/guile.git] / libguile / init.c
index 02b438a..9b0946c 100644 (file)
@@ -1,4 +1,4 @@
-/*     Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
+/*     Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
  * 
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -39,6 +39,8 @@
  * whether to permit this exception to apply to your modifications.
  * If you do not wish that, delete this exception notice.  */
 \f
+/* Include the headers for just about everything.
+   We call all their initialization functions.  */
 
 #include <stdio.h>
 #include "_scm.h"
@@ -59,6 +61,7 @@
 #include "eq.h"
 #include "error.h"
 #include "eval.h"
+#include "evalext.h"
 #include "feature.h"
 #include "filesys.h"
 #include "fluids.h"
 #include "iselect.h"
 #endif
 #include "ioext.h"
-#include "kw.h"
+#include "keywords.h"
 #include "list.h"
 #include "load.h"
+#include "macros.h"
 #include "mallocs.h"
+#include "modules.h"
 #include "net_db.h"
 #include "numbers.h"
 #include "objects.h"
 #include "procprop.h"
 #include "procs.h"
 #include "ramap.h"
+#include "random.h"
 #include "read.h"
-#include "readline.h"
 #include "scmsigs.h"
 #include "script.h"
 #include "simpos.h"
 #include "smob.h"
 #include "socket.h"
+#include "sort.h"
 #include "srcprop.h"
 #include "stackchk.h"
 #include "stacks.h"
 #include "version.h"
 #include "vports.h"
 #include "weaks.h"
+#include "guardians.h"
 
 #include "init.h"
 
 #include <unistd.h>
 #endif
 \f
+/* Setting up the stack.  */
 
 static void start_stack SCM_P ((void *base));
 static void restart_stack SCM_P ((void * base));
@@ -261,11 +269,12 @@ scm_init_standard_ports ()
      and scsh, read stdin unbuffered.  Applications that can tolerate
      buffered input on stdin can reset \ex{(current-input-port)} to
      block buffering for higher performance.  */
-  scm_def_inp = scm_stdio_to_port (stdin, 
+  scm_def_inp
+    = scm_standard_stream_to_port (stdin, 
                                   (isatty (fileno (stdin)) ? "r0" : "r"),
                                   "standard input");
-  scm_def_outp = scm_stdio_to_port (stdout, "w", "standard output");
-  scm_def_errp = scm_stdio_to_port (stderr, "w", "standard error");
+  scm_def_outp = scm_standard_stream_to_port (stdout, "w", "standard output");
+  scm_def_errp = scm_standard_stream_to_port (stderr, "w", "standard error");
 
   scm_cur_inp = scm_def_inp;
   scm_cur_outp = scm_def_outp;
@@ -275,6 +284,34 @@ scm_init_standard_ports ()
 
 
 \f
+/* Loading the startup Scheme files.  */
+
+/* The boot code "ice-9/boot-9" is only loaded by scm_boot_guile when
+   this is false.  The unexec code uses this, to keep ice_9 from being
+   loaded into dumped guile executables.  */
+int scm_ice_9_already_loaded = 0;
+
+void
+scm_load_startup_files ()
+{
+  /* We want a path only containing directories from GUILE_LOAD_PATH,
+     SCM_SITE_DIR and SCM_LIBRARY_DIR when searching for the site init
+     file, so we do this before loading Ice-9.  */
+  SCM init_path = scm_sys_search_load_path (scm_makfrom0str ("init.scm"));
+
+  /* Load Ice-9.  */
+  if (!scm_ice_9_already_loaded)
+    scm_primitive_load_path (scm_makfrom0str ("ice-9/boot-9.scm"));
+
+  /* Load the init.scm file.  */
+  if (SCM_NFALSEP (init_path))
+    scm_primitive_load (init_path);
+}
+
+
+\f
+/* The main init code.  */
+
 #ifdef _UNICOS
 typedef int setjmp_type;
 #else
@@ -410,9 +447,11 @@ scm_boot_guile_1 (base, closure)
       scm_init_iselect ();
 #endif
       scm_init_ioext ();
-      scm_init_kw ();
+      scm_init_keywords ();
       scm_init_list ();
+      scm_init_macros ();
       scm_init_mallocs ();
+      scm_init_modules ();
       scm_init_net_db ();
       scm_init_numbers ();
       scm_init_objprop ();
@@ -427,6 +466,7 @@ scm_boot_guile_1 (base, closure)
       scm_init_procprop ();
       scm_init_scmsigs ();
       scm_init_socket ();
+      scm_init_sort ();
 #ifdef DEBUG_EXTENSIONS
       scm_init_srcprop ();
 #endif
@@ -449,18 +489,18 @@ scm_boot_guile_1 (base, closure)
       scm_init_vectors ();
       scm_init_version ();
       scm_init_weaks ();
+      scm_init_guardian ();
       scm_init_vports ();
       scm_init_eval ();
+      scm_init_evalext ();
 #ifdef DEBUG_EXTENSIONS
       scm_init_debug ();       /* Requires macro smobs */
 #endif
       scm_init_ramap ();
+      scm_init_random ();
       scm_init_unif ();
       scm_init_simpos ();
       scm_init_load_path ();
-#if defined (HAVE_RL_GETC_FUNCTION)
-      scm_init_readline ();
-#endif
       scm_init_standard_ports ();
       scm_init_dynamic_linking ();
       scm_init_script ();
@@ -478,8 +518,8 @@ scm_boot_guile_1 (base, closure)
   if (!setjmp_val)
     {
       scm_set_program_arguments (closure->argc, closure->argv, 0);
-      scm_internal_catch (SCM_BOOL_T, invoke_main_func, closure,
-                         scm_handle_by_message, 0);
+      scm_internal_lazy_catch (SCM_BOOL_T, invoke_main_func, closure,
+                              scm_handle_by_message, 0);
     }
 
   scm_restore_signals ();
@@ -502,6 +542,10 @@ invoke_main_func (body_data)
 {
   struct main_func_closure *closure = (struct main_func_closure *) body_data;
 
+  scm_load_startup_files ();
+
+  scm_post_boot_init_modules ();
+
   (*closure->main_func) (closure->closure, closure->argc, closure->argv);
 
   /* never reached */