summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixTest.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tclUnixTest.c')
-rw-r--r--unix/tclUnixTest.c372
1 files changed, 171 insertions, 201 deletions
diff --git a/unix/tclUnixTest.c b/unix/tclUnixTest.c
index 905a986..a894d4d 100644
--- a/unix/tclUnixTest.c
+++ b/unix/tclUnixTest.c
@@ -1,4 +1,4 @@
-/*
+/*
* tclUnixTest.c --
*
* Contains platform specific test commands for the Unix platform.
@@ -6,31 +6,30 @@
* Copyright (c) 1996-1997 Sun Microsystems, Inc.
* Copyright (c) 1998 by Scriptics Corporation.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixTest.c,v 1.14.2.2 2006/03/19 22:47:30 vincentdarley Exp $
+ * RCS: @(#) $Id: tclUnixTest.c,v 1.26 2007/04/20 06:11:00 kennykb Exp $
*/
#include "tclInt.h"
-#include "tclPort.h"
/*
- * The headers are needed for the testalarm command that verifies the
- * use of SA_RESTART in signal handlers.
+ * The headers are needed for the testalarm command that verifies the use of
+ * SA_RESTART in signal handlers.
*/
#include <signal.h>
#include <sys/resource.h>
/*
- * The following macros convert between TclFile's and fd's. The conversion
+ * The following macros convert between TclFile's and fd's. The conversion
* simple involves shifting fd's up by one to ensure that no valid fd is ever
- * the same as NULL. Note that this code is duplicated from tclUnixPipe.c
+ * the same as NULL. Note that this code is duplicated from tclUnixPipe.c
*/
-#define MakeFile(fd) ((TclFile)((fd)+1))
-#define GetFd(file) (((int)file)-1)
+#define MakeFile(fd) ((TclFile)INT2PTR(((int)(fd))+1))
+#define GetFd(file) (PTR2INT(file)-1)
/*
* The stuff below is used to keep track of file handlers created and
@@ -38,16 +37,15 @@
*/
typedef struct Pipe {
- TclFile readFile; /* File handle for reading from the
- * pipe. NULL means pipe doesn't exist yet. */
- TclFile writeFile; /* File handle for writing from the
- * pipe. */
- int readCount; /* Number of times the file handler for
- * this file has triggered and the file
- * was readable. */
- int writeCount; /* Number of times the file handler for
- * this file has triggered and the file
- * was writable. */
+ TclFile readFile; /* File handle for reading from the pipe.
+ * NULL means pipe doesn't exist yet. */
+ TclFile writeFile; /* File handle for writing from the pipe. */
+ int readCount; /* Number of times the file handler for this
+ * file has triggered and the file was
+ * readable. */
+ int writeCount; /* Number of times the file handler for this
+ * file has triggered and the file was
+ * writable. */
} Pipe;
#define MAX_PIPES 10
@@ -60,39 +58,38 @@ static Pipe testPipes[MAX_PIPES];
static char *gotsig = "0";
/*
- * Forward declarations of procedures defined later in this file:
+ * Forward declarations of functions defined later in this file:
*/
-static void TestFileHandlerProc _ANSI_ARGS_((ClientData clientData,
- int mask));
-static int TestfilehandlerCmd _ANSI_ARGS_((ClientData dummy,
- Tcl_Interp *interp, int argc, CONST char **argv));
-static int TestfilewaitCmd _ANSI_ARGS_((ClientData dummy,
- Tcl_Interp *interp, int argc, CONST char **argv));
-static int TestfindexecutableCmd _ANSI_ARGS_((ClientData dummy,
- Tcl_Interp *interp, int argc, CONST char **argv));
-static int TestgetopenfileCmd _ANSI_ARGS_((ClientData dummy,
- Tcl_Interp *interp, int argc, CONST char **argv));
-static int TestgetdefencdirCmd _ANSI_ARGS_((ClientData dummy,
- Tcl_Interp *interp, int argc, CONST char **argv));
-static int TestsetdefencdirCmd _ANSI_ARGS_((ClientData dummy,
- Tcl_Interp *interp, int argc, CONST char **argv));
-int TclplatformtestInit _ANSI_ARGS_((Tcl_Interp *interp));
-static int TestalarmCmd _ANSI_ARGS_((ClientData dummy,
- Tcl_Interp *interp, int argc, CONST char **argv));
-static int TestgotsigCmd _ANSI_ARGS_((ClientData dummy,
- Tcl_Interp *interp, int argc, CONST char **argv));
-static void AlarmHandler _ANSI_ARGS_(());
-static int TestchmodCmd _ANSI_ARGS_((ClientData dummy,
- Tcl_Interp *interp, int argc, CONST char **argv));
+static void TestFileHandlerProc(ClientData clientData, int mask);
+static int TestfilehandlerCmd(ClientData dummy,
+ Tcl_Interp *interp, int argc, CONST char **argv);
+static int TestfilewaitCmd(ClientData dummy,
+ Tcl_Interp *interp, int argc, CONST char **argv);
+static int TestfindexecutableCmd(ClientData dummy,
+ Tcl_Interp *interp, int argc, CONST char **argv);
+static int TestgetopenfileCmd(ClientData dummy,
+ Tcl_Interp *interp, int argc, CONST char **argv);
+static int TestgetdefencdirCmd(ClientData dummy,
+ Tcl_Interp *interp, int argc, CONST char **argv);
+static int TestsetdefencdirCmd(ClientData dummy,
+ Tcl_Interp *interp, int argc, CONST char **argv);
+int TclplatformtestInit(Tcl_Interp *interp);
+static int TestalarmCmd(ClientData dummy,
+ Tcl_Interp *interp, int argc, CONST char **argv);
+static int TestgotsigCmd(ClientData dummy,
+ Tcl_Interp *interp, int argc, CONST char **argv);
+static void AlarmHandler(int signum);
+static int TestchmodCmd(ClientData dummy,
+ Tcl_Interp *interp, int argc, CONST char **argv);
/*
*----------------------------------------------------------------------
*
* TclplatformtestInit --
*
- * Defines commands that test platform specific functionality for
- * Unix platforms.
+ * Defines commands that test platform specific functionality for Unix
+ * platforms.
*
* Results:
* A standard Tcl result.
@@ -104,27 +101,27 @@ static int TestchmodCmd _ANSI_ARGS_((ClientData dummy,
*/
int
-TclplatformtestInit(interp)
- Tcl_Interp *interp; /* Interpreter to add commands to. */
+TclplatformtestInit(
+ Tcl_Interp *interp) /* Interpreter to add commands to. */
{
Tcl_CreateCommand(interp, "testchmod", TestchmodCmd,
- (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
+ (ClientData) 0, NULL);
Tcl_CreateCommand(interp, "testfilehandler", TestfilehandlerCmd,
- (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
+ (ClientData) 0, NULL);
Tcl_CreateCommand(interp, "testfilewait", TestfilewaitCmd,
- (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
+ (ClientData) 0, NULL);
Tcl_CreateCommand(interp, "testfindexecutable", TestfindexecutableCmd,
- (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
+ (ClientData) 0, NULL);
Tcl_CreateCommand(interp, "testgetopenfile", TestgetopenfileCmd,
- (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
+ (ClientData) 0, NULL);
Tcl_CreateCommand(interp, "testgetdefenc", TestgetdefencdirCmd,
- (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
+ (ClientData) 0, NULL);
Tcl_CreateCommand(interp, "testsetdefenc", TestsetdefencdirCmd,
- (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
+ (ClientData) 0, NULL);
Tcl_CreateCommand(interp, "testalarm", TestalarmCmd,
- (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
+ (ClientData) 0, NULL);
Tcl_CreateCommand(interp, "testgotsig", TestgotsigCmd,
- (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
+ (ClientData) 0, NULL);
return TCL_OK;
}
@@ -133,9 +130,8 @@ TclplatformtestInit(interp)
*
* TestfilehandlerCmd --
*
- * This procedure implements the "testfilehandler" command. It is
- * used to test Tcl_CreateFileHandler, Tcl_DeleteFileHandler, and
- * TclWaitForFile.
+ * This function implements the "testfilehandler" command. It is used to
+ * test Tcl_CreateFileHandler, Tcl_DeleteFileHandler, and TclWaitForFile.
*
* Results:
* A standard Tcl result.
@@ -147,11 +143,11 @@ TclplatformtestInit(interp)
*/
static int
-TestfilehandlerCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Not used. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- CONST char **argv; /* Argument strings. */
+TestfilehandlerCmd(
+ ClientData clientData, /* Not used. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int argc, /* Number of arguments. */
+ CONST char **argv) /* Argument strings. */
{
Pipe *pipePtr;
int i, mask, timeout;
@@ -163,7 +159,7 @@ TestfilehandlerCmd(clientData, interp, argc, argv)
* NOTE: When we make this code work on Windows also, the following
* variable needs to be made Unix-only.
*/
-
+
if (!initialized) {
for (i = 0; i < MAX_PIPES; i++) {
testPipes[i].readFile = NULL;
@@ -173,7 +169,7 @@ TestfilehandlerCmd(clientData, interp, argc, argv)
if (argc < 2) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
- " option ... \"", (char *) NULL);
+ " option ... \"", NULL);
return TCL_ERROR;
}
pipePtr = NULL;
@@ -182,7 +178,7 @@ TestfilehandlerCmd(clientData, interp, argc, argv)
return TCL_ERROR;
}
if (i >= MAX_PIPES) {
- Tcl_AppendResult(interp, "bad index ", argv[2], (char *) NULL);
+ Tcl_AppendResult(interp, "bad index ", argv[2], NULL);
return TCL_ERROR;
}
pipePtr = &testPipes[i];
@@ -200,16 +196,16 @@ TestfilehandlerCmd(clientData, interp, argc, argv)
} else if (strcmp(argv[1], "clear") == 0) {
if (argc != 3) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"",
- argv[0], " clear index\"", (char *) NULL);
+ argv[0], " clear index\"", NULL);
return TCL_ERROR;
}
pipePtr->readCount = pipePtr->writeCount = 0;
} else if (strcmp(argv[1], "counts") == 0) {
char buf[TCL_INTEGER_SPACE * 2];
-
+
if (argc != 3) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"",
- argv[0], " counts index\"", (char *) NULL);
+ argv[0], " counts index\"", NULL);
return TCL_ERROR;
}
sprintf(buf, "%d %d", pipePtr->readCount, pipePtr->writeCount);
@@ -217,14 +213,13 @@ TestfilehandlerCmd(clientData, interp, argc, argv)
} else if (strcmp(argv[1], "create") == 0) {
if (argc != 5) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"",
- argv[0], " create index readMode writeMode\"",
- (char *) NULL);
+ argv[0], " create index readMode writeMode\"", NULL);
return TCL_ERROR;
}
if (pipePtr->readFile == NULL) {
if (!TclpCreatePipe(&pipePtr->readFile, &pipePtr->writeFile)) {
Tcl_AppendResult(interp, "couldn't open pipe: ",
- Tcl_PosixError(interp), (char *) NULL);
+ Tcl_PosixError(interp), NULL);
return TCL_ERROR;
}
#ifdef O_NONBLOCK
@@ -248,8 +243,7 @@ TestfilehandlerCmd(clientData, interp, argc, argv)
Tcl_CreateFileHandler(GetFd(pipePtr->readFile), 0,
TestFileHandlerProc, (ClientData) pipePtr);
} else {
- Tcl_AppendResult(interp, "bad read mode \"", argv[3], "\"",
- (char *) NULL);
+ Tcl_AppendResult(interp, "bad read mode \"", argv[3], "\"", NULL);
return TCL_ERROR;
}
if (strcmp(argv[4], "writable") == 0) {
@@ -261,14 +255,13 @@ TestfilehandlerCmd(clientData, interp, argc, argv)
Tcl_CreateFileHandler(GetFd(pipePtr->writeFile), 0,
TestFileHandlerProc, (ClientData) pipePtr);
} else {
- Tcl_AppendResult(interp, "bad read mode \"", argv[4], "\"",
- (char *) NULL);
+ Tcl_AppendResult(interp, "bad read mode \"", argv[4], "\"", NULL);
return TCL_ERROR;
}
} else if (strcmp(argv[1], "empty") == 0) {
if (argc != 3) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"",
- argv[0], " empty index\"", (char *) NULL);
+ argv[0], " empty index\"", NULL);
return TCL_ERROR;
}
@@ -278,24 +271,24 @@ TestfilehandlerCmd(clientData, interp, argc, argv)
} else if (strcmp(argv[1], "fill") == 0) {
if (argc != 3) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"",
- argv[0], " fill index\"", (char *) NULL);
+ argv[0], " fill index\"", NULL);
return TCL_ERROR;
}
- memset((VOID *) buffer, 'a', 4000);
+ memset(buffer, 'a', 4000);
while (write(GetFd(pipePtr->writeFile), buffer, 4000) > 0) {
/* Empty loop body. */
}
} else if (strcmp(argv[1], "fillpartial") == 0) {
char buf[TCL_INTEGER_SPACE];
-
+
if (argc != 3) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"",
- argv[0], " fillpartial index\"", (char *) NULL);
+ argv[0], " fillpartial index\"", NULL);
return TCL_ERROR;
}
- memset((VOID *) buffer, 'b', 10);
+ memset(buffer, 'b', 10);
TclFormatInt(buf, write(GetFd(pipePtr->writeFile), buffer, 10));
Tcl_SetResult(interp, buf, TCL_VOLATILE);
} else if (strcmp(argv[1], "oneevent") == 0) {
@@ -303,13 +296,11 @@ TestfilehandlerCmd(clientData, interp, argc, argv)
} else if (strcmp(argv[1], "wait") == 0) {
if (argc != 5) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"",
- argv[0], " wait index readable|writable timeout\"",
- (char *) NULL);
+ argv[0], " wait index readable|writable timeout\"", NULL);
return TCL_ERROR;
}
if (pipePtr->readFile == NULL) {
- Tcl_AppendResult(interp, "pipe ", argv[2], " doesn't exist",
- (char *) NULL);
+ Tcl_AppendResult(interp, "pipe ", argv[2], " doesn't exist", NULL);
return TCL_ERROR;
}
if (strcmp(argv[3], "readable") == 0) {
@@ -333,17 +324,17 @@ TestfilehandlerCmd(clientData, interp, argc, argv)
Tcl_DoOneEvent(TCL_WINDOW_EVENTS|TCL_DONT_WAIT);
} else {
Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be close, clear, counts, create, empty, fill, ",
- "fillpartial, oneevent, wait, or windowevent",
- (char *) NULL);
+ "\": must be close, clear, counts, create, empty, fill, "
+ "fillpartial, oneevent, wait, or windowevent", NULL);
return TCL_ERROR;
}
return TCL_OK;
}
-static void TestFileHandlerProc(clientData, mask)
- ClientData clientData; /* Points to a Pipe structure. */
- int mask; /* Indicates which events happened:
+static void
+TestFileHandlerProc(
+ ClientData clientData, /* Points to a Pipe structure. */
+ int mask) /* Indicates which events happened:
* TCL_READABLE or TCL_WRITABLE. */
{
Pipe *pipePtr = (Pipe *) clientData;
@@ -361,8 +352,8 @@ static void TestFileHandlerProc(clientData, mask)
*
* TestfilewaitCmd --
*
- * This procedure implements the "testfilewait" command. It is
- * used to test TclUnixWaitForFile.
+ * This function implements the "testfilewait" command. It is used to
+ * test TclUnixWaitForFile.
*
* Results:
* A standard Tcl result.
@@ -374,11 +365,11 @@ static void TestFileHandlerProc(clientData, mask)
*/
static int
-TestfilewaitCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Not used. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- CONST char **argv; /* Argument strings. */
+TestfilewaitCmd(
+ ClientData clientData, /* Not used. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int argc, /* Number of arguments. */
+ CONST char **argv) /* Argument strings. */
{
int mask, result, timeout;
Tcl_Channel channel;
@@ -387,7 +378,7 @@ TestfilewaitCmd(clientData, interp, argc, argv)
if (argc != 4) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
- " file readable|writable|both timeout\"", (char *) NULL);
+ " file readable|writable|both timeout\"", NULL);
return TCL_ERROR;
}
channel = Tcl_GetChannel(interp, argv[1], NULL);
@@ -402,16 +393,16 @@ TestfilewaitCmd(clientData, interp, argc, argv)
mask = TCL_WRITABLE|TCL_READABLE;
} else {
Tcl_AppendResult(interp, "bad argument \"", argv[2],
- "\": must be readable, writable, or both", (char *) NULL);
+ "\": must be readable, writable, or both", NULL);
return TCL_ERROR;
}
- if (Tcl_GetChannelHandle(channel,
+ if (Tcl_GetChannelHandle(channel,
(mask & TCL_READABLE) ? TCL_READABLE : TCL_WRITABLE,
(ClientData*) &data) != TCL_OK) {
Tcl_SetResult(interp, "couldn't get channel file", TCL_STATIC);
return TCL_ERROR;
}
- fd = (int) data;
+ fd = PTR2INT(data);
if (Tcl_GetInt(interp, argv[3], &timeout) != TCL_OK) {
return TCL_ERROR;
}
@@ -430,8 +421,8 @@ TestfilewaitCmd(clientData, interp, argc, argv)
*
* TestfindexecutableCmd --
*
- * This procedure implements the "testfindexecutable" command. It is
- * used to test Tcl_FindExecutable.
+ * This function implements the "testfindexecutable" command. It is used
+ * to test TclpFindExecutable.
*
* Results:
* A standard Tcl result.
@@ -443,39 +434,28 @@ TestfilewaitCmd(clientData, interp, argc, argv)
*/
static int
-TestfindexecutableCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Not used. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- CONST char **argv; /* Argument strings. */
+TestfindexecutableCmd(
+ ClientData clientData, /* Not used. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int argc, /* Number of arguments. */
+ CONST char **argv) /* Argument strings. */
{
- char *oldName;
- char *oldNativeName;
+ Tcl_Obj *saveName;
if (argc != 2) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
- " argv0\"", (char *) NULL);
+ " argv0\"", NULL);
return TCL_ERROR;
}
- oldName = tclExecutableName;
- oldNativeName = tclNativeExecutableName;
-
- tclExecutableName = NULL;
- tclNativeExecutableName = NULL;
-
- Tcl_FindExecutable(argv[1]);
- if (tclExecutableName != NULL) {
- Tcl_SetResult(interp, tclExecutableName, TCL_VOLATILE);
- ckfree(tclExecutableName);
- }
- if (tclNativeExecutableName != NULL) {
- ckfree(tclNativeExecutableName);
- }
+ saveName = TclGetObjNameOfExecutable();
+ Tcl_IncrRefCount(saveName);
- tclExecutableName = oldName;
- tclNativeExecutableName = oldNativeName;
+ TclpFindExecutable(argv[1]);
+ Tcl_SetObjResult(interp, TclGetObjNameOfExecutable());
+ TclSetObjNameOfExecutable(saveName, NULL);
+ Tcl_DecrRefCount(saveName);
return TCL_OK;
}
@@ -484,8 +464,8 @@ TestfindexecutableCmd(clientData, interp, argc, argv)
*
* TestgetopenfileCmd --
*
- * This procedure implements the "testgetopenfile" command. It is
- * used to get a FILE * value from a registered channel.
+ * This function implements the "testgetopenfile" command. It is used to
+ * get a FILE * value from a registered channel.
*
* Results:
* A standard Tcl result.
@@ -497,19 +477,17 @@ TestfindexecutableCmd(clientData, interp, argc, argv)
*/
static int
-TestgetopenfileCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Not used. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- CONST char **argv; /* Argument strings. */
+TestgetopenfileCmd(
+ ClientData clientData, /* Not used. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int argc, /* Number of arguments. */
+ CONST char **argv) /* Argument strings. */
{
ClientData filePtr;
if (argc != 3) {
- Tcl_AppendResult(interp,
- "wrong # args: should be \"", argv[0],
- " channelName forWriting\"",
- (char *) NULL);
+ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
+ " channelName forWriting\"", NULL);
return TCL_ERROR;
}
if (Tcl_GetOpenFile(interp, argv[1], atoi(argv[2]), 1, &filePtr)
@@ -518,7 +496,7 @@ TestgetopenfileCmd(clientData, interp, argc, argv)
}
if (filePtr == (ClientData) NULL) {
Tcl_AppendResult(interp,
- "Tcl_GetOpenFile succeeded but FILE * NULL!", (char *) NULL);
+ "Tcl_GetOpenFile succeeded but FILE * NULL!", NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -529,8 +507,8 @@ TestgetopenfileCmd(clientData, interp, argc, argv)
*
* TestsetdefencdirCmd --
*
- * This procedure implements the "testsetdefenc" command. It is
- * used to set the value of tclDefaultEncodingDir.
+ * This function implements the "testsetdefenc" command. It is used to
+ * test Tcl_SetDefaultEncodingDir().
*
* Results:
* A standard Tcl result.
@@ -542,29 +520,19 @@ TestgetopenfileCmd(clientData, interp, argc, argv)
*/
static int
-TestsetdefencdirCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Not used. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- CONST char **argv; /* Argument strings. */
+TestsetdefencdirCmd(
+ ClientData clientData, /* Not used. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int argc, /* Number of arguments. */
+ CONST char **argv) /* Argument strings. */
{
if (argc != 2) {
- Tcl_AppendResult(interp,
- "wrong # args: should be \"", argv[0],
- " defaultDir\"",
- (char *) NULL);
+ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
+ " defaultDir\"", NULL);
return TCL_ERROR;
}
- if (tclDefaultEncodingDir != NULL) {
- ckfree(tclDefaultEncodingDir);
- tclDefaultEncodingDir = NULL;
- }
- if (*argv[1] != '\0') {
- tclDefaultEncodingDir = (char *)
- ckalloc((unsigned) strlen(argv[1]) + 1);
- strcpy(tclDefaultEncodingDir, argv[1]);
- }
+ Tcl_SetDefaultEncodingDir(argv[1]);
return TCL_OK;
}
@@ -573,8 +541,8 @@ TestsetdefencdirCmd(clientData, interp, argc, argv)
*
* TestgetdefencdirCmd --
*
- * This procedure implements the "testgetdefenc" command. It is
- * used to get the value of tclDefaultEncodingDir.
+ * This function implements the "testgetdefenc" command. It is used to
+ * test Tcl_GetDefaultEncodingDir().
*
* Results:
* A standard Tcl result.
@@ -586,32 +554,29 @@ TestsetdefencdirCmd(clientData, interp, argc, argv)
*/
static int
-TestgetdefencdirCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Not used. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- CONST char **argv; /* Argument strings. */
+TestgetdefencdirCmd(
+ ClientData clientData, /* Not used. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int argc, /* Number of arguments. */
+ CONST char **argv) /* Argument strings. */
{
if (argc != 1) {
- Tcl_AppendResult(interp,
- "wrong # args: should be \"", argv[0],
- (char *) NULL);
+ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], NULL);
return TCL_ERROR;
}
- if (tclDefaultEncodingDir != NULL) {
- Tcl_AppendResult(interp, tclDefaultEncodingDir, (char *) NULL);
- }
+ Tcl_AppendResult(interp, Tcl_GetDefaultEncodingDir(), NULL);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
+ *
* TestalarmCmd --
*
- * Test that EINTR is handled correctly by generating and
- * handling a signal. This requires using the SA_RESTART
- * flag when registering the signal handler.
+ * Test that EINTR is handled correctly by generating and handling a
+ * signal. This requires using the SA_RESTART flag when registering the
+ * signal handler.
*
* Results:
* None.
@@ -623,11 +588,11 @@ TestgetdefencdirCmd(clientData, interp, argc, argv)
*/
static int
-TestalarmCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Not used. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- CONST char **argv; /* Argument strings. */
+TestalarmCmd(
+ ClientData clientData, /* Not used. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int argc, /* Number of arguments. */
+ CONST char **argv) /* Argument strings. */
{
#ifdef SA_RESTART
unsigned int sec;
@@ -640,21 +605,24 @@ TestalarmCmd(clientData, interp, argc, argv)
}
/*
- * Setup the signal handling that automatically retries
- * any interupted I/O system calls.
+ * Setup the signal handling that automatically retries any interrupted
+ * I/O system calls.
*/
+
action.sa_handler = AlarmHandler;
- memset((void *)&action.sa_mask, 0, sizeof(sigset_t));
+ memset((void *) &action.sa_mask, 0, sizeof(sigset_t));
action.sa_flags = SA_RESTART;
if (sigaction(SIGALRM, &action, NULL) < 0) {
Tcl_AppendResult(interp, "sigaction: ", Tcl_PosixError(interp), NULL);
return TCL_ERROR;
}
- (void)alarm(sec);
+ (void) alarm(sec);
return TCL_OK;
#else
- Tcl_AppendResult(interp, "warning: sigaction SA_RESTART not support on this platform", NULL);
+ Tcl_AppendResult(interp,
+ "warning: sigaction SA_RESTART not support on this platform",
+ NULL);
return TCL_ERROR;
#endif
}
@@ -676,13 +644,15 @@ TestalarmCmd(clientData, interp, argc, argv)
*/
static void
-AlarmHandler()
+AlarmHandler(
+ int signum)
{
gotsig = "1";
}
/*
*----------------------------------------------------------------------
+ *
* TestgotsigCmd --
*
* Verify the signal was handled after the testalarm command.
@@ -697,13 +667,13 @@ AlarmHandler()
*/
static int
-TestgotsigCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Not used. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- CONST char **argv; /* Argument strings. */
+TestgotsigCmd(
+ ClientData clientData, /* Not used. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int argc, /* Number of arguments. */
+ CONST char **argv) /* Argument strings. */
{
- Tcl_AppendResult(interp, gotsig, (char *) NULL);
+ Tcl_AppendResult(interp, gotsig, NULL);
gotsig = "0";
return TCL_OK;
}
@@ -728,11 +698,11 @@ TestgotsigCmd(clientData, interp, argc, argv)
*/
static int
-TestchmodCmd(dummy, interp, argc, argv)
- ClientData dummy; /* Not used. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- CONST char **argv; /* Argument strings. */
+TestchmodCmd(
+ ClientData dummy, /* Not used. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int argc, /* Number of arguments. */
+ CONST char **argv) /* Argument strings. */
{
int i, mode;
char *rest;