summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixTest.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tclUnixTest.c')
-rw-r--r--unix/tclUnixTest.c396
1 files changed, 212 insertions, 184 deletions
diff --git a/unix/tclUnixTest.c b/unix/tclUnixTest.c
index 46fc972..b657aeb 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,29 @@
* 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.
*/
-#ifndef USE_TCL_STUBS
-# define USE_TCL_STUBS
-#endif
#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)INT2PTR(((int)(fd))+1))
-#define GetFd(file) (PTR2INT(file)-1)
+#define MakeFile(fd) ((TclFile)((fd)+1))
+#define GetFd(file) (((int)file)-1)
/*
* The stuff below is used to keep track of file handlers created and
@@ -38,15 +36,16 @@
*/
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
@@ -56,31 +55,42 @@ static Pipe testPipes[MAX_PIPES];
* The stuff below is used by the testalarm and testgotsig ommands.
*/
-static const char *gotsig = "0";
+static char *gotsig = "0";
/*
- * Forward declarations of functions defined later in this file:
+ * Forward declarations of procedures defined later in this file:
*/
-static Tcl_CmdProc TestalarmCmd;
-static Tcl_CmdProc TestchmodCmd;
-static Tcl_CmdProc TestfilehandlerCmd;
-static Tcl_CmdProc TestfilewaitCmd;
-static Tcl_CmdProc TestfindexecutableCmd;
-static Tcl_CmdProc TestgetdefencdirCmd;
-static Tcl_CmdProc TestgetopenfileCmd;
-static Tcl_CmdProc TestgotsigCmd;
-static Tcl_CmdProc TestsetdefencdirCmd;
-static Tcl_FileProc TestFileHandlerProc;
-static void AlarmHandler(int signum);
+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));
/*
*----------------------------------------------------------------------
*
* 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.
@@ -92,27 +102,27 @@ static void AlarmHandler(int signum);
*/
int
-TclplatformtestInit(
- Tcl_Interp *interp) /* Interpreter to add commands to. */
+TclplatformtestInit(interp)
+ Tcl_Interp *interp; /* Interpreter to add commands to. */
{
Tcl_CreateCommand(interp, "testchmod", TestchmodCmd,
- NULL, NULL);
+ (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp, "testfilehandler", TestfilehandlerCmd,
- NULL, NULL);
+ (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp, "testfilewait", TestfilewaitCmd,
- NULL, NULL);
+ (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp, "testfindexecutable", TestfindexecutableCmd,
- NULL, NULL);
+ (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp, "testgetopenfile", TestgetopenfileCmd,
- NULL, NULL);
+ (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp, "testgetdefenc", TestgetdefencdirCmd,
- NULL, NULL);
+ (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp, "testsetdefenc", TestsetdefencdirCmd,
- NULL, NULL);
+ (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp, "testalarm", TestalarmCmd,
- NULL, NULL);
+ (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp, "testgotsig", TestgotsigCmd,
- NULL, NULL);
+ (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
return TCL_OK;
}
@@ -121,8 +131,9 @@ TclplatformtestInit(
*
* TestfilehandlerCmd --
*
- * This function implements the "testfilehandler" command. It is used to
- * test Tcl_CreateFileHandler, Tcl_DeleteFileHandler, and TclWaitForFile.
+ * This procedure implements the "testfilehandler" command. It is
+ * used to test Tcl_CreateFileHandler, Tcl_DeleteFileHandler, and
+ * TclWaitForFile.
*
* Results:
* A standard Tcl result.
@@ -134,11 +145,11 @@ TclplatformtestInit(
*/
static int
-TestfilehandlerCmd(
- ClientData clientData, /* Not used. */
- Tcl_Interp *interp, /* Current interpreter. */
- int argc, /* Number of arguments. */
- const char **argv) /* Argument strings. */
+TestfilehandlerCmd(clientData, interp, argc, argv)
+ 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;
@@ -150,7 +161,7 @@ TestfilehandlerCmd(
* 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;
@@ -160,7 +171,7 @@ TestfilehandlerCmd(
if (argc < 2) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
- " option ... \"", NULL);
+ " option ... \"", (char *) NULL);
return TCL_ERROR;
}
pipePtr = NULL;
@@ -169,7 +180,7 @@ TestfilehandlerCmd(
return TCL_ERROR;
}
if (i >= MAX_PIPES) {
- Tcl_AppendResult(interp, "bad index ", argv[2], NULL);
+ Tcl_AppendResult(interp, "bad index ", argv[2], (char *) NULL);
return TCL_ERROR;
}
pipePtr = &testPipes[i];
@@ -187,16 +198,16 @@ TestfilehandlerCmd(
} else if (strcmp(argv[1], "clear") == 0) {
if (argc != 3) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"",
- argv[0], " clear index\"", NULL);
+ argv[0], " clear index\"", (char *) 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\"", NULL);
+ argv[0], " counts index\"", (char *) NULL);
return TCL_ERROR;
}
sprintf(buf, "%d %d", pipePtr->readCount, pipePtr->writeCount);
@@ -204,13 +215,14 @@ TestfilehandlerCmd(
} else if (strcmp(argv[1], "create") == 0) {
if (argc != 5) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"",
- argv[0], " create index readMode writeMode\"", NULL);
+ argv[0], " create index readMode writeMode\"",
+ (char *) NULL);
return TCL_ERROR;
}
if (pipePtr->readFile == NULL) {
if (!TclpCreatePipe(&pipePtr->readFile, &pipePtr->writeFile)) {
Tcl_AppendResult(interp, "couldn't open pipe: ",
- Tcl_PosixError(interp), NULL);
+ Tcl_PosixError(interp), (char *) NULL);
return TCL_ERROR;
}
#ifdef O_NONBLOCK
@@ -227,59 +239,61 @@ TestfilehandlerCmd(
if (strcmp(argv[3], "readable") == 0) {
Tcl_CreateFileHandler(GetFd(pipePtr->readFile), TCL_READABLE,
- TestFileHandlerProc, pipePtr);
+ TestFileHandlerProc, (ClientData) pipePtr);
} else if (strcmp(argv[3], "off") == 0) {
Tcl_DeleteFileHandler(GetFd(pipePtr->readFile));
} else if (strcmp(argv[3], "disabled") == 0) {
Tcl_CreateFileHandler(GetFd(pipePtr->readFile), 0,
- TestFileHandlerProc, pipePtr);
+ TestFileHandlerProc, (ClientData) pipePtr);
} else {
- Tcl_AppendResult(interp, "bad read mode \"", argv[3], "\"", NULL);
+ Tcl_AppendResult(interp, "bad read mode \"", argv[3], "\"",
+ (char *) NULL);
return TCL_ERROR;
}
if (strcmp(argv[4], "writable") == 0) {
Tcl_CreateFileHandler(GetFd(pipePtr->writeFile), TCL_WRITABLE,
- TestFileHandlerProc, pipePtr);
+ TestFileHandlerProc, (ClientData) pipePtr);
} else if (strcmp(argv[4], "off") == 0) {
Tcl_DeleteFileHandler(GetFd(pipePtr->writeFile));
} else if (strcmp(argv[4], "disabled") == 0) {
Tcl_CreateFileHandler(GetFd(pipePtr->writeFile), 0,
- TestFileHandlerProc, pipePtr);
+ TestFileHandlerProc, (ClientData) pipePtr);
} else {
- Tcl_AppendResult(interp, "bad read mode \"", argv[4], "\"", NULL);
+ Tcl_AppendResult(interp, "bad read mode \"", argv[4], "\"",
+ (char *) 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\"", NULL);
+ argv[0], " empty index\"", (char *) NULL);
return TCL_ERROR;
}
while (read(GetFd(pipePtr->readFile), buffer, 4000) > 0) {
- /* Empty loop body. */
+ /* Empty loop body. */
}
} else if (strcmp(argv[1], "fill") == 0) {
if (argc != 3) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"",
- argv[0], " fill index\"", NULL);
+ argv[0], " fill index\"", (char *) NULL);
return TCL_ERROR;
}
- memset(buffer, 'a', 4000);
+ memset((VOID *) buffer, 'a', 4000);
while (write(GetFd(pipePtr->writeFile), buffer, 4000) > 0) {
- /* Empty loop body. */
+ /* 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\"", NULL);
+ argv[0], " fillpartial index\"", (char *) NULL);
return TCL_ERROR;
}
- memset(buffer, 'b', 10);
+ memset((VOID *) buffer, 'b', 10);
TclFormatInt(buf, write(GetFd(pipePtr->writeFile), buffer, 10));
Tcl_SetResult(interp, buf, TCL_VOLATILE);
} else if (strcmp(argv[1], "oneevent") == 0) {
@@ -287,11 +301,13 @@ TestfilehandlerCmd(
} else if (strcmp(argv[1], "wait") == 0) {
if (argc != 5) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"",
- argv[0], " wait index readable|writable timeout\"", NULL);
+ argv[0], " wait index readable|writable timeout\"",
+ (char *) NULL);
return TCL_ERROR;
}
if (pipePtr->readFile == NULL) {
- Tcl_AppendResult(interp, "pipe ", argv[2], " doesn't exist", NULL);
+ Tcl_AppendResult(interp, "pipe ", argv[2], " doesn't exist",
+ (char *) NULL);
return TCL_ERROR;
}
if (strcmp(argv[3], "readable") == 0) {
@@ -315,20 +331,20 @@ TestfilehandlerCmd(
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", NULL);
+ "\": must be close, clear, counts, create, empty, fill, ",
+ "fillpartial, oneevent, wait, or windowevent",
+ (char *) NULL);
return TCL_ERROR;
}
return TCL_OK;
}
-static void
-TestFileHandlerProc(
- ClientData clientData, /* Points to a Pipe structure. */
- int mask) /* Indicates which events happened:
+static void TestFileHandlerProc(clientData, mask)
+ ClientData clientData; /* Points to a Pipe structure. */
+ int mask; /* Indicates which events happened:
* TCL_READABLE or TCL_WRITABLE. */
{
- Pipe *pipePtr = clientData;
+ Pipe *pipePtr = (Pipe *) clientData;
if (mask & TCL_READABLE) {
pipePtr->readCount++;
@@ -343,8 +359,8 @@ TestFileHandlerProc(
*
* TestfilewaitCmd --
*
- * This function implements the "testfilewait" command. It is used to
- * test TclUnixWaitForFile.
+ * This procedure implements the "testfilewait" command. It is
+ * used to test TclUnixWaitForFile.
*
* Results:
* A standard Tcl result.
@@ -356,11 +372,11 @@ TestFileHandlerProc(
*/
static int
-TestfilewaitCmd(
- ClientData clientData, /* Not used. */
- Tcl_Interp *interp, /* Current interpreter. */
- int argc, /* Number of arguments. */
- const char **argv) /* Argument strings. */
+TestfilewaitCmd(clientData, interp, argc, argv)
+ 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;
@@ -369,7 +385,7 @@ TestfilewaitCmd(
if (argc != 4) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
- " file readable|writable|both timeout\"", NULL);
+ " file readable|writable|both timeout\"", (char *) NULL);
return TCL_ERROR;
}
channel = Tcl_GetChannel(interp, argv[1], NULL);
@@ -384,16 +400,16 @@ TestfilewaitCmd(
mask = TCL_WRITABLE|TCL_READABLE;
} else {
Tcl_AppendResult(interp, "bad argument \"", argv[2],
- "\": must be readable, writable, or both", NULL);
+ "\": must be readable, writable, or both", (char *) 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 = PTR2INT(data);
+ fd = (int) data;
if (Tcl_GetInt(interp, argv[3], &timeout) != TCL_OK) {
return TCL_ERROR;
}
@@ -412,8 +428,8 @@ TestfilewaitCmd(
*
* TestfindexecutableCmd --
*
- * This function implements the "testfindexecutable" command. It is used
- * to test TclpFindExecutable.
+ * This procedure implements the "testfindexecutable" command. It is
+ * used to test Tcl_FindExecutable.
*
* Results:
* A standard Tcl result.
@@ -425,28 +441,39 @@ TestfilewaitCmd(
*/
static int
-TestfindexecutableCmd(
- ClientData clientData, /* Not used. */
- Tcl_Interp *interp, /* Current interpreter. */
- int argc, /* Number of arguments. */
- const char **argv) /* Argument strings. */
+TestfindexecutableCmd(clientData, interp, argc, argv)
+ ClientData clientData; /* Not used. */
+ Tcl_Interp *interp; /* Current interpreter. */
+ int argc; /* Number of arguments. */
+ CONST char **argv; /* Argument strings. */
{
- Tcl_Obj *saveName;
+ char *oldName;
+ char *oldNativeName;
if (argc != 2) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
- " argv0\"", NULL);
+ " argv0\"", (char *) NULL);
return TCL_ERROR;
}
- saveName = TclGetObjNameOfExecutable();
- Tcl_IncrRefCount(saveName);
+ oldName = tclExecutableName;
+ oldNativeName = tclNativeExecutableName;
- TclpFindExecutable(argv[1]);
- Tcl_SetObjResult(interp, TclGetObjNameOfExecutable());
+ tclExecutableName = NULL;
+ tclNativeExecutableName = NULL;
+
+ Tcl_FindExecutable(argv[1]);
+ if (tclExecutableName != NULL) {
+ Tcl_SetResult(interp, tclExecutableName, TCL_VOLATILE);
+ ckfree(tclExecutableName);
+ }
+ if (tclNativeExecutableName != NULL) {
+ ckfree(tclNativeExecutableName);
+ }
+
+ tclExecutableName = oldName;
+ tclNativeExecutableName = oldNativeName;
- TclSetObjNameOfExecutable(saveName, NULL);
- Tcl_DecrRefCount(saveName);
return TCL_OK;
}
@@ -455,8 +482,8 @@ TestfindexecutableCmd(
*
* TestgetopenfileCmd --
*
- * This function implements the "testgetopenfile" command. It is used to
- * get a FILE * value from a registered channel.
+ * This procedure implements the "testgetopenfile" command. It is
+ * used to get a FILE * value from a registered channel.
*
* Results:
* A standard Tcl result.
@@ -468,26 +495,28 @@ TestfindexecutableCmd(
*/
static int
-TestgetopenfileCmd(
- ClientData clientData, /* Not used. */
- Tcl_Interp *interp, /* Current interpreter. */
- int argc, /* Number of arguments. */
- const char **argv) /* Argument strings. */
+TestgetopenfileCmd(clientData, interp, argc, argv)
+ 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\"", NULL);
+ Tcl_AppendResult(interp,
+ "wrong # args: should be \"", argv[0],
+ " channelName forWriting\"",
+ (char *) NULL);
return TCL_ERROR;
}
if (Tcl_GetOpenFile(interp, argv[1], atoi(argv[2]), 1, &filePtr)
- == TCL_ERROR) {
+ == TCL_ERROR) {
return TCL_ERROR;
}
- if (filePtr == NULL) {
+ if (filePtr == (ClientData) NULL) {
Tcl_AppendResult(interp,
- "Tcl_GetOpenFile succeeded but FILE * NULL!", NULL);
+ "Tcl_GetOpenFile succeeded but FILE * NULL!", (char *) NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -498,8 +527,8 @@ TestgetopenfileCmd(
*
* TestsetdefencdirCmd --
*
- * This function implements the "testsetdefenc" command. It is used to
- * test Tcl_SetDefaultEncodingDir().
+ * This procedure implements the "testsetdefenc" command. It is
+ * used to set the value of tclDefaultEncodingDir.
*
* Results:
* A standard Tcl result.
@@ -511,19 +540,29 @@ TestgetopenfileCmd(
*/
static int
-TestsetdefencdirCmd(
- ClientData clientData, /* Not used. */
- Tcl_Interp *interp, /* Current interpreter. */
- int argc, /* Number of arguments. */
- const char **argv) /* Argument strings. */
+TestsetdefencdirCmd(clientData, interp, argc, argv)
+ 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\"", NULL);
+ Tcl_AppendResult(interp,
+ "wrong # args: should be \"", argv[0],
+ " defaultDir\"",
+ (char *) NULL);
return TCL_ERROR;
}
- Tcl_SetDefaultEncodingDir(argv[1]);
+ if (tclDefaultEncodingDir != NULL) {
+ ckfree(tclDefaultEncodingDir);
+ tclDefaultEncodingDir = NULL;
+ }
+ if (*argv[1] != '\0') {
+ tclDefaultEncodingDir = (char *)
+ ckalloc((unsigned) strlen(argv[1]) + 1);
+ strcpy(tclDefaultEncodingDir, argv[1]);
+ }
return TCL_OK;
}
@@ -532,8 +571,8 @@ TestsetdefencdirCmd(
*
* TestgetdefencdirCmd --
*
- * This function implements the "testgetdefenc" command. It is used to
- * test Tcl_GetDefaultEncodingDir().
+ * This procedure implements the "testgetdefenc" command. It is
+ * used to get the value of tclDefaultEncodingDir.
*
* Results:
* A standard Tcl result.
@@ -545,29 +584,32 @@ TestsetdefencdirCmd(
*/
static int
-TestgetdefencdirCmd(
- ClientData clientData, /* Not used. */
- Tcl_Interp *interp, /* Current interpreter. */
- int argc, /* Number of arguments. */
- const char **argv) /* Argument strings. */
+TestgetdefencdirCmd(clientData, interp, argc, argv)
+ 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], NULL);
+ Tcl_AppendResult(interp,
+ "wrong # args: should be \"", argv[0],
+ (char *) NULL);
return TCL_ERROR;
}
- Tcl_AppendResult(interp, Tcl_GetDefaultEncodingDir(), NULL);
+ if (tclDefaultEncodingDir != NULL) {
+ Tcl_AppendResult(interp, tclDefaultEncodingDir, (char *) 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.
@@ -579,11 +621,11 @@ TestgetdefencdirCmd(
*/
static int
-TestalarmCmd(
- ClientData clientData, /* Not used. */
- Tcl_Interp *interp, /* Current interpreter. */
- int argc, /* Number of arguments. */
- const char **argv) /* Argument strings. */
+TestalarmCmd(clientData, interp, argc, argv)
+ 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;
@@ -596,24 +638,21 @@ TestalarmCmd(
}
/*
- * Setup the signal handling that automatically retries any interrupted
- * I/O system calls.
+ * Setup the signal handling that automatically retries
+ * any interupted 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
}
@@ -635,15 +674,13 @@ TestalarmCmd(
*/
static void
-AlarmHandler(
- int signum)
+AlarmHandler()
{
gotsig = "1";
}
/*
*----------------------------------------------------------------------
- *
* TestgotsigCmd --
*
* Verify the signal was handled after the testalarm command.
@@ -658,13 +695,13 @@ AlarmHandler(
*/
static int
-TestgotsigCmd(
- ClientData clientData, /* Not used. */
- Tcl_Interp *interp, /* Current interpreter. */
- int argc, /* Number of arguments. */
- const char **argv) /* Argument strings. */
+TestgotsigCmd(clientData, interp, argc, argv)
+ ClientData clientData; /* Not used. */
+ Tcl_Interp *interp; /* Current interpreter. */
+ int argc; /* Number of arguments. */
+ CONST char **argv; /* Argument strings. */
{
- Tcl_AppendResult(interp, gotsig, NULL);
+ Tcl_AppendResult(interp, gotsig, (char *) NULL);
gotsig = "0";
return TCL_OK;
}
@@ -689,17 +726,17 @@ TestgotsigCmd(
*/
static int
-TestchmodCmd(
- ClientData dummy, /* Not used. */
- Tcl_Interp *interp, /* Current interpreter. */
- int argc, /* Number of arguments. */
- const char **argv) /* Argument strings. */
+TestchmodCmd(dummy, interp, argc, argv)
+ ClientData dummy; /* Not used. */
+ Tcl_Interp *interp; /* Current interpreter. */
+ int argc; /* Number of arguments. */
+ CONST char **argv; /* Argument strings. */
{
int i, mode;
char *rest;
if (argc < 2) {
- usage:
+ usage:
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" mode file ?file ...?", NULL);
return TCL_ERROR;
@@ -712,7 +749,7 @@ TestchmodCmd(
for (i = 2; i < argc; i++) {
Tcl_DString buffer;
- const char *translated;
+ CONST char *translated;
translated = Tcl_TranslateFileName(interp, argv[i], &buffer);
if (translated == NULL) {
@@ -727,12 +764,3 @@ TestchmodCmd(
}
return TCL_OK;
}
-
-/*
- * Local Variables:
- * mode: c
- * c-basic-offset: 4
- * fill-column: 78
- * tab-width: 8
- * End:
- */