Are questions about C better asked here or on MVS-OE?  Surely
not on ASSEMBLER_LIST -- it's far too busy this week with a
nostalgia thread.

The C test program:
/* ---------------------------------------------------------*/
#include <stdarg.h>
#include <stdio.h>
#include <string.h>

static char buffer[ 100 ];

static void f2( char *fmt, va_list xp ) {
va_list ap;
char *a;

memcpy( &ap, &xp, sizeof( va_list ) );
                           printf("Format: \"%s\"\n", fmt );
a = va_arg( ap, char * );  printf("First : \"%s\"\n", a );
a = va_arg( ap, char * );  printf("Second: \"%s\"\n", a );

memcpy( &ap, &xp, sizeof( va_list ) );
printf( "\nRetrying\n" );
a = va_arg( ap, char * );  printf("First : \"%s\"\n", a );
a = va_arg( ap, char * );  printf("Second: \"%s\"\n", a );

memcpy( &ap, &xp, sizeof( va_list ) );
printf( "\nTrying vsnprintf();\n" );
vsnprintf( buffer, 99, fmt, ap );
printf( "%s\n", buffer );
return; }


static void f1( char *fmt, ... ) {
va_list ap;
char *a;

va_start( ap, fmt );
f2( fmt, ap );
return; }


int main( void ) {

f1( " %s -- %s ", "foo", "bar" );

return( 0 ); }
/* ---------------------------------------------------------*/

On Solaris and OS X prints, as I expect:

Format: " %s -- %s "
First : "foo"
Second: "bar"

Retrying
First : "foo"
Second: "bar"

Trying vsnprintf();
 foo -- bar 

But on z/OS 1.10 and 1.7, the unexpected:

Format: " %s -- %s "
First : " %s -- %s "
Second: "foo"

Retrying
First : " %s -- %s "
Second: "foo"

Trying vsnprintf();
  %s -- %s  -- foo 

Do I fail to understand something, or have I (again)
encountered a bug?  I'll welcome any workaround that
doesn't break compatibility with the other 2 systems.
I'll likewise welcome a test on another system (Linux?)

Thanks,
gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to