* convert.c: include <string.h> for convert_i.c.
[bpt/guile.git] / libguile / error.c
index 33665a0..e17231f 100644 (file)
@@ -151,6 +151,17 @@ SCM_DEFINE (scm_error_scm, "scm-error", 5, 0, 0,
 }
 #undef FUNC_NAME
 
+#ifdef __MINGW32__
+# include "win32-socket.h"
+# define SCM_I_STRERROR(err) \
+    ((err >= WSABASEERR) ? scm_i_socket_strerror (err) : strerror (err))
+# define SCM_I_ERRNO() \
+    (errno ? errno : scm_i_socket_errno ())
+#else
+# define SCM_I_STRERROR(err) strerror (err)
+# define SCM_I_ERRNO() errno
+#endif /* __MINGW32__ */
+
 SCM_DEFINE (scm_strerror, "strerror", 1, 0, 0, 
             (SCM err),
            "Return the Unix error message corresponding to @var{err}, which\n"
@@ -158,20 +169,20 @@ SCM_DEFINE (scm_strerror, "strerror", 1, 0, 0,
 #define FUNC_NAME s_scm_strerror
 {
   SCM_VALIDATE_INUM (1,err);
-  return scm_makfrom0str (strerror (SCM_INUM (err)));
+  return scm_makfrom0str (SCM_I_STRERROR (SCM_INUM (err)));
 }
 #undef FUNC_NAME
 
-SCM_SYMBOL (scm_system_error_key, "system-error");
+SCM_GLOBAL_SYMBOL (scm_system_error_key, "system-error");
 void
 scm_syserror (const char *subr)
 {
-  int save_errno = errno;
+  int save_errno = SCM_I_ERRNO ();
   
   scm_error (scm_system_error_key,
             subr,
             "~A",
-            scm_cons (scm_makfrom0str (strerror (save_errno)), SCM_EOL),
+            scm_cons (scm_makfrom0str (SCM_I_STRERROR (save_errno)), SCM_EOL),
             scm_cons (SCM_MAKINUM (save_errno), SCM_EOL));
 }
 
@@ -185,7 +196,7 @@ scm_syserror_msg (const char *subr, const char *message, SCM args, int eno)
             scm_cons (SCM_MAKINUM (eno), SCM_EOL));
 }
 
-SCM_SYMBOL (scm_num_overflow_key, "numerical-overflow");
+SCM_GLOBAL_SYMBOL (scm_num_overflow_key, "numerical-overflow");
 void
 scm_num_overflow (const char *subr)
 {
@@ -196,7 +207,7 @@ scm_num_overflow (const char *subr)
             SCM_BOOL_F);
 }
 
-SCM_SYMBOL (scm_out_of_range_key, "out-of-range");
+SCM_GLOBAL_SYMBOL (scm_out_of_range_key, "out-of-range");
 void
 scm_out_of_range (const char *subr, SCM bad_value)
 {
@@ -218,7 +229,7 @@ scm_out_of_range_pos (const char *subr, SCM bad_value, SCM pos)
 }
 
 
-SCM_SYMBOL (scm_args_number_key, "wrong-number-of-args");
+SCM_GLOBAL_SYMBOL (scm_args_number_key, "wrong-number-of-args");
 void
 scm_wrong_num_args (SCM proc)
 {
@@ -241,7 +252,7 @@ scm_error_num_args_subr (const char *subr)
 }
 
 
-SCM_SYMBOL (scm_arg_type_key, "wrong-type-arg");
+SCM_GLOBAL_SYMBOL (scm_arg_type_key, "wrong-type-arg");
 void
 scm_wrong_type_arg (const char *subr, int pos, SCM bad_value)
 {
@@ -273,7 +284,7 @@ scm_wrong_type_arg_msg (const char *subr, int pos, SCM bad_value, const char *sz
 }
 
 
-SCM_SYMBOL (scm_memory_alloc_key, "memory-allocation-error");
+SCM_GLOBAL_SYMBOL (scm_memory_alloc_key, "memory-allocation-error");
 void
 scm_memory_error (const char *subr)
 {
@@ -284,7 +295,7 @@ scm_memory_error (const char *subr)
             SCM_BOOL_F);
 }
 
-SCM_SYMBOL (scm_misc_error_key, "misc-error");
+SCM_GLOBAL_SYMBOL (scm_misc_error_key, "misc-error");
 void
 scm_misc_error (const char *subr, const char *message, SCM args)
 {