diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 1998-08-19 13:11:47 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 1998-08-19 13:11:47 +0000 |
commit | 48a7201a4a9833e4587d0cb0e04042c845f7f146 (patch) | |
tree | edc2be476f210eae05781ceeeb88a8c70b0b1e2d /otherlibs/win32unix/unixsupport.c | |
parent | 3eccaad8ecb28294bddd562b1247a7509e456a19 (diff) | |
download | ocaml-48a7201a4a9833e4587d0cb0e04042c845f7f146.tar.gz |
Bug dans unix_error (cst_to_constr renvoie un entier code!)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2079 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/win32unix/unixsupport.c')
-rw-r--r-- | otherlibs/win32unix/unixsupport.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/otherlibs/win32unix/unixsupport.c b/otherlibs/win32unix/unixsupport.c index 8a2bb0fc22..e631ccbdb9 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(); |