Attachments (2)
Change History (7)
comment:1 by , 21 years ago
comment:2 by , 21 years ago
I clarified the behaviour of psTraceSetDestination recently, so the 0,1,2 ==
stdin,stdout,stderr probably isn't in the last version of the SDRS.
comment:3 by , 21 years ago
| Severity: | normal → critical |
|---|
comment:4 by , 21 years ago
| Owner: | changed from to |
|---|
comment:5 by , 21 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.

psTraceV has some serious bugs in the code related to printing the message. It
calls fmt = va_arg(ap, char *) even though the function received va_list, not
the ellipsis (...) argument. It also is printing the format line nLevel times
rather than just a space. Basically, it is all buggered up.
In a related vein, I am concerned about the use of FILE * implementations of the
trace printing commands when the APIs are being passed file descriptors. Mixing
and matching between these can be done, but it can be dangerous. It is also not
needed in this case. sprintf and write can be used to replace fprintf. I have
implemented a version of psTrace.c using fd's and fixing the bug in psTraceV,
which i am attaching.
Another problem in this code is the behavior when the trace destination is given
as 0. The SDRS says the code should not emit any trace messages, and points out
the similarity of destination = 0,1,2 equivalent to STDIN, STDOUT, STDERR. The
document says that the symbol PS_TRACE_NONE should be defined for 0, equivalent
to the position of STDIN. The code instead sets the destination actually to
STDIN. This seems dangerous, and is not what is requested. This is also fixed
in the sample.
Finally, the sample code does not dynamically allocate the line: the psLib
implementation should do so. I am attaching a second block of code illustrating
the use of vsprintf and a 0 byte output line to discover how much memory to
allocate.