Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 679a3afc33b5300c9b0e5eafe942e59c41e922d932431d4219cd507c2a899e82
Ticket: 0238027108506a3271543dcc297ac71d3cb41d3f
Tcl_ParseArgsObjv TCL_ARGV_CONSTANT documentation error
User & Date: anonymous on 2019-01-29 23:00:13
Changes

  1. comment changed to:
    I quote the doc:
           TCL_ARGV_CONSTANT
                  The argument does not take any following value
                  argument. If this argument is present, the int pointed
                  to by the srcPtr field is copied to the dstPtr
                  field. The clientData field is ignored.
    
    But today, while programming an extension, I noticed that it's not
    "the int pointed to by the srcPtr field" but the pointer itself being
    put in dstPtr. When compiling the attached "test.c" and testing it, I get:
    
      $ gcc -shared -o test.{so,c} -DUSE_TCL_STUBS -I/usr/include -L/usr/lib64 -ltclstub8.6
      $ tclsh
      > load ./test.so
      > test1 -opt
      515178680
      > test2 -opt
      10
    
    
    After looking at the source code, the solution is either applying
    
    diff --git a/tclIndexObj.c b/tclIndexObj.c
    index 30c33f1..07792c5 100644
    --- a/tclIndexObj.c
    +++ b/tclIndexObj.c
    @@ -1207,7 +1207,7 @@ Tcl_ParseArgsObjv(
     	infoPtr = matchPtr;
     	switch (infoPtr->type) {
     	case TCL_ARGV_CONSTANT:
    -	    *((int *) infoPtr->dstPtr) = PTR2INT(infoPtr->srcPtr);
    +	    *((int *) infoPtr->dstPtr) = *((int *) infoPtr->srcPtr);
     	    break;
     	case TCL_ARGV_INT:
     	    if (objc == 0) {
    
    
    or changing the documentation to mean that it's the value being copied.
    
  2. login: "anonymous"
  3. mimetype: "text/plain"