From feed575edf673f8860aa50a1eaaddc5aa887b893 Mon Sep 17 00:00:00 2001 From: hobbs Date: Tue, 4 Oct 2005 23:49:45 +0000 Subject: * generic/tclParse.c (Tcl_ParseCommand): add code that recognizes {} in addition to {expand} for word expansion (make with -DALLOW_EMPTY_EXPAND). --- ChangeLog | 6 ++++++ generic/tclParse.c | 38 +++++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a0f33a..1464a38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-10-04 Jeff Hobbs + + * generic/tclParse.c (Tcl_ParseCommand): add code that recognizes + {} in addition to {expand} for word expansion (make with + -DALLOW_EMPTY_EXPAND). + 2005-10-04 Zoran Vasiljevic * generic/tclIO.c (Tcl_ClearChannelHandlers): now deletes any diff --git a/generic/tclParse.c b/generic/tclParse.c index 53b2021..eac35be 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.43 2005/07/21 14:38:50 dkf Exp $ + * RCS: @(#) $Id: tclParse.c,v 1.44 2005/10/04 23:49:45 hobbs Exp $ */ #include "tclInt.h" @@ -374,20 +374,28 @@ Tcl_ParseCommand(interp, start, numBytes, nested, parsePtr) */ expPtr = &parsePtr->tokenPtr[expIdx]; - if ((expPfxLen == (size_t) expPtr->size) - /* Same length as prefix */ - && (0 == expandWord) - /* Haven't seen prefix already */ - && (1 == parsePtr->numTokens - expIdx) - /* Only one token */ - && (0 == strncmp(expPfx,expPtr->start,expPfxLen)) - /* Is the prefix */ - && (numBytes > 0) - && (TclParseWhiteSpace(termPtr, numBytes, parsePtr, &type) - == 0) - && (type != TYPE_COMMAND_END) - /* Non-whitespace follows */ - ) { + if ( + (0 == expandWord) + /* Haven't seen prefix already */ + && (1 == parsePtr->numTokens - expIdx) + /* Only one token */ + && (((expPfxLen == (size_t) expPtr->size) + /* Same length as prefix */ + && (0 == strncmp(expPfx,expPtr->start,expPfxLen))) +#ifdef ALLOW_EMPTY_EXPAND + /* + * Allow {} in addition to {expand} + */ + || (0 == (size_t) expPtr->size) +#endif + ) + /* Is the prefix */ + && (numBytes > 0) + && (TclParseWhiteSpace(termPtr, numBytes, parsePtr, + &type) == 0) + && (type != TYPE_COMMAND_END) + /* Non-whitespace follows */ + ) { expandWord = 1; parsePtr->numTokens--; goto parseWord; -- cgit v0.12