From 9472fc9496ffa1b561e42b87aba86e26c96e993f Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 4 Mar 2004 23:25:09 +0000 Subject: * generic/tclInt.h (TclParseInit): Factored the common code * generic/tclParse.c (TclParseInit): for initializing a Tcl_Parse * generic/tclParseExpr.c: struct into one routine. --- ChangeLog | 5 +++-- generic/tclInt.h | 5 ++++- generic/tclParse.c | 27 ++++++++++++--------------- generic/tclParseExpr.c | 16 ++-------------- 4 files changed, 21 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6df04f8..abb88f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,8 +5,9 @@ 2004-03-04 Don Porter - * generic/tclParse.c (InitParse): Factored the common code - for initializing a Tcl_Parse struct into one routine. + * generic/tclInt.h (TclParseInit): Factored the common code + * generic/tclParse.c (TclParseInit): for initializing a Tcl_Parse + * generic/tclParseExpr.c: struct into one routine. 2004-03-04 Pat Thoyts diff --git a/generic/tclInt.h b/generic/tclInt.h index 27dbc89..1e66abc 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.144 2004/02/24 22:58:46 dkf Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.145 2004/03/04 23:25:10 dgp Exp $ */ #ifndef _TCLINT @@ -1733,6 +1733,9 @@ EXTERN int TclParseBackslash _ANSI_ARGS_((CONST char *src, int numBytes, int *readPtr, char *dst)); EXTERN int TclParseHex _ANSI_ARGS_((CONST char *src, int numBytes, Tcl_UniChar *resultPtr)); +EXTERN void TclParseInit _ANSI_ARGS_ ((Tcl_Interp *interp, + CONST char *string, int numBytes, + Tcl_Parse *parsePtr)); EXTERN int TclParseInteger _ANSI_ARGS_((CONST char *string, int numBytes)); EXTERN int TclParseWhiteSpace _ANSI_ARGS_((CONST char *src, diff --git a/generic/tclParse.c b/generic/tclParse.c index 7c21fe6..de95afe 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.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: tclParse.c,v 1.33 2004/03/04 22:39:30 dgp Exp $ + * RCS: @(#) $Id: tclParse.c,v 1.34 2004/03/04 23:25:14 dgp Exp $ */ #include "tclInt.h" @@ -176,9 +176,6 @@ static CONST char charTypeTable[] = { static int CommandComplete _ANSI_ARGS_((CONST char *script, int numBytes)); -void InitParse _ANSI_ARGS_((Tcl_Interp *interp, - CONST char *string, int numBytes, - Tcl_Parse *parsePtr)); static int ParseComment _ANSI_ARGS_((CONST char *src, int numBytes, Tcl_Parse *parsePtr)); static int ParseTokens _ANSI_ARGS_((CONST char *src, int numBytes, @@ -187,7 +184,7 @@ static int ParseTokens _ANSI_ARGS_((CONST char *src, int numBytes, /* *---------------------------------------------------------------------- * - * InitParse -- + * TclParseInit -- * * Initialize the fields of a Tcl_Parse struct. * @@ -201,7 +198,7 @@ static int ParseTokens _ANSI_ARGS_((CONST char *src, int numBytes, */ void -InitParse(interp, string, numBytes, parsePtr) +TclParseInit(interp, string, numBytes, parsePtr) Tcl_Interp *interp; /* Interpreter to use for error reporting */ CONST char *string; /* String to be parsed. */ int numBytes; /* Total number of bytes in string. If < 0, @@ -209,6 +206,10 @@ InitParse(interp, string, numBytes, parsePtr) * the first null character. */ Tcl_Parse *parsePtr; /* Points to struct to initialize */ { + parsePtr->commentStart = NULL; + parsePtr->commentSize = 0; + parsePtr->commandStart = NULL; + parsePtr->commandSize = 0; parsePtr->numWords = 0; parsePtr->tokenPtr = parsePtr->staticTokens; parsePtr->numTokens = 0; @@ -286,11 +287,7 @@ Tcl_ParseCommand(interp, string, numBytes, nested, parsePtr) if (numBytes < 0) { numBytes = strlen(string); } - InitParse(interp, string, numBytes, parsePtr); - parsePtr->commentStart = NULL; - parsePtr->commentSize = 0; - parsePtr->commandStart = NULL; - parsePtr->commandSize = 0; + TclParseInit(interp, string, numBytes, parsePtr); if (nested != 0) { terminators = TYPE_COMMAND_END | TYPE_CLOSE_BRACK; } else { @@ -1185,7 +1182,7 @@ Tcl_ParseVarName(interp, string, numBytes, parsePtr, append) } if (!append) { - InitParse(interp, string, numBytes, parsePtr); + TclParseInit(interp, string, numBytes, parsePtr); } /* @@ -1476,7 +1473,7 @@ Tcl_ParseBraces(interp, string, numBytes, parsePtr, append, termPtr) } if (!append) { - InitParse(interp, string, numBytes, parsePtr); + TclParseInit(interp, string, numBytes, parsePtr); } src = string; @@ -1675,7 +1672,7 @@ Tcl_ParseQuotedString(interp, string, numBytes, parsePtr, append, termPtr) } if (!append) { - InitParse(interp, string, numBytes, parsePtr); + TclParseInit(interp, string, numBytes, parsePtr); } if (TCL_OK != ParseTokens(string+1, numBytes-1, TYPE_QUOTE, @@ -1733,7 +1730,7 @@ Tcl_SubstObj(interp, objPtr, flags) Tcl_Obj *errMsg = NULL; CONST char *p = Tcl_GetStringFromObj(objPtr, &length); - InitParse(interp, p, length, &parse); + TclParseInit(interp, p, length, &parse); /* * First parse the string rep of objPtr, as if it were enclosed diff --git a/generic/tclParseExpr.c b/generic/tclParseExpr.c index 84094f4..3a0574e 100644 --- a/generic/tclParseExpr.c +++ b/generic/tclParseExpr.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: tclParseExpr.c,v 1.19 2003/10/14 15:44:53 dgp Exp $ + * RCS: @(#) $Id: tclParseExpr.c,v 1.20 2004/03/04 23:25:15 dgp Exp $ */ #include "tclInt.h" @@ -245,19 +245,7 @@ Tcl_ParseExpr(interp, string, numBytes, parsePtr) } #endif /* TCL_COMPILE_DEBUG */ - parsePtr->commentStart = NULL; - parsePtr->commentSize = 0; - parsePtr->commandStart = NULL; - parsePtr->commandSize = 0; - parsePtr->numWords = 0; - parsePtr->tokenPtr = parsePtr->staticTokens; - parsePtr->numTokens = 0; - parsePtr->tokensAvailable = NUM_STATIC_TOKENS; - parsePtr->string = string; - parsePtr->end = (string + numBytes); - parsePtr->interp = interp; - parsePtr->term = string; - parsePtr->incomplete = 0; + TclParseInit(interp, string, numBytes, parsePtr); /* * Initialize the ParseInfo structure that holds state while parsing -- cgit v0.12