Tcl Source Code

Artifact [c1870c35c7]
Login

Artifact c1870c35c78037d977d944b5cd8cac6c0a158e826b071f481e305649af8ece8f:

Attachment "parseargs.diff" to ticket [7cb7409e05] added by emiliano 2024-04-03 20:30:49. (unpublished)
Index: doc/ParseArgs.3
==================================================================
--- doc/ParseArgs.3
+++ doc/ParseArgs.3
@@ -154,15 +154,15 @@
         int \fIobjc\fR,
         Tcl_Obj *const *\fIobjv\fR,
         void *\fIdstPtr\fR);
 .CE
 .PP
-The \fIclientData\fR is the value from the table entry, the \fIinterp\fR is
-where to store any error messages, the \fIkeyStr\fR is the name of the
-argument, \fIobjc\fR and \fIobjv\fR describe an array of all the remaining
-arguments, and \fIdstPtr\fR argument to the \fBTcl_ArgvGenFuncProc\fR is the
-location to write the parsed value (or values) to.
+The \fIclientData\fR is the value from the table entry, the \fIinterp\fR
+is where to store any error messages, \fIobjc\fR and \fIobjv\fR describe
+an array of all the remaining arguments, and \fIdstPtr\fR argument to the
+\fBTcl_ArgvGenFuncProc\fR is the location to write the parsed value
+(or values) to.
 .RE
 .TP
 \fBTCL_ARGV_HELP\fR
 .
 This special argument does not take any following value argument, but instead

Index: generic/tclIndexObj.c
==================================================================
--- generic/tclIndexObj.c
+++ generic/tclIndexObj.c
@@ -1111,10 +1111,11 @@
     Tcl_Size dstIndex;	/* Used to keep track of current arguments
 				 * being processed, primarily for error
 				 * reporting. */
     Tcl_Size objc;		/* # arguments in objv still to process. */
     Tcl_Size length;		/* Number of characters in current argument */
+    Tcl_Size gf_ret;		/* Return value from Tcl_ArgvGenFuncProc*/
 
     if (remObjv != NULL) {
 	/*
 	 * Then we should copy the name of the command (0th argument). The
 	 * upper bound on the number of elements is known, and (undocumented,
@@ -1266,14 +1267,17 @@
 	}
 	case TCL_ARGV_GENFUNC: {
 	    Tcl_ArgvGenFuncProc *handlerProc = (Tcl_ArgvGenFuncProc *)
 		    infoPtr->srcPtr;
 
-	    objc = handlerProc(infoPtr->clientData, interp, objc,
+	    gf_ret = handlerProc(infoPtr->clientData, interp, objc,
 		    &objv[srcIndex], infoPtr->dstPtr);
-	    if (objc < 0) {
+	    if (gf_ret < 0) {
 		goto error;
+	    } else {
+		srcIndex += gf_ret;
+		objc -= gf_ret;
 	    }
 	    break;
 	}
 	case TCL_ARGV_HELP:
 	    PrintUsage(interp, argTable);