[Tcl] Prevent SWIG_Tcl_ConvertPtr from calling the unknown proc.
Add Examples/tcl/std_vector/ which this change fixes. Patch is from "Cliff C" in SF#1809819. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9989 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b1b889059d
commit
6fdeeafb88
7 changed files with 136 additions and 5 deletions
|
|
@ -125,15 +125,38 @@ SWIG_Tcl_ConvertPtrFromString(Tcl_Interp *interp, const char *c, void **ptr, swi
|
|||
while (*c != '_') {
|
||||
*ptr = (void *) 0;
|
||||
if (strcmp(c,"NULL") == 0) return SWIG_OK;
|
||||
|
||||
/* Empty string: not a pointer */
|
||||
if (*c == 0) return SWIG_ERROR;
|
||||
|
||||
/* Hmmm. It could be an object name. */
|
||||
if (Tcl_VarEval(interp,c," cget -this", (char *) NULL) == TCL_OK) {
|
||||
|
||||
/* Check if this is a command at all. Prevents <c> cget -this */
|
||||
/* from being called when c is not a command, firing the unknown proc */
|
||||
if (Tcl_VarEval(interp,"info commands ", c, (char *) NULL) == TCL_OK) {
|
||||
Tcl_Obj *result = Tcl_GetObjResult(interp);
|
||||
c = Tcl_GetStringFromObj(result, NULL);
|
||||
continue;
|
||||
if (*(Tcl_GetStringFromObj(result, NULL)) == 0) {
|
||||
/* It's not a command, so it can't be a pointer */
|
||||
Tcl_ResetResult(interp);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
} else {
|
||||
/* This will only fail if the argument is multiple words. */
|
||||
/* Multiple words are also not commands. */
|
||||
Tcl_ResetResult(interp);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
Tcl_ResetResult(interp);
|
||||
return SWIG_ERROR;
|
||||
|
||||
/* Check if this is really a SWIG pointer */
|
||||
if (Tcl_VarEval(interp,c," cget -this", (char *) NULL) != TCL_OK) {
|
||||
Tcl_ResetResult(interp);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
Tcl_Obj *result = Tcl_GetObjResult(interp);
|
||||
c = Tcl_GetStringFromObj(result, NULL);
|
||||
}
|
||||
|
||||
c++;
|
||||
c = SWIG_UnpackData(c,ptr,sizeof(void *));
|
||||
if (ty) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue