diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2005-11-02 15:59:48 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2005-11-02 15:59:48 (GMT) |
commit | 4fc8ab60904ddf9c20b0ec362fa8c179a6cb7424 (patch) | |
tree | 2022311f9fa368c4723313f09f6a4c487f90d65c /generic/tclTestProcBodyObj.c | |
parent | 4f31953cdce3f382551e258f2ff7c157d7c4908f (diff) | |
download | tcl-4fc8ab60904ddf9c20b0ec362fa8c179a6cb7424.zip tcl-4fc8ab60904ddf9c20b0ec362fa8c179a6cb7424.tar.gz tcl-4fc8ab60904ddf9c20b0ec362fa8c179a6cb7424.tar.bz2 |
ANSIfy the test code (well, strip some of the worst offences!)
Diffstat (limited to 'generic/tclTestProcBodyObj.c')
-rw-r--r-- | generic/tclTestProcBodyObj.c | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/generic/tclTestProcBodyObj.c b/generic/tclTestProcBodyObj.c index 5d8084d..e3f12a1 100644 --- a/generic/tclTestProcBodyObj.c +++ b/generic/tclTestProcBodyObj.c @@ -1,16 +1,16 @@ -/* +/* * tclTestProcBodyObj.c -- * - * Implements the "procbodytest" package, which contains commands - * to test creation of Tcl procedures whose body argument is a - * Tcl_Obj of type "procbody" rather than a string. + * Implements the "procbodytest" package, which contains commands to test + * creation of Tcl procedures whose body argument is a Tcl_Obj of type + * "procbody" rather than a string. * * 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: tclTestProcBodyObj.c,v 1.3 2004/08/25 01:11:20 dgp Exp $ + * RCS: @(#) $Id: tclTestProcBodyObj.c,v 1.4 2005/11/02 15:59:49 dkf Exp $ */ #include "tclInt.h" @@ -44,31 +44,26 @@ typedef struct CmdTable * Declarations for functions defined in this file. */ -static int ProcBodyTestProcObjCmd _ANSI_ARGS_((ClientData dummy, - Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -static int ProcBodyTestInitInternal _ANSI_ARGS_((Tcl_Interp *interp, - int isSafe)); -static int RegisterCommand _ANSI_ARGS_((Tcl_Interp* interp, - char *namespace, CONST CmdTable *cmdTablePtr)); -int Procbodytest_Init _ANSI_ARGS_((Tcl_Interp * interp)); -int Procbodytest_SafeInit _ANSI_ARGS_((Tcl_Interp * interp)); +static int ProcBodyTestProcObjCmd(ClientData dummy, + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); +static int ProcBodyTestInitInternal(Tcl_Interp *interp, int isSafe); +static int RegisterCommand(Tcl_Interp* interp, + char *namespace, CONST CmdTable *cmdTablePtr); +int Procbodytest_Init(Tcl_Interp * interp); +int Procbodytest_SafeInit(Tcl_Interp * interp); /* * List of commands to create when the package is loaded; must go after the * declarations of the enable command procedure. */ -static CONST CmdTable commands[] = -{ +static CONST CmdTable commands[] = { { procCommand, ProcBodyTestProcObjCmd, 1 }, - { 0, 0, 0 } }; -static CONST CmdTable safeCommands[] = -{ +static CONST CmdTable safeCommands[] = { { procCommand, ProcBodyTestProcObjCmd, 1 }, - { 0, 0, 0 } }; @@ -77,7 +72,7 @@ static CONST CmdTable safeCommands[] = * * Procbodytest_Init -- * - * This procedure initializes the "procbodytest" package. + * This function initializes the "procbodytest" package. * * Results: * A standard Tcl result. @@ -101,7 +96,7 @@ Procbodytest_Init(interp) * * Procbodytest_SafeInit -- * - * This procedure initializes the "procbodytest" package. + * This function initializes the "procbodytest" package. * * Results: * A standard Tcl result. @@ -125,7 +120,7 @@ Procbodytest_SafeInit(interp) * * RegisterCommand -- * - * This procedure registers a command in the context of the given namespace. + * This function registers a command in the context of the given namespace. * * Results: * A standard Tcl result. @@ -137,11 +132,11 @@ Procbodytest_SafeInit(interp) */ static int RegisterCommand(interp, namespace, cmdTablePtr) - Tcl_Interp* interp; /* the Tcl interpreter for which the - * operation is performed */ - char *namespace; /* the namespace in which the command - * is registered */ - CONST CmdTable *cmdTablePtr; /* the command to register */ + Tcl_Interp* interp; /* the Tcl interpreter for which the operation + * is performed */ + char *namespace; /* the namespace in which the command is + * registered */ + CONST CmdTable *cmdTablePtr;/* the command to register */ { char buf[128]; @@ -151,7 +146,7 @@ static int RegisterCommand(interp, namespace, cmdTablePtr) if (Tcl_Eval(interp, buf) != TCL_OK) return TCL_ERROR; } - + sprintf(buf, "%s::%s", namespace, cmdTablePtr->cmdName); Tcl_CreateObjCommand(interp, buf, cmdTablePtr->proc, 0, 0); @@ -163,7 +158,7 @@ static int RegisterCommand(interp, namespace, cmdTablePtr) * * ProcBodyTestInitInternal -- * - * This procedure initializes the Loader package. + * This function initializes the Loader package. * The isSafe flag is 1 if the interpreter is safe, 0 otherwise. * * Results: @@ -189,7 +184,7 @@ ProcBodyTestInitInternal(interp, isSafe) return TCL_ERROR; } } - + return Tcl_PkgProvide(interp, packageName, packageVersion); } @@ -236,11 +231,11 @@ ProcBodyTestProcObjCmd (dummy, interp, objc, objv) char *fullName; Tcl_Command procCmd; Command *cmdPtr; - Proc *procPtr = (Proc *) NULL; + Proc *procPtr = NULL; Tcl_Obj *bodyObjPtr; Tcl_Obj *myobjv[5]; int result; - + if (objc != 4) { Tcl_WrongNumArgs(interp, 1, objv, "newName argsList bodyName"); return TCL_ERROR; @@ -249,10 +244,9 @@ ProcBodyTestProcObjCmd (dummy, interp, objc, objv) /* * Find the Command pointer to this procedure */ - - fullName = Tcl_GetStringFromObj(objv[3], (int *) NULL); - procCmd = Tcl_FindCommand(interp, fullName, (Tcl_Namespace *) NULL, - TCL_LEAVE_ERR_MSG); + + fullName = Tcl_GetStringFromObj(objv[3], NULL); + procCmd = Tcl_FindCommand(interp, fullName, NULL, TCL_LEAVE_ERR_MSG); if (procCmd == NULL) { return TCL_ERROR; } @@ -266,23 +260,22 @@ ProcBodyTestProcObjCmd (dummy, interp, objc, objv) if (cmdPtr->objProc != TclGetObjInterpProc()) { Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - "command \"", fullName, - "\" is not a Tcl procedure", (char *) NULL); + "command \"", fullName, "\" is not a Tcl procedure", NULL); return TCL_ERROR; } /* * it is a Tcl procedure: the client data is the Proc structure */ - + procPtr = (Proc *) cmdPtr->objClientData; if (procPtr == NULL) { Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "procedure \"", fullName, - "\" does not have a Proc struct!", (char *) NULL); + "\" does not have a Proc struct!", NULL); return TCL_ERROR; } - + /* * create a new object, initialize our argument vector, call into Tcl */ @@ -291,7 +284,7 @@ ProcBodyTestProcObjCmd (dummy, interp, objc, objv) if (bodyObjPtr == NULL) { Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "failed to create a procbody object for procedure \"", - fullName, "\"", (char *) NULL); + fullName, "\"", NULL); return TCL_ERROR; } Tcl_IncrRefCount(bodyObjPtr); @@ -300,10 +293,18 @@ ProcBodyTestProcObjCmd (dummy, interp, objc, objv) myobjv[1] = objv[1]; myobjv[2] = objv[2]; myobjv[3] = bodyObjPtr; - myobjv[4] = (Tcl_Obj *) NULL; + myobjv[4] = NULL; result = Tcl_ProcObjCmd((ClientData) NULL, interp, objc, myobjv); Tcl_DecrRefCount(bodyObjPtr); return result; } + +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ |