I get this:
Code:
...
pawPrintf( "%u", 10 ) gave:
10pawPrintf( "%d, %s", did, "abc" ) gave:
2, abc
...
From this:
Code:
pawd test_Printf()
{
#define PRINTF( ARGS, ... ) \
do \
{ \
puts( "pawPrintf( " #ARGS ", " #__VA_ARGS__ " ); gave:" ); \
did = pawPrintf( ARGS "\n", __VA_ARGS__ ); \
} \
while(0)
pawd did;
puts("Attempting pawPrintf...\n");
PRINTF( "%u", 10 );
if ( did < 0 )
return -1;
PRINTF( "%d, %s", did, "abc" );
return -(did < 0);
#undef PRINTF
}
Because I don't want my library to rely on CRT (and all the problems it comes with) I'm trying to remove reliance on standard C libraries (with exceptions for things like limits.h), I'm starting off with the file descriptors since they're the native format for linux/unix/osx which makes it convenient for me to test the wrapper functions work correctly. I've tried all I can think of but I still haven't been able to get the newline character to print, or at least produce the expected output, anyone have any familiarity with this, or any ideas to try?
Edit: For reference the internal calls fob things down to here:
Code:
PAW_API pawzd pawFdPrintv( PAWFD fd, void *inf, paws args, va_list va )
{
PAWS STR = {{0}};
pawzd did = pawInitStringv( &STR, args, va );
if ( did >= 0 )
{
paws str = pawSeekBufferHead( &STR );
did = pawFdPrint( fd, inf, str, did );
pawTermString( &STR );
}
return did;
}
I used PAWFD since I need the type name to be consistent across systems, on windows it's HANDLE instead of int, the final functions ares these:
Code:
PAW_API pawzd pawFdPrint( PAWFD fd, PAWOPS *ops, void const *src, pawzd cap )
{
(void)ops;
if ( cap >= 0 )
return write( fd, src, cap );
return -1;
}
PAW_API pawzd pawFdParse( PAWFD fd, PAWOPS *ops, void *dst, pawzd cap )
{
(void)ops;
if ( cap >= 0 )
return read( fd, dst, cap );
return -1;
}
PAW_API void pawFdFlush( PAWFD fd ) { fsync(fd); }
Don't have anything for opening & closing yet, figured I'd first make sure I can output correctly before focusing on extras