summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix/unixsupport.c
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/win32unix/unixsupport.c')
-rw-r--r--otherlibs/win32unix/unixsupport.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/otherlibs/win32unix/unixsupport.c b/otherlibs/win32unix/unixsupport.c
index 8a2bb0fc2..e631ccbdb 100644
--- a/otherlibs/win32unix/unixsupport.c
+++ b/otherlibs/win32unix/unixsupport.c
@@ -88,27 +88,31 @@ int error_table[] = {
static value * unix_error_exn = NULL;
-void unix_error(errcode, cmdname, cmdarg)
- int errcode;
- char * cmdname;
- value cmdarg;
+void unix_error(int errcode, char *cmdname, value cmdarg)
{
value res;
- value name = Val_unit, arg = Val_unit;
+ value name = Val_unit, err = Val_unit, arg = Val_unit;
+ int errconstr;
- Begin_roots2 (name, arg);
+ Begin_roots3 (name, err, arg);
+ arg = cmdarg == Nothing ? copy_string("") : cmdarg;
+ name = copy_string(cmdname);
+ errconstr =
+ cst_to_constr(errcode, error_table, sizeof(error_table)/sizeof(int), -1);
+ if (errconstr == Val_int(-1)) {
+ err = alloc(1, 0);
+ Field(err, 0) = Val_int(errcode);
+ } else {
+ err = errconstr;
+ }
if (unix_error_exn == NULL) {
unix_error_exn = caml_named_value("Unix.Unix_error");
if (unix_error_exn == NULL)
- invalid_argument("Exception Unix.Unix_error not initialized, must link unix.cma");
+ invalid_argument("Exception Unix.Unix_error not initialized, please link unix.cma");
}
- arg = cmdarg == Nothing ? copy_string("") : cmdarg;
- name = copy_string(cmdname);
res = alloc(4, 0);
Field(res, 0) = *unix_error_exn;
- Field(res, 1) =
- cst_to_constr(errcode, error_table, sizeof(error_table)/sizeof(int),
- sizeof(error_table)/sizeof(int));
+ Field(res, 1) = err;
Field(res, 2) = name;
Field(res, 3) = arg;
End_roots();