summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2024-06-18 22:41:30 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2024-06-18 22:41:30 (GMT)
commitd064b77a41441825f6578546de36e0122cd344d0 (patch)
tree9820165ca2a729857567712e412335ffd755bf4a
parent40e19dd4d7d78b7bd499730dd7fb0097f54624d9 (diff)
parent0076b1a3093eb2a605073a84e090d0bb94fd4475 (diff)
downloadtcl-d064b77a41441825f6578546de36e0122cd344d0.zip
tcl-d064b77a41441825f6578546de36e0122cd344d0.tar.gz
tcl-d064b77a41441825f6578546de36e0122cd344d0.tar.bz2
Fix some more indenting
-rw-r--r--unix/Makefile.in2
-rwxr-xr-xunix/installManPage4
-rw-r--r--unix/tclEpollNotfy.c8
-rw-r--r--unix/tclLoadOSF.c2
-rw-r--r--unix/tclUnixCompat.c16
-rw-r--r--unix/tclUnixInit.c28
-rw-r--r--unix/tclUnixSock.c599
-rw-r--r--win/Makefile.in2
-rw-r--r--win/nmakehlp.c45
9 files changed, 354 insertions, 352 deletions
diff --git a/unix/Makefile.in b/unix/Makefile.in
index 29d3228..bd06089 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -1101,7 +1101,7 @@ install-libraries: libraries
@if [ -n "$(TCL_MODULE_PATH)" -a -f $(TOP_DIR)/library/tm.tcl ] ; then \
echo "Customizing tcl module path"; \
echo "if {![interp issafe]} { ::tcl::tm::roots [list $(TCL_MODULE_PATH)] }" >> \
- "$(SCRIPT_INSTALL_DIR)/tm.tcl"; \
+ "$(SCRIPT_INSTALL_DIR)/tm.tcl"; \
fi
install-tzdata:
diff --git a/unix/installManPage b/unix/installManPage
index 3d5fa7b..3cb266d 100755
--- a/unix/installManPage
+++ b/unix/installManPage
@@ -12,8 +12,8 @@ Suffix=""
while true; do
case $1 in
- -s | --symlinks ) Sym="-s " ;;
- -z | --compress ) Gzip=$2; shift ;;
+ -s | --symlinks ) Sym="-s " ;;
+ -z | --compress ) Gzip=$2; shift ;;
-e | --extension ) Gz=$2; shift ;;
-x | --suffix ) Suffix=$2; shift ;;
-*) cat <<EOF
diff --git a/unix/tclEpollNotfy.c b/unix/tclEpollNotfy.c
index 8cb9166..8c392f0 100644
--- a/unix/tclEpollNotfy.c
+++ b/unix/tclEpollNotfy.c
@@ -207,10 +207,10 @@ PlatformEventsControl(
newEvent.events |= EPOLLOUT;
}
if (isNew) {
- newPedPtr = (struct PlatformEventData *)
+ newPedPtr = (struct PlatformEventData *)
Tcl_Alloc(sizeof(struct PlatformEventData));
- newPedPtr->filePtr = filePtr;
- newPedPtr->tsdPtr = tsdPtr;
+ newPedPtr->filePtr = filePtr;
+ newPedPtr->tsdPtr = tsdPtr;
filePtr->pedPtr = newPedPtr;
}
newEvent.data.ptr = filePtr->pedPtr;
@@ -367,7 +367,7 @@ PlatformEventsInit(void)
filePtr->mask = TCL_READABLE;
PlatformEventsControl(filePtr, tsdPtr, EPOLL_CTL_ADD, 1);
if (!tsdPtr->readyEvents) {
- tsdPtr->maxReadyEvents = 512;
+ tsdPtr->maxReadyEvents = 512;
tsdPtr->readyEvents = (struct epoll_event *) Tcl_Alloc(
tsdPtr->maxReadyEvents * sizeof(tsdPtr->readyEvents[0]));
}
diff --git a/unix/tclLoadOSF.c b/unix/tclLoadOSF.c
index 81f314f..9c34e73 100644
--- a/unix/tclLoadOSF.c
+++ b/unix/tclLoadOSF.c
@@ -128,7 +128,7 @@ TclpDlopen(
*/
if ((pkg = strrchr(fileName, '/')) == NULL) {
- pkg = fileName;
+ pkg = fileName;
} else {
pkg++;
}
diff --git a/unix/tclUnixCompat.c b/unix/tclUnixCompat.c
index 30ddb71..def69fa 100644
--- a/unix/tclUnixCompat.c
+++ b/unix/tclUnixCompat.c
@@ -994,17 +994,17 @@ TclWinCPUID(
/* See: <http://en.wikipedia.org/wiki/CPUID> */
#if defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
__asm__ __volatile__("movq %%rbx, %%rsi \n\t" /* save %rbx */
- "cpuid \n\t"
- "xchgq %%rsi, %%rbx \n\t" /* restore the old %rbx */
- : "=a"(regsPtr[0]), "=S"(regsPtr[1]), "=c"(regsPtr[2]), "=d"(regsPtr[3])
- : "a"(index));
+ "cpuid \n\t"
+ "xchgq %%rsi, %%rbx \n\t" /* restore the old %rbx */
+ : "=a"(regsPtr[0]), "=S"(regsPtr[1]), "=c"(regsPtr[2]), "=d"(regsPtr[3])
+ : "a"(index));
status = TCL_OK;
#elif defined(__i386__) || defined(_M_IX86)
__asm__ __volatile__("mov %%ebx, %%esi \n\t" /* save %ebx */
- "cpuid \n\t"
- "xchg %%esi, %%ebx \n\t" /* restore the old %ebx */
- : "=a"(regsPtr[0]), "=S"(regsPtr[1]), "=c"(regsPtr[2]), "=d"(regsPtr[3])
- : "a"(index));
+ "cpuid \n\t"
+ "xchg %%esi, %%ebx \n\t" /* restore the old %ebx */
+ : "=a"(regsPtr[0]), "=S"(regsPtr[1]), "=c"(regsPtr[2]), "=d"(regsPtr[3])
+ : "a"(index));
status = TCL_OK;
#else
(void)index;
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c
index 81e3af5..63167c6 100644
--- a/unix/tclUnixInit.c
+++ b/unix/tclUnixInit.c
@@ -54,11 +54,11 @@ static const char *const processors[NUMPROCESSORS] = {
typedef struct {
union {
- unsigned int dwOemId;
- struct {
- int wProcessorArchitecture;
- int wReserved;
- };
+ unsigned int dwOemId;
+ struct {
+ int wProcessorArchitecture;
+ int wReserved;
+ };
};
unsigned int dwPageSize;
void *lpMinimumApplicationAddress;
@@ -860,15 +860,15 @@ TclpSetVariables(
}
Tcl_ObjSetVar2(interp, Tcl_NewStringObj("tcl_pkgPath", -1), NULL, pkgListObj, TCL_GLOBAL_ONLY);
{
- /* Some platforms build configure scripts expect ~ expansion so do that */
- Tcl_Obj *origPaths;
- Tcl_Obj *resolvedPaths;
-
- origPaths = Tcl_GetVar2Ex(interp, "tcl_pkgPath", NULL, TCL_GLOBAL_ONLY);
- resolvedPaths = TclResolveTildePathList(origPaths);
- if (resolvedPaths != origPaths && resolvedPaths != NULL) {
- Tcl_SetVar2Ex(interp, "tcl_pkgPath", NULL, resolvedPaths, TCL_GLOBAL_ONLY);
- }
+ /* Some platforms build configure scripts expect ~ expansion so do that */
+ Tcl_Obj *origPaths;
+ Tcl_Obj *resolvedPaths;
+
+ origPaths = Tcl_GetVar2Ex(interp, "tcl_pkgPath", NULL, TCL_GLOBAL_ONLY);
+ resolvedPaths = TclResolveTildePathList(origPaths);
+ if (resolvedPaths != origPaths && resolvedPaths != NULL) {
+ Tcl_SetVar2Ex(interp, "tcl_pkgPath", NULL, resolvedPaths, TCL_GLOBAL_ONLY);
+ }
}
#ifdef DJGPP
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index d518453..f2b15b2 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -63,8 +63,7 @@ struct TcpState {
* Only needed for server sockets
*/
- Tcl_TcpAcceptProc *acceptProc;
- /* Proc to call on accept. */
+ Tcl_TcpAcceptProc *acceptProc; /* Proc to call on accept. */
void *acceptProcData; /* The data for the accept proc. */
/*
@@ -227,7 +226,7 @@ InitializeHostName(
memset(&u, (int) 0, sizeof(struct utsname));
if (uname(&u) >= 0) { /* INTL: Native. */
- hp = TclpGetHostByName(u.nodename); /* INTL: Native. */
+ hp = TclpGetHostByName(u.nodename); /* INTL: Native. */
if (hp == NULL) {
/*
* Sometimes the nodename is fully qualified, but gets truncated
@@ -246,11 +245,11 @@ InitializeHostName(
Tcl_Free(node);
}
}
- if (hp != NULL) {
+ if (hp != NULL) {
native = hp->h_name;
- } else {
+ } else {
native = u.nodename;
- }
+ }
}
#else /* !NO_UNAME */
/*
@@ -370,8 +369,8 @@ TcpBlockModeProc(
SET_BITS(statePtr->flags, TCP_NONBLOCKING);
}
if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
- statePtr->cachedBlocking = mode;
- return 0;
+ statePtr->cachedBlocking = mode;
+ return 0;
}
if (TclUnixSetBlockingMode(statePtr->fds.fd, mode) < 0) {
return errno;
@@ -443,37 +442,37 @@ WaitForConnect(
*/
if (GOT_BITS(statePtr->flags, TCP_ASYNC_TEST_MODE)
- && !(errorCodePtr != NULL
- && !GOT_BITS(statePtr->flags, TCP_NONBLOCKING))) {
+ && !(errorCodePtr != NULL
+ && !GOT_BITS(statePtr->flags, TCP_NONBLOCKING))) {
*errorCodePtr = EWOULDBLOCK;
return -1;
}
if (errorCodePtr == NULL || GOT_BITS(statePtr->flags, TCP_NONBLOCKING)) {
- timeout = 0;
+ timeout = 0;
} else {
- timeout = -1;
+ timeout = -1;
}
do {
- if (TclUnixWaitForFile(statePtr->fds.fd,
- TCL_WRITABLE | TCL_EXCEPTION, timeout) != 0) {
- TcpConnect(NULL, statePtr);
- }
-
- /*
- * Do this only once in the nonblocking case and repeat it until the
- * socket is final when blocking.
- */
+ if (TclUnixWaitForFile(statePtr->fds.fd,
+ TCL_WRITABLE | TCL_EXCEPTION, timeout) != 0) {
+ TcpConnect(NULL, statePtr);
+ }
+
+ /*
+ * Do this only once in the nonblocking case and repeat it until the
+ * socket is final when blocking.
+ */
} while (timeout == -1 && GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT));
if (errorCodePtr != NULL) {
- if (GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
- *errorCodePtr = EAGAIN;
- return -1;
- } else if (statePtr->connectError != 0) {
- *errorCodePtr = ENOTCONN;
- return -1;
- }
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
+ *errorCodePtr = EAGAIN;
+ return -1;
+ } else if (statePtr->connectError != 0) {
+ *errorCodePtr = ENOTCONN;
+ return -1;
+ }
}
return 0;
}
@@ -627,10 +626,10 @@ TcpCloseProc(
fds = next;
}
if (statePtr->addrlist != NULL) {
- freeaddrinfo(statePtr->addrlist);
+ freeaddrinfo(statePtr->addrlist);
}
if (statePtr->myaddrlist != NULL) {
- freeaddrinfo(statePtr->myaddrlist);
+ freeaddrinfo(statePtr->myaddrlist);
}
Tcl_Free(statePtr);
return errorCode;
@@ -706,7 +705,7 @@ IPv6AddressNeedsNumericRendering(
struct in6_addr addr)
{
if (IN6_ARE_ADDR_EQUAL(&addr, &in6addr_any)) {
- return 1;
+ return 1;
}
/*
@@ -715,11 +714,11 @@ IPv6AddressNeedsNumericRendering(
*/
if (!IN6_IS_ADDR_V4MAPPED(&addr)) {
- return 0;
+ return 0;
}
return (addr.s6_addr[12] == 0 && addr.s6_addr[13] == 0
- && addr.s6_addr[14] == 0 && addr.s6_addr[15] == 0);
+ && addr.s6_addr[14] == 0 && addr.s6_addr[15] == 0);
}
#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
#pragma GCC diagnostic pop
@@ -738,7 +737,7 @@ TcpHostPortList(
int flags = 0;
getnameinfo(&addr.sa, salen, nhost, sizeof(nhost), nport, sizeof(nport),
- NI_NUMERICHOST | NI_NUMERICSERV);
+ NI_NUMERICHOST | NI_NUMERICSERV);
Tcl_DStringAppendElement(dsPtr, nhost);
/*
@@ -747,14 +746,14 @@ TcpHostPortList(
*/
if (addr.sa.sa_family == AF_INET) {
- if (addr.sa4.sin_addr.s_addr == INADDR_ANY) {
- flags |= NI_NUMERICHOST;
- }
+ if (addr.sa4.sin_addr.s_addr == INADDR_ANY) {
+ flags |= NI_NUMERICHOST;
+ }
#ifndef NEED_FAKE_RFC2553
} else if (addr.sa.sa_family == AF_INET6) {
- if (IPv6AddressNeedsNumericRendering(addr.sa6.sin6_addr)) {
- flags |= NI_NUMERICHOST;
- }
+ if (IPv6AddressNeedsNumericRendering(addr.sa6.sin6_addr)) {
+ flags |= NI_NUMERICHOST;
+ }
#endif /* NEED_FAKE_RFC2553 */
}
@@ -763,22 +762,22 @@ TcpHostPortList(
*/
if (interp != NULL &&
- Tcl_GetVar2(interp, SUPPRESS_RDNS_VAR, NULL, 0) != NULL) {
- flags |= NI_NUMERICHOST;
+ Tcl_GetVar2(interp, SUPPRESS_RDNS_VAR, NULL, 0) != NULL) {
+ flags |= NI_NUMERICHOST;
}
if (getnameinfo(&addr.sa, salen, host, sizeof(host), NULL, 0,
- flags) == 0) {
- /*
- * Reverse mapping worked.
- */
+ flags) == 0) {
+ /*
+ * Reverse mapping worked.
+ */
- Tcl_DStringAppendElement(dsPtr, host);
+ Tcl_DStringAppendElement(dsPtr, host);
} else {
- /*
- * Reverse mapping failed - use the numeric rep once more.
- */
+ /*
+ * Reverse mapping failed - use the numeric rep once more.
+ */
- Tcl_DStringAppendElement(dsPtr, nhost);
+ Tcl_DStringAppendElement(dsPtr, nhost);
}
Tcl_DStringAppendElement(dsPtr, nport);
}
@@ -907,25 +906,25 @@ TcpGetOptionProc(
socklen_t optlen = sizeof(int);
WaitForConnect(statePtr, NULL);
- if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
- /*
- * Suppress errors as long as we are not done.
- */
-
- errno = 0;
- } else if (statePtr->connectError != 0) {
- errno = statePtr->connectError;
- statePtr->connectError = 0;
- } else {
- int err;
-
- getsockopt(statePtr->fds.fd, SOL_SOCKET, SO_ERROR, (char *) &err,
- &optlen);
- errno = err;
- }
- if (errno != 0) {
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
+ /*
+ * Suppress errors as long as we are not done.
+ */
+
+ errno = 0;
+ } else if (statePtr->connectError != 0) {
+ errno = statePtr->connectError;
+ statePtr->connectError = 0;
+ } else {
+ int err;
+
+ getsockopt(statePtr->fds.fd, SOL_SOCKET, SO_ERROR, (char *) &err,
+ &optlen);
+ errno = err;
+ }
+ if (errno != 0) {
Tcl_DStringAppend(dsPtr, Tcl_ErrnoMsg(errno), TCL_INDEX_NONE);
- }
+ }
return TCL_OK;
}
@@ -934,13 +933,13 @@ TcpGetOptionProc(
WaitForConnect(statePtr, NULL);
Tcl_DStringAppend(dsPtr,
GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT) ? "1" : "0", TCL_INDEX_NONE);
- return TCL_OK;
+ return TCL_OK;
}
if ((len == 0) || ((len > 1) && (optionName[1] == 'p') &&
(strncmp(optionName, "-peername", len) == 0))) {
- address peername;
- socklen_t size = sizeof(peername);
+ address peername;
+ socklen_t size = sizeof(peername);
WaitForConnect(statePtr, NULL);
if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
@@ -963,11 +962,11 @@ TcpGetOptionProc(
Tcl_DStringAppendElement(dsPtr, "-peername");
Tcl_DStringStartSublist(dsPtr);
}
- TcpHostPortList(interp, dsPtr, peername, size);
+ TcpHostPortList(interp, dsPtr, peername, size);
if (len) {
- return TCL_OK;
- }
- Tcl_DStringEndSublist(dsPtr);
+ return TCL_OK;
+ }
+ Tcl_DStringEndSublist(dsPtr);
} else {
/*
* getpeername failed - but if we were asked for all the options
@@ -979,7 +978,7 @@ TcpGetOptionProc(
if (len) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't get peername: %s",
+ "can't get peername: %s",
Tcl_PosixError(interp)));
}
return TCL_ERROR;
@@ -1004,7 +1003,7 @@ TcpGetOptionProc(
* In async connect output an empty string
*/
- found = 1;
+ found = 1;
} else {
for (fds = &statePtr->fds; fds != NULL; fds = fds->next) {
size = sizeof(sockname);
@@ -1014,16 +1013,16 @@ TcpGetOptionProc(
}
}
}
- if (found) {
- if (len) {
- return TCL_OK;
- }
- Tcl_DStringEndSublist(dsPtr);
- } else {
- if (interp) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't get sockname: %s", Tcl_PosixError(interp)));
- }
+ if (found) {
+ if (len) {
+ return TCL_OK;
+ }
+ Tcl_DStringEndSublist(dsPtr);
+ } else {
+ if (interp) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't get sockname: %s", Tcl_PosixError(interp)));
+ }
return TCL_ERROR;
}
}
@@ -1070,7 +1069,7 @@ TcpGetOptionProc(
if (len > 0) {
return Tcl_BadChannelOption(interp, optionName,
- "connecting keepalive nodelay peername sockname");
+ "connecting keepalive nodelay peername sockname");
}
return TCL_OK;
@@ -1177,22 +1176,22 @@ TcpWatchProc(
TcpState *statePtr = (TcpState *)instanceData;
if (statePtr->acceptProc != NULL) {
- /*
- * Make sure we don't mess with server sockets since they will never
- * be readable or writable at the Tcl level. This keeps Tcl scripts
- * from interfering with the -accept behavior (bug #3394732).
- */
+ /*
+ * Make sure we don't mess with server sockets since they will never
+ * be readable or writable at the Tcl level. This keeps Tcl scripts
+ * from interfering with the -accept behavior (bug #3394732).
+ */
return;
}
if (GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
- /*
- * Async sockets use a FileHandler internally while connecting, so we
- * need to cache this request until the connection has succeeded.
- */
+ /*
+ * Async sockets use a FileHandler internally while connecting, so we
+ * need to cache this request until the connection has succeeded.
+ */
- statePtr->filehandlers = mask;
+ statePtr->filehandlers = mask;
} else if (mask) {
/*
@@ -1314,14 +1313,14 @@ TcpConnect(
static const int reuseaddr = 1;
if (async_callback) {
- goto reenter;
+ goto reenter;
}
for (statePtr->addr = statePtr->addrlist; statePtr->addr != NULL;
- statePtr->addr = statePtr->addr->ai_next) {
- for (statePtr->myaddr = statePtr->myaddrlist;
- statePtr->myaddr != NULL;
- statePtr->myaddr = statePtr->myaddr->ai_next) {
+ statePtr->addr = statePtr->addr->ai_next) {
+ for (statePtr->myaddr = statePtr->myaddrlist;
+ statePtr->myaddr != NULL;
+ statePtr->myaddr = statePtr->myaddr->ai_next) {
/*
* No need to try combinations of local and remote addresses of
* different families.
@@ -1331,19 +1330,19 @@ TcpConnect(
continue;
}
- /*
- * Close the socket if it is still open from the last unsuccessful
- * iteration.
- */
+ /*
+ * Close the socket if it is still open from the last unsuccessful
+ * iteration.
+ */
- if (statePtr->fds.fd >= 0) {
+ if (statePtr->fds.fd >= 0) {
close(statePtr->fds.fd);
statePtr->fds.fd = -1;
- errno = 0;
+ errno = 0;
}
statePtr->fds.fd = socket(statePtr->addr->ai_family, SOCK_STREAM,
- 0);
+ 0);
if (statePtr->fds.fd < 0) {
continue;
}
@@ -1362,28 +1361,28 @@ TcpConnect(
TclSockMinimumBuffers(INT2PTR(statePtr->fds.fd), SOCKET_BUFSIZE);
if (async) {
- ret = TclUnixSetBlockingMode(statePtr->fds.fd,
- TCL_MODE_NONBLOCKING);
- if (ret < 0) {
- continue;
- }
- }
-
- /*
- * Must reset the error variable here, before we use it for the
- * first time in this iteration.
- */
-
- error = 0;
-
- (void) setsockopt(statePtr->fds.fd, SOL_SOCKET, SO_REUSEADDR,
- (char *) &reuseaddr, sizeof(reuseaddr));
- ret = bind(statePtr->fds.fd, statePtr->myaddr->ai_addr,
- statePtr->myaddr->ai_addrlen);
- if (ret < 0) {
- error = errno;
- continue;
- }
+ ret = TclUnixSetBlockingMode(statePtr->fds.fd,
+ TCL_MODE_NONBLOCKING);
+ if (ret < 0) {
+ continue;
+ }
+ }
+
+ /*
+ * Must reset the error variable here, before we use it for the
+ * first time in this iteration.
+ */
+
+ error = 0;
+
+ (void) setsockopt(statePtr->fds.fd, SOL_SOCKET, SO_REUSEADDR,
+ (char *) &reuseaddr, sizeof(reuseaddr));
+ ret = bind(statePtr->fds.fd, statePtr->myaddr->ai_addr,
+ statePtr->myaddr->ai_addrlen);
+ if (ret < 0) {
+ error = errno;
+ continue;
+ }
/*
* Attempt to connect. The connect may fail at present with an
@@ -1393,35 +1392,35 @@ TcpConnect(
*/
ret = connect(statePtr->fds.fd, statePtr->addr->ai_addr,
- statePtr->addr->ai_addrlen);
- if (ret < 0) {
- error = errno;
- }
+ statePtr->addr->ai_addrlen);
+ if (ret < 0) {
+ error = errno;
+ }
if (ret < 0 && errno == EINPROGRESS) {
- Tcl_CreateFileHandler(statePtr->fds.fd,
- TCL_WRITABLE | TCL_EXCEPTION, TcpAsyncCallback,
- statePtr);
- errno = EWOULDBLOCK;
- SET_BITS(statePtr->flags, TCP_ASYNC_PENDING);
- return TCL_OK;
-
- reenter:
- CLEAR_BITS(statePtr->flags, TCP_ASYNC_PENDING);
- Tcl_DeleteFileHandler(statePtr->fds.fd);
-
- /*
- * Read the error state from the socket to see if the async
- * connection has succeeded or failed. As this clears the
- * error condition, we cache the status in the socket state
- * struct for later retrieval by [fconfigure -error].
- */
-
- optlen = sizeof(int);
-
- getsockopt(statePtr->fds.fd, SOL_SOCKET, SO_ERROR,
- (char *) &error, &optlen);
- errno = error;
- }
+ Tcl_CreateFileHandler(statePtr->fds.fd,
+ TCL_WRITABLE | TCL_EXCEPTION, TcpAsyncCallback,
+ statePtr);
+ errno = EWOULDBLOCK;
+ SET_BITS(statePtr->flags, TCP_ASYNC_PENDING);
+ return TCL_OK;
+
+ reenter:
+ CLEAR_BITS(statePtr->flags, TCP_ASYNC_PENDING);
+ Tcl_DeleteFileHandler(statePtr->fds.fd);
+
+ /*
+ * Read the error state from the socket to see if the async
+ * connection has succeeded or failed. As this clears the
+ * error condition, we cache the status in the socket state
+ * struct for later retrieval by [fconfigure -error].
+ */
+
+ optlen = sizeof(int);
+
+ getsockopt(statePtr->fds.fd, SOL_SOCKET, SO_ERROR,
+ (char *) &error, &optlen);
+ errno = error;
+ }
if (error == 0) {
goto out;
}
@@ -1432,43 +1431,43 @@ TcpConnect(
statePtr->connectError = error;
CLEAR_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
if (async_callback) {
- /*
- * An asynchonous connection has finally succeeded or failed.
- */
-
- TcpWatchProc(statePtr, statePtr->filehandlers);
- TclUnixSetBlockingMode(statePtr->fds.fd, statePtr->cachedBlocking);
-
- if (error != 0) {
- SET_BITS(statePtr->flags, TCP_ASYNC_FAILED);
- }
-
- /*
- * We need to forward the writable event that brought us here, because
- * upon reading of getsockopt(SO_ERROR), at least some OSes clear the
- * writable state from the socket, and so a subsequent select() on
- * behalf of a script level [fileevent] would not fire. It doesn't
- * hurt that this is also called in the successful case and will save
- * the event mechanism one roundtrip through select().
- */
+ /*
+ * An asynchonous connection has finally succeeded or failed.
+ */
+
+ TcpWatchProc(statePtr, statePtr->filehandlers);
+ TclUnixSetBlockingMode(statePtr->fds.fd, statePtr->cachedBlocking);
+
+ if (error != 0) {
+ SET_BITS(statePtr->flags, TCP_ASYNC_FAILED);
+ }
+
+ /*
+ * We need to forward the writable event that brought us here, because
+ * upon reading of getsockopt(SO_ERROR), at least some OSes clear the
+ * writable state from the socket, and so a subsequent select() on
+ * behalf of a script level [fileevent] would not fire. It doesn't
+ * hurt that this is also called in the successful case and will save
+ * the event mechanism one roundtrip through select().
+ */
if (statePtr->cachedBlocking == TCL_MODE_NONBLOCKING) {
Tcl_NotifyChannel(statePtr->channel, TCL_WRITABLE);
}
}
if (error != 0) {
- /*
- * Failure for either a synchronous connection, or an async one that
- * failed before it could enter background mode, e.g. because an
- * invalid -myaddr was given.
- */
-
- if (interp != NULL) {
- errno = error;
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "couldn't open socket: %s", Tcl_PosixError(interp)));
- }
- return TCL_ERROR;
+ /*
+ * Failure for either a synchronous connection, or an async one that
+ * failed before it could enter background mode, e.g. because an
+ * invalid -myaddr was given.
+ */
+
+ if (interp != NULL) {
+ errno = error;
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "couldn't open socket: %s", Tcl_PosixError(interp)));
+ }
+ return TCL_ERROR;
}
return TCL_OK;
}
@@ -1511,16 +1510,16 @@ Tcl_OpenTcpClient(
*/
if (!TclCreateSocketAddress(interp, &addrlist, host, port, 0, &errorMsg)
- || !TclCreateSocketAddress(interp, &myaddrlist, myaddr, myport, 1,
- &errorMsg)) {
- if (addrlist != NULL) {
- freeaddrinfo(addrlist);
- }
- if (interp != NULL) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "couldn't open socket: %s", errorMsg));
- }
- return NULL;
+ || !TclCreateSocketAddress(interp, &myaddrlist, myaddr, myport, 1,
+ &errorMsg)) {
+ if (addrlist != NULL) {
+ freeaddrinfo(addrlist);
+ }
+ if (interp != NULL) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "couldn't open socket: %s", errorMsg));
+ }
+ return NULL;
}
/*
@@ -1540,14 +1539,14 @@ Tcl_OpenTcpClient(
*/
if (TcpConnect(interp, statePtr) != TCL_OK) {
- TcpCloseProc(statePtr, NULL);
- return NULL;
+ TcpCloseProc(statePtr, NULL);
+ return NULL;
}
snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, PTR2INT(statePtr));
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
- statePtr, TCL_READABLE | TCL_WRITABLE);
+ statePtr, TCL_READABLE | TCL_WRITABLE);
if (Tcl_SetChannelOption(interp, statePtr->channel, "-translation",
"auto crlf") == TCL_ERROR) {
Tcl_CloseEx(NULL, statePtr->channel, 0);
@@ -1577,7 +1576,7 @@ Tcl_MakeTcpClientChannel(
void *sock) /* The socket to wrap up into a channel. */
{
return (Tcl_Channel) TclpMakeTcpClientChannelMode(sock,
- TCL_READABLE | TCL_WRITABLE);
+ TCL_READABLE | TCL_WRITABLE);
}
/*
@@ -1684,17 +1683,17 @@ Tcl_OpenTcpServerEx(
repeat:
if (retry > 0) {
- if (statePtr != NULL) {
- TcpCloseProc(statePtr, NULL);
- statePtr = NULL;
- }
- if (addrlist != NULL) {
- freeaddrinfo(addrlist);
- addrlist = NULL;
- }
- if (retry >= MAXRETRY) {
- goto error;
- }
+ if (statePtr != NULL) {
+ TcpCloseProc(statePtr, NULL);
+ statePtr = NULL;
+ }
+ if (addrlist != NULL) {
+ freeaddrinfo(addrlist);
+ addrlist = NULL;
+ }
+ if (retry >= MAXRETRY) {
+ goto error;
+ }
}
retry++;
chosenport = 0;
@@ -1705,14 +1704,14 @@ Tcl_OpenTcpServerEx(
}
if (!TclCreateSocketAddress(interp, &addrlist, myHost, port, 1,
- &errorMsg)) {
+ &errorMsg)) {
my_errno = errno;
goto error;
}
for (addrPtr = addrlist; addrPtr != NULL; addrPtr = addrPtr->ai_next) {
sock = socket(addrPtr->ai_family, addrPtr->ai_socktype,
- addrPtr->ai_protocol);
+ addrPtr->ai_protocol);
if (sock == -1) {
if (howfar < SOCKET) {
howfar = SOCKET;
@@ -1760,100 +1759,100 @@ Tcl_OpenTcpServerEx(
#endif
}
- /*
- * Make sure we use the same port number when opening two server
- * sockets for IPv4 and IPv6 on a random port.
- *
- * As sockaddr_in6 uses the same offset and size for the port member
- * as sockaddr_in, we can handle both through the IPv4 API.
- */
+ /*
+ * Make sure we use the same port number when opening two server
+ * sockets for IPv4 and IPv6 on a random port.
+ *
+ * As sockaddr_in6 uses the same offset and size for the port member
+ * as sockaddr_in, we can handle both through the IPv4 API.
+ */
if (port == 0 && chosenport != 0) {
((struct sockaddr_in *) addrPtr->ai_addr)->sin_port =
- htons(chosenport);
+ htons(chosenport);
}
#ifdef IPV6_V6ONLY
/*
- * Missing on: Solaris 2.8
- */
+ * Missing on: Solaris 2.8
+ */
- if (addrPtr->ai_family == AF_INET6) {
- int v6only = 1;
+ if (addrPtr->ai_family == AF_INET6) {
+ int v6only = 1;
- (void) setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
- &v6only, sizeof(v6only));
- }
+ (void) setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
+ &v6only, sizeof(v6only));
+ }
#endif /* IPV6_V6ONLY */
status = bind(sock, addrPtr->ai_addr, addrPtr->ai_addrlen);
- if (status == -1) {
+ if (status == -1) {
if (howfar < BIND) {
howfar = BIND;
my_errno = errno;
}
- close(sock);
- sock = -1;
- if (port == 0 && errno == EADDRINUSE) {
- goto repeat;
- }
- continue;
- }
- if (port == 0 && chosenport == 0) {
- address sockname;
- socklen_t namelen = sizeof(sockname);
-
- /*
- * Synchronize port numbers when binding to port 0 of multiple
- * addresses.
- */
-
- if (getsockname(sock, &sockname.sa, &namelen) >= 0) {
- chosenport = ntohs(sockname.sa4.sin_port);
- }
- }
- if (backlog < 0) {
- backlog = SOMAXCONN;
- }
- status = listen(sock, backlog);
- if (status < 0) {
+ close(sock);
+ sock = -1;
+ if (port == 0 && errno == EADDRINUSE) {
+ goto repeat;
+ }
+ continue;
+ }
+ if (port == 0 && chosenport == 0) {
+ address sockname;
+ socklen_t namelen = sizeof(sockname);
+
+ /*
+ * Synchronize port numbers when binding to port 0 of multiple
+ * addresses.
+ */
+
+ if (getsockname(sock, &sockname.sa, &namelen) >= 0) {
+ chosenport = ntohs(sockname.sa4.sin_port);
+ }
+ }
+ if (backlog < 0) {
+ backlog = SOMAXCONN;
+ }
+ status = listen(sock, backlog);
+ if (status < 0) {
if (howfar < LISTEN) {
howfar = LISTEN;
my_errno = errno;
}
- close(sock);
- sock = -1;
- if (port == 0 && errno == EADDRINUSE) {
- goto repeat;
- }
- continue;
- }
- if (statePtr == NULL) {
- /*
- * Allocate a new TcpState for this socket.
- */
-
- statePtr = (TcpState *)Tcl_Alloc(sizeof(TcpState));
- memset(statePtr, 0, sizeof(TcpState));
- statePtr->acceptProc = acceptProc;
- statePtr->acceptProcData = acceptProcData;
- snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, PTR2INT(statePtr));
- newfds = &statePtr->fds;
- } else {
- newfds = (TcpFdList *)Tcl_Alloc(sizeof(TcpFdList));
- memset(newfds, (int) 0, sizeof(TcpFdList));
- fds->next = newfds;
- }
- newfds->fd = sock;
- newfds->statePtr = statePtr;
- fds = newfds;
-
- /*
- * Set up the callback mechanism for accepting connections from new
- * clients.
- */
-
- Tcl_CreateFileHandler(sock, TCL_READABLE, TcpAccept, fds);
+ close(sock);
+ sock = -1;
+ if (port == 0 && errno == EADDRINUSE) {
+ goto repeat;
+ }
+ continue;
+ }
+ if (statePtr == NULL) {
+ /*
+ * Allocate a new TcpState for this socket.
+ */
+
+ statePtr = (TcpState *)Tcl_Alloc(sizeof(TcpState));
+ memset(statePtr, 0, sizeof(TcpState));
+ statePtr->acceptProc = acceptProc;
+ statePtr->acceptProcData = acceptProcData;
+ snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, PTR2INT(statePtr));
+ newfds = &statePtr->fds;
+ } else {
+ newfds = (TcpFdList *)Tcl_Alloc(sizeof(TcpFdList));
+ memset(newfds, (int) 0, sizeof(TcpFdList));
+ fds->next = newfds;
+ }
+ newfds->fd = sock;
+ newfds->statePtr = statePtr;
+ fds = newfds;
+
+ /*
+ * Set up the callback mechanism for accepting connections from new
+ * clients.
+ */
+
+ Tcl_CreateFileHandler(sock, TCL_READABLE, TcpAccept, fds);
}
error:
@@ -1866,15 +1865,15 @@ Tcl_OpenTcpServerEx(
return statePtr->channel;
}
if (interp != NULL) {
- Tcl_Obj *errorObj = Tcl_NewStringObj("couldn't open socket: ", TCL_INDEX_NONE);
+ Tcl_Obj *errorObj = Tcl_NewStringObj("couldn't open socket: ", TCL_INDEX_NONE);
if (errorMsg == NULL) {
- errno = my_errno;
- Tcl_AppendToObj(errorObj, Tcl_PosixError(interp), TCL_INDEX_NONE);
- } else {
+ errno = my_errno;
+ Tcl_AppendToObj(errorObj, Tcl_PosixError(interp), TCL_INDEX_NONE);
+ } else {
Tcl_AppendToObj(errorObj, errorMsg, TCL_INDEX_NONE);
}
- Tcl_SetObjResult(interp, errorObj);
+ Tcl_SetObjResult(interp, errorObj);
}
if (sock != -1) {
close(sock);
@@ -1938,9 +1937,9 @@ TcpAccept(
if (fds->statePtr->acceptProc != NULL) {
getnameinfo(&addr.sa, len, host, sizeof(host), port, sizeof(port),
- NI_NUMERICHOST|NI_NUMERICSERV);
+ NI_NUMERICHOST|NI_NUMERICSERV);
fds->statePtr->acceptProc(fds->statePtr->acceptProcData,
- newSockState->channel, host, atoi(port));
+ newSockState->channel, host, atoi(port));
}
}
diff --git a/win/Makefile.in b/win/Makefile.in
index 0773bce..98e2cec 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -617,7 +617,7 @@ ${TEST_DLL_FILE}: ${TCL_STUB_LIB_FILE} ${TCLTEST_OBJS}
${TEST_EXE_FILE}: ${TCL_STUB_LIB_FILE} ${TCLTEST_OBJS} tclTestMain.${OBJEXT}
@$(RM) ${TEST_EXE_FILE}
$(CC) $(CFLAGS) $(TCLTEST_OBJS) tclTestMain.$(OBJEXT) $(TCL_LIB_FILE) $(TCL_STUB_LIB_FILE) $(LIBS) \
- tclsh.$(RES) $(CC_EXENAME) $(LDFLAGS_CONSOLE)
+ tclsh.$(RES) $(CC_EXENAME) $(LDFLAGS_CONSOLE)
$(COPY) tclsh.exe.manifest ${TEST_EXE_FILE}.manifest
# use prebuilt zlib1.dll
diff --git a/win/nmakehlp.c b/win/nmakehlp.c
index b0799f8..4fc9f7a 100644
--- a/win/nmakehlp.c
+++ b/win/nmakehlp.c
@@ -90,7 +90,7 @@ main(
case 'c':
if (argc != 3) {
chars = snprintf(msg, sizeof(msg) - 1,
- "usage: %s -c <compiler option>\n"
+ "usage: %s -c <compiler option>\n"
"Tests for whether cl.exe supports an option\n"
"exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
@@ -271,7 +271,7 @@ CheckForCompilerFeature(
if (!ok) {
DWORD err = GetLastError();
int chars = snprintf(msg, sizeof(msg) - 1,
- "Tried to launch: \"%s\", but got error [%lu]: ", cmdline, err);
+ "Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|
FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPSTR)&msg[chars],
@@ -318,11 +318,11 @@ CheckForCompilerFeature(
*/
return !(strstr(Out.buffer, "D4002") != NULL
- || strstr(Err.buffer, "D4002") != NULL
- || strstr(Out.buffer, "D9002") != NULL
- || strstr(Err.buffer, "D9002") != NULL
- || strstr(Out.buffer, "D2021") != NULL
- || strstr(Err.buffer, "D2021") != NULL);
+ || strstr(Err.buffer, "D4002") != NULL
+ || strstr(Out.buffer, "D9002") != NULL
+ || strstr(Err.buffer, "D9002") != NULL
+ || strstr(Out.buffer, "D2021") != NULL
+ || strstr(Err.buffer, "D2021") != NULL);
}
static int
@@ -405,7 +405,7 @@ CheckForLinkerFeature(
if (!ok) {
DWORD err = GetLastError();
int chars = snprintf(msg, sizeof(msg) - 1,
- "Tried to launch: \"%s\", but got error [%lu]: ", cmdline, err);
+ "Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|
FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPSTR)&msg[chars],
@@ -600,9 +600,9 @@ list_free(list_item_t **listPtrPtr)
*
* Usage is something like:
* nmakehlp -S << $** > $@
- * @PACKAGE_NAME@ $(PACKAGE_NAME)
- * @PACKAGE_VERSION@ $(PACKAGE_VERSION)
- * <<
+ * @PACKAGE_NAME@ $(PACKAGE_NAME)
+ * @PACKAGE_VERSION@ $(PACKAGE_VERSION)
+ * <<
*/
static int
@@ -730,7 +730,7 @@ static int LocateDependencyHelper(const char *dir, const char *keypath)
return 2; /* Have no real error reporting mechanism into nmake */
}
dirlen = strlen(dir);
- if (dirlen > sizeof(path) - 3) {
+ if ((dirlen + 3) > sizeof(path)) {
return 2;
}
strncpy(path, dir, dirlen);
@@ -747,8 +747,9 @@ static int LocateDependencyHelper(const char *dir, const char *keypath)
#else
hSearch = FindFirstFile(path, &finfo);
#endif
- if (hSearch == INVALID_HANDLE_VALUE)
+ if (hSearch == INVALID_HANDLE_VALUE) {
return 1; /* Not found */
+ }
/* Loop through all subdirs checking if the keypath is under there */
ret = 1; /* Assume not found */
@@ -758,11 +759,13 @@ static int LocateDependencyHelper(const char *dir, const char *keypath)
* We need to check it is a directory despite the
* FindExSearchLimitToDirectories in the above call. See SDK docs
*/
- if ((finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
+ if ((finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
continue;
+ }
sublen = strlen(finfo.cFileName);
- if ((dirlen+1+sublen+1+keylen+1) > sizeof(path))
+ if ((dirlen+1+sublen+1+keylen+1) > sizeof(path)) {
continue; /* Path does not fit, assume not matched */
+ }
strncpy(path+dirlen+1, finfo.cFileName, sublen);
path[dirlen+1+sublen] = '\\';
strncpy(path+dirlen+1+sublen+1, keypath, keylen+1);
@@ -782,13 +785,13 @@ static int LocateDependencyHelper(const char *dir, const char *keypath)
* LocateDependency --
*
* Locates a dependency for a package.
- * keypath - a relative path within the package directory
- * that is used to confirm it is the correct directory.
+ * keypath - a relative path within the package directory
+ * that is used to confirm it is the correct directory.
* The search path for the package directory is currently only
- * the parent and grandparent of the current working directory.
- * If found, the command prints
- * name_DIRPATH=<full path of located directory>
- * and returns 0. If not found, does not print anything and returns 1.
+ * the parent and grandparent of the current working directory.
+ * If found, the command prints
+ * name_DIRPATH=<full path of located directory>
+ * and returns 0. If not found, does not print anything and returns 1.
*/
static int LocateDependency(const char *keypath)
{