From 48a7201a4a9833e4587d0cb0e04042c845f7f146 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Wed, 19 Aug 1998 13:11:47 +0000 Subject: 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 --- otherlibs/win32unix/unixsupport.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'otherlibs/win32unix/unixsupport.c') 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(); -- cgit v1.2.1