| Ticket UUID: | ece07271f480ae32005ef014d72520e9a595012 | ||
| Title: | Bug in Tcl_ParseArgsObjv() TCL_ARGV_GENFUNC | ||
| Type: | Bug | Created on: | 2019-03-25 12:43:53 |
| Submitter: | anonymous | Assigned to: | nobody |
| Subsystem: | 45. Parsing and Eval | Severity: | Minor |
| Priority: | 5 Medium | Last modified: | 2026-10-22 17:19:29 |
| Status: | Closed | Closed by: | serhiy.storchaka |
| Resolution: | Duplicate | Closed on: | 2026-10-21 09:58:25 |
| Version: | 8.6.9 | ||
| Description: | ||||
Hi,
I was playing with the Tcl_ParseArgsObjv() function and I needed it to do something more specific than what the pre-defined matchers provide. The TCL_ARGV_GENFUNC option seemed like a good solution. However I couldn't get it to work. After some debugging, I believe, I tracked it down to a bug in Tcl_ParseArgsObjv() itself.
Currently tcl8.6.9/generic/TclIndexObj.c:1275 is
case TCL_ARGV_GENFUNC: {
Tcl_ArgvGenFuncProc *handlerProc = (Tcl_ArgvGenFuncProc *)infoPtr->srcPtr;
objc = handlerProc(infoPtr->clientData, interp, objc, &objv[srcIndex], infoPtr->dstPtr);
if (objc < 0) {
goto error;
}
break;
}
But I believe it should be
case TCL_ARGV_GENFUNC: {
Tcl_ArgvGenFuncProc *handlerProc = (Tcl_ArgvGenFuncProc *)infoPtr->srcPtr;
int consumed = handlerProc(infoPtr->clientData, interp, objc, &objv[srcIndex], infoPtr->dstPtr);
if (consumed < 0) {
goto error;
}
srcIndex += consumed;
objc -= consumed;
break;
}
If I read the documentation correctly (https://www.tcl.tk/man/tcl8.6/TclLib/ParseArgs.htm#M14), then the return value of handlerProc indicates how many arguments must be consumed, not how many are still remaining.
I verified that tcl8.7a1 still contains the same bug.
Wouter
| ||||
| User Comments: | ||||
serhiy.storchaka added on 2026-10-21 09:58:25:
Duplicate of [7cb7409e05]. Fixed by [8cfa5d1ee9] (8.6.15) and [c28a455139] (9.0.0): the handler's return value is now treated as the number of consumed arguments. | ||||
