summaryrefslogtreecommitdiffstats
path: root/generic/tclParse.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2007-11-18 22:30:10 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2007-11-18 22:30:10 (GMT)
commit238ad5bc9e7a3a174084646bd915e2392030cfdd (patch)
treea168b4a14a7f4bf466ffa4d2ea1903339cbd0221 /generic/tclParse.c
parent2b41844782e22787bbd8b88ba36bf09ee9f09be0 (diff)
downloadtcl-238ad5bc9e7a3a174084646bd915e2392030cfdd.zip
tcl-238ad5bc9e7a3a174084646bd915e2392030cfdd.tar.gz
tcl-238ad5bc9e7a3a174084646bd915e2392030cfdd.tar.bz2
More minor cleanup
Diffstat (limited to 'generic/tclParse.c')
-rw-r--r--generic/tclParse.c251
1 files changed, 124 insertions, 127 deletions
diff --git a/generic/tclParse.c b/generic/tclParse.c
index ba1198a..211a10b 100644
--- a/generic/tclParse.c
+++ b/generic/tclParse.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: tclParse.c,v 1.58 2007/11/11 19:32:17 msofer Exp $
+ * RCS: @(#) $Id: tclParse.c,v 1.59 2007/11/18 22:30:10 dkf Exp $
*/
#include "tclInt.h"
@@ -54,7 +54,7 @@
#define CHAR_TYPE(c) (charTypeTable+128)[(int)(c)]
-static CONST char charTypeTable[] = {
+static const char charTypeTable[] = {
/*
* Negative character values, from -128 to -1:
*/
@@ -171,12 +171,12 @@ static CONST char charTypeTable[] = {
* Prototypes for local functions defined in this file:
*/
-static int CommandComplete(CONST char *script, int numBytes);
-static int ParseComment(CONST char *src, int numBytes,
+static inline int CommandComplete(const char *script, int numBytes);
+static int ParseComment(const char *src, int numBytes,
Tcl_Parse *parsePtr);
-static int ParseTokens(CONST char *src, int numBytes, int mask,
+static int ParseTokens(const char *src, int numBytes, int mask,
int flags, Tcl_Parse *parsePtr);
-static int ParseWhiteSpace(CONST char *src, int numBytes,
+static int ParseWhiteSpace(const char *src, int numBytes,
int *incompletePtr, char *typePtr);
/*
@@ -198,7 +198,7 @@ static int ParseWhiteSpace(CONST char *src, int numBytes,
void
TclParseInit(
Tcl_Interp *interp, /* Interpreter to use for error reporting */
- CONST char *string, /* String to be parsed. */
+ const char *string, /* String to be parsed. */
int numBytes, /* Total number of bytes in string. If < 0,
* the script consists of all bytes up to the
* first null character. */
@@ -243,7 +243,7 @@ int
Tcl_ParseCommand(
Tcl_Interp *interp, /* Interpreter to use for error reporting; if
* NULL, then no error message is provided. */
- CONST char *start, /* First character of string containing one or
+ const char *start, /* First character of string containing one or
* more Tcl commands. */
register int numBytes, /* Total number of bytes in string. If < 0,
* the script consists of all bytes up to the
@@ -257,14 +257,14 @@ Tcl_ParseCommand(
* the parsed command; any previous
* information in the structure is ignored. */
{
- register CONST char *src; /* Points to current character in the
+ register const char *src; /* Points to current character in the
* command. */
char type; /* Result returned by CHAR_TYPE(*src). */
Tcl_Token *tokenPtr; /* Pointer to token being filled in. */
int wordIndex; /* Index of word token for current word. */
int terminators; /* CHAR_TYPE bits that indicate the end of a
* command. */
- CONST char *termPtr; /* Set by Tcl_ParseBraces/QuotedString to
+ const char *termPtr; /* Set by Tcl_ParseBraces/QuotedString to
* point to char after terminating one. */
int scanned;
@@ -327,7 +327,7 @@ Tcl_ParseCommand(
* sequence: it should be treated just like white space.
*/
- scanned = ParseWhiteSpace(src, numBytes, &(parsePtr->incomplete), &type);
+ scanned = ParseWhiteSpace(src,numBytes, &parsePtr->incomplete, &type);
src += scanned;
numBytes -= scanned;
if (numBytes == 0) {
@@ -351,8 +351,8 @@ Tcl_ParseCommand(
parseWord:
if (*src == '"') {
- if (Tcl_ParseQuotedString(interp, src, numBytes,
- parsePtr, 1, &termPtr) != TCL_OK) {
+ if (Tcl_ParseQuotedString(interp, src, numBytes, parsePtr, 1,
+ &termPtr) != TCL_OK) {
goto error;
}
src = termPtr;
@@ -361,33 +361,31 @@ Tcl_ParseCommand(
int expIdx = wordIndex + 1;
Tcl_Token *expPtr;
- if (Tcl_ParseBraces(interp, src, numBytes,
- parsePtr, 1, &termPtr) != TCL_OK) {
+ if (Tcl_ParseBraces(interp, src, numBytes, parsePtr, 1,
+ &termPtr) != TCL_OK) {
goto error;
}
src = termPtr;
numBytes = parsePtr->end - src;
/*
- * Check whether the braces contained the word expansion prefix {*}
+ * Check whether the braces contained the word expansion prefix
+ * {*}
*/
expPtr = &parsePtr->tokenPtr[expIdx];
- if (
- (0 == expandWord)
- /* Haven't seen prefix already */
- && (1 == parsePtr->numTokens - expIdx)
- /* Only one token */
- && (((1 == (size_t) expPtr->size)
+ if ((0 == expandWord)
+ /* Haven't seen prefix already */
+ && (1 == parsePtr->numTokens - expIdx)
+ /* Only one token */
+ && (((1 == (size_t) expPtr->size)
/* Same length as prefix */
- && (expPtr->start[0] == '*'))
- )
- /* Is the prefix */
- && (numBytes > 0) && (0 ==
- ParseWhiteSpace(termPtr, numBytes, &(parsePtr->incomplete), &type))
- && (type != TYPE_COMMAND_END)
- /* Non-whitespace follows */
- ) {
+ && (expPtr->start[0] == '*')))
+ /* Is the prefix */
+ && (numBytes > 0) && (0 == ParseWhiteSpace(termPtr,
+ numBytes, &parsePtr->incomplete, &type))
+ && (type != TYPE_COMMAND_END)
+ /* Non-whitespace follows */) {
expandWord = 1;
parsePtr->numTokens--;
goto parseWord;
@@ -417,12 +415,12 @@ Tcl_ParseCommand(
if (expandWord) {
int i, isLiteral = 1;
- /*
- * When a command includes a word that is an expanded literal;
- * for example, {*}{1 2 3}, the parser performs that expansion
+ /*
+ * When a command includes a word that is an expanded literal; for
+ * example, {*}{1 2 3}, the parser performs that expansion
* immediately, generating several TCL_TOKEN_SIMPLE_WORDs instead
* of a single TCL_TOKEN_EXPAND_WORD that the Tcl_ParseCommand()
- * caller might have to expand. This notably makes it simpler for
+ * caller might have to expand. This notably makes it simpler for
* those callers that wish to track line endings, such as those
* that implement key parts of TIP 280.
*
@@ -442,12 +440,12 @@ Tcl_ParseCommand(
int elemCount = 0, code = TCL_OK;
const char *nextElem, *listEnd, *elemStart;
- /*
+ /*
* The word to be expanded is a literal, so determine the
* boundaries of the literal string to be treated as a list
- * and expanded. That literal string starts at
- * tokenPtr[1].start, and includes all bytes up to, but
- * not including (tokenPtr[tokenPtr->numComponents].start +
+ * and expanded. That literal string starts at
+ * tokenPtr[1].start, and includes all bytes up to, but not
+ * including (tokenPtr[tokenPtr->numComponents].start +
* tokenPtr[tokenPtr->numComponents].size)
*/
@@ -455,11 +453,11 @@ Tcl_ParseCommand(
tokenPtr[tokenPtr->numComponents].size);
nextElem = tokenPtr[1].start;
- /*
- * Step through the literal string, parsing and counting
- * list elements.
+ /*
+ * Step through the literal string, parsing and counting list
+ * elements.
*/
-
+
while (nextElem < listEnd) {
code = TclFindElement(NULL, nextElem, listEnd - nextElem,
&elemStart, &nextElem, NULL, NULL);
@@ -470,29 +468,26 @@ Tcl_ParseCommand(
}
if (code != TCL_OK) {
-
/*
- * Some list element could not be parsed. This means
- * the literal string was not in fact a valid list.
- * Defer the handling of this to compile/eval time, where
- * code is already in place to report the "attempt to
- * expand a non-list" error.
+ * Some list element could not be parsed. This means the
+ * literal string was not in fact a valid list. Defer the
+ * handling of this to compile/eval time, where code is
+ * already in place to report the "attempt to expand a
+ * non-list" error.
*/
tokenPtr->type = TCL_TOKEN_EXPAND_WORD;
} else if (elemCount == 0) {
-
/*
- * We are expanding a literal empty list. This means
- * that the expanding word completely disappears, leaving
- * no word generated this pass through the loop. Adjust
+ * We are expanding a literal empty list. This means that
+ * the expanding word completely disappears, leaving no
+ * word generated this pass through the loop. Adjust
* accounting appropriately.
*/
parsePtr->numWords--;
parsePtr->numTokens = wordIndex;
} else {
-
/*
* Recalculate the number of Tcl_Tokens needed to store
* tokens representing the expanded list.
@@ -508,9 +503,9 @@ Tcl_ParseCommand(
/*
* Generate a TCL_TOKEN_SIMPLE_WORD token sequence for
* each element of the literal list we are expanding in
- * place. Take care with the start and size fields of
- * each token so they point to the right literal characters
- * in the original script to represent the right expanded
+ * place. Take care with the start and size fields of each
+ * token so they point to the right literal characters in
+ * the original script to represent the right expanded
* word value.
*/
@@ -542,8 +537,7 @@ Tcl_ParseCommand(
}
}
} else {
-
- /*
+ /*
* The word to be expanded is not a literal, so defer
* expansion to compile/eval time by marking with a
* TCL_TOKEN_EXPAND_WORD token.
@@ -562,7 +556,7 @@ Tcl_ParseCommand(
* word), and (b) check for the end of the command.
*/
- scanned = ParseWhiteSpace(src, numBytes, &(parsePtr->incomplete), &type);
+ scanned = ParseWhiteSpace(src,numBytes, &parsePtr->incomplete, &type);
if (scanned) {
src += scanned;
numBytes -= scanned;
@@ -626,7 +620,7 @@ Tcl_ParseCommand(
static int
ParseWhiteSpace(
- CONST char *src, /* First character to parse. */
+ const char *src, /* First character to parse. */
register int numBytes, /* Max number of bytes to scan. */
int *incompletePtr, /* Set this boolean memory to true if parsing
* indicates an incomplete command. */
@@ -634,7 +628,7 @@ ParseWhiteSpace(
* of character that ends run of whitespace */
{
register char type = TYPE_NORMAL;
- register CONST char *p = src;
+ register const char *p = src;
while (1) {
while (numBytes && ((type = CHAR_TYPE(*p)) & TYPE_SPACE)) {
@@ -680,12 +674,12 @@ ParseWhiteSpace(
int
TclParseAllWhiteSpace(
- CONST char *src, /* First character to parse. */
+ const char *src, /* First character to parse. */
int numBytes) /* Max number of byes to scan */
{
int dummy;
char type;
- CONST char *p = src;
+ const char *p = src;
do {
int scanned = ParseWhiteSpace(p, numBytes, &dummy, &type);
@@ -720,14 +714,14 @@ TclParseAllWhiteSpace(
int
TclParseHex(
- CONST char *src, /* First character to parse. */
+ const char *src, /* First character to parse. */
int numBytes, /* Max number of byes to scan */
Tcl_UniChar *resultPtr) /* Points to storage provided by caller where
* the Tcl_UniChar resulting from the
* conversion is to be written. */
{
Tcl_UniChar result = 0;
- register CONST char *p = src;
+ register const char *p = src;
while (numBytes--) {
unsigned char digit = UCHAR(*p);
@@ -775,7 +769,7 @@ TclParseHex(
int
TclParseBackslash(
- CONST char *src, /* Points to the backslash character of a a
+ const char *src, /* Points to the backslash character of a a
* backslash sequence. */
int numBytes, /* Max number of bytes to scan. */
int *readPtr, /* NULL, or points to storage where the number
@@ -785,7 +779,7 @@ TclParseBackslash(
* written. At most TCL_UTF_MAX bytes will be
* written there. */
{
- register CONST char *p = src+1;
+ register const char *p = src+1;
Tcl_UniChar result;
int count;
char buf[TCL_UTF_MAX];
@@ -948,13 +942,14 @@ TclParseBackslash(
static int
ParseComment(
- CONST char *src, /* First character to parse. */
+ const char *src, /* First character to parse. */
register int numBytes, /* Max number of bytes to scan. */
Tcl_Parse *parsePtr) /* Information about parse in progress.
* Updated if parsing indicates an incomplete
* command. */
{
- register CONST char *p = src;
+ register const char *p = src;
+
while (numBytes) {
char type;
int scanned;
@@ -972,7 +967,8 @@ ParseComment(
while (numBytes) {
if (*p == '\\') {
- scanned = ParseWhiteSpace(p, numBytes, &(parsePtr->incomplete), &type);
+ scanned = ParseWhiteSpace(p, numBytes, &parsePtr->incomplete,
+ &type);
if (scanned) {
p += scanned;
numBytes -= scanned;
@@ -1028,7 +1024,7 @@ ParseComment(
static int
ParseTokens(
- register CONST char *src, /* First character to parse. */
+ register const char *src, /* First character to parse. */
register int numBytes, /* Max number of bytes to scan. */
int mask, /* Specifies when to stop parsing. The parse
* stops at the first unquoted character whose
@@ -1094,8 +1090,8 @@ ParseTokens(
*/
varToken = parsePtr->numTokens;
- if (Tcl_ParseVarName(parsePtr->interp, src, numBytes,
- parsePtr, 1) != TCL_OK) {
+ if (Tcl_ParseVarName(parsePtr->interp, src, numBytes, parsePtr,
+ 1) != TCL_OK) {
return TCL_ERROR;
}
src += parsePtr->tokenPtr[varToken].size;
@@ -1123,8 +1119,8 @@ ParseTokens(
nestedPtr = (Tcl_Parse *)
TclStackAlloc(parsePtr->interp, sizeof(Tcl_Parse));
while (1) {
- if (Tcl_ParseCommand(parsePtr->interp, src,
- numBytes, 1, nestedPtr) != TCL_OK) {
+ if (Tcl_ParseCommand(parsePtr->interp, src, numBytes, 1,
+ nestedPtr) != TCL_OK) {
parsePtr->errorType = nestedPtr->errorType;
parsePtr->term = nestedPtr->term;
parsePtr->incomplete = nestedPtr->incomplete;
@@ -1141,7 +1137,8 @@ ParseTokens(
* parsed command.
*/
- if ((nestedPtr->term < parsePtr->end) && (*(nestedPtr->term) == ']')
+ if ((nestedPtr->term < parsePtr->end)
+ && (*(nestedPtr->term) == ']')
&& !(nestedPtr->incomplete)) {
break;
}
@@ -1300,13 +1297,14 @@ TclExpandTokenArray(
int newCount = parsePtr->tokensAvailable*2;
if (parsePtr->tokenPtr != parsePtr->staticTokens) {
- parsePtr->tokenPtr = (Tcl_Token *) ckrealloc ((char *)
- (parsePtr->tokenPtr), newCount * sizeof(Tcl_Token));
+ parsePtr->tokenPtr = (Tcl_Token *) ckrealloc((char *)
+ parsePtr->tokenPtr, newCount * sizeof(Tcl_Token));
} else {
- Tcl_Token *newPtr = (Tcl_Token *) ckalloc(
- newCount * sizeof(Tcl_Token));
+ Tcl_Token *newPtr = (Tcl_Token *)
+ ckalloc(newCount * sizeof(Tcl_Token));
+
memcpy(newPtr, parsePtr->tokenPtr,
- (size_t) (parsePtr->tokensAvailable * sizeof(Tcl_Token)));
+ (size_t) parsePtr->tokensAvailable * sizeof(Tcl_Token));
parsePtr->tokenPtr = newPtr;
}
parsePtr->tokensAvailable = newCount;
@@ -1343,7 +1341,7 @@ int
Tcl_ParseVarName(
Tcl_Interp *interp, /* Interpreter to use for error reporting; if
* NULL, then no error message is provided. */
- CONST char *start, /* Start of variable substitution string.
+ const char *start, /* Start of variable substitution string.
* First character must be "$". */
register int numBytes, /* Total number of bytes in string. If < 0,
* the string consists of all bytes up to the
@@ -1356,7 +1354,7 @@ Tcl_ParseVarName(
* reinitialize it. */
{
Tcl_Token *tokenPtr;
- register CONST char *src;
+ register const char *src;
unsigned char c;
int varIndex, offset;
Tcl_UniChar ch;
@@ -1379,7 +1377,7 @@ Tcl_ParseVarName(
*/
src = start;
- if ((parsePtr->numTokens + 2) > parsePtr->tokensAvailable) {
+ if (parsePtr->numTokens+2 > parsePtr->tokensAvailable) {
TclExpandTokenArray(parsePtr);
}
tokenPtr = &parsePtr->tokenPtr[parsePtr->numTokens];
@@ -1454,7 +1452,7 @@ Tcl_ParseVarName(
offset = Tcl_UtfToUniChar(utfBytes, &ch);
}
c = UCHAR(ch);
- if (isalnum(c) || (c == '_')) { /* INTL: ISO only, UCHAR. */
+ if (isalnum(c) || (c == '_')) { /* INTL: ISO only, UCHAR. */
src += offset;
numBytes -= offset;
continue;
@@ -1492,7 +1490,7 @@ Tcl_ParseVarName(
TCL_SUBST_ALL, parsePtr)) {
goto error;
}
- if ((parsePtr->term == src+numBytes) || (*parsePtr->term != ')')) {
+ if ((parsePtr->term == src+numBytes) || (*parsePtr->term != ')')){
if (parsePtr->interp != NULL) {
Tcl_SetResult(parsePtr->interp, "missing )",
TCL_STATIC);
@@ -1549,18 +1547,19 @@ Tcl_ParseVarName(
*----------------------------------------------------------------------
*/
-CONST char *
+const char *
Tcl_ParseVar(
- Tcl_Interp *interp, /* Context for looking up variable. */
- register CONST char *start, /* Start of variable substitution.
- * First character must be "$". */
- CONST char **termPtr) /* If non-NULL, points to word to fill
- * in with character just after last
- * one in the variable specifier. */
+ Tcl_Interp *interp, /* Context for looking up variable. */
+ register const char *start, /* Start of variable substitution. First
+ * character must be "$". */
+ const char **termPtr) /* If non-NULL, points to word to fill in with
+ * character just after last one in the
+ * variable specifier. */
{
register Tcl_Obj *objPtr;
int code;
- Tcl_Parse *parsePtr = (Tcl_Parse *) TclStackAlloc(interp, sizeof(Tcl_Parse));
+ Tcl_Parse *parsePtr = (Tcl_Parse *)
+ TclStackAlloc(interp, sizeof(Tcl_Parse));
if (Tcl_ParseVarName(interp, start, -1, parsePtr, 0) != TCL_OK) {
TclStackFree(interp, parsePtr);
@@ -1579,7 +1578,8 @@ Tcl_ParseVar(
return "$";
}
- code = TclSubstTokens(interp, parsePtr->tokenPtr, parsePtr->numTokens, NULL, 1);
+ code = TclSubstTokens(interp, parsePtr->tokenPtr, parsePtr->numTokens,
+ NULL, 1);
TclStackFree(interp, parsePtr);
if (code != TCL_OK) {
return NULL;
@@ -1636,7 +1636,7 @@ int
Tcl_ParseBraces(
Tcl_Interp *interp, /* Interpreter to use for error reporting; if
* NULL, then no error message is provided. */
- CONST char *start, /* Start of string enclosed in braces. The
+ const char *start, /* Start of string enclosed in braces. The
* first character must be {'. */
register int numBytes, /* Total number of bytes in string. If < 0,
* the string consists of all bytes up to the
@@ -1648,13 +1648,13 @@ Tcl_ParseBraces(
* information in parsePtr; zero means ignore
* existing tokens in parsePtr and
* reinitialize it. */
- CONST char **termPtr) /* If non-NULL, points to word in which to
+ const char **termPtr) /* If non-NULL, points to word in which to
* store a pointer to the character just after
* the terminating '}' if the parse was
* successful. */
{
Tcl_Token *tokenPtr;
- register CONST char *src;
+ register const char *src;
int startIndex, level, length;
if ((numBytes == 0) || (start == NULL)) {
@@ -1794,10 +1794,9 @@ Tcl_ParseBraces(
openBrace = 0;
break;
case '#' :
- if (openBrace && (isspace(UCHAR(src[-1])))) {
+ if (openBrace && isspace(UCHAR(src[-1]))) {
Tcl_AppendResult(parsePtr->interp,
- ": possible unbalanced brace in comment",
- (char *) NULL);
+ ": possible unbalanced brace in comment", NULL);
goto error;
}
break;
@@ -1842,7 +1841,7 @@ int
Tcl_ParseQuotedString(
Tcl_Interp *interp, /* Interpreter to use for error reporting; if
* NULL, then no error message is provided. */
- CONST char *start, /* Start of the quoted string. The first
+ const char *start, /* Start of the quoted string. The first
* character must be '"'. */
register int numBytes, /* Total number of bytes in string. If < 0,
* the string consists of all bytes up to the
@@ -1854,7 +1853,7 @@ Tcl_ParseQuotedString(
* information in parsePtr; zero means ignore
* existing tokens in parsePtr and
* reinitialize it. */
- CONST char **termPtr) /* If non-NULL, points to word in which to
+ const char **termPtr) /* If non-NULL, points to word in which to
* store a pointer to the character just after
* the quoted string's terminating close-quote
* if the parse succeeds. */
@@ -1870,8 +1869,8 @@ Tcl_ParseQuotedString(
TclParseInit(interp, start, numBytes, parsePtr);
}
- if (TCL_OK != ParseTokens(start+1, numBytes-1, TYPE_QUOTE,
- TCL_SUBST_ALL, parsePtr)) {
+ if (TCL_OK != ParseTokens(start+1, numBytes-1, TYPE_QUOTE, TCL_SUBST_ALL,
+ parsePtr)) {
goto error;
}
if (*parsePtr->term != '"') {
@@ -1919,10 +1918,10 @@ Tcl_SubstObj(
{
int length, tokensLeft, code;
Tcl_Token *endTokenPtr;
- Tcl_Obj *result;
- Tcl_Obj *errMsg = NULL;
+ Tcl_Obj *result, *errMsg = NULL;
CONST char *p = TclGetStringFromObj(objPtr, &length);
- Tcl_Parse *parsePtr = (Tcl_Parse *) TclStackAlloc(interp, sizeof(Tcl_Parse));
+ Tcl_Parse *parsePtr = (Tcl_Parse *)
+ TclStackAlloc(interp, sizeof(Tcl_Parse));
TclParseInit(interp, p, length, parsePtr);
@@ -2036,9 +2035,9 @@ Tcl_SubstObj(
*/
Tcl_Token *tokenPtr;
- CONST char *lastTerm = parsePtr->term;
- Tcl_Parse *nestedPtr =
- (Tcl_Parse *) TclStackAlloc(interp, sizeof(Tcl_Parse));
+ const char *lastTerm = parsePtr->term;
+ Tcl_Parse *nestedPtr = (Tcl_Parse *)
+ TclStackAlloc(interp, sizeof(Tcl_Parse));
while (TCL_OK ==
Tcl_ParseCommand(NULL, p, length, 0, nestedPtr)) {
@@ -2178,7 +2177,7 @@ TclSubstTokens(
int *tokensLeftPtr, /* If not NULL, points to memory where an
* integer representing the number of tokens
* left to be substituted will be written */
- int line) /* The line the script starts on. */
+ int line) /* The line the script starts on. */
{
Tcl_Obj *result;
int code = TCL_OK;
@@ -2196,7 +2195,7 @@ TclSubstTokens(
result = NULL;
for (; count>0 && code==TCL_OK ; count--, tokenPtr++) {
Tcl_Obj *appendObj = NULL;
- CONST char *append = NULL;
+ const char *append = NULL;
int appendByteLength = 0;
char utfCharBytes[TCL_UTF_MAX];
@@ -2207,7 +2206,7 @@ TclSubstTokens(
break;
case TCL_TOKEN_BS:
- appendByteLength = Tcl_UtfBackslash(tokenPtr->start, (int *) NULL,
+ appendByteLength = Tcl_UtfBackslash(tokenPtr->start, NULL,
utfCharBytes);
append = utfCharBytes;
break;
@@ -2354,19 +2353,18 @@ TclSubstTokens(
*----------------------------------------------------------------------
*/
-static int
+static inline int
CommandComplete(
- CONST char *script, /* Script to check. */
+ const char *script, /* Script to check. */
int numBytes) /* Number of bytes in script. */
{
Tcl_Parse parse;
- CONST char *p, *end;
+ const char *p, *end;
int result;
p = script;
end = p + numBytes;
- while (Tcl_ParseCommand((Tcl_Interp *) NULL, p, end - p, 0, &parse)
- == TCL_OK) {
+ while (Tcl_ParseCommand(NULL, p, end - p, 0, &parse) == TCL_OK) {
p = parse.commandStart + parse.commandSize;
if (p >= end) {
break;
@@ -2404,7 +2402,7 @@ CommandComplete(
int
Tcl_CommandComplete(
- CONST char *script) /* Script to check. */
+ const char *script) /* Script to check. */
{
return CommandComplete(script, (int) strlen(script));
}
@@ -2432,10 +2430,9 @@ TclObjCommandComplete(
Tcl_Obj *objPtr) /* Points to object holding script to
* check. */
{
- CONST char *script;
int length;
+ const char *script = Tcl_GetStringFromObj(objPtr, &length);
- script = TclGetStringFromObj(objPtr, &length);
return CommandComplete(script, length);
}
@@ -2458,11 +2455,11 @@ TclObjCommandComplete(
int
TclIsLocalScalar(
- CONST char *src,
+ const char *src,
int len)
{
- CONST char *p;
- CONST char *lastChar = src + (len - 1);
+ const char *p;
+ const char *lastChar = src + (len - 1);
for (p=src ; p<=lastChar ; p++) {
if ((CHAR_TYPE(*p) != TYPE_NORMAL) &&
@@ -2476,11 +2473,11 @@ TclIsLocalScalar(
return 0;
}
if (*p == '(') {
- if (*lastChar == ')') { /* we have an array element */
+ if (*lastChar == ')') { /* We have an array element */
return 0;
}
} else if (*p == ':') {
- if ((p != lastChar) && *(p+1) == ':') { /* qualified name */
+ if ((p != lastChar) && *(p+1) == ':') { /* qualified name */
return 0;
}
}