Skip to content
Tcl Source Code View Ticket
Login

View Ticket

info complete gives wrong answer

Closed / Fixed217886ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:45:23
OriginalBugID: 2382 Bug
Version: 8.2b1
SubmitDate: '1999-07-16'
LastModified: '1999-07-29'
Severity: LOW
Status: Closed
Submitter: techsupp
ChangedBy: redman
RelatedBugIDs: 2466
OS: Other
Machine: NA
FixedDate: '1999-07-21'
ClosedDate: '1999-07-29'


Name:

Peter Spjuth



ObservedBehavior:

info complete returns 1 for a string missing a close 

    bracket, if the last char is a close bracket:

    

    % info complete {[a [b]}

    1

    

    By adding a space:

    

    % info complete {[a [b] }

    0

    

    They are also treated slightly differently by eval,

    the difference is that the error is caught later in the

    buggy case:

    

    % eval {[a [b]}

    missing close-bracket

    % set errorInfo

    missing close-bracket

        while compiling

    "a"

        while compiling

    "[a [b]"

        ("eval" body line 1)

        invoked from within

    "eval {[a [b]}"

    

    % eval {[a [b] }

    missing close-bracket

    % set errorInfo

    missing close-bracket

        while compiling

    "[a [b] "

        ("eval" body line 1)

        invoked from within

    "eval {[a [b] }"

    

    The bug is in ParseTokens() in tclParse.c

    When encountering an open bracket, the rest is parsed until a 

    matching close bracket is found, or the string is ended.

    After that, the only check is whether the last parsed char was 

    a close bracket. No check is made if it was that close bracket, 

    or an end of string that terminated the parse.



Patch:

*** tclParse.orig       Fri Jul 16 22:02:32 1999

--- tclParse.c  Fri Jul 16 22:23:54 1999

***************

*** 607,613 ****

                if (nested.tokenPtr != nested.staticTokens) {

                    ckfree((char *) nested.tokenPtr);

                }

!               if ((src[-1] == ']') && !nested.incomplete) {

                    break;

                }

                if (src == parsePtr->end) {

--- 607,614 ----

                if (nested.tokenPtr != nested.staticTokens) {

                    ckfree((char *) nested.tokenPtr);

                }

!               if ((*nested.term != 0) && (src[-1] == ']')

!                       && !nested.incomplete) {

                    break;

                }

                if (src == parsePtr->end) {



PatchFiles:

tclParse.c (CVS 1.8)





Applied patch, added test case.  Fixed in 8.2b2. 
-- 07/21/1999 redman
Bad patch, removed changes.  The patch breaks other test cases on Unix but not Windows.  Needs more investigation.

-- 07/23/1999 redman
See 2466, new patch.

-- 07/29/1999 redman
welch Closed ticket [217886ffff]. [History diff]2000-10-26 08:09:11
dgp Ticket [217886ffff]: 1 change [History diff]2001-04-14 01:41:53
dgp Ticket [217886ffff]: 2 changes [History diff]2001-04-14 01:41:54
Log in (anonymous is fine) to add a comment.