* error.c, error.h (scm_error_callback): Removed (see NEWS).
[bpt/guile.git] / libguile / error.c
index a2a8c7f..175655b 100644 (file)
@@ -12,7 +12,8 @@
  * 
  * You should have received a copy of the GNU General Public License
  * along with this software; see the file COPYING.  If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307 USA
  *
  * As a special exception, the Free Software Foundation gives permission
  * for additional uses of the text contained in its release of GUILE.
@@ -36,8 +37,7 @@
  *
  * If you write modifications of your own for GUILE, it is your choice
  * whether to permit this exception to apply to your modifications.
- * If you do not wish that, delete this exception notice.  
- */
+ * If you do not wish that, delete this exception notice.  */
 \f
 
 #include <stdio.h>
@@ -60,8 +60,6 @@
 
 extern int errno;
 
-void (*scm_error_callback) () = 0;
-
 /* All errors should pass through here.  */
 void
 scm_error (key, subr, message, args, rest)
@@ -72,9 +70,6 @@ scm_error (key, subr, message, args, rest)
      SCM rest;
 {
   SCM arg_list;
-  if (scm_error_callback)
-    (*scm_error_callback) (key, subr, message, args, rest);
-
   arg_list = scm_listify (subr ? scm_makfrom0str (subr) : SCM_BOOL_F,
                          message ? scm_makfrom0str (message) : SCM_BOOL_F,
                          args,
@@ -84,7 +79,8 @@ scm_error (key, subr, message, args, rest)
   
   /* No return, but just in case: */
 
-  write (2, "unhandled system error", sizeof ("unhandled system error") - 1);
+  write (2, "unhandled system error\n",
+        sizeof ("unhandled system error\n") - 1);
   exit (1);
 }
 
@@ -105,6 +101,8 @@ scm_error_scm (key, subr, message, args, rest)
              || (SCM_NIMP (message) && SCM_ROSTRINGP (message)),
              message, SCM_ARG3, s_error_scm);
 
+  SCM_COERCE_SUBSTR (message);
+
   scm_error (key,
             (SCM_FALSEP (subr)) ? NULL : SCM_ROCHARS (subr),
             (SCM_FALSEP (message)) ? NULL : SCM_ROCHARS (message),
@@ -113,6 +111,14 @@ scm_error_scm (key, subr, message, args, rest)
   /* not reached.  */
 }
 
+SCM_PROC (s_strerror, "strerror", 1, 0, 0, scm_strerror);
+SCM
+scm_strerror (SCM err)
+{
+  SCM_ASSERT (SCM_INUMP (err), err, SCM_ARG1, s_strerror);
+  return scm_makfrom0str (strerror (SCM_INUM (err)));
+}
+
 SCM_SYMBOL (scm_system_error_key, "system-error");
 void
 scm_syserror (subr)
@@ -246,7 +252,7 @@ scm_wta (arg, pos, s_subr)
   if ((~0x1fL) & (long) pos)
     {
       /* error string supplied.  */
-      scm_misc_error (s_subr, pos, SCM_BOOL_F);
+      scm_misc_error (s_subr, pos, SCM_EOL);
     }
   else
     {
@@ -275,7 +281,7 @@ scm_wta (arg, pos, s_subr)
          scm_memory_error (s_subr);
        default:
          /* this shouldn't happen.  */
-         scm_misc_error (s_subr, "Unknown error", SCM_BOOL_F);
+         scm_misc_error (s_subr, "Unknown error", SCM_EOL);
        }
     }
   return SCM_UNSPECIFIED;
@@ -287,7 +293,7 @@ scm_wta (arg, pos, s_subr)
 void
 scm_init_error ()
 {
-#include "errnos.c"
+#include "cpp_err_symbols.c"
 #include "error.x"
 }