Tcl Source Code

View Ticket
Login
Ticket UUID: 1689385
Title: Tcl_SetObjLength documentation incomplete
Type: Bug Created on: 2007-03-27 17:47:01
Submitter: dgp Assigned to: dgp
Subsystem: 10. Objects Severity:
Priority: 5 Medium Last modified: 2008-03-12 22:41:24
Status: Open Closed by:
Resolution: None Closed on:
Version: obsolete: 8.5a7
Description:
The documentation for

  Tcl_SetObjLength(objPtr, newLength)

suggests that it will leave
objPtr->bytes pointing to a buffer
of at least length newLength+1,
that it will write a null byte
at objPtr->bytes[newLength], and
that it will leave objPtr->length
with the new value of newLength.

This is often true.

However, when objPtr points to
a pure unicode object with at least
one multibyte character, or with
some other history that leaves
objPtr->bytes == NULL and
stringPtr->hasUnicode != 0, then
Tcl_SetObjLength() manipulates
the unicode representation, growing
it to hold at least newLength *characters*
(not bytes).  It's possible that a
caller expecting the documentation to be
true might get a nasty surprise.

The ability to grow the unicode rep
is useful.  Perhaps that functionality
should have its own API, rather than
having undocumented, semi-magical modes
of operation?
User Comments:
msofer added on 2007-09-13 08:00:32:
Logged In: YES 
user_id=148712
Originator: NO

I do not feel qualified for this one, returning to sender.