[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DIGITAL UNIX (FORMERLY KNOWN AS DEC OSF/1) |
Notice: | Welcome to the Digital UNIX Conference |
Moderator: | SMURF::DENHAM |
|
Created: | Thu Mar 16 1995 |
Last Modified: | Fri Jun 06 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 10068 |
Total number of notes: | 35879 |
sprintf() on Digital UNIX gets confused by a trailing %, which really shouldn't
be there anyway (should be %s, %d, ..., %%, or nothing at all).
For example the following code:
#include <stdio.h>
#include <errno.h>
main()
{
extern int errno;
char * g_outBuf = (char *) malloc(1024);
int r, count = 5;
r = sprintf (g_outBuf, "SET^DOSET^%s^%d%", "source", count);
printf ("count = %d, g_outBuf = <%s>\n", count, g_outBuf);
printf ("r = %d, errno = %d\n", r, errno);
}
prints this under Digital UNIX:
count = 5, g_outBuf = <>
r = -1, errno = 0
but under other OS's, e.g. NT:
count = 5, g_outBuf = <SET^DOSET^source^5>
r = 18, errno = 0
Boris Gubenko in a reply to my original posting in the DECC conference (note
2149) advises:
NT exhibits the correct behavior. A single "%" presents an illegal conversion
specification. The result of processing such specification in not specified
by the standard.
From XPG4, for example, "if a conversion specification does not match one
of the above forms, the behavior is undefined".
However, each legal conversion specification must result in fetching one or
more arguments and converting, formatting and printing them.
The function also should not return -1 due to illegal conversion
specification.
From the Return Value section:
... these function return ... a negative value if an output error was
encountered.
Should I QAR this?
Richard
T.R | Title | User | Personal Name | Date | Lines |
---|
9545.1 | | QUARRY::neth | Craig Neth | Fri Apr 18 1997 10:41 | 3 |
| >Should I QAR this?
Yup.
|