Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 56ff55e846c1601b6973ccf3116b890908552b71
Ticket: 536831ffffffffffffffffffffffffffffffffff
Tcl_SubstObj: add precompilation
User & Date: dkf on 2002-04-05 15:45:07
Changes

  1. icomment:
    Logged In: YES 
    user_id=79902
    
    Example that exhibits the problem:
       subst {abc[continue;[foobarspong}
    
    The problem is that there is currently no pre-parsing stage
    involved in Tcl_SubstObj (I thought about adding one, but
    didn't) so scanning forward on a command substitution to
    find the end of the command substitution (which would more
    accurately be described as a script substitution, BTW) is
    only done when needed.  Now, for each of the evaluation
    return codes, the following is the behaviour:
      TCL_OK: insert string from interp
      TCL_ERROR: error!  :^)
      TCL_BREAK: return everything done up to the start of the
                 command substitution
      TCL_CONTINUE: insert nothing and go from end of command
                    substitution
      TCL_RETURN: as with TCL_OK
    The problem with TCL_CONTINUE and TCL_RETURN stems from the
    fact that they can be issued from the middle of a script,
    yet their behaviour really requires scanning to the end of
    the script (TCL_OK is not a problem, since that only ever
    comes from the end of the script.)  If the script being
    evaluated is not well-formed, the code that does the
    scanning forward (located somewhere inside the
    implementation of Tcl_EvalEx) does not operate properly, and
    I'm not sure how to change this (or even what the recovery
    ought to be.)
    
    As it is; the problem is a deep and nasty parsing problem.
    The comment just documents the fact, and the problem isn't
    exposed elsewhere because nowhere else in the core needs to
    access parts of a string following an ill-formed command.
    
    Suggested fix: compile [subst] strings so you can apply the
    well-formedness checks first (and gain a performance boost
    on objects that get fed into [susbst] several times too.)
    
    
  2. login: "dkf"
  3. mimetype: "text/plain"
  4. subsystem changed to: "45. Parsing and Eval"
  5. username: "dkf"