diff options
| author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-03-28 13:32:37 (GMT) |
|---|---|---|
| committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-03-28 13:32:37 (GMT) |
| commit | 47e821e8297b9b9d7bb295a11f35c0307f2c1a7a (patch) | |
| tree | 968af4744acfc6496b9611741040c3da171cb682 /win/tclWinError.c | |
| parent | 6540c1e7abc493b3684a2b1312717329494b96b1 (diff) | |
| parent | 1251bcbcc6272da5c31c077c03ce238cfde19844 (diff) | |
| download | tcl-47e821e8297b9b9d7bb295a11f35c0307f2c1a7a.zip tcl-47e821e8297b9b9d7bb295a11f35c0307f2c1a7a.tar.gz tcl-47e821e8297b9b9d7bb295a11f35c0307f2c1a7a.tar.bz2 | |
merge trunk
Diffstat (limited to 'win/tclWinError.c')
| -rw-r--r-- | win/tclWinError.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/win/tclWinError.c b/win/tclWinError.c index 4fee02b..1b59dbe 100644 --- a/win/tclWinError.c +++ b/win/tclWinError.c @@ -12,11 +12,19 @@ #include "tclInt.h" +#ifndef WSAEWOULDBLOCK +# define WSAEWOULDBLOCK 10035L +#endif + +#ifndef __WIN32__ +# define DWORD unsigned int +#endif + /* * The following table contains the mapping from Win32 errors to errno errors. */ -static char errorTable[] = { +static const unsigned char errorTable[] = { 0, EINVAL, /* ERROR_INVALID_FUNCTION 1 */ ENOENT, /* ERROR_FILE_NOT_FOUND 2 */ @@ -284,18 +292,16 @@ static char errorTable[] = { EINVAL, /* 264 */ EINVAL, /* 265 */ EINVAL, /* 266 */ - ENOTDIR, /* ERROR_DIRECTORY 267 */ + ENOTDIR /* ERROR_DIRECTORY 267 */ }; -static const unsigned int tableLen = sizeof(errorTable); - /* * The following table contains the mapping from WinSock errors to * errno errors. */ -static int wsaErrorTable[] = { - EWOULDBLOCK, /* WSAEWOULDBLOCK */ +static const unsigned char wsaErrorTable[] = { + EAGAIN, /* WSAEWOULDBLOCK */ EINPROGRESS, /* WSAEINPROGRESS */ EALREADY, /* WSAEALREADY */ ENOTSOCK, /* WSAENOTSOCK */ @@ -331,7 +337,7 @@ static int wsaErrorTable[] = { EUSERS, /* WSAEUSERS */ EDQUOT, /* WSAEDQUOT */ ESTALE, /* WSAESTALE */ - EREMOTE, /* WSAEREMOTE */ + EREMOTE /* WSAEREMOTE */ }; /* @@ -352,9 +358,9 @@ static int wsaErrorTable[] = { void TclWinConvertError( - unsigned long errCode) /* Win32 error code. */ + DWORD errCode) /* Win32 error code. */ { - if (errCode >= tableLen) { + if (errCode >= sizeof(errorTable)/sizeof(errorTable[0])) { Tcl_SetErrno(EINVAL); } else { Tcl_SetErrno(errorTable[errCode]); @@ -379,12 +385,13 @@ TclWinConvertError( void TclWinConvertWSAError( - unsigned long errCode) /* Win32 error code. */ + DWORD errCode) /* Win32 error code. */ { - if ((errCode >= WSAEWOULDBLOCK) && (errCode <= WSAEREMOTE)) { - Tcl_SetErrno(wsaErrorTable[errCode - WSAEWOULDBLOCK]); - } else { + errCode -= WSAEWOULDBLOCK; + if (errCode >= sizeof(wsaErrorTable)/sizeof(wsaErrorTable[0])) { Tcl_SetErrno(EINVAL); + } else { + Tcl_SetErrno(wsaErrorTable[errCode]); } } |
