summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authornijtmans <nijtmans>2009-02-03 23:34:32 (GMT)
committernijtmans <nijtmans>2009-02-03 23:34:32 (GMT)
commit22d5aa3e9618d2c3f426a16282fbdb93be01b417 (patch)
tree7d87c563d81459de0af29d9c6276a5d4c21f403b /generic
parent6b40f13d26013e672072cb794817a2d322d8127e (diff)
downloadtcl-22d5aa3e9618d2c3f426a16282fbdb93be01b417.zip
tcl-22d5aa3e9618d2c3f426a16282fbdb93be01b417.tar.gz
tcl-22d5aa3e9618d2c3f426a16282fbdb93be01b417.tar.bz2
- eliminate some unnessary type casts
- some internal const decorations - spacing
Diffstat (limited to 'generic')
-rw-r--r--generic/tclBasic.c20
-rw-r--r--generic/tclBinary.c18
-rw-r--r--generic/tclCmdAH.c8
-rw-r--r--generic/tclCmdIL.c28
-rw-r--r--generic/tclCmdMZ.c32
-rw-r--r--generic/tclCompCmds.c8
-rw-r--r--generic/tclDictObj.c21
7 files changed, 69 insertions, 66 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 0cd1196..b1a8d35 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.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: tclBasic.c,v 1.384 2009/01/28 16:28:32 dkf Exp $
+ * RCS: @(#) $Id: tclBasic.c,v 1.385 2009/02/03 23:34:33 nijtmans Exp $
*/
#include "tclInt.h"
@@ -4141,7 +4141,7 @@ TclNREvalObjv(
}
if (TCL_DTRACE_CMD_ARGS_ENABLED()) {
- char *a[10];
+ const char *a[10];
int i = 0;
while (i < 10) {
@@ -4460,7 +4460,7 @@ TEOV_Error(
{
Interp *iPtr = (Interp *) interp;
Tcl_Obj *listPtr;
- char *cmdString;
+ const char *cmdString;
int cmdLen;
int objc = PTR2INT(data[0]);
Tcl_Obj **objv = data[1];
@@ -4590,7 +4590,7 @@ TEOV_RunEnterTraces(
int traceCode = TCL_OK;
int cmdEpoch = cmdPtr->cmdEpoch;
int newEpoch;
- char *command;
+ const char *command;
int length;
Tcl_Obj *commandPtr;
@@ -4648,7 +4648,7 @@ TEOV_RunLeaveTraces(
int result)
{
Interp *iPtr = (Interp *) interp;
- char *command;
+ const char *command;
int length, objc;
Tcl_Obj **objv;
int traceCode = PTR2INT(data[0]);
@@ -5862,7 +5862,7 @@ TclNREvalObjEx(
* in the bytecode compiler.
*/
- char *script;
+ const char *script;
int numSrcBytes;
Tcl_IncrRefCount(objPtr);
@@ -5953,7 +5953,7 @@ TEOEx_ByteCodeCallback(
result = TclUpdateReturnInfo(iPtr);
}
if ((result != TCL_OK) && (result != TCL_ERROR) && !allowExceptions) {
- char *script;
+ const char *script;
int numSrcBytes;
ProcessUnexpectedResult(interp, result);
@@ -6363,7 +6363,7 @@ TclObjInvoke(
{
register Interp *iPtr = (Interp *) interp;
Tcl_HashTable *hTblPtr; /* Table of hidden commands. */
- char *cmdName; /* Name of the command from objv[0]. */
+ const char *cmdName; /* Name of the command from objv[0]. */
Tcl_HashEntry *hPtr = NULL;
Command *cmdPtr;
int result;
@@ -7844,7 +7844,7 @@ Tcl_NRCallObjProc(
TEOV_callback *rootPtr = TOP_CB(interp);
if (TCL_DTRACE_CMD_ARGS_ENABLED()) {
- char *a[10];
+ const char *a[10];
int i = 0;
while (i < 10) {
@@ -8399,7 +8399,7 @@ TclNRCoroutineObjCmd(
Tcl_Obj *cmdObjPtr;
CallFrame *framePtr, **framePtrPtr;
TEOV_callback *rootPtr = TOP_CB(interp);
- char *fullName;
+ const char *fullName;
const char *procName;
Namespace *nsPtr, *altNsPtr, *cxtNsPtr;
Tcl_DString ds;
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index 6802c10..68409d1 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.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: tclBinary.c,v 1.53 2009/01/09 11:21:45 dkf Exp $
+ * RCS: @(#) $Id: tclBinary.c,v 1.54 2009/02/03 23:34:32 nijtmans Exp $
*/
#include "tclInt.h"
@@ -61,7 +61,7 @@ static void DupByteArrayInternalRep(Tcl_Obj *srcPtr,
static int FormatNumber(Tcl_Interp *interp, int type,
Tcl_Obj *src, unsigned char **cursorPtr);
static void FreeByteArrayInternalRep(Tcl_Obj *objPtr);
-static int GetFormatSpec(char **formatPtr, char *cmdPtr,
+static int GetFormatSpec(const char **formatPtr, char *cmdPtr,
int *countPtr, int *flagsPtr);
static Tcl_Obj * ScanNumber(unsigned char *buffer, int type,
int flags, Tcl_HashTable **numberCachePtr);
@@ -425,7 +425,7 @@ SetByteArrayFromAny(
Tcl_Obj *objPtr) /* The object to convert to type ByteArray. */
{
int length;
- char *src, *srcEnd;
+ const char *src, *srcEnd;
unsigned char *dst;
ByteArray *byteArrayPtr;
Tcl_UniChar ch;
@@ -651,7 +651,7 @@ BinaryFormatCmd(
int count; /* Count associated with current format
* character. */
int flags; /* Format field flags */
- char *format; /* Pointer to current position in format
+ const char *format; /* Pointer to current position in format
* string. */
Tcl_Obj *resultPtr = NULL; /* Object holding result buffer. */
unsigned char *buffer; /* Start of result buffer. */
@@ -659,7 +659,7 @@ BinaryFormatCmd(
unsigned char *maxPos; /* Greatest position within result buffer that
* cursor has visited.*/
const char *errorString;
- char *errorValue, *str;
+ const char *errorValue, *str;
int offset, size, length;
if (objc < 2) {
@@ -1155,13 +1155,13 @@ BinaryScanCmd(
int count; /* Count associated with current format
* character. */
int flags; /* Format field flags */
- char *format; /* Pointer to current position in format
+ const char *format; /* Pointer to current position in format
* string. */
Tcl_Obj *resultPtr = NULL; /* Object holding result buffer. */
unsigned char *buffer; /* Start of result buffer. */
unsigned char *cursor; /* Current position within result buffer. */
const char *errorString;
- char *str;
+ const char *str;
int offset, size, length;
int i;
@@ -1520,7 +1520,7 @@ BinaryScanCmd(
static int
GetFormatSpec(
- char **formatPtr, /* Pointer to format string. */
+ const char **formatPtr, /* Pointer to format string. */
char *cmdPtr, /* Pointer to location of command char. */
int *countPtr, /* Pointer to repeat count value. */
int *flagsPtr) /* Pointer to field flags */
@@ -1555,7 +1555,7 @@ GetFormatSpec(
(*formatPtr)++;
*countPtr = BINARY_ALL;
} else if (isdigit(UCHAR(**formatPtr))) { /* INTL: digit */
- *countPtr = strtoul(*formatPtr, formatPtr, 10);
+ *countPtr = strtoul(*formatPtr, (char **) formatPtr, 10);
} else {
*countPtr = BINARY_NOCOUNT;
}
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index 988f21f..c8829f8 100644
--- a/generic/tclCmdAH.c
+++ b/generic/tclCmdAH.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: tclCmdAH.c,v 1.114 2009/01/04 22:57:39 dkf Exp $
+ * RCS: @(#) $Id: tclCmdAH.c,v 1.115 2009/02/03 23:34:33 nijtmans Exp $
*/
#include "tclInt.h"
@@ -126,7 +126,7 @@ Tcl_CaseObjCmd(
{
register int i;
int body, result, caseObjc;
- char *stringPtr, *arg;
+ const char *stringPtr, *arg;
Tcl_Obj *const *caseObjv;
Tcl_Obj *armPtr;
@@ -163,7 +163,7 @@ Tcl_CaseObjCmd(
for (i = 0; i < caseObjc; i += 2) {
int patObjc, j;
const char **patObjv;
- char *pat;
+ const char *pat;
unsigned char *p;
if (i == caseObjc-1) {
@@ -514,7 +514,7 @@ Tcl_EncodingObjCmd(
Tcl_DString ds;
Tcl_Encoding encoding;
int length;
- char *stringPtr;
+ const char *stringPtr;
if (objc == 3) {
encoding = Tcl_GetEncoding(interp, NULL);
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index 8dc4c12..be62444 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.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: tclCmdIL.c,v 1.164 2009/01/09 11:21:45 dkf Exp $
+ * RCS: @(#) $Id: tclCmdIL.c,v 1.165 2009/02/03 23:34:32 nijtmans Exp $
*/
#include "tclInt.h"
@@ -30,7 +30,7 @@
typedef struct SortElement {
union {
- char *strValuePtr;
+ const char *strValuePtr;
long intValue;
double doubleValue;
Tcl_Obj *objValuePtr;
@@ -103,7 +103,7 @@ typedef struct SortInfo {
* Forward declarations for procedures defined in this file:
*/
-static int DictionaryCompare(char *left, char *right);
+static int DictionaryCompare(const char *left, const char *right);
static int InfoArgsCmd(ClientData dummy, Tcl_Interp *interp,
int objc, Tcl_Obj *const objv[]);
static int InfoBodyCmd(ClientData dummy, Tcl_Interp *interp,
@@ -223,7 +223,7 @@ TclNRIfObjCmd(
* check. */
Interp *iPtr = (Interp *) interp;
int i, result, value;
- char *clause;
+ const char *clause;
i = 1;
while (1) {
@@ -431,7 +431,7 @@ InfoArgsCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
register Interp *iPtr = (Interp *) interp;
- char *name;
+ const char *name;
Proc *procPtr;
CompiledLocal *localPtr;
Tcl_Obj *listObjPtr;
@@ -492,7 +492,7 @@ InfoBodyCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
register Interp *iPtr = (Interp *) interp;
- char *name;
+ const char *name;
Proc *procPtr;
Tcl_Obj *bodyPtr, *resultPtr;
@@ -602,7 +602,7 @@ InfoCommandsCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- char *cmdName, *pattern;
+ const char *cmdName, *pattern;
const char *simplePattern;
register Tcl_HashEntry *entryPtr;
Tcl_HashSearch search;
@@ -917,7 +917,7 @@ InfoDefaultCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
Interp *iPtr = (Interp *) interp;
- char *procName, *argName, *varName;
+ const char *procName, *argName, *varName;
Proc *procPtr;
CompiledLocal *localPtr;
Tcl_Obj *valueObjPtr;
@@ -998,7 +998,7 @@ TclInfoExistsCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- char *varName;
+ const char *varName;
Var *varPtr;
if (objc != 2) {
@@ -1357,7 +1357,7 @@ InfoFunctionsCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- char *pattern;
+ const char *pattern;
if (objc == 1) {
pattern = NULL;
@@ -1558,7 +1558,7 @@ InfoLoadedCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- char *interpName;
+ const char *interpName;
int result;
if ((objc != 1) && (objc != 2)) {
@@ -1686,7 +1686,7 @@ InfoProcsCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- char *cmdName, *pattern;
+ const char *cmdName, *pattern;
const char *simplePattern;
Namespace *nsPtr;
#ifdef INFO_PROCS_SEARCH_GLOBAL_NS
@@ -2750,7 +2750,7 @@ Tcl_LsearchObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
- char *bytes, *patternBytes;
+ const char *bytes, *patternBytes;
int i, match, index, result, listc, length, elemLen, bisect;
int dataType, isIncreasing, lower, upper, patInt, objInt, offset;
int allMatches, inlineReturn, negatedMatch, returnSubindices, noCase;
@@ -4194,7 +4194,7 @@ SortCompare(
static int
DictionaryCompare(
- char *left, char *right) /* The strings to compare. */
+ const char *left, const char *right) /* The strings to compare. */
{
Tcl_UniChar uniLeft, uniRight, uniLeftLower, uniRightLower;
int diff, zeros;
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 7cb14b5..22de674 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdMZ.c,v 1.176 2009/01/13 20:30:03 dkf Exp $
+ * RCS: @(#) $Id: tclCmdMZ.c,v 1.177 2009/02/03 23:34:32 nijtmans Exp $
*/
#include "tclInt.h"
@@ -121,7 +121,7 @@ Tcl_RegexpObjCmd(
doinline = 0;
for (i = 1; i < objc; i++) {
- char *name;
+ const char *name;
int index;
name = TclGetString(objv[i]);
@@ -470,7 +470,7 @@ Tcl_RegsubObjCmd(
resultPtr = NULL;
for (idx = 1; idx < objc; idx++) {
- char *name;
+ const char *name;
int index;
name = TclGetString(objv[idx]);
@@ -855,7 +855,7 @@ Tcl_RenameObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- char *oldName, *newName;
+ const char *oldName, *newName;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "oldName newName");
@@ -1001,7 +1001,8 @@ Tcl_SplitObjCmd(
Tcl_UniChar ch;
int len;
const char *splitChars;
- char *stringPtr, *end;
+ const char *stringPtr;
+ const char *end;
int splitCharLen, stringLen;
Tcl_Obj *listPtr, *objPtr;
@@ -2458,7 +2459,7 @@ StringEqualCmd(
* the expr string comparison in INST_EQ/INST_NEQ/INST_LT/...).
*/
- char *string1, *string2;
+ const char *string1, *string2;
int length1, length2, i, match, length, nocase = 0, reqlength = -1;
typedef int (*strCmpFn_t)(const char *, const char *, unsigned int);
strCmpFn_t strCmpFn;
@@ -2605,7 +2606,7 @@ StringCmpCmd(
* the expr string comparison in INST_EQ/INST_NEQ/INST_LT/...).
*/
- char *string1, *string2;
+ const char *string1, *string2;
int length1, length2, i, match, length, nocase = 0, reqlength = -1;
typedef int (*strCmpFn_t)(const char *, const char *, unsigned int);
strCmpFn_t strCmpFn;
@@ -2829,7 +2830,8 @@ StringLowerCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
int length1, length2;
- char *string1, *string2;
+ const char *string1;
+ char *string2;
if (objc < 2 || objc > 4) {
Tcl_WrongNumArgs(interp, 1, objv, "string ?first? ?last?");
@@ -2913,7 +2915,8 @@ StringUpperCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
int length1, length2;
- char *string1, *string2;
+ const char *string1;
+ char *string2;
if (objc < 2 || objc > 4) {
Tcl_WrongNumArgs(interp, 1, objv, "string ?first? ?last?");
@@ -2997,7 +3000,8 @@ StringTitleCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
int length1, length2;
- char *string1, *string2;
+ const char *string1;
+ char *string2;
if (objc < 2 || objc > 4) {
Tcl_WrongNumArgs(interp, 1, objv, "string ?first? ?last?");
@@ -3454,7 +3458,7 @@ Tcl_SwitchObjCmd(
{
int i,j, index, mode, foundmode, result, splitObjs, numMatchesSaved;
int noCase, patternLength;
- char *pattern;
+ const char *pattern;
Tcl_Obj *stringObj, *indexVarObj, *matchVarObj;
Tcl_Obj *const *savedObjv = objv;
Tcl_RegExp regExpr = NULL;
@@ -4085,7 +4089,7 @@ Tcl_TryObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- return Tcl_NRCallObjProc(interp, TclNRTryObjCmd, dummy, objc, objv);
+ return Tcl_NRCallObjProc(interp, TclNRTryObjCmd, dummy, objc, objv);
}
int
@@ -4095,7 +4099,7 @@ TclNRTryObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
-
+
}
#endif /* not yet implemented */
@@ -4127,7 +4131,7 @@ Tcl_WhileObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- return Tcl_NRCallObjProc(interp, TclNRWhileObjCmd, dummy, objc, objv);
+ return Tcl_NRCallObjProc(interp, TclNRWhileObjCmd, dummy, objc, objv);
}
int
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 5d8e31a..8403a98 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.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: tclCompCmds.c,v 1.151 2009/01/09 11:21:45 dkf Exp $
+ * RCS: @(#) $Id: tclCompCmds.c,v 1.152 2009/02/03 23:34:32 nijtmans Exp $
*/
#include "tclInt.h"
@@ -3107,7 +3107,7 @@ TclCompileRegexpCmd(
Tcl_Token *varTokenPtr; /* Pointer to the Tcl_Token representing the
* parse of the RE or string. */
int i, len, nocase, exact, sawLast, simple;
- char *str;
+ const char *str;
DefineLineInformation; /* TIP #280 */
/*
@@ -3141,7 +3141,7 @@ TclCompileRegexpCmd(
return TCL_ERROR;
}
- str = (char *) varTokenPtr[1].start;
+ str = varTokenPtr[1].start;
len = varTokenPtr[1].size;
if ((len == 2) && (str[0] == '-') && (str[1] == '-')) {
sawLast++;
@@ -3177,7 +3177,7 @@ TclCompileRegexpCmd(
if (varTokenPtr->type == TCL_TOKEN_SIMPLE_WORD) {
Tcl_DString ds;
- str = (char *) varTokenPtr[1].start;
+ str = varTokenPtr[1].start;
len = varTokenPtr[1].size;
/*
* If it has a '-', it could be an incorrectly formed regexp command.
diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c
index c800441..ef0ebe9 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.76 2009/01/28 16:28:32 dkf Exp $
+ * RCS: @(#) $Id: tclDictObj.c,v 1.77 2009/02/03 23:34:32 nijtmans Exp $
*/
#include "tclInt.h"
@@ -473,7 +473,8 @@ UpdateStringOfDict(
ChainEntry *cPtr;
Tcl_Obj *keyPtr, *valuePtr;
int numElems, i, length;
- char *elem, *dst;
+ const char *elem;
+ char *dst;
/*
* This field is the most useful one in the whole hash structure, and it
@@ -564,10 +565,11 @@ SetDictFromAny(
Tcl_Interp *interp,
Tcl_Obj *objPtr)
{
- char *string, *s;
+ const char *string;
+ char *s;
const char *elemStart, *nextElem;
int lenRemain, length, elemSize, hasBrace, result, isNew;
- char *limit; /* Points just after string's last byte. */
+ const char *limit; /* Points just after string's last byte. */
register const char *p;
register Tcl_Obj *keyPtr, *valuePtr;
Dict *dict;
@@ -1835,7 +1837,7 @@ DictKeysCmd(
Tcl_Obj *const *objv)
{
Tcl_Obj *listPtr;
- char *pattern = NULL;
+ const char *pattern = NULL;
if (objc!=2 && objc!=3) {
Tcl_WrongNumArgs(interp, 1, objv, "dictionary ?pattern?");
@@ -1920,7 +1922,7 @@ DictValuesCmd(
Tcl_Obj *valuePtr = NULL, *listPtr;
Tcl_DictSearch search;
int done;
- char *pattern;
+ const char *pattern;
if (objc!=2 && objc!=3) {
Tcl_WrongNumArgs(interp, 1, objv, "dictionary ?pattern?");
@@ -2067,7 +2069,6 @@ DictInfoCmd(
{
Tcl_Obj *dictPtr;
Dict *dict;
- char *buf;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "dictionary");
@@ -2083,9 +2084,7 @@ DictInfoCmd(
}
dict = dictPtr->internalRep.otherValuePtr;
- buf = Tcl_HashStats(&dict->table);
- Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1));
- ckfree(buf);
+ Tcl_SetResult(interp, Tcl_HashStats(&dict->table), TCL_DYNAMIC);
return TCL_OK;
}
@@ -2720,7 +2719,7 @@ DictFilterCmd(
Tcl_Obj **varv, *keyObj = NULL, *valueObj = NULL, *resultObj, *boolObj;
Tcl_DictSearch search;
int index, varc, done, result, satisfied;
- char *pattern;
+ const char *pattern;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv, "dictionary filterType ?arg ...?");