Only include strings.h where it is actually needed.
[bpt/guile.git] / libguile / srcprop.c
index 40d854b..c0845b3 100644 (file)
@@ -1,4 +1,4 @@
-/*     Copyright (C) 1995,1996,1997,1998 Free Software Foundation
+/*     Copyright (C) 1995, 1996, 1997, 1998, 1999 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
  *
  * The author can be reached at djurfeldt@nada.kth.se
  * Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+   gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
+
 \f
 
 #include <stdio.h>
 #include "_scm.h"
 #include "smob.h"
-#include "genio.h"
 #include "alist.h"
 #include "debug.h"
 #include "hashtab.h"
 #include "hash.h"
+#include "ports.h"
 #include "weaks.h"
 
+#include "validate.h"
 #include "srcprop.h"
 \f
 /* {Source Properties}
@@ -81,11 +86,8 @@ static scm_srcprops_chunk *srcprops_chunklist = 0;
 static scm_srcprops *srcprops_freelist = 0;
 
 
-static SCM marksrcprops SCM_P ((SCM obj));
-
 static SCM
-marksrcprops (obj)
-     SCM obj;
+marksrcprops (SCM obj)
 {
   scm_gc_mark (SRCPROPFNAME (obj));
   scm_gc_mark (SRCPROPCOPY (obj));
@@ -93,11 +95,8 @@ marksrcprops (obj)
 }
 
 
-static scm_sizet freesrcprops SCM_P ((SCM obj));
-
 static scm_sizet
-freesrcprops (obj)
-     SCM obj;
+freesrcprops (SCM obj)
 {
   *((scm_srcprops **) SCM_CDR (obj)) = srcprops_freelist;
   srcprops_freelist = (scm_srcprops *) SCM_CDR (obj);
@@ -105,13 +104,8 @@ freesrcprops (obj)
 }
 
 
-static int prinsrcprops SCM_P ((SCM obj, SCM port, scm_print_state *pstate));
-
 static int
-prinsrcprops (obj, port, pstate)
-     SCM obj;
-     SCM port;
-     scm_print_state *pstate;
+prinsrcprops (SCM obj,SCM port,scm_print_state *pstate)
 {
   int writingp = SCM_WRITINGP (pstate);
   scm_puts ("#<srcprops ", port);
@@ -124,12 +118,7 @@ prinsrcprops (obj, port, pstate)
 
 
 SCM
-scm_make_srcprops (line, col, filename, copy, plist)
-     int line;
-     int col;
-     SCM filename;
-     SCM copy;
-     SCM plist;
+scm_make_srcprops (int line, int col, SCM filename, SCM copy, SCM plist)
 {
   register scm_srcprops *ptr;
   SCM_DEFER_INTS;
@@ -161,8 +150,7 @@ scm_make_srcprops (line, col, filename, copy, plist)
 
 
 SCM
-scm_srcprops_to_plist (obj)
-     SCM obj;
+scm_srcprops_to_plist (SCM obj)
 {
   SCM plist = SRCPROPPLIST (obj);
   if (!SCM_UNBNDP (SRCPROPCOPY (obj)))
@@ -175,62 +163,59 @@ scm_srcprops_to_plist (obj)
   return plist;
 }
 
-SCM_PROC (s_source_properties, "source-properties", 1, 0, 0, scm_source_properties);
-
-SCM
-scm_source_properties (obj)
-     SCM obj;
+SCM_DEFINE (scm_source_properties, "source-properties", 1, 0, 0, 
+            (SCM obj),
+"")
+#define FUNC_NAME s_scm_source_properties
 {
   SCM p;
-  SCM_ASSERT (SCM_NIMP (obj), obj, SCM_ARG1, s_source_properties);
+  SCM_VALIDATE_NIM (1,obj);
   if (SCM_MEMOIZEDP (obj))
     obj = SCM_MEMOIZED_EXP (obj);
 #ifndef SCM_RECKLESS
   else if (SCM_NCONSP (obj))
-    scm_wrong_type_arg (s_source_properties, 1, obj);
+    SCM_WRONG_TYPE_ARG (1, obj);
 #endif
   p = scm_hashq_ref (scm_source_whash, obj, (SCM) NULL);
   if (p != (SCM) NULL && SRCPROPSP (p))
     return scm_srcprops_to_plist (p);
   return SCM_EOL;
 }
+#undef FUNC_NAME
 
 /* Perhaps this procedure should look through an alist
    and try to make a srcprops-object...? */
-SCM_PROC (s_set_source_properties_x, "set-source-properties!", 2, 0, 0, scm_set_source_properties_x);
-
-SCM
-scm_set_source_properties_x (obj, plist)
-     SCM obj;
-     SCM plist;
+SCM_DEFINE (scm_set_source_properties_x, "set-source-properties!", 2, 0, 0,
+            (SCM obj, SCM plist),
+"")
+#define FUNC_NAME s_scm_set_source_properties_x
 {
   SCM handle;
-  SCM_ASSERT (SCM_NIMP (obj), obj, SCM_ARG1, s_set_source_properties_x);
+  SCM_VALIDATE_NIM (1,obj);
   if (SCM_MEMOIZEDP (obj))
     obj = SCM_MEMOIZED_EXP (obj);
 #ifndef SCM_RECKLESS
   else if (SCM_NCONSP (obj))
-    scm_wrong_type_arg (s_set_source_properties_x, 1, obj);
+    SCM_WRONG_TYPE_ARG(1, obj);
 #endif
   handle = scm_hashq_create_handle_x (scm_source_whash, obj, plist);
   SCM_SETCDR (handle, plist);
   return plist;
 }
+#undef FUNC_NAME
 
-SCM_PROC (s_source_property, "source-property", 2, 0, 0, scm_source_property);
-
-SCM
-scm_source_property (obj, key)
-     SCM obj;
-     SCM key;
+SCM_DEFINE (scm_source_property, "source-property", 2, 0, 0,
+            (SCM obj, SCM key),
+"")
+#define FUNC_NAME s_scm_source_property
 {
   SCM p;
-  SCM_ASSERT (SCM_NIMP (obj), obj, SCM_ARG1, s_source_property);
+  SCM_VALIDATE_NIM (1,obj);
   if (SCM_MEMOIZEDP (obj))
     obj = SCM_MEMOIZED_EXP (obj);
 #ifndef SCM_RECKLESS
-  else if (SCM_NCONSP (obj))
-    scm_wrong_type_arg (s_source_property, 1, obj);
+  else if (SCM_NECONSP (obj))
+    SCM_WRONG_TYPE_ARG (1, obj);
 #endif
   p = scm_hashq_ref (scm_source_whash, obj, SCM_EOL);
   if (SCM_IMP (p) || !SRCPROPSP (p))
@@ -249,23 +234,21 @@ scm_source_property (obj, key)
     }
   return SCM_UNBNDP (p) ? SCM_BOOL_F : p;
 }
+#undef FUNC_NAME
 
-SCM_PROC (s_set_source_property_x, "set-source-property!", 3, 0, 0, scm_set_source_property_x);
-
-SCM
-scm_set_source_property_x (obj, key, datum)
-     SCM obj;
-     SCM key;
-     SCM datum;
+SCM_DEFINE (scm_set_source_property_x, "set-source-property!", 3, 0, 0,
+            (SCM obj, SCM key, SCM datum),
+"")
+#define FUNC_NAME s_scm_set_source_property_x
 {
   scm_whash_handle h;
   SCM p;
-  SCM_ASSERT (SCM_NIMP (obj), obj, SCM_ARG1, s_set_source_property_x);
+  SCM_VALIDATE_NIM (1,obj);
   if (SCM_MEMOIZEDP (obj))
     obj = SCM_MEMOIZED_EXP (obj);
 #ifndef SCM_RECKLESS
   else if (SCM_NCONSP (obj))
-    scm_wrong_type_arg (s_set_source_property_x, 1, obj);
+    SCM_WRONG_TYPE_ARG (1, obj);
 #endif
   h = scm_whash_get_handle (scm_source_whash, obj);
   if (SCM_WHASHFOUNDP (h))
@@ -278,7 +261,7 @@ scm_set_source_property_x (obj, key, datum)
   if (scm_sym_breakpoint == key)
     {
       if (SCM_FALSEP (datum))
-       CLEARSRCPROPBRK (SCM_NIMP (p) && SRCPROPSP (p)
+       CLEARSRCPROPBRK (SRCPROPSP (p)
                         ? p
                         : SCM_WHASHSET (scm_source_whash, h,
                                         scm_make_srcprops (0,
@@ -287,7 +270,7 @@ scm_set_source_property_x (obj, key, datum)
                                                            SCM_UNDEFINED,
                                                            p)));
       else
-       SETSRCPROPBRK (SCM_NIMP (p) && SRCPROPSP (p)
+       SETSRCPROPBRK (SRCPROPSP (p)
                       ? p
                       : SCM_WHASHSET (scm_source_whash, h,
                                       scm_make_srcprops (0,
@@ -298,9 +281,8 @@ scm_set_source_property_x (obj, key, datum)
     }
   else if (scm_sym_line == key)
     {
-      SCM_ASSERT (SCM_INUMP (datum),
-                 datum, SCM_ARG3, s_set_source_property_x);
-      if (SCM_NIMP (p) && SRCPROPSP (p))
+      SCM_VALIDATE_INUM (3,datum);
+      if (SRCPROPSP (p))
        SETSRCPROPLINE (p, SCM_INUM (datum));
       else
        SCM_WHASHSET (scm_source_whash, h,
@@ -309,9 +291,8 @@ scm_set_source_property_x (obj, key, datum)
     }
   else if (scm_sym_column == key)
     {
-      SCM_ASSERT (SCM_INUMP (datum),
-                 datum, SCM_ARG3, s_set_source_property_x);
-      if (SCM_NIMP (p) && SRCPROPSP (p))
+      SCM_VALIDATE_INUM (3,datum);
+      if (SRCPROPSP (p))
        SETSRCPROPCOL (p, SCM_INUM (datum));
       else
        SCM_WHASHSET (scm_source_whash, h,
@@ -320,14 +301,14 @@ scm_set_source_property_x (obj, key, datum)
     }
   else if (scm_sym_filename == key)
     {
-      if (SCM_NIMP (p) && SRCPROPSP (p))
+      if (SRCPROPSP (p))
        SRCPROPFNAME (p) = datum;
       else
        SCM_WHASHSET (scm_source_whash, h, scm_make_srcprops (0, 0, datum, SCM_UNDEFINED, p));
     }
   else if (scm_sym_filename == key)
     {
-      if (SCM_NIMP (p) && SRCPROPSP (p))
+      if (SRCPROPSP (p))
        SRCPROPCOPY (p) = datum;
       else
        SCM_WHASHSET (scm_source_whash, h, scm_make_srcprops (0, 0, SCM_UNDEFINED, datum, p));
@@ -336,6 +317,7 @@ scm_set_source_property_x (obj, key, datum)
     SCM_WHASHSET (scm_source_whash, h, scm_acons (key, datum, p));
   return SCM_UNSPECIFIED;
 }
+#undef FUNC_NAME
 
 
 void