summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2024-05-13 15:41:44 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2024-05-13 15:41:44 (GMT)
commit83a70980d73aee113b565c0960e28f94061cf49b (patch)
tree5b346cf1401c23c69c43d84a1eb6986e442c7dfd /unix
parent064ea7546804d70edaa512f5b2e5cc36693aaff4 (diff)
downloadtcl-83a70980d73aee113b565c0960e28f94061cf49b.zip
tcl-83a70980d73aee113b565c0960e28f94061cf49b.tar.gz
tcl-83a70980d73aee113b565c0960e28f94061cf49b.tar.bz2
Clean up a lot of small whitespace issues dkf/to-redo
This is the dullest commit ever. Sorry.
Diffstat (limited to 'unix')
-rw-r--r--unix/tclAppInit.c2
-rw-r--r--unix/tclEpollNotfy.c43
-rw-r--r--unix/tclKqueueNotfy.c6
-rw-r--r--unix/tclLoadDyld.c4
-rw-r--r--unix/tclLoadNext.c6
-rw-r--r--unix/tclLoadOSF.c2
-rw-r--r--unix/tclSelectNotfy.c6
-rw-r--r--unix/tclUnixChan.c38
-rw-r--r--unix/tclUnixCompat.c116
-rw-r--r--unix/tclUnixFCmd.c22
-rw-r--r--unix/tclUnixFile.c60
-rw-r--r--unix/tclUnixInit.c53
-rw-r--r--unix/tclUnixPipe.c22
-rw-r--r--unix/tclUnixPort.h2
-rw-r--r--unix/tclUnixSock.c650
-rw-r--r--unix/tclUnixThrd.c4
-rw-r--r--unix/tclXtNotify.c8
17 files changed, 531 insertions, 513 deletions
diff --git a/unix/tclAppInit.c b/unix/tclAppInit.c
index 6158c99..fd9d752 100644
--- a/unix/tclAppInit.c
+++ b/unix/tclAppInit.c
@@ -29,7 +29,7 @@ extern Tcl_LibraryInitProc Tcltest_SafeInit;
#endif /* TCL_TEST */
#ifdef TCL_XT_TEST
-extern void XtToolkitInitialize(void);
+extern void XtToolkitInitialize(void);
extern Tcl_LibraryInitProc Tclxttest_Init;
#endif /* TCL_XT_TEST */
diff --git a/unix/tclEpollNotfy.c b/unix/tclEpollNotfy.c
index 2a1733a..76377d3 100644
--- a/unix/tclEpollNotfy.c
+++ b/unix/tclEpollNotfy.c
@@ -42,7 +42,7 @@ typedef struct FileHandler {
* for this file. */
Tcl_FileProc *proc; /* Function to call, in the style of
* Tcl_CreateFileHandler. */
- void *clientData; /* Argument to pass to proc. */
+ void *clientData; /* Argument to pass to proc. */
struct FileHandler *nextPtr;/* Next in list of all files we care about. */
LIST_ENTRY(FileHandler) readyNode;
/* Next/previous in list of FileHandlers asso-
@@ -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;
@@ -227,23 +227,22 @@ PlatformEventsControl(
}
if (epoll_ctl(tsdPtr->eventsFd, op, filePtr->fd, &newEvent) == -1) {
- switch (errno) {
- case EPERM:
- switch (op) {
- case EPOLL_CTL_ADD:
- if (isNew) {
- LIST_INSERT_HEAD(&tsdPtr->firstReadyFileHandlerPtr, filePtr,
- readyNode);
- }
- break;
- case EPOLL_CTL_DEL:
- LIST_REMOVE(filePtr, readyNode);
- break;
-
+ switch (errno) {
+ case EPERM:
+ switch (op) {
+ case EPOLL_CTL_ADD:
+ if (isNew) {
+ LIST_INSERT_HEAD(&tsdPtr->firstReadyFileHandlerPtr,
+ filePtr, readyNode);
}
break;
- default:
- Tcl_Panic("epoll_ctl: %s", strerror(errno));
+ case EPOLL_CTL_DEL:
+ LIST_REMOVE(filePtr, readyNode);
+ break;
+ }
+ break;
+ default:
+ Tcl_Panic("epoll_ctl: %s", strerror(errno));
}
}
return;
@@ -367,7 +366,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]));
}
@@ -513,7 +512,7 @@ TclpCreateFileHandler(
* called. */
Tcl_FileProc *proc, /* Function to call for each selected
* event. */
- void *clientData) /* Arbitrary data to pass to proc. */
+ void *clientData) /* Arbitrary data to pass to proc. */
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
FileHandler *filePtr = LookUpFileHandler(tsdPtr, fd, NULL);
@@ -791,7 +790,7 @@ int
TclAsyncNotifier(
int sigNumber, /* Signal number. */
Tcl_ThreadId threadId, /* Target thread. */
- void *clientData, /* Notifier data. */
+ void *clientData, /* Notifier data. */
int *flagPtr, /* Flag to mark. */
int value) /* Value of mark. */
{
diff --git a/unix/tclKqueueNotfy.c b/unix/tclKqueueNotfy.c
index ba49842..b58ab41 100644
--- a/unix/tclKqueueNotfy.c
+++ b/unix/tclKqueueNotfy.c
@@ -40,7 +40,7 @@ typedef struct FileHandler {
* for this file. */
Tcl_FileProc *proc; /* Function to call, in the style of
* Tcl_CreateFileHandler. */
- void *clientData; /* Argument to pass to proc. */
+ void *clientData; /* Argument to pass to proc. */
struct FileHandler *nextPtr;/* Next in list of all files we care about. */
LIST_ENTRY(FileHandler) readyNode;
/* Next/previous in list of FileHandlers asso-
@@ -517,7 +517,7 @@ TclpCreateFileHandler(
* called. */
Tcl_FileProc *proc, /* Function to call for each selected
* event. */
- void *clientData) /* Arbitrary data to pass to proc. */
+ void *clientData) /* Arbitrary data to pass to proc. */
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
FileHandler *filePtr = LookUpFileHandler(tsdPtr, fd, NULL);
@@ -786,7 +786,7 @@ int
TclAsyncNotifier(
int sigNumber, /* Signal number. */
Tcl_ThreadId threadId, /* Target thread. */
- void *clientData, /* Notifier data. */
+ void *clientData, /* Notifier data. */
int *flagPtr, /* Flag to mark. */
int value) /* Value of mark. */
{
diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c
index 54290ec..e0d8c53 100644
--- a/unix/tclLoadDyld.c
+++ b/unix/tclLoadDyld.c
@@ -148,7 +148,7 @@ TclpDlopen(
Tcl_Interp *interp, /* Used for error reporting. */
Tcl_Obj *pathPtr, /* Name of the file containing the desired
* code (UTF-8). */
- Tcl_LoadHandle *loadHandle, /* Filled with token for dynamically loaded
+ Tcl_LoadHandle *loadHandle, /* Filled with token for dynamically loaded
* file which will be passed back to
* (*unloadProcPtr)() to unload the file. */
Tcl_FSUnloadFileProc **unloadProcPtr,
@@ -548,7 +548,7 @@ TclpLoadMemory(
int codeSize, /* Size of code data read into buffer or -1 if
* an error occurred and the buffer should
* just be freed. */
- Tcl_LoadHandle *loadHandle, /* Filled with token for dynamically loaded
+ Tcl_LoadHandle *loadHandle, /* Filled with token for dynamically loaded
* file which will be passed back to
* (*unloadProcPtr)() to unload the file. */
Tcl_FSUnloadFileProc **unloadProcPtr,
diff --git a/unix/tclLoadNext.c b/unix/tclLoadNext.c
index de185fb..fc10162 100644
--- a/unix/tclLoadNext.c
+++ b/unix/tclLoadNext.c
@@ -61,7 +61,7 @@ TclpDlopen(
const char *native;
int result = 1;
- NXStream *errorStream = NXOpenMemory(0,0,NX_READWRITE);
+ NXStream *errorStream = NXOpenMemory(0, 0, NX_READWRITE);
fileName = TclGetString(pathPtr);
@@ -72,7 +72,7 @@ TclpDlopen(
*/
native = Tcl_FSGetNativePath(pathPtr);
- files = {native,NULL};
+ files = {native, NULL};
result = rld_load(errorStream, &header, files, NULL);
@@ -90,7 +90,7 @@ TclpDlopen(
return TCL_ERROR;
}
native = Tcl_DStringValue(&ds);
- files = {native,NULL};
+ files = {native, NULL};
result = rld_load(errorStream, &header, files, NULL);
Tcl_DStringFree(&ds);
}
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/tclSelectNotfy.c b/unix/tclSelectNotfy.c
index bede898..7c74dfc 100644
--- a/unix/tclSelectNotfy.c
+++ b/unix/tclSelectNotfy.c
@@ -32,7 +32,7 @@ typedef struct FileHandler {
* for this file. */
Tcl_FileProc *proc; /* Function to call, in the style of
* Tcl_CreateFileHandler. */
- void *clientData; /* Argument to pass to proc. */
+ void *clientData; /* Argument to pass to proc. */
struct FileHandler *nextPtr;/* Next in list of all files we care about. */
} FileHandler;
@@ -480,7 +480,7 @@ TclpCreateFileHandler(
* called. */
Tcl_FileProc *proc, /* Function to call for each selected
* event. */
- void *clientData) /* Arbitrary data to pass to proc. */
+ void *clientData) /* Arbitrary data to pass to proc. */
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
FileHandler *filePtr = LookUpFileHandler(tsdPtr, fd, NULL);
@@ -921,7 +921,7 @@ int
TclAsyncNotifier(
int sigNumber, /* Signal number. */
TCL_UNUSED(Tcl_ThreadId), /* Target thread. */
- TCL_UNUSED(void *), /* Notifier data. */
+ TCL_UNUSED(void *), /* Notifier data. */
int *flagPtr, /* Flag to mark. */
int value) /* Value of mark. */
{
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 3f972ae..c04c4fa 100644
--- a/unix/tclUnixChan.c
+++ b/unix/tclUnixChan.c
@@ -30,7 +30,7 @@
# elif defined(FIORDCHK)
# define GETREADQUEUE(fd, int) int = ioctl((fd), FIORDCHK, NULL)
# else
-# define GETREADQUEUE(fd, int) int = 0
+# define GETREADQUEUE(fd, int) int = 0
# endif
# ifdef TIOCOUTQ
@@ -162,10 +162,10 @@ static int TtySetOptionProc(void *instanceData,
static const Tcl_ChannelType fileChannelType = {
"file", /* Type name. */
TCL_CHANNEL_VERSION_5, /* v5 channel */
- NULL, /* Close proc. */
+ NULL, /* Close proc. */
FileInputProc, /* Input proc. */
FileOutputProc, /* Output proc. */
- NULL,
+ NULL,
NULL, /* Set option proc. */
FileGetOptionProc, /* Get option proc. */
FileWatchProc, /* Initialize notifier. */
@@ -188,7 +188,7 @@ static const Tcl_ChannelType fileChannelType = {
static const Tcl_ChannelType ttyChannelType = {
"tty", /* Type name. */
TCL_CHANNEL_VERSION_5, /* v5 channel */
- NULL, /* Close proc. */
+ NULL,
FileInputProc, /* Input proc. */
FileOutputProc, /* Output proc. */
NULL, /* Seek proc. */
@@ -196,7 +196,7 @@ static const Tcl_ChannelType ttyChannelType = {
TtyGetOptionProc, /* Get option proc. */
FileWatchProc, /* Initialize notifier. */
FileGetHandleProc, /* Get OS handles out of channel. */
- TtyCloseProc, /* close2proc. */
+ TtyCloseProc, /* New-style close proc. */
FileBlockModeProc, /* Set blocking or non-blocking mode.*/
NULL, /* flush proc. */
NULL, /* handler proc. */
@@ -225,7 +225,7 @@ static const Tcl_ChannelType ttyChannelType = {
static int
FileBlockModeProc(
- void *instanceData, /* File state. */
+ void *instanceData, /* File state. */
int mode) /* The mode to set. Can be TCL_MODE_BLOCKING
* or TCL_MODE_NONBLOCKING. */
{
@@ -258,7 +258,7 @@ FileBlockModeProc(
static int
FileInputProc(
- void *instanceData, /* File state. */
+ void *instanceData, /* File state. */
char *buf, /* Where to store data read. */
int toRead, /* How much space is available in the
* buffer? */
@@ -308,7 +308,7 @@ FileInputProc(
static int
FileOutputProc(
- void *instanceData, /* File state. */
+ void *instanceData, /* File state. */
const char *buf, /* The data buffer. */
int toWrite, /* How many bytes to write? */
int *errorCodePtr) /* Where to store error code. */
@@ -355,7 +355,7 @@ FileOutputProc(
static int
FileCloseProc(
- void *instanceData, /* File state. */
+ void *instanceData, /* File state. */
TCL_UNUSED(Tcl_Interp *),
int flags)
{
@@ -448,7 +448,7 @@ TtyCloseProc(
static long long
FileWideSeekProc(
- void *instanceData, /* File state. */
+ void *instanceData, /* File state. */
long long offset, /* Offset to seek to. */
int mode, /* Relative to where should we seek? Can be
* one of SEEK_START, SEEK_CUR or SEEK_END. */
@@ -496,7 +496,7 @@ FileWatchNotifyChannelWrapper(
static void
FileWatchProc(
- void *instanceData, /* The file state. */
+ void *instanceData, /* The file state. */
int mask) /* Events of interest; an OR-ed combination of
* TCL_READABLE, TCL_WRITABLE and
* TCL_EXCEPTION. */
@@ -536,9 +536,9 @@ FileWatchProc(
static int
FileGetHandleProc(
- void *instanceData, /* The file state. */
+ void *instanceData, /* The file state. */
int direction, /* TCL_READABLE or TCL_WRITABLE */
- void **handlePtr) /* Where to store the handle. */
+ void **handlePtr) /* Where to store the handle. */
{
FileState *fsPtr = (FileState *)instanceData;
@@ -773,7 +773,7 @@ TtyModemStatusStr(
static int
TtySetOptionProc(
- void *instanceData, /* File state. */
+ void *instanceData, /* File state. */
Tcl_Interp *interp, /* For error reporting - can be NULL. */
const char *optionName, /* Which option to set? */
const char *value) /* New value for option. */
@@ -1113,7 +1113,7 @@ TtySetOptionProc(
static int
TtyGetOptionProc(
- void *instanceData, /* File state. */
+ void *instanceData, /* File state. */
Tcl_Interp *interp, /* For error reporting - can be NULL. */
const char *optionName, /* Option to get. */
Tcl_DString *dsPtr) /* Where to store value(s). */
@@ -1654,11 +1654,11 @@ TtyParseMode(
if (
#if defined(PAREXT)
- strchr("noems", parity)
+ strchr("noems", parity)
#else
- strchr("noe", parity)
+ strchr("noe", parity)
#endif /* PAREXT */
- == NULL) {
+ == NULL) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"%s parity: should be %s", bad,
@@ -2069,7 +2069,7 @@ Tcl_GetOpenFile(
* Ignored, we always check that
* the channel is open for the requested
* mode. */
- void **filePtr) /* Store pointer to FILE structure here. */
+ void **filePtr) /* Store pointer to FILE structure here. */
{
Tcl_Channel chan;
int chanMode, fd;
diff --git a/unix/tclUnixCompat.c b/unix/tclUnixCompat.c
index 30ddb71..8b6a421 100644
--- a/unix/tclUnixCompat.c
+++ b/unix/tclUnixCompat.c
@@ -164,14 +164,14 @@ TclUnixSetBlockingMode(
*
* TclpGetPwNam --
*
- * Thread-safe wrappers for getpwnam(). See "man getpwnam" for more
- * details.
+ * Thread-safe wrappers for getpwnam(). See "man getpwnam" for more
+ * details.
*
* Results:
- * Pointer to struct passwd on success or NULL on error.
+ * Pointer to struct passwd on success or NULL on error.
*
* Side effects:
- * None.
+ * None.
*
*---------------------------------------------------------------------------
*/
@@ -244,14 +244,14 @@ TclpGetPwNam(
*
* TclpGetPwUid --
*
- * Thread-safe wrappers for getpwuid(). See "man getpwuid" for more
- * details.
+ * Thread-safe wrappers for getpwuid(). See "man getpwuid" for more
+ * details.
*
* Results:
- * Pointer to struct passwd on success or NULL on error.
+ * Pointer to struct passwd on success or NULL on error.
*
* Side effects:
- * None.
+ * None.
*
*---------------------------------------------------------------------------
*/
@@ -347,14 +347,14 @@ FreePwBuf(
*
* TclpGetGrNam --
*
- * Thread-safe wrappers for getgrnam(). See "man getgrnam" for more
- * details.
+ * Thread-safe wrappers for getgrnam(). See "man getgrnam" for more
+ * details.
*
* Results:
- * Pointer to struct group on success or NULL on error.
+ * Pointer to struct group on success or NULL on error.
*
* Side effects:
- * None.
+ * None.
*
*---------------------------------------------------------------------------
*/
@@ -427,14 +427,14 @@ TclpGetGrNam(
*
* TclpGetGrGid --
*
- * Thread-safe wrappers for getgrgid(). See "man getgrgid" for more
- * details.
+ * Thread-safe wrappers for getgrgid(). See "man getgrgid" for more
+ * details.
*
* Results:
- * Pointer to struct group on success or NULL on error.
+ * Pointer to struct group on success or NULL on error.
*
* Side effects:
- * None.
+ * None.
*
*---------------------------------------------------------------------------
*/
@@ -530,14 +530,14 @@ FreeGrBuf(
*
* TclpGetHostByName --
*
- * Thread-safe wrappers for gethostbyname(). See "man gethostbyname" for
- * more details.
+ * Thread-safe wrappers for gethostbyname(). See "man gethostbyname" for
+ * more details.
*
* Results:
- * Pointer to struct hostent on success or NULL on error.
+ * Pointer to struct hostent on success or NULL on error.
*
* Side effects:
- * None.
+ * None.
*
*---------------------------------------------------------------------------
*/
@@ -598,14 +598,14 @@ TclpGetHostByName(
*
* TclpGetHostByAddr --
*
- * Thread-safe wrappers for gethostbyaddr(). See "man gethostbyaddr" for
- * more details.
+ * Thread-safe wrappers for gethostbyaddr(). See "man gethostbyaddr" for
+ * more details.
*
* Results:
- * Pointer to struct hostent on success or NULL on error.
+ * Pointer to struct hostent on success or NULL on error.
*
* Side effects:
- * None.
+ * None.
*
*---------------------------------------------------------------------------
*/
@@ -661,14 +661,14 @@ TclpGetHostByAddr(
*
* CopyGrp --
*
- * Copies string fields of the group structure to the private buffer,
- * honouring the size of the buffer.
+ * Copies string fields of the group structure to the private buffer,
+ * honouring the size of the buffer.
*
* Results:
- * 0 on success or -1 on error (errno = ERANGE).
+ * 0 on success or -1 on error (errno = ERANGE).
*
* Side effects:
- * None.
+ * None.
*
*---------------------------------------------------------------------------
*/
@@ -734,14 +734,14 @@ CopyGrp(
*
* CopyHostent --
*
- * Copies string fields of the hostent structure to the private buffer,
- * honouring the size of the buffer.
+ * Copies string fields of the hostent structure to the private buffer,
+ * honouring the size of the buffer.
*
* Results:
- * Number of bytes copied on success or -1 on error (errno = ERANGE)
+ * Number of bytes copied on success or -1 on error (errno = ERANGE)
*
* Side effects:
- * None
+ * None
*
*---------------------------------------------------------------------------
*/
@@ -796,15 +796,15 @@ CopyHostent(
*
* CopyPwd --
*
- * Copies string fields of the passwd structure to the private buffer,
- * honouring the size of the buffer.
+ * Copies string fields of the passwd structure to the private buffer,
+ * honouring the size of the buffer.
*
* Results:
- * 0 on success or -1 on error (errno = ERANGE).
+ * 0 on success or -1 on error (errno = ERANGE).
*
* Side effects:
- * We are not copying the gecos field as it may not be supported on all
- * platforms.
+ * We are not copying the gecos field as it may not be supported on all
+ * platforms.
*
*---------------------------------------------------------------------------
*/
@@ -862,14 +862,14 @@ CopyPwd(
*
* CopyArray --
*
- * Copies array of NULL-terminated or fixed-length strings to the private
- * buffer, honouring the size of the buffer.
+ * Copies array of NULL-terminated or fixed-length strings to the private
+ * buffer, honouring the size of the buffer.
*
* Results:
- * Number of bytes copied on success or -1 on error (errno = ERANGE)
+ * Number of bytes copied on success or -1 on error (errno = ERANGE)
*
* Side effects:
- * None.
+ * None.
*
*---------------------------------------------------------------------------
*/
@@ -926,14 +926,14 @@ CopyArray(
*
* CopyString --
*
- * Copies a NULL-terminated string to the private buffer, honouring the
- * size of the buffer
+ * Copies a NULL-terminated string to the private buffer, honouring the
+ * size of the buffer
*
* Results:
- * 0 success or -1 on error (errno = ERANGE)
+ * 0 success or -1 on error (errno = ERANGE)
*
* Side effects:
- * None
+ * None
*
*---------------------------------------------------------------------------
*/
@@ -986,25 +986,27 @@ CopyString(
int
TclWinCPUID(
- int index, /* Which CPUID value to retrieve. */
- int *regsPtr) /* Registers after the CPUID. */
+ int index, /* Which CPUID value to retrieve. */
+ int *regsPtr) /* Registers after the CPUID. */
{
int status = TCL_ERROR;
/* 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));
+ __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));
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));
+ __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));
status = TCL_OK;
#else
(void)index;
diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c
index b65cdb1..b9348aa 100644
--- a/unix/tclUnixFCmd.c
+++ b/unix/tclUnixFCmd.c
@@ -14,7 +14,7 @@
* following copyright notice:
*
* Copyright © 1988, 1993, 1994
- * The Regents of the University of California. All rights reserved.
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -757,7 +757,7 @@ TclpObjCopyDirectory(
int ret;
Tcl_Obj *transPtr;
- transPtr = Tcl_FSGetTranslatedPath(NULL,srcPathPtr);
+ transPtr = Tcl_FSGetTranslatedPath(NULL, srcPathPtr);
ret = Tcl_UtfToExternalDStringEx(NULL, NULL,
(transPtr != NULL ? TclGetString(transPtr) : NULL),
-1, 0, &srcString, NULL);
@@ -767,7 +767,7 @@ TclpObjCopyDirectory(
if (ret != TCL_OK) {
*errorPtr = srcPathPtr;
} else {
- transPtr = Tcl_FSGetTranslatedPath(NULL,destPathPtr);
+ transPtr = Tcl_FSGetTranslatedPath(NULL, destPathPtr);
ret = Tcl_UtfToExternalDStringEx(NULL, NULL,
(transPtr != NULL ? TclGetString(transPtr) : NULL),
-1, TCL_ENCODING_PROFILE_TCL8, &dstString, NULL);
@@ -1292,7 +1292,7 @@ TraversalDelete(
static int
CopyFileAtts(
#ifdef MAC_OSX_TCL
- const char *src, /* Path name of source file (native). */
+ const char *src, /* Path name of source file (native). */
#else
TCL_UNUSED(const char *) /*src*/,
#endif
@@ -1766,14 +1766,14 @@ TclpObjListVolumes(void)
static int
GetModeFromPermString(
TCL_UNUSED(Tcl_Interp *),
- const char *modeStringPtr, /* Permissions string */
+ const char *modeStringPtr, /* Permissions string */
mode_t *modePtr) /* pointer to the mode value */
{
mode_t newMode;
mode_t oldMode; /* Storage for the value of the old mode (that
* is passed in), to allow for the chmod style
* manipulation. */
- int i,n, who, op, what, op_found, who_found;
+ int i, n, who, op, what, op_found, who_found;
/*
* We start off checking for an "rwxrwxrwx" style permissions string
@@ -2075,7 +2075,7 @@ TclpObjNormalizePath(
return 0;
}
- if (Tcl_UtfToExternalDStringEx(interp, NULL, path,nextCheckpoint, 0, &ds, NULL)) {
+ if (Tcl_UtfToExternalDStringEx(interp, NULL, path, nextCheckpoint, 0, &ds, NULL)) {
Tcl_DStringFree(&ds);
return -1;
}
@@ -2488,10 +2488,10 @@ GetUnixFileAttributes(
static int
SetUnixFileAttributes(
- Tcl_Interp *interp, /* The interp we are using for errors. */
- int objIndex, /* The index of the attribute. */
- Tcl_Obj *fileName, /* The name of the file (UTF-8). */
- Tcl_Obj *attributePtr) /* The attribute to set. */
+ Tcl_Interp *interp, /* The interp we are using for errors. */
+ int objIndex, /* The index of the attribute. */
+ Tcl_Obj *fileName, /* The name of the file (UTF-8). */
+ Tcl_Obj *attributePtr) /* The attribute to set. */
{
int yesNo, fileAttributes, old;
WCHAR *winPath;
diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c
index 444c73f..95a0d9e 100644
--- a/unix/tclUnixFile.c
+++ b/unix/tclUnixFile.c
@@ -155,9 +155,11 @@ TclpFindExecutable(
#endif
{
encoding = Tcl_GetEncoding(NULL, NULL);
- Tcl_ExternalToUtfDStringEx(NULL, encoding, name, TCL_INDEX_NONE, TCL_ENCODING_PROFILE_TCL8, &utfName, NULL);
+ Tcl_ExternalToUtfDStringEx(NULL, encoding, name, TCL_INDEX_NONE,
+ TCL_ENCODING_PROFILE_TCL8, &utfName, NULL);
TclSetObjNameOfExecutable(
- Tcl_NewStringObj(Tcl_DStringValue(&utfName), TCL_INDEX_NONE), encoding);
+ Tcl_NewStringObj(Tcl_DStringValue(&utfName), TCL_INDEX_NONE),
+ encoding);
Tcl_DStringFree(&utfName);
goto done;
}
@@ -192,10 +194,11 @@ TclpFindExecutable(
Tcl_DStringFree(&nameString);
encoding = Tcl_GetEncoding(NULL, NULL);
- Tcl_ExternalToUtfDStringEx(NULL, encoding, Tcl_DStringValue(&buffer), TCL_INDEX_NONE,
- TCL_ENCODING_PROFILE_TCL8, &utfName, NULL);
+ Tcl_ExternalToUtfDStringEx(NULL, encoding, Tcl_DStringValue(&buffer),
+ TCL_INDEX_NONE, TCL_ENCODING_PROFILE_TCL8, &utfName, NULL);
TclSetObjNameOfExecutable(
- Tcl_NewStringObj(Tcl_DStringValue(&utfName), TCL_INDEX_NONE), encoding);
+ Tcl_NewStringObj(Tcl_DStringValue(&utfName), TCL_INDEX_NONE),
+ encoding);
Tcl_DStringFree(&utfName);
done:
@@ -308,7 +311,8 @@ TclpMatchInDirectory(
* Now open the directory for reading and iterate over the contents.
*/
- if (Tcl_UtfToExternalDStringEx(interp, NULL, dirName, TCL_INDEX_NONE, 0, &ds, NULL) != TCL_OK) {
+ if (Tcl_UtfToExternalDStringEx(interp, NULL, dirName, TCL_INDEX_NONE,
+ 0, &ds, NULL) != TCL_OK) {
Tcl_DStringFree(&dsOrig);
Tcl_DStringFree(&ds);
Tcl_DecrRefCount(fileNamePtr);
@@ -324,7 +328,7 @@ TclpMatchInDirectory(
return TCL_OK;
}
- d = TclOSopendir(native); /* INTL: Native. */
+ d = TclOSopendir(native); /* INTL: Native. */
if (d == NULL) {
Tcl_DStringFree(&ds);
if (interp != NULL) {
@@ -378,8 +382,8 @@ TclpMatchInDirectory(
* and pattern. If so, add the file to the result.
*/
- if (Tcl_ExternalToUtfDStringEx(interp, NULL, entryPtr->d_name, TCL_INDEX_NONE,
- 0, &utfDs, NULL) != TCL_OK) {
+ if (Tcl_ExternalToUtfDStringEx(interp, NULL, entryPtr->d_name,
+ TCL_INDEX_NONE, 0, &utfDs, NULL) != TCL_OK) {
matchResult = -1;
break;
}
@@ -389,7 +393,8 @@ TclpMatchInDirectory(
if (types != NULL) {
Tcl_DStringSetLength(&ds, nativeDirLen);
- native = Tcl_DStringAppend(&ds, entryPtr->d_name, TCL_INDEX_NONE);
+ native = Tcl_DStringAppend(&ds, entryPtr->d_name,
+ TCL_INDEX_NONE);
matchResult = NativeMatchType(interp, native,
entryPtr->d_name, types);
typeOk = (matchResult == 1);
@@ -438,10 +443,10 @@ TclpMatchInDirectory(
static int
NativeMatchType(
- Tcl_Interp *interp, /* Interpreter to receive errors. */
- const char *nativeEntry, /* Native path to check. */
- const char *nativeName, /* Native filename to check. */
- Tcl_GlobTypeData *types) /* Type description to match against. */
+ Tcl_Interp *interp, /* Interpreter to receive errors. */
+ const char *nativeEntry, /* Native path to check. */
+ const char *nativeName, /* Native filename to check. */
+ Tcl_GlobTypeData *types) /* Type description to match against. */
{
Tcl_StatBuf buf;
@@ -611,7 +616,8 @@ TclpGetUserHome(
Tcl_DString ds;
const char *native;
- if (Tcl_UtfToExternalDStringEx(NULL, NULL, name, TCL_INDEX_NONE, 0, &ds, NULL) != TCL_OK) {
+ if (Tcl_UtfToExternalDStringEx(NULL, NULL, name, TCL_INDEX_NONE, 0, &ds,
+ NULL) != TCL_OK) {
Tcl_DStringFree(&ds);
return NULL;
}
@@ -623,7 +629,8 @@ TclpGetUserHome(
if (pwPtr == NULL) {
return NULL;
}
- if (Tcl_ExternalToUtfDStringEx(NULL, NULL, pwPtr->pw_dir, TCL_INDEX_NONE, 0, bufferPtr, NULL) != TCL_OK) {
+ if (Tcl_ExternalToUtfDStringEx(NULL, NULL, pwPtr->pw_dir, TCL_INDEX_NONE,
+ 0, bufferPtr, NULL) != TCL_OK) {
return NULL;
} else {
return Tcl_DStringValue(bufferPtr);
@@ -805,7 +812,8 @@ TclpGetCwd(
}
return NULL;
}
- if (Tcl_ExternalToUtfDStringEx(interp, NULL, buffer, TCL_INDEX_NONE, 0, bufferPtr, NULL) != TCL_OK) {
+ if (Tcl_ExternalToUtfDStringEx(interp, NULL, buffer, TCL_INDEX_NONE, 0,
+ bufferPtr, NULL) != TCL_OK) {
return NULL;
}
return Tcl_DStringValue(bufferPtr);
@@ -843,7 +851,8 @@ TclpReadlink(
const char *native;
Tcl_DString ds;
- if (Tcl_UtfToExternalDStringEx(NULL, NULL, path, TCL_INDEX_NONE, 0, &ds, NULL) != TCL_OK) {
+ if (Tcl_UtfToExternalDStringEx(NULL, NULL, path, TCL_INDEX_NONE, 0, &ds,
+ NULL) != TCL_OK) {
Tcl_DStringFree(&ds);
return NULL;
}
@@ -855,7 +864,8 @@ TclpReadlink(
return NULL;
}
- if (Tcl_ExternalToUtfDStringEx(NULL, NULL, link, length, 0, linkPtr, NULL) == TCL_OK) {
+ if (Tcl_ExternalToUtfDStringEx(NULL, NULL, link, length, 0, linkPtr,
+ NULL) == TCL_OK) {
return Tcl_DStringValue(linkPtr);
}
#endif /* !DJGPP */
@@ -990,7 +1000,8 @@ TclpObjLink(
return NULL;
}
target = TclGetStringFromObj(transPtr, &length);
- if (Tcl_UtfToExternalDStringEx(NULL, NULL, target, length, 0, &ds, NULL) != TCL_OK) {
+ if (Tcl_UtfToExternalDStringEx(NULL, NULL, target, length, 0, &ds,
+ NULL) != TCL_OK) {
Tcl_DStringFree(&ds);
return NULL;
}
@@ -1024,12 +1035,14 @@ TclpObjLink(
}
Tcl_DecrRefCount(transPtr);
- length = readlink((const char *)Tcl_FSGetNativePath(pathPtr), link, sizeof(link));
+ length = readlink((const char *)Tcl_FSGetNativePath(pathPtr), link,
+ sizeof(link));
if (length < 0) {
return NULL;
}
- if (Tcl_ExternalToUtfDStringEx(NULL, NULL, link, (size_t)length, 0, &ds, NULL) != TCL_OK) {
+ if (Tcl_ExternalToUtfDStringEx(NULL, NULL, link, (size_t)length, 0,
+ &ds, NULL) != TCL_OK) {
return NULL;
}
linkPtr = Tcl_DStringToObj(&ds);
@@ -1096,7 +1109,8 @@ TclpNativeToNormalized(
{
Tcl_DString ds;
- Tcl_ExternalToUtfDStringEx(NULL, NULL, (const char *) clientData, TCL_INDEX_NONE, TCL_ENCODING_PROFILE_TCL8, &ds, NULL);
+ Tcl_ExternalToUtfDStringEx(NULL, NULL, (const char *) clientData,
+ TCL_INDEX_NONE, TCL_ENCODING_PROFILE_TCL8, &ds, NULL);
return Tcl_DStringToObj(&ds);
}
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c
index 81e3af5..ac743cc 100644
--- a/unix/tclUnixInit.c
+++ b/unix/tclUnixInit.c
@@ -54,21 +54,21 @@ 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;
+ unsigned int dwPageSize;
void *lpMinimumApplicationAddress;
void *lpMaximumApplicationAddress;
void *dwActiveProcessorMask;
- unsigned int dwNumberOfProcessors;
- unsigned int dwProcessorType;
- unsigned int dwAllocationGranularity;
- int wProcessorLevel;
- int wProcessorRevision;
+ unsigned int dwNumberOfProcessors;
+ unsigned int dwProcessorType;
+ unsigned int dwAllocationGranularity;
+ int wProcessorLevel;
+ int wProcessorRevision;
} SYSTEM_INFO;
typedef struct {
@@ -852,23 +852,25 @@ TclpSetVariables(
#endif /* HAVE_COREFOUNDATION */
p = pkgPath;
while ((q = strchr(p, ':')) != NULL) {
- Tcl_ListObjAppendElement(NULL, pkgListObj, Tcl_NewStringObj(p, q-p));
- p = q+1;
+ Tcl_ListObjAppendElement(NULL, pkgListObj, Tcl_NewStringObj(p, q - p));
+ p = q + 1;
}
if (*p) {
Tcl_ListObjAppendElement(NULL, pkgListObj, Tcl_NewStringObj(p, -1));
}
- Tcl_ObjSetVar2(interp, Tcl_NewStringObj("tcl_pkgPath", -1), NULL, pkgListObj, TCL_GLOBAL_ONLY);
+ 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
@@ -897,7 +899,8 @@ TclpSetVariables(
osInfo.dwMajorVersion = 11;
}
Tcl_SetVar2(interp, "tcl_platform", "os", "Windows NT", TCL_GLOBAL_ONLY);
- snprintf(buffer, sizeof(buffer), "%d.%d", osInfo.dwMajorVersion, osInfo.dwMinorVersion);
+ snprintf(buffer, sizeof(buffer), "%d.%d",
+ osInfo.dwMajorVersion, osInfo.dwMinorVersion);
Tcl_SetVar2(interp, "tcl_platform", "osVersion", buffer, TCL_GLOBAL_ONLY);
if (sysInfo.wProcessorArchitecture < NUMPROCESSORS) {
Tcl_SetVar2(interp, "tcl_platform", "machine",
@@ -987,7 +990,7 @@ TclpSetVariables(
* Define what the platform PATH separator is. [TIP #315]
*/
- Tcl_SetVar2(interp, "tcl_platform","pathSeparator", ":", TCL_GLOBAL_ONLY);
+ Tcl_SetVar2(interp, "tcl_platform", "pathSeparator", ":", TCL_GLOBAL_ONLY);
}
/*
diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c
index 939ec85..e0b8753 100644
--- a/unix/tclUnixPipe.c
+++ b/unix/tclUnixPipe.c
@@ -80,7 +80,7 @@ static int SetupStdFile(TclFile file, int type);
static const Tcl_ChannelType pipeChannelType = {
"pipe", /* Type name. */
TCL_CHANNEL_VERSION_5, /* v5 channel */
- NULL, /* Close proc. */
+ NULL, /* Close proc. */
PipeInputProc, /* Input proc. */
PipeOutputProc, /* Output proc. */
NULL, /* Seek proc. */
@@ -356,7 +356,7 @@ TclpCreatePipe(
int
TclpCloseFile(
- TclFile file) /* The file to close. */
+ TclFile file) /* The file to close. */
{
int fd = GetFd(file);
@@ -401,7 +401,7 @@ TclpCreateProcess(
* occurred when creating the child process.
* Error messages from the child process
* itself are sent to errorFile. */
- size_t argc, /* Number of arguments in following array. */
+ size_t argc, /* Number of arguments in following array. */
const char **argv, /* Array of argument strings in UTF-8.
* argv[0] contains the name of the executable
* translated using Tcl_TranslateFileName
@@ -572,7 +572,7 @@ TclpCreateProcess(
|| !SetupStdFile(outputFile, TCL_STDOUT)
|| (!joinThisError && !SetupStdFile(errorFile, TCL_STDERR))
|| (joinThisError &&
- ((dup2(1,2) == -1) || (fcntl(2, F_SETFD, 0) != 0)))) {
+ ((dup2(1, 2) == -1) || (fcntl(2, F_SETFD, 0) != 0)))) {
snprintf(errSpace, sizeof(errSpace),
"%dforked process couldn't set up input/output", errno);
len = strlen(errSpace);
@@ -1003,7 +1003,7 @@ TclGetAndDetachPids(
static int
PipeBlockModeProc(
- void *instanceData, /* Pipe state. */
+ void *instanceData, /* Pipe state. */
int mode) /* The mode to set. Can be one of
* TCL_MODE_BLOCKING or
* TCL_MODE_NONBLOCKING. */
@@ -1043,7 +1043,7 @@ PipeBlockModeProc(
static int
PipeClose2Proc(
- void *instanceData, /* The pipe to close. */
+ void *instanceData, /* The pipe to close. */
Tcl_Interp *interp, /* For error reporting. */
int flags) /* Flags that indicate which side to close. */
{
@@ -1140,7 +1140,7 @@ PipeClose2Proc(
static int
PipeInputProc(
- void *instanceData, /* Pipe state. */
+ void *instanceData, /* Pipe state. */
char *buf, /* Where to store data read. */
int toRead, /* How much space is available in the
* buffer? */
@@ -1191,7 +1191,7 @@ PipeInputProc(
static int
PipeOutputProc(
- void *instanceData, /* Pipe state. */
+ void *instanceData, /* Pipe state. */
const char *buf, /* The data buffer. */
int toWrite, /* How many bytes to write? */
int *errorCodePtr) /* Where to store error code. */
@@ -1250,7 +1250,7 @@ PipeWatchNotifyChannelWrapper(
static void
PipeWatchProc(
- void *instanceData, /* The pipe state. */
+ void *instanceData, /* The pipe state. */
int mask) /* Events of interest; an OR-ed combination of
* TCL_READABLE, TCL_WRITABLE and
* TCL_EXCEPTION. */
@@ -1298,9 +1298,9 @@ PipeWatchProc(
static int
PipeGetHandleProc(
- void *instanceData, /* The pipe state. */
+ void *instanceData, /* The pipe state. */
int direction, /* TCL_READABLE or TCL_WRITABLE */
- void **handlePtr) /* Where to store the handle. */
+ void **handlePtr) /* Where to store the handle. */
{
PipeState *psPtr = (PipeState *)instanceData;
diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h
index 513ffdd..94af19b 100644
--- a/unix/tclUnixPort.h
+++ b/unix/tclUnixPort.h
@@ -236,7 +236,7 @@ MODULE_SCOPE int TclUnixSetBlockingMode(int fd, int mode);
#ifndef WIFSIGNALED
# define WIFSIGNALED(stat) \
- (((*((int *) &(stat)))) && ((*((int *) &(stat))) \
+ (((*((int *) &(stat)))) && ((*((int *) &(stat))) \
== ((*((int *) &(stat))) & 0x00FF)))
#endif
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 78ed008..14be638 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -23,8 +23,8 @@
#define GOT_BITS(var, bits) (((var) & (bits)) != 0)
/* "sock" + a pointer in hex + \0 */
-#define SOCK_CHAN_LENGTH (4 + sizeof(void *) * 2 + 1)
-#define SOCK_TEMPLATE "sock%" TCL_Z_MODIFIER "x"
+#define SOCK_CHAN_LENGTH (4 + sizeof(void *) * 2 + 1)
+#define SOCK_TEMPLATE "sock%" TCL_Z_MODIFIER "x"
#undef SOCKET /* Possible conflict with win32 SOCKET */
@@ -64,8 +64,8 @@ struct TcpState {
*/
Tcl_TcpAcceptProc *acceptProc;
- /* Proc to call on accept. */
- void *acceptProcData; /* The data for the accept proc. */
+ /* Proc to call on accept. */
+ void *acceptProcData; /* The data for the accept proc. */
/*
* Only needed for client sockets
@@ -75,10 +75,10 @@ struct TcpState {
struct addrinfo *addr; /* Iterator over addrlist. */
struct addrinfo *myaddrlist;/* Local address. */
struct addrinfo *myaddr; /* Iterator over myaddrlist. */
- int filehandlers; /* Caches FileHandlers that get set up while
- * an async socket is not yet connected. */
- int connectError; /* Cache SO_ERROR of async socket. */
- int cachedBlocking; /* Cache blocking mode of async socket. */
+ int filehandlers; /* Caches FileHandlers that get set up while
+ * an async socket is not yet connected. */
+ int connectError; /* Cache SO_ERROR of async socket. */
+ int cachedBlocking; /* Cache blocking mode of async socket. */
};
/*
@@ -156,7 +156,7 @@ static Tcl_FileProc WrapNotify;
static const Tcl_ChannelType tcpChannelType = {
"tcp", /* Type name. */
TCL_CHANNEL_VERSION_5, /* v5 channel */
- NULL, /* Close proc. */
+ NULL, /* Close proc. */
TcpInputProc, /* Input proc. */
TcpOutputProc, /* Output proc. */
NULL, /* Seek proc. */
@@ -195,7 +195,7 @@ printaddrinfo(
getnameinfo(ai->ai_addr, ai->ai_addrlen,
host, sizeof(host), port, sizeof(port),
NI_NUMERICHOST|NI_NUMERICSERV);
- fprintf(stderr,"%s: %s:%s\n", prefix, host, port);
+ fprintf(stderr, "%s: %s:%s\n", prefix, host, port);
}
}
#endif
@@ -227,7 +227,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 +246,11 @@ InitializeHostName(
Tcl_Free(node);
}
}
- if (hp != NULL) {
+ if (hp != NULL) {
native = hp->h_name;
- } else {
+ } else {
native = u.nodename;
- }
+ }
}
#else /* !NO_UNAME */
/*
@@ -357,7 +357,7 @@ TclpFinalizeSockets(void)
static int
TcpBlockModeProc(
- void *instanceData, /* Socket state. */
+ void *instanceData, /* Socket state. */
int mode) /* The mode to set. Can be one of
* TCL_MODE_BLOCKING or
* TCL_MODE_NONBLOCKING. */
@@ -370,8 +370,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 +443,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;
}
@@ -502,7 +502,7 @@ WaitForConnect(
static int
TcpInputProc(
- void *instanceData, /* Socket state. */
+ void *instanceData, /* Socket state. */
char *buf, /* Where to store data read. */
int bufSize, /* How much space is available in the
* buffer? */
@@ -553,7 +553,7 @@ TcpInputProc(
static int
TcpOutputProc(
- void *instanceData, /* Socket state. */
+ void *instanceData, /* Socket state. */
const char *buf, /* The data buffer. */
int toWrite, /* How many bytes to write? */
int *errorCodePtr) /* Where to store error code. */
@@ -594,7 +594,7 @@ TcpOutputProc(
static int
TcpCloseProc(
- void *instanceData, /* The socket to close. */
+ void *instanceData, /* The socket to close. */
TCL_UNUSED(Tcl_Interp *))
{
TcpState *statePtr = (TcpState *)instanceData;
@@ -627,10 +627,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;
@@ -655,7 +655,7 @@ TcpCloseProc(
static int
TcpClose2Proc(
- void *instanceData, /* The socket to close. */
+ void *instanceData, /* The socket to close. */
TCL_UNUSED(Tcl_Interp *),
int flags) /* Flags that indicate which side to close. */
{
@@ -706,7 +706,7 @@ IPv6AddressNeedsNumericRendering(
struct in6_addr addr)
{
if (IN6_ARE_ADDR_EQUAL(&addr, &in6addr_any)) {
- return 1;
+ return 1;
}
/*
@@ -715,11 +715,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 +738,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 +747,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 +763,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 +907,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 +934,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 +963,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 +979,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 +1004,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 +1014,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 +1070,7 @@ TcpGetOptionProc(
if (len > 0) {
return Tcl_BadChannelOption(interp, optionName,
- "connecting keepalive nodelay peername sockname");
+ "connecting keepalive nodelay peername sockname");
}
return TCL_OK;
@@ -1169,7 +1169,7 @@ WrapNotify(
static void
TcpWatchProc(
- void *instanceData, /* The socket state. */
+ void *instanceData, /* The socket state. */
int mask) /* Events of interest; an OR-ed combination of
* TCL_READABLE, TCL_WRITABLE and
* TCL_EXCEPTION. */
@@ -1177,24 +1177,23 @@ 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) {
-
/*
* Whether it is a bug or feature or otherwise, it is a fact of life
* that on at least some Linux kernels select() fails to report that a
@@ -1242,9 +1241,9 @@ TcpWatchProc(
static int
TcpGetHandleProc(
- void *instanceData, /* The socket state. */
+ void *instanceData, /* The socket state. */
TCL_UNUSED(int) /*direction*/,
- void **handlePtr) /* Where to store the handle. */
+ void **handlePtr) /* Where to store the handle. */
{
TcpState *statePtr = (TcpState *)instanceData;
@@ -1266,7 +1265,7 @@ TcpGetHandleProc(
static void
TcpAsyncCallback(
- void *clientData, /* The socket state. */
+ void *clientData, /* The socket state. */
TCL_UNUSED(int) /*mask*/)
{
TcpConnect(NULL, (TcpState *)clientData);
@@ -1280,9 +1279,9 @@ TcpAsyncCallback(
* This function opens a new socket in client mode.
*
* Results:
- * TCL_OK, if the socket was successfully connected or an asynchronous
- * connection is in progress. If an error occurs, TCL_ERROR is returned
- * and an error message is left in interp.
+ * TCL_OK, if the socket was successfully connected or an asynchronous
+ * connection is in progress. If an error occurs, TCL_ERROR is returned
+ * and an error message is left in interp.
*
* Side effects:
* Opens a socket.
@@ -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);
@@ -1574,10 +1573,10 @@ Tcl_OpenTcpClient(
Tcl_Channel
Tcl_MakeTcpClientChannel(
- void *sock) /* The socket to wrap up into a channel. */
+ void *sock) /* The socket to wrap up into a channel. */
{
return (Tcl_Channel) TclpMakeTcpClientChannelMode(sock,
- TCL_READABLE | TCL_WRITABLE);
+ TCL_READABLE | TCL_WRITABLE);
}
/*
@@ -1599,7 +1598,7 @@ Tcl_MakeTcpClientChannel(
void *
TclpMakeTcpClientChannelMode(
- void *sock, /* The socket to wrap up into a channel. */
+ void *sock, /* The socket to wrap up into a channel. */
int mode) /* OR'ed combination of TCL_READABLE and
* TCL_WRITABLE to indicate file mode. */
{
@@ -1646,7 +1645,7 @@ Tcl_OpenTcpServerEx(
const char *service, /* Port number to open. */
const char *myHost, /* Name of local host. */
unsigned int flags, /* Flags. */
- int backlog, /* Length of OS listen backlog queue. */
+ int backlog, /* Length of OS listen backlog queue. */
Tcl_TcpAcceptProc *acceptProc,
/* Callback for accepting connections from new
* clients. */
@@ -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,101 @@ 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 +1866,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);
@@ -1900,7 +1900,7 @@ Tcl_OpenTcpServerEx(
static void
TcpAccept(
- void *data, /* Callback token. */
+ void *data, /* Callback token. */
TCL_UNUSED(int) /*mask*/)
{
TcpFdList *fds = (TcpFdList *)data; /* Client data of server socket. */
@@ -1938,9 +1938,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/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index 24bc72d..da39a96 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -213,8 +213,8 @@ int
TclpThreadCreate(
Tcl_ThreadId *idPtr, /* Return, the ID of the thread */
Tcl_ThreadCreateProc *proc, /* Main() function of the thread */
- void *clientData, /* The one argument to Main() */
- size_t stackSize, /* Size of stack for the new thread */
+ void *clientData, /* The one argument to Main() */
+ size_t stackSize, /* Size of stack for the new thread */
int flags) /* Flags controlling behaviour of the new
* thread. */
{
diff --git a/unix/tclXtNotify.c b/unix/tclXtNotify.c
index 8ca2c5f..6d4e3c9 100644
--- a/unix/tclXtNotify.c
+++ b/unix/tclXtNotify.c
@@ -33,7 +33,7 @@ typedef struct FileHandler {
XtInputId except; /* Xt exception callback handle. */
Tcl_FileProc *proc; /* Procedure to call, in the style of
* Tcl_CreateFileHandler. */
- void *clientData; /* Argument to pass to proc. */
+ void *clientData; /* Argument to pass to proc. */
struct FileHandler *nextPtr;/* Next in list of all files we care about. */
} FileHandler;
@@ -263,7 +263,7 @@ NotifierExitHandler(
static void
SetTimer(
- const Tcl_Time *timePtr) /* Timeout value, may be NULL. */
+ const Tcl_Time *timePtr) /* Timeout value, may be NULL. */
{
unsigned long timeout;
@@ -339,7 +339,7 @@ CreateFileHandler(
* called. */
Tcl_FileProc *proc, /* Procedure to call for each selected
* event. */
- void *clientData) /* Arbitrary data to pass to proc. */
+ void *clientData) /* Arbitrary data to pass to proc. */
{
FileHandler *filePtr;
@@ -627,7 +627,7 @@ FileHandlerEventProc(
static int
WaitForEvent(
- const Tcl_Time *timePtr) /* Maximum block time, or NULL. */
+ const Tcl_Time *timePtr) /* Maximum block time, or NULL. */
{
int timeout;