*** empty log message ***
[bpt/guile.git] / libguile / options.c
index 5ac0a43..c5260e6 100644 (file)
@@ -1,4 +1,4 @@
-/*     Copyright (C) 1995, 1996, 1998 Free Software Foundation
+/*     Copyright (C) 1995, 1996, 1998, 2000 Free Software Foundation
  * 
  * 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
 
 \f
 
-#include <stdio.h>
-#include "_scm.h"
+#include "libguile/_scm.h"
+#include "libguile/strings.h"
 
-#include "options.h"
+#include "libguile/options.h"
 \f
 
 /* {Run-time options}
@@ -123,9 +123,7 @@ static SCM protected_objects;
 SCM
 scm_options (SCM arg, scm_option options[], int n, const char *s)
 {
-  int i, docp = (!SCM_UNBNDP (arg)
-                && !SCM_NULLP (arg)
-                && (SCM_IMP (arg) || SCM_NCONSP (arg)));
+  int i, docp = (!SCM_UNBNDP (arg) && !SCM_NULLP (arg) && !SCM_CONSP (arg));
   /* Let `arg' GC protect the arguments */
   SCM new_mode = arg, ans = SCM_EOL, ls;
   for (i = 0; i < n; ++i)
@@ -186,23 +184,24 @@ scm_options (SCM arg, scm_option options[], int n, const char *s)
                  goto cont;
                case SCM_OPTION_SCM:
                  new_mode = SCM_CDR (new_mode);
-                 flags[i] = SCM_CARBITS (new_mode);
+                 flags[i] = SCM_UNPACK (SCM_CAR (new_mode));
                  goto cont;
                }
 #ifndef SCM_RECKLESS
          scm_must_free ((char *) flags);
-         scm_wta (SCM_CAR (new_mode), "Unknown mode flag", s);
+         scm_misc_error (s, "Unknown mode flag: ~S", 
+                         SCM_LIST1 (SCM_CAR (new_mode)));
 #endif
        cont:
          new_mode = SCM_CDR (new_mode);
        }
       for (i = 0; i < n; ++i)
        {
-         // scm_option doesn't know if its a long or an SCM
+         /* scm_option doesn't know if its a long or an SCM */
          if (options[i].type == SCM_OPTION_SCM)
            SCM_SETCDR (protected_objects,
-                       scm_cons (SCM_SCM(flags[i]),
-                                 scm_delq1_x (SCM_SCM(options[i].val),
+                       scm_cons (SCM_PACK(flags[i]),
+                                 scm_delq1_x (SCM_PACK(options[i].val),
                                               SCM_CDR (protected_objects))));
          options[i].val = flags[i];
        }
@@ -219,12 +218,18 @@ scm_init_opts (SCM (*func) (SCM), scm_option options[], int n)
 
   for (i = 0; i < n; ++i)
     {
-      options[i].name =        (char *) SCM_CAR (scm_sysintern0 (options[i].name));
-      options[i].doc = (char *) scm_permanent_object (scm_take0str
-                                                     (options[i].doc));
+      SCM name;
+      SCM doc;
+
+      name = scm_str2symbol (options[i].name);
+      options[i].name =        (char *) name;
+      scm_permanent_object (name);
+      doc = scm_take0str (options[i].doc);
+      options[i].doc = (char *) doc;
+      scm_permanent_object (doc);
       if (options[i].type == SCM_OPTION_SCM)
        SCM_SETCDR (protected_objects,
-                   scm_cons (SCM_SCM(options[i].val), SCM_CDR (protected_objects)));
+                   scm_cons (SCM_PACK(options[i].val), SCM_CDR (protected_objects)));
     }
   func (SCM_UNDEFINED);
 }
@@ -234,5 +239,13 @@ void
 scm_init_options ()
 {
   protected_objects = scm_permanent_object (scm_cons (SCM_UNDEFINED, SCM_EOL));
-#include "options.x"
+#ifndef SCM_MAGIC_SNARFER
+#include "libguile/options.x"
+#endif
 }
+
+/*
+  Local Variables:
+  c-file-style: "gnu"
+  End:
+*/