summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-03-22 21:34:27 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-03-22 21:34:27 (GMT)
commit6efd3e5fb18780e9e765151e807ed04c34293aa6 (patch)
treea0689274b7976a41688599a7ac390b3ea85b3966 /win
parent90b55a0053849e5a6c0483f716de14cb4639ce08 (diff)
downloadtcl-6efd3e5fb18780e9e765151e807ed04c34293aa6.zip
tcl-6efd3e5fb18780e9e765151e807ed04c34293aa6.tar.gz
tcl-6efd3e5fb18780e9e765151e807ed04c34293aa6.tar.bz2
add TclWinConvertError and TclWinConvertWSAError for cygwin
Diffstat (limited to 'win')
-rw-r--r--win/tclWinError.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/win/tclWinError.c b/win/tclWinError.c
index da1e335..d718584 100644
--- a/win/tclWinError.c
+++ b/win/tclWinError.c
@@ -10,14 +10,22 @@
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-#include "tclWinInt.h"
+#include "tclPort.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 */
@@ -285,17 +293,15 @@ 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[] = {
+static CONST unsigned char wsaErrorTable[] = {
EWOULDBLOCK, /* WSAEWOULDBLOCK */
EINPROGRESS, /* WSAEINPROGRESS */
EALREADY, /* WSAEALREADY */
@@ -332,7 +338,7 @@ static int wsaErrorTable[] = {
EUSERS, /* WSAEUSERS */
EDQUOT, /* WSAEDQUOT */
ESTALE, /* WSAESTALE */
- EREMOTE, /* WSAEREMOTE */
+ EREMOTE /* WSAEREMOTE */
};
/*
@@ -355,7 +361,7 @@ void
TclWinConvertError(errCode)
DWORD errCode; /* Win32 error code. */
{
- if (errCode >= tableLen) {
+ if (errCode >= sizeof(errorTable)) {
Tcl_SetErrno(EINVAL);
} else {
Tcl_SetErrno(errorTable[errCode]);
@@ -382,8 +388,9 @@ void
TclWinConvertWSAError(errCode)
DWORD errCode; /* Win32 error code. */
{
- if ((errCode >= WSAEWOULDBLOCK) && (errCode <= WSAEREMOTE)) {
- Tcl_SetErrno(wsaErrorTable[errCode - WSAEWOULDBLOCK]);
+ errCode -= WSAEWOULDBLOCK;
+ if ((errCode <= (DWORD) sizeof(wsaErrorTable))) {
+ Tcl_SetErrno(wsaErrorTable[errCode]);
} else {
Tcl_SetErrno(EINVAL);
}