diff options
Diffstat (limited to 'generic/tclGet.c')
-rw-r--r-- | generic/tclGet.c | 84 |
1 files changed, 20 insertions, 64 deletions
diff --git a/generic/tclGet.c b/generic/tclGet.c index b28b3f92..97e8c7b 100644 --- a/generic/tclGet.c +++ b/generic/tclGet.c @@ -10,12 +10,9 @@ * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tclGet.c,v 1.16 2005/07/24 22:56:43 dkf Exp $ */ #include "tclInt.h" - /* *---------------------------------------------------------------------- @@ -37,11 +34,12 @@ */ int -Tcl_GetInt(interp, src, intPtr) - Tcl_Interp *interp; /* Interpreter to use for error reporting. */ - CONST char *src; /* String containing a (possibly signed) - * integer in a form acceptable to strtoul. */ - int *intPtr; /* Place to store converted result. */ +Tcl_GetInt( + Tcl_Interp *interp, /* Interpreter to use for error reporting. */ + const char *src, /* String containing a (possibly signed) + * integer in a form acceptable to + * Tcl_GetIntFromObj(). */ + int *intPtr) /* Place to store converted result. */ { Tcl_Obj obj; int code; @@ -55,50 +53,7 @@ Tcl_GetInt(interp, src, intPtr) if (obj.refCount > 1) { Tcl_Panic("invalid sharing of Tcl_Obj on C stack"); } - return code; -} - -/* - *---------------------------------------------------------------------- - * - * TclGetLong -- - * - * Given a string, produce the corresponding long integer value. This - * routine is a version of Tcl_GetInt but returns a "long" instead of an - * "int" (a difference that matters on 64-bit architectures). - * - * Results: - * The return value is normally TCL_OK; in this case *longPtr will be set - * to the long integer value equivalent to src. If src is improperly - * formed then TCL_ERROR is returned and an error message will be left in - * the interp's result if interp is non-NULL. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -TclGetLong(interp, src, longPtr) - Tcl_Interp *interp; /* Interpreter used for error reporting if not - * NULL. */ - CONST char *src; /* String containing a (possibly signed) long - * integer in a form acceptable to strtoul. */ - long *longPtr; /* Place to store converted long result. */ -{ - Tcl_Obj obj; - int code; - - obj.refCount = 1; - obj.bytes = (char *) src; - obj.length = strlen(src); - obj.typePtr = NULL; - - code = Tcl_GetLongFromObj(interp, &obj, longPtr); - if (obj.refCount > 1) { - Tcl_Panic("invalid sharing of Tcl_Obj on C stack"); - } + TclFreeIntRep(&obj); return code; } @@ -123,11 +78,12 @@ TclGetLong(interp, src, longPtr) */ int -Tcl_GetDouble(interp, src, doublePtr) - Tcl_Interp *interp; /* Interpreter used for error reporting. */ - CONST char *src; /* String containing a floating-point number - * in a form acceptable to strtod. */ - double *doublePtr; /* Place to store converted result. */ +Tcl_GetDouble( + Tcl_Interp *interp, /* Interpreter used for error reporting. */ + const char *src, /* String containing a floating-point number + * in a form acceptable to + * Tcl_GetDoubleFromObj(). */ + double *doublePtr) /* Place to store converted result. */ { Tcl_Obj obj; int code; @@ -141,6 +97,7 @@ Tcl_GetDouble(interp, src, doublePtr) if (obj.refCount > 1) { Tcl_Panic("invalid sharing of Tcl_Obj on C stack"); } + TclFreeIntRep(&obj); return code; } @@ -165,12 +122,11 @@ Tcl_GetDouble(interp, src, doublePtr) */ int -Tcl_GetBoolean(interp, src, boolPtr) - Tcl_Interp *interp; /* Interpreter used for error reporting. */ - CONST char *src; /* String containing a boolean number - * specified either as 1/0 or true/false or - * yes/no. */ - int *boolPtr; /* Place to store converted result, which will +Tcl_GetBoolean( + Tcl_Interp *interp, /* Interpreter used for error reporting. */ + const char *src, /* String containing one of the boolean values + * 1, 0, true, false, yes, no, on, off. */ + int *boolPtr) /* Place to store converted result, which will * be 0 or 1. */ { Tcl_Obj obj; @@ -181,7 +137,7 @@ Tcl_GetBoolean(interp, src, boolPtr) obj.length = strlen(src); obj.typePtr = NULL; - code = Tcl_ConvertToType(interp, &obj, &tclBooleanType); + code = TclSetBooleanFromAny(interp, &obj); if (obj.refCount > 1) { Tcl_Panic("invalid sharing of Tcl_Obj on C stack"); } |