diff options
author | Kevin B Kenny <kennykb@acm.org> | 2004-10-21 03:53:03 (GMT) |
---|---|---|
committer | Kevin B Kenny <kennykb@acm.org> | 2004-10-21 03:53:03 (GMT) |
commit | 0e16d1cc7dd629f7bb9a3d1af174b072e9c8ae6c (patch) | |
tree | 7f3016e32458ec2688cfc76dc6342bd0b2097191 /generic | |
parent | 02b44df49ea3df0256e9e7b48d0f45f29840defe (diff) | |
download | tcl-0e16d1cc7dd629f7bb9a3d1af174b072e9c8ae6c.zip tcl-0e16d1cc7dd629f7bb9a3d1af174b072e9c8ae6c.tar.gz tcl-0e16d1cc7dd629f7bb9a3d1af174b072e9c8ae6c.tar.bz2 |
doubled speed of clock format
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclBasic.c | 5 | ||||
-rw-r--r-- | generic/tclClock.c | 49 | ||||
-rw-r--r-- | generic/tclInt.h | 4 |
3 files changed, 55 insertions, 3 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c index c568e30..1a370bc 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclBasic.c,v 1.129 2004/10/19 21:54:06 dgp Exp $ + * RCS: @(#) $Id: tclBasic.c,v 1.130 2004/10/21 03:53:04 kennykb Exp $ */ #include "tclInt.h" @@ -382,6 +382,9 @@ Tcl_CreateInterp() Tcl_CreateObjCommand( interp, "::tcl::clock::clicks", TclClockClicksObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc*) NULL ); + Tcl_CreateObjCommand( interp, "::tcl::clock::getenv", + TclClockGetenvObjCmd, (ClientData) NULL, + (Tcl_CmdDeleteProc*) NULL ); Tcl_CreateObjCommand( interp, "::tcl::clock::microseconds", TclClockMicrosecondsObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc*) NULL ); diff --git a/generic/tclClock.c b/generic/tclClock.c index e30760b..68b7142 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.34 2004/09/27 14:31:17 kennykb Exp $ + * RCS: @(#) $Id: tclClock.c,v 1.35 2004/10/21 03:53:04 kennykb Exp $ */ #include "tclInt.h" @@ -47,6 +47,53 @@ static struct tm* ThreadSafeLocalTime _ANSI_ARGS_(( CONST time_t* )); static void TzsetIfNecessary _ANSI_ARGS_(( void )); /* + *---------------------------------------------------------------------- + * + * TclClockGetenvObjCmd -- + * + * Tcl command that reads an environment variable from the system + * + * Usage: + * ::tcl::clock::getEnv NAME + * + * Parameters: + * NAME - Name of the environment variable desired + * + * Results: + * Returns a standard Tcl result. Returns an error if the + * variable does not exist, with a message left in the interpreter. + * Returns TCL_OK and the value of the variable if the variable + * does exist, + * + *---------------------------------------------------------------------- + */ + +int +TclClockGetenvObjCmd( ClientData clientData, + Tcl_Interp* interp, + int objc, + Tcl_Obj *CONST objv[] ) +{ + + CONST char* varName; + CONST char* varValue; + if ( objc != 2 ) { + Tcl_WrongNumArgs( interp, 1, objv, "name" ); + return TCL_ERROR; + } + varName = Tcl_GetStringFromObj( objv[1], NULL ); + varValue = getenv( varName ); + if ( varValue == NULL ) { + Tcl_SetObjResult( interp, + Tcl_NewStringObj( "variable not found", -1 ) ); + return TCL_ERROR; + } else { + Tcl_SetObjResult( interp, Tcl_NewStringObj( varValue, -1 ) ); + return TCL_OK; + } +} + +/* *------------------------------------------------------------------------- * * TclClockLocaltimeObjCmd -- diff --git a/generic/tclInt.h b/generic/tclInt.h index 260e8dc..f2dc36e 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -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: tclInt.h,v 1.183 2004/10/19 21:54:07 dgp Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.184 2004/10/21 03:53:04 kennykb Exp $ */ #ifndef _TCLINT @@ -1956,6 +1956,8 @@ EXTERN int Tcl_CdObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); EXTERN int TclClockClicksObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); +EXTERN int TclClockGetenvObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); EXTERN int TclClockMicrosecondsObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); EXTERN int TclClockMillisecondsObjCmd _ANSI_ARGS_((ClientData clientData, |