-/* $Id$ */
-
/* _PDCLIB_scan( const char *, struct _PDCLIB_status_t * )
This file is part of the Public Domain C Library (PDCLib).
#define E_intmax 1<<10
#define E_size 1<<11
#define E_ptrdiff 1<<12
-#define E_intptr 1<<13
+#define E_pointer 1<<13
#define E_ldouble 1<<14
#define E_unsigned 1<<16
case 's':
{
char * c = va_arg( status->arg, char * );
- while ( ( status->current < status->width ) &&
+ while ( ( status->current < status->width ) &&
( ( rc = GET( status ) ) != EOF ) )
{
if ( isspace( rc ) )
} while ( *endspec != ']' );
// read according to scanlist, equiv. to %s above
char * c = va_arg( status->arg, char * );
- while ( ( status->current < status->width ) &&
+ while ( ( status->current < status->width ) &&
( ( rc = GET( status ) ) != EOF ) )
{
if ( negative_scanlist )
}
case 'p':
status->base = 16;
- status->flags |= E_unsigned;
+ status->flags |= E_pointer;
break;
case 'n':
{
if ( ! ( status->flags & E_suppressed ) )
{
switch ( status->flags & ( E_char | E_short | E_long | E_llong |
- E_intmax | E_size | E_ptrdiff |
+ E_intmax | E_size | E_ptrdiff | E_pointer |
E_unsigned ) )
{
case E_char:
*( va_arg( status->arg, ptrdiff_t * ) ) = (ptrdiff_t)( value * sign );
break;
+ case E_pointer:
+ /* E_pointer always implies unsigned */
+ *( uintptr_t* )( va_arg( status->arg, void * ) ) = (uintptr_t)( value * sign );
+ break;
+
default:
puts( "UNSUPPORTED SCANF FLAG COMBINATION" );
return NULL; /* behaviour unspecified */
#define _PDCLIB_FILEID "_PDCLIB/scan.c"
#define _PDCLIB_STRINGIO
-#include <_PDCLIB_test.h>
+#include "_PDCLIB_test.h"
static int testscanf( char const * s, char const * format, ... )
{