Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2019-07-23
09:39 • Ticket [6e156333bc] Documentation: Contradiction in Tcl_GetSring/Tcl_GetStringFr... artifact: 95b1188f83 user: sebres
2002-06-26
18:51 • Closed ticket [500930ffff]: Tcl_GetString* doc inconsistency plus 3 other ch... artifact: 5081fea4eb user: msofer
07:11 • Ticket [500930ffff]: 4 changes artifact: f05cc278e3 user: dgp
07:11 • Add attachment 500930.patch to ticket [500930ffff] artifact: c5dc0b4e97 user: dgp
2002-01-08
17:51 • New ticket [500930ffff] Tcl_GetString* doc inconsistency. artifact: a554c0d0db user: dgp

Tcl_GetString* doc inconsistency

Closed / Accepted500930ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 24 years ago
Descriptionplain2002-01-08 17:51:08
In doc/StringObj.3, the docs for Tcl_GetString
and Tcl_GetStringFromObj say:

 Tcl_GetStringFromObj and Tcl_GetString return an
 object's string representation. ... The storage
 referenced by the returned  byte pointer is owned
 by the object manager and should not be modified
 by the caller.  ...

If it is true that the caller should not modify the
storage referenced by the returned pointer, then
these routines should return a (CONST char *) so
that the return type enforces the documented
requirement.

However, there are many places within Tcl and
popular extensions such as Tk where the returned
value is stored in a (char *) variable, and some
places where the referenced storage is modified
directly, when it is known that it is safe to do
so within the rules of Tcl's copy-on-write rules
for Tcl_Obj's.

One choice or the other should be made.  It seems
likely that the documentation should be changed to
note the conditions where it is safe for the caller
to modify the internal storage of a Tcl_Obj referenced
by the returned pointer.
dgpplain2002-06-26 07:11:26
File Added - 25828: 500930.patch

Logged In: YES 
user_id=80530

here's a patch.  please consider it for 8.4b.
msofer Closed ticket [500930ffff]. [History diff]2002-06-26 18:51:07
Log in (anonymous is fine) to add a comment.

Attachments: