From db2e6bf825388498ab5798bbeca26fce23d4286f Mon Sep 17 00:00:00 2001 From: nijtmans Date: Mon, 17 Nov 2008 22:15:34 +0000 Subject: Fix signature and implementation of Tcl_HashStats, such that it conforms to the documentation. --- ChangeLog | 9 +++++++++ doc/Hash.3 | 4 ++-- generic/tcl.decls | 4 ++-- generic/tclDecls.h | 6 +++--- generic/tclDictObj.c | 11 +++++------ generic/tclHash.c | 10 +++------- generic/tclVar.c | 4 ++-- 7 files changed, 26 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 81ce5f8..3f01f47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-11-16 Jan Nijtmans + + * generic/tcl.decls: Fix signature and implementation of + * generic/tclDecls.h: Tcl_HashStats, such that it conforms + * generic/tclHash.c: to the documentation. + * generic/tclVar.c: + * doc/Hash.3 + * generic/tclDictObj.c Convert Tcl_SetResult call to Tcl_SetObjResult. + 2008-11-17 Alexandre Ferrieux * tests/for.test: Check for uncompiled-for-continue [Bug 2186888] diff --git a/doc/Hash.3 b/doc/Hash.3 index 6e57cf3..f2e5228 100644 --- a/doc/Hash.3 +++ b/doc/Hash.3 @@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: Hash.3,v 1.30 2008/10/17 10:22:25 dkf Exp $ +'\" RCS: @(#) $Id: Hash.3,v 1.31 2008/11/17 22:15:34 nijtmans Exp $ '\" .so man.macros .TH Tcl_Hash 3 "" Tcl "Tcl Library Procedures" @@ -46,7 +46,7 @@ Tcl_HashEntry * Tcl_HashEntry * \fBTcl_NextHashEntry\fR(\fIsearchPtr\fR) .sp -const char * +char * \fBTcl_HashStats\fR(\fItablePtr\fR) .SH ARGUMENTS .AS "const Tcl_HashKeyType" *searchPtr out diff --git a/generic/tcl.decls b/generic/tcl.decls index 53604a6..715c2ad 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -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: tcl.decls,v 1.153 2008/10/22 20:23:59 nijtmans Exp $ +# RCS: @(#) $Id: tcl.decls,v 1.154 2008/11/17 22:15:34 nijtmans Exp $ library tcl @@ -953,7 +953,7 @@ declare 268 generic { void Tcl_AppendStringsToObjVA(Tcl_Obj *objPtr, va_list argList) } declare 269 generic { - CONST84_RETURN char * Tcl_HashStats(Tcl_HashTable *tablePtr) + char * Tcl_HashStats(Tcl_HashTable *tablePtr) } declare 270 generic { CONST84_RETURN char * Tcl_ParseVar(Tcl_Interp *interp, const char *start, diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 784f1ca..2578df2 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclDecls.h,v 1.155 2008/10/22 20:23:59 nijtmans Exp $ + * RCS: @(#) $Id: tclDecls.h,v 1.156 2008/11/17 22:15:34 nijtmans Exp $ */ #ifndef _TCLDECLS @@ -1692,7 +1692,7 @@ EXTERN void Tcl_AppendStringsToObjVA (Tcl_Obj * objPtr, #ifndef Tcl_HashStats_TCL_DECLARED #define Tcl_HashStats_TCL_DECLARED /* 269 */ -EXTERN CONST84_RETURN char * Tcl_HashStats (Tcl_HashTable * tablePtr); +EXTERN char * Tcl_HashStats (Tcl_HashTable * tablePtr); #endif #ifndef Tcl_ParseVar_TCL_DECLARED #define Tcl_ParseVar_TCL_DECLARED @@ -3985,7 +3985,7 @@ typedef struct TclStubs { void (*tcl_ValidateAllMemory) (const char * file, int line); /* 266 */ void (*tcl_AppendResultVA) (Tcl_Interp * interp, va_list argList); /* 267 */ void (*tcl_AppendStringsToObjVA) (Tcl_Obj * objPtr, va_list argList); /* 268 */ - CONST84_RETURN char * (*tcl_HashStats) (Tcl_HashTable * tablePtr); /* 269 */ + char * (*tcl_HashStats) (Tcl_HashTable * tablePtr); /* 269 */ CONST84_RETURN char * (*tcl_ParseVar) (Tcl_Interp * interp, const char * start, CONST84 char ** termPtr); /* 270 */ CONST84_RETURN char * (*tcl_PkgPresent) (Tcl_Interp * interp, const char * name, const char * version, int exact); /* 271 */ CONST84_RETURN char * (*tcl_PkgPresentEx) (Tcl_Interp * interp, const char * name, const char * version, int exact, ClientData * clientDataPtr); /* 272 */ diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index 2b87c01..75e1478 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclDictObj.c,v 1.69 2008/10/15 06:17:04 nijtmans Exp $ + * RCS: @(#) $Id: tclDictObj.c,v 1.70 2008/11/17 22:15:34 nijtmans Exp $ */ #include "tclInt.h" @@ -2061,6 +2061,7 @@ DictInfoCmd( { Tcl_Obj *dictPtr; Dict *dict; + char *buf; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "dictionary"); @@ -2076,11 +2077,9 @@ DictInfoCmd( } dict = dictPtr->internalRep.otherValuePtr; - /* - * This next cast is actually OK. - */ - - Tcl_SetResult(interp, (char *) Tcl_HashStats(&dict->table), TCL_DYNAMIC); + buf = Tcl_HashStats(&dict->table); + Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1)); + ckfree(buf); return TCL_OK; } diff --git a/generic/tclHash.c b/generic/tclHash.c index dd995f0..89fbb6f 100644 --- a/generic/tclHash.c +++ b/generic/tclHash.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclHash.c,v 1.36 2008/10/15 06:17:03 nijtmans Exp $ + * RCS: @(#) $Id: tclHash.c,v 1.37 2008/11/17 22:15:34 nijtmans Exp $ */ #include "tclInt.h" @@ -614,7 +614,7 @@ Tcl_NextHashEntry( *---------------------------------------------------------------------- */ -const char * +char * Tcl_HashStats( Tcl_HashTable *tablePtr) /* Table for which to produce stats. */ { @@ -665,11 +665,7 @@ Tcl_HashStats( * Print out the histogram and a few other pieces of information. */ - if (typePtr->flags & TCL_HASH_KEY_SYSTEM_HASH) { - result = (char *) TclpSysAlloc((unsigned) (NUM_COUNTERS*60) + 300, 0); - } else { - result = (char *) ckalloc((unsigned) (NUM_COUNTERS*60) + 300); - } + result = (char *) ckalloc((unsigned) (NUM_COUNTERS*60) + 300); sprintf(result, "%d entries in table, %d buckets\n", tablePtr->numEntries, tablePtr->numBuckets); p = result + strlen(result); diff --git a/generic/tclVar.c b/generic/tclVar.c index dc35f69..34d3741 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -16,7 +16,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclVar.c,v 1.171 2008/10/26 18:34:04 dkf Exp $ + * RCS: @(#) $Id: tclVar.c,v 1.172 2008/11/17 22:15:34 nijtmans Exp $ */ #include "tclInt.h" @@ -3214,7 +3214,7 @@ Tcl_ArrayObjCmd( } case ARRAY_STATISTICS: { - const char *stats; + char *stats; if (notArray) { goto error; -- cgit v0.12