Tcl Source Code

Artifact [acfbf4d138]
Login

Artifact acfbf4d138a8d5edc449dc475790afcf17d48eda:

Attachment "parse-error.c" to ticket [2141271fff] added by yurivict 2008-10-02 05:43:45.

#include <tcl.h> // for TCL constants only
#include <stdlib.h>
#include <string.h>

int myinit_helper(Tcl_Interp *interp) {
  if (Tcl_Init(interp) == TCL_ERROR) {
    printf("Error while Tcl_Init\n");
    exit(-1);
  }
  {
    int res;
    //char *p = "\n      set subtxt [util strsep $txt_copy $off \" \t\n.!?,:;\"'`<>(){}[]@#$%^&*+-=/\"]\n";
    char *p = "set x \" xxx\"'`xxxxxxx\"\n";
    Tcl_Parse parse;
    res = Tcl_ParseCommand(interp, p, strlen(p), 0, &parse); // <---- ***** statement that's failing w/out the error message
    if (res == TCL_ERROR) {
      const char *msg = Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY);
      printf("Tcl_ParseCommand: error: %s\n", msg ? msg : "<null>");
    } else {
      printf("Tcl_ParseCommand: success\n");
    }
  }
  return TCL_OK;
}

main(int argc, char *argv[]) {
  Tcl_Main(argc, argv, &myinit_helper);
}