summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2010-04-04 15:11:51 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2010-04-04 15:11:51 (GMT)
commitc6d34ccc4d42388a8d6b75ea241569fa500aa0fe (patch)
tree100d20b7ba4b8d8b3d3937cc7cbf6ebee2649d69 /generic
parent89b9cfbb6ef818bf151a6edeb87edb4c2d2d9a50 (diff)
downloadtcl-c6d34ccc4d42388a8d6b75ea241569fa500aa0fe.zip
tcl-c6d34ccc4d42388a8d6b75ea241569fa500aa0fe.tar.gz
tcl-c6d34ccc4d42388a8d6b75ea241569fa500aa0fe.tar.bz2
Minor changes to enforce Engineering Manual style rules.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclIOUtil.c139
1 files changed, 74 insertions, 65 deletions
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index ff7af5a..6723f27 100644
--- a/generic/tclIOUtil.c
+++ b/generic/tclIOUtil.c
@@ -17,7 +17,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIOUtil.c,v 1.173 2010/04/02 23:11:55 nijtmans Exp $
+ * RCS: @(#) $Id: tclIOUtil.c,v 1.174 2010/04/04 15:11:51 dkf Exp $
*/
#include "tclInt.h"
@@ -42,9 +42,8 @@ static void FsUpdateCwd(Tcl_Obj *cwdObj, ClientData clientData);
#ifdef TCL_THREADS
static void FsRecacheFilesystemList(void);
#endif
-static void* DivertFindSymbol(Tcl_Interp* interp,
- Tcl_LoadHandle loadHandle,
- const char* symbol);
+static void * DivertFindSymbol(Tcl_Interp *interp,
+ Tcl_LoadHandle loadHandle, const char *symbol);
static void DivertUnloadFile(Tcl_LoadHandle loadHandle);
/*
@@ -2989,8 +2988,8 @@ Tcl_FSLoadFile(
res = Tcl_LoadFile(interp, pathPtr, symbols, 0, procPtrs, handlePtr);
if (res == TCL_OK) {
- *proc1Ptr = (Tcl_PackageInitProc*) procPtrs[0];
- *proc2Ptr = (Tcl_PackageInitProc*) procPtrs[1];
+ *proc1Ptr = (Tcl_PackageInitProc *) procPtrs[0];
+ *proc2Ptr = (Tcl_PackageInitProc *) procPtrs[1];
} else {
*proc1Ptr = *proc2Ptr = NULL;
}
@@ -3031,7 +3030,7 @@ Tcl_LoadFile(
Tcl_Interp *interp, /* Used for error reporting. */
Tcl_Obj *pathPtr, /* Name of the file containing the desired
* code. */
- const char *const symbols[], /* Names of functions to look up in the file's
+ const char *const symbols[],/* Names of functions to look up in the file's
* symbol table. */
int flags, /* Flags (unused) */
void *procVPtrs, /* Where to return the addresses corresponding
@@ -3040,10 +3039,10 @@ Tcl_LoadFile(
* information which can be used in
* TclpFindSymbol. */
{
- void** procPtrs = (void**) procVPtrs;
+ void **procPtrs = (void **) procVPtrs;
const Tcl_Filesystem *fsPtr = Tcl_FSGetFileSystemForPath(pathPtr);
const Tcl_Filesystem *copyFsPtr;
- Tcl_FSUnloadFileProc* unloadProcPtr;
+ Tcl_FSUnloadFileProc *unloadProcPtr;
Tcl_Obj *copyToPtr;
Tcl_LoadHandle newLoadHandle = NULL;
Tcl_LoadHandle divertedLoadHandle = NULL;
@@ -3152,7 +3151,8 @@ Tcl_LoadFile(
Tcl_FSDeleteFile(copyToPtr);
Tcl_DecrRefCount(copyToPtr);
- Tcl_AppendResult(interp, "couldn't load from current filesystem",NULL);
+ Tcl_AppendResult(interp, "couldn't load from current filesystem",
+ NULL);
return TCL_ERROR;
}
@@ -3166,7 +3166,7 @@ Tcl_LoadFile(
return TCL_ERROR;
}
-#if !defined(__WIN32__)
+#ifndef __WIN32__
/*
* Do we need to set appropriate permissions on the file? This may be
* required on some systems. On Unix we could loop over the file
@@ -3195,7 +3195,7 @@ Tcl_LoadFile(
Tcl_ResetResult(interp);
retVal = Tcl_LoadFile(interp, copyToPtr, symbols, 0, procPtrs,
- &newLoadHandle);
+ &newLoadHandle);
if (retVal != TCL_OK) {
/*
* The file didn't load successfully.
@@ -3279,7 +3279,7 @@ Tcl_LoadFile(
divertedLoadHandle = (Tcl_LoadHandle)
- ckalloc(sizeof (struct Tcl_LoadHandle_));
+ ckalloc(sizeof (struct Tcl_LoadHandle_));
divertedLoadHandle->clientData = (ClientData) tvdlPtr;
divertedLoadHandle->findSymbolProcPtr = DivertFindSymbol;
divertedLoadHandle->unloadFileProcPtr = DivertUnloadFile;
@@ -3293,16 +3293,18 @@ Tcl_LoadFile(
* At this point, *handlePtr is already set up to the handle for the
* loaded library. We now try to resolve the symbols.
*/
+
if (symbols != NULL) {
for (i=0 ; symbols[i] != NULL; i++) {
procPtrs[i] = Tcl_FindSymbol(interp, *handlePtr, symbols[i]);
if (procPtrs[i] == NULL) {
/*
- * At least one symbol in the list was not found.
- * Unload the file, and report the problem back to the
- * caller. (Tcl_FindSymbol should already have left an
- * appropriate error message.)
- */
+ * At least one symbol in the list was not found. Unload the
+ * file, and report the problem back to the caller.
+ * (Tcl_FindSymbol should already have left an appropriate
+ * error message.)
+ */
+
(*handlePtr)->unloadFileProcPtr(*handlePtr);
*handlePtr = NULL;
return TCL_ERROR;
@@ -3313,44 +3315,47 @@ Tcl_LoadFile(
}
/*
- *-----------------------------------------------------------------------------
+ *----------------------------------------------------------------------
*
* DivertFindSymbol --
*
* Find a symbol in a shared library loaded by copy-from-VFS.
*
- *-----------------------------------------------------------------------------
+ *----------------------------------------------------------------------
*/
-static void*
-DivertFindSymbol(Tcl_Interp* interp, /* Tcl interpreter */
- Tcl_LoadHandle loadHandle, /* Handle to the diverted module */
- const char* symbol) /* Symbol to resolve */
+static void *
+DivertFindSymbol(
+ Tcl_Interp *interp, /* Tcl interpreter */
+ Tcl_LoadHandle loadHandle, /* Handle to the diverted module */
+ const char *symbol) /* Symbol to resolve */
{
- FsDivertLoad* tvdlPtr = (FsDivertLoad*) (loadHandle->clientData);
+ FsDivertLoad *tvdlPtr = (FsDivertLoad *) loadHandle->clientData;
Tcl_LoadHandle originalHandle = tvdlPtr->loadHandle;
+
return originalHandle->findSymbolProcPtr(interp, originalHandle, symbol);
}
/*
- *-----------------------------------------------------------------------------
+ *----------------------------------------------------------------------
*
* DivertUnloadFile --
*
- * Unloads a file that has been loaded by copying from VFS to the
- * native filesystem.
+ * Unloads a file that has been loaded by copying from VFS to the native
+ * filesystem.
*
* Parameters:
* loadHandle -- Handle of the file to unload
*
- *-----------------------------------------------------------------------------
+ *----------------------------------------------------------------------
*/
static void
-DivertUnloadFile(Tcl_LoadHandle loadHandle)
+DivertUnloadFile(
+ Tcl_LoadHandle loadHandle)
{
- FsDivertLoad* tvdlPtr = (FsDivertLoad*) (loadHandle->clientData);
- Tcl_LoadHandle originalHandle = tvdlPtr->loadHandle;
+ FsDivertLoad *tvdlPtr = (FsDivertLoad *) loadHandle->clientData;
+ Tcl_LoadHandle originalHandle;
/*
* This test should never trigger, since we give the client data in the
@@ -3360,6 +3365,7 @@ DivertUnloadFile(Tcl_LoadHandle loadHandle)
if (tvdlPtr == NULL) {
return;
}
+ originalHandle = tvdlPtr->loadHandle;
/*
* Call the real 'unloadfile' proc we actually used. It is very important
@@ -3370,7 +3376,9 @@ DivertUnloadFile(Tcl_LoadHandle loadHandle)
originalHandle->unloadFileProcPtr(originalHandle);
- /* What filesystem contains the temp copy of the library? */
+ /*
+ * What filesystem contains the temp copy of the library?
+ */
if (tvdlPtr->divertedFilesystem == NULL) {
/*
@@ -3415,8 +3423,8 @@ DivertUnloadFile(Tcl_LoadHandle loadHandle)
Tcl_DecrRefCount(tvdlPtr->divertedFile);
}
- ckfree((void*)tvdlPtr);
- ckfree((void*)loadHandle);
+ ckfree((void *) tvdlPtr);
+ ckfree((void *) loadHandle);
}
/*
@@ -3464,82 +3472,83 @@ TclpLoadFile(
}
/*
- *-----------------------------------------------------------------------------
+ *----------------------------------------------------------------------
*
* Tcl_FindSymbol --
*
* Find a symbol in a loaded library
*
* Results:
- * Returns a pointer to the symbol if found. If not found, returns
- * NULL and leaves an error message in the interpreter result.
+ * Returns a pointer to the symbol if found. If not found, returns NULL
+ * and leaves an error message in the interpreter result.
*
- * This function was once filesystem-specific, but has been made portable
- * by having TclpDlopen return a structure that includes procedure pointers.
+ * This function was once filesystem-specific, but has been made portable by
+ * having TclpDlopen return a structure that includes procedure pointers.
*
- *-----------------------------------------------------------------------------
+ *----------------------------------------------------------------------
*/
-void*
-Tcl_FindSymbol(Tcl_Interp* interp, /* Tcl interpreter */
- Tcl_LoadHandle loadHandle, /* Handle to the loaded library */
- const char* symbol) /* Name of the symbol to resolve */
+void *
+Tcl_FindSymbol(
+ Tcl_Interp *interp, /* Tcl interpreter */
+ Tcl_LoadHandle loadHandle, /* Handle to the loaded library */
+ const char *symbol) /* Name of the symbol to resolve */
{
- return (*(loadHandle->findSymbolProcPtr))(interp, loadHandle, symbol);
+ return loadHandle->findSymbolProcPtr(interp, loadHandle, symbol);
}
/*
- *-----------------------------------------------------------------------------
+ *----------------------------------------------------------------------
*
* Tcl_FSUnloadFile --
*
* Unloads a library given its handle. Checks first that the library
* supports unloading.
*
- *-----------------------------------------------------------------------------
+ *----------------------------------------------------------------------
*/
int
-Tcl_FSUnloadFile(Tcl_Interp* interp, /* Tcl interpreter */
- Tcl_LoadHandle handle) /* Handle of the file to unload */
+Tcl_FSUnloadFile(
+ Tcl_Interp *interp, /* Tcl interpreter */
+ Tcl_LoadHandle handle) /* Handle of the file to unload */
{
if (handle->unloadFileProcPtr == NULL) {
if (interp != NULL) {
- Tcl_SetObjResult(interp,
- Tcl_NewStringObj("cannot unload: filesystem "
- "does not support unloading",
- -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "cannot unload: filesystem does not support unloading",
+ -1));
}
return TCL_ERROR;
- } else {
- TclpUnloadFile(handle);
- return TCL_OK;
}
+ TclpUnloadFile(handle);
+ return TCL_OK;
}
/*
- *-----------------------------------------------------------------------------
+ *----------------------------------------------------------------------
*
* TclpUnloadFile --
*
* Unloads a library given its handle
*
- * This function was once filesystem-specific, but has been made portable
- * by having TclpDlopen return a structure that includes procedure pointers.
+ * This function was once filesystem-specific, but has been made portable by
+ * having TclpDlopen return a structure that includes procedure pointers.
*
- *-----------------------------------------------------------------------------
+ *----------------------------------------------------------------------
*/
void
-TclpUnloadFile(Tcl_LoadHandle handle)
+TclpUnloadFile(
+ Tcl_LoadHandle handle)
{
if (handle->unloadFileProcPtr != NULL) {
- (*(handle->unloadFileProcPtr))(handle);
+ handle->unloadFileProcPtr(handle);
}
}
/*
- *---------------------------------------------------------------------------
+ *----------------------------------------------------------------------
*
* TclFSUnloadTempFile --
*
@@ -3554,7 +3563,7 @@ TclpUnloadFile(Tcl_LoadHandle handle)
* The effects of the 'unload' function called, and of course the
* temporary file will be deleted.
*
- *---------------------------------------------------------------------------
+ *----------------------------------------------------------------------
*/
void