Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2006-11-14
23:33 • Closed ticket [1184069fff]: New API function: Tcl_PrintfResult plus 7 other ... artifact: c1c6fc93e7 user: dgp
2006-11-03
02:40 • Ticket [1184069fff]: 4 changes artifact: 121ec6ad6b user: dgp
2006-08-09
20:53 • Ticket [1184069fff]: 4 changes artifact: 7311b5507b user: dgp
17:24 • Ticket [1184069fff]: 1 change artifact: 4e51c6fa16 user: dkf
2005-11-26
17:41 • Ticket [1184069fff]: 1 change artifact: b600da8692 user: msofer
2005-11-01
23:54 • Ticket [1184069fff]: 4 changes artifact: 81297eb243 user: dgp
2005-05-04
06:07 • Ticket [1184069fff]: 4 changes artifact: 73dc469eda user: dkf
04:54 • Ticket [1184069fff]: 4 changes artifact: 73424019cb user: jenglish
2005-04-15
23:14 • New ticket [1184069fff]. artifact: f0060bf354 user: dkf

New API function: Tcl_PrintfResult

Closed / Accepted1184069fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 20 years ago
Descriptionplain2005-04-15 23:14:26
It would be really nice (especially for error
generation) if we could have a function that let us
write strings into the interpreter result as a
replacement for the old trick of:
  sprintf(interp->result, "pattern")

Notes on implementation: Need to use vsnprintf
internally to work out the required size of buffer
before allocating it and feeding it through vsprintf
(the trick done in glib is not portable enough without
this).
jenglishplain2005-05-04 04:54:49
Logged In: YES 
user_id=68433

vsnprintf() is new in C99, it's not part of C89.

Since C99 still isn't widely supported (and the core hasn't
even been fully update to C89 yet), we should tread
carefully when approaching C9X-isms.
dkfplain2005-05-04 06:07:11
Logged In: YES 
user_id=79902

Yuck. The problem is that only (v)snprintf() returns the
number of characters that would have been written instead of
the number of characters actually written. Without it,
sizing the buffer for vsprintf() is tricky/impossible.
dgpplain2005-11-01 23:54:39
Logged In: YES 
user_id=80530


See TclObjPrintf() and
TclFormatToErrorInfo()
on the HEAD.
msofer Ticket [1184069fff]: 1 change [History diff]2005-11-26 17:41:04
dkf Ticket [1184069fff]: 1 change [History diff]2006-08-09 17:24:52
dgpplain2006-08-09 20:53:27
Logged In: YES 
user_id=80530


See TIP 270.  In terms of
the routines proposed there:

  objPtr = Tcl_NewObj();
  Tcl_ObjPrintf(NULL, objPtr, format, arg, arg);
  Tcl_SetObjResult(interp, objPtr);
dgpplain2006-11-03 02:40:55
Logged In: YES 
user_id=80530


After some revisions to
TIP 270, this request is
satisfied in terms of the
proposed routines by:

  Tcl_SetObjResult(interp,
      Tcl_ObjPrintf(format, arg, arg));
dgpplain2006-11-14 23:33:49
Logged In: YES 
user_id=80530

TIP 270 accepted for 8.5a6.
Log in (anonymous is fine) to add a comment.