summaryrefslogtreecommitdiffstats
path: root/generic/tkMenu.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkMenu.c')
-rw-r--r--generic/tkMenu.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
index 3b648ff..0a297a6 100644
--- a/generic/tkMenu.c
+++ b/generic/tkMenu.c
@@ -2128,7 +2128,8 @@ GetMenuIndex(
const char *string;
if (TkGetIntForIndex(objPtr, menuPtr->numEntries - 1, lastOK, indexPtr) == TCL_OK) {
- if (*indexPtr != TCL_INDEX_NONE) {
+ /* TCL_INDEX_NONE is only accepted if it does not result from a negative number */
+ if (*indexPtr != TCL_INDEX_NONE || Tcl_GetString(objPtr)[0] != '-') {
if (*indexPtr >= menuPtr->numEntries) {
*indexPtr = menuPtr->numEntries - ((lastOK) ? 0 : 1);
}
@@ -2360,7 +2361,7 @@ MenuAddOrInsert(
}
if (index == TCL_INDEX_NONE) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad index \"%s\"", Tcl_GetString(indexPtr)));
+ "bad menu entry index \"%s\"", Tcl_GetString(indexPtr)));
Tcl_SetErrorCode(interp, "TK", "MENU", "INDEX", NULL);
return TCL_ERROR;
}