Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 81abfb6416a2db0eba5d22618624b1faab1fec09
Ticket: 218300ffffffffffffffffffffffffffffffffff
Tcl_EvalFile does not return a value to interp->result.
User & Date: nobody on 2000-10-26 00:55:54
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 3650 Bug
    Version: 8.2.2
    SubmitDate: '1999-11-23'
    LastModified: '1999-12-03'
    Severity: MED
    Status: Closed
    Submitter: techsupp
    ChangedBy: hobbs
    OS: HP-UX
    OSVersion: HP-UX B 10.20
    Machine: HP 9000/782
    FixedDate: '2000-10-25'
    ClosedDate: '1999-12-03'
    
    
    TclPro Tcl 1.3 Bug
    
    Name:  Charles Gilman
    email:  [email protected]
    Support:  Update
    Severity:  2
    OperatingSystem:  HP-UX
    Synopsis:  UPDATE TO BUG REPORT: Tcl_EvalFile does not return a value to interp->result.
    
    Comments:
    This is an update to my bug report pf 11/15/99 (no reference number).
    
    I have discovered that I was using the depricated construct interp->result. I should have been using
    the function Tcl_GetStringResult(interp). However, I have not found any documentation except under
    the man page for Tcl_GetStringResult that says that interp->result was depricated. I could find
    no information in the release notes or on the Addison Weslet Web Site for the "Tcl and the Tk
    Toolkit" book indicating that direct access to the interpreter result was discouraged. 
    
    Name:
    Charles Gilman
    
    Comments:
    The expected output was generated when the the program was compiled and linked
    with tcl7.6.
    
    The TCL library in TCLPro 1.3 is tcl8.2
    
    ReproducibleScript:
    This is from chapter 30.1 and 30.2 of TCL and the Tk Toolkit by Ousterhout (modified with some printf commands.
    
    The input file to this program contains a single TCL line: "eq 1 1"
    
    #include <stdio.h>
    #include "tcl.h"
    
    int EqCmd(ClientData clientData,
      Tcl_Interp *interp,
      int argc,
      char **argv)
    {
        if (argc != 3) {
    interp->result = "wrong # args";
    return TCL_ERROR;
        }
        if ( strcmp(argv[1], argv[2]) == 0 ) {
    interp->result = "1";
        }
        else {
    interp->result = "0";
        }
        printf("EQ Result:%s:\n",interp->result);
        return TCL_OK;
    }
    
    main (int argc, char **argv)
    {
        Tcl_Interp *interp;
        int code;
    
        if (argc != 2) {
    fprintf(stderr, "Wrong # arguments: ");
    fprintf(stderr, "should be \"%s fileName\"\n",
    argv[0]);
    exit(1);
        }
        interp = Tcl_CreateInterp();
    
        Tcl_CreateCommand(interp, 
          "eq", 
          EqCmd,
          (ClientData) NULL, 
          (Tcl_CmdDeleteProc *) NULL);
    
        code = Tcl_Eval(interp, "set q 44");
        printf("Main Result:%s:\n",interp->result);
        if (*interp->result != 0) {
    printf("Result: %s\n", interp->result);
        }
        if (code != TCL_OK) {
    printf("TCL_ERROR\n");
    exit(1);
        }
    
        code = Tcl_Eval(interp, "eq 34 34");
        printf("Main Result:%s:\n",interp->result);
        if (*interp->result != 0) {
    printf("Result: %s\n", interp->result);
        }
        if (code != TCL_OK) {
    printf("TCL_ERROR\n");
    exit(1);
        }
    
        code = Tcl_EvalFile(interp, argv[1]);
        printf("Main Result:%s:\n",interp->result);
        if (*interp->result != 0) {
    printf("Result: %s\n", interp->result);
        }
        if (code != TCL_OK) {
    printf("TCL_ERROR\n");
    exit(1);
        }
    
        exit(0);
    }
    #include <stdio.h>
    #include "tcl.h"
    
    int EqCmd(ClientData clientData,
      Tcl_Interp *interp,
      int argc,
      char **argv)
    {
        if (argc != 3) {
    interp->result = "wrong # args";
    return TCL_ERROR;
        }
        if ( strcmp(argv[1], argv[2]) == 0 ) {
    interp->result = "1";
        }
        else {
    interp->result = "0";
        }
        printf("EQ Result:%s:\n",interp->result);
        return TCL_OK;
    }
    
    ObservedBehavior:
    The program out put is a follows. This output shoes that Tcl_Eval(interp, "eq 1 1")
    prodices the correct result  and Tcl_Eval_File(interp, argv[1]) does not. 
    
    %a.out test.tcl
    Main Result:44:
    Result: 44
    EQ Result:1:
    Main Result:1:
    Result: 1
    EQ Result:1:
    Main Result::
    
    DesiredBehavior:
    This is the output I expected to see.
    
    %a.out test.tcl
    Main Result:44:
    Result: 44
    EQ Result:1:
    Main Result:1:
    Result: 1
    EQ Result:1:
    Main Result:1:
    Result: 1
    
    
    
    The AW book mentioned (by Ousterhout) is *ancient*, I would
    recommend the 3rd edition from Welch, which includes porting
    notes in the appendices.  Use of inter->result is indeed
    deprecated, although we still need to fix some of our docs. 
    -- 12/03/1999 hobbs
    
  4. foundin changed to: "obsolete: 8.2.2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "69. Other"
  10. title changed to:
    Tcl_EvalFile does not return a value to interp->result.
    
  11. type changed to: "Bug"