summaryrefslogtreecommitdiffstats
path: root/generic/tclClock.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-10-29 15:39:02 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-10-29 15:39:02 (GMT)
commitf21fa0e01c0fb463b0ec26f3b0cef1218243908a (patch)
tree0fe2010a58b021f880f03fd319b7dce9e764cd63 /generic/tclClock.c
parent151836cea1737631c005e07ca9a26e7641ff009d (diff)
downloadtcl-f21fa0e01c0fb463b0ec26f3b0cef1218243908a.zip
tcl-f21fa0e01c0fb463b0ec26f3b0cef1218243908a.tar.gz
tcl-f21fa0e01c0fb463b0ec26f3b0cef1218243908a.tar.bz2
Allow ensembles to rewrite their subcommands' error messages to be more
relevant to users. [Patch 1056864] Also patches to core to take advantage of this Also other general cleaning up of Tcl_WrongNumArgs usage
Diffstat (limited to 'generic/tclClock.c')
-rw-r--r--generic/tclClock.c108
1 files changed, 51 insertions, 57 deletions
diff --git a/generic/tclClock.c b/generic/tclClock.c
index 68b7142..ff63767 100644
--- a/generic/tclClock.c
+++ b/generic/tclClock.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclClock.c,v 1.35 2004/10/21 03:53:04 kennykb Exp $
+ * RCS: @(#) $Id: tclClock.c,v 1.36 2004/10/29 15:39:05 dkf Exp $
*/
#include "tclInt.h"
@@ -336,7 +336,6 @@ TclClockMktimeObjCmd( ClientData clientData,
}
-
/*----------------------------------------------------------------------
*
* TclClockClicksObjCmd --
@@ -356,7 +355,7 @@ TclClockMktimeObjCmd( ClientData clientData,
*/
int
-TclClockClicksObjCmd( clientData, interp, objc, objv )
+TclClockClicksObjCmd(clientData, interp, objc, objv)
ClientData clientData; /* Client data is unused */
Tcl_Interp* interp; /* Tcl interpreter */
int objc; /* Parameter count */
@@ -371,46 +370,43 @@ TclClockClicksObjCmd( clientData, interp, objc, objv )
int index = CLICKS_NATIVE;
Tcl_Time now;
- switch ( objc ) {
- case 1:
- break;
- case 2:
- if ( Tcl_GetIndexFromObj( interp, objv[1], clicksSwitches,
- "option", 0, &index) != TCL_OK ) {
- return TCL_ERROR;
- }
- break;
- default:
- Tcl_WrongNumArgs( interp, 1, objv, "?option?" );
+ switch (objc) {
+ case 1:
+ break;
+ case 2:
+ if (Tcl_GetIndexFromObj(interp, objv[1], clicksSwitches, "option", 0,
+ &index) != TCL_OK) {
return TCL_ERROR;
+ }
+ break;
+ default:
+ Tcl_WrongNumArgs(interp, 1, objv, "?option?");
+ return TCL_ERROR;
}
- switch ( index ) {
- case CLICKS_MILLIS:
- Tcl_GetTime( &now );
- Tcl_SetObjResult( interp,
- Tcl_NewWideIntObj( (Tcl_WideInt) now.sec * 1000
- + now.usec / 1000 ) );
- break;
- case CLICKS_NATIVE:
+ switch (index) {
+ case CLICKS_MILLIS:
+ Tcl_GetTime(&now);
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj( (Tcl_WideInt)
+ now.sec * 1000 + now.usec / 1000 ) );
+ break;
+ case CLICKS_NATIVE:
#if 0
- /*
- * The following code will be used once this is incorporated
- * into Tcl. But TEA bugs prevent it for right now. :(
- * So we fall through this case and return the microseconds
- * instead.
- */
- Tcl_SetObjResult( interp,
- Tcl_NewWideIntObj( (Tcl_WideInt) TclpGetClicks() ) );
- break;
+ /*
+ * The following code will be used once this is incorporated
+ * into Tcl. But TEA bugs prevent it for right now. :(
+ * So we fall through this case and return the microseconds
+ * instead.
+ */
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj( (Tcl_WideInt)
+ TclpGetClicks()));
+ break;
#endif
- case CLICKS_MICROS:
- Tcl_GetTime( &now );
- Tcl_SetObjResult( interp,
- Tcl_NewWideIntObj( ( (Tcl_WideInt) now.sec
- * 1000000 )
- + now.usec ) );
- break;
+ case CLICKS_MICROS:
+ Tcl_GetTime(&now);
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
+ ((Tcl_WideInt) now.sec * 1000000) + now.usec));
+ break;
}
return TCL_OK;
@@ -435,21 +431,20 @@ TclClockClicksObjCmd( clientData, interp, objc, objv )
*/
int
-TclClockMillisecondsObjCmd( clientData, interp, objc, objv )
+TclClockMillisecondsObjCmd(clientData, interp, objc, objv)
ClientData clientData; /* Client data is unused */
Tcl_Interp* interp; /* Tcl interpreter */
int objc; /* Parameter count */
Tcl_Obj* CONST* objv; /* Parameter values */
{
Tcl_Time now;
- if ( objc != 1 ) {
- Tcl_WrongNumArgs( interp, 1, objv, "" );
+ if (objc != 1) {
+ Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
- Tcl_GetTime( &now );
- Tcl_SetObjResult( interp,
- Tcl_NewWideIntObj( (Tcl_WideInt) now.sec * 1000
- + now.usec / 1000 ) );
+ Tcl_GetTime(&now);
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj( (Tcl_WideInt)
+ now.sec * 1000 + now.usec / 1000));
return TCL_OK;
}
@@ -472,21 +467,20 @@ TclClockMillisecondsObjCmd( clientData, interp, objc, objv )
*/
int
-TclClockMicrosecondsObjCmd( clientData, interp, objc, objv )
+TclClockMicrosecondsObjCmd(clientData, interp, objc, objv)
ClientData clientData; /* Client data is unused */
Tcl_Interp* interp; /* Tcl interpreter */
int objc; /* Parameter count */
Tcl_Obj* CONST* objv; /* Parameter values */
{
Tcl_Time now;
- if ( objc != 1 ) {
- Tcl_WrongNumArgs( interp, 1, objv, "" );
+ if (objc != 1) {
+ Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
- Tcl_GetTime( &now );
- Tcl_SetObjResult( interp,
- Tcl_NewWideIntObj( ( (Tcl_WideInt) now.sec * 1000000 )
- + now.usec ) );
+ Tcl_GetTime(&now);
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
+ ((Tcl_WideInt) now.sec * 1000000) + now.usec));
return TCL_OK;
}
@@ -509,19 +503,19 @@ TclClockMicrosecondsObjCmd( clientData, interp, objc, objv )
*/
int
-TclClockSecondsObjCmd( clientData, interp, objc, objv )
+TclClockSecondsObjCmd(clientData, interp, objc, objv)
ClientData clientData; /* Client data is unused */
Tcl_Interp* interp; /* Tcl interpreter */
int objc; /* Parameter count */
Tcl_Obj* CONST* objv; /* Parameter values */
{
Tcl_Time now;
- if ( objc != 1 ) {
- Tcl_WrongNumArgs( interp, 1, objv, "" );
+ if (objc != 1) {
+ Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
- Tcl_GetTime( &now );
- Tcl_SetObjResult( interp, Tcl_NewWideIntObj( (Tcl_WideInt) now.sec ) );
+ Tcl_GetTime(&now);
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj((Tcl_WideInt) now.sec));
return TCL_OK;
}