From: Owen Shepherd Date: Sat, 25 Aug 2012 14:31:04 +0000 (+0100) Subject: PDCLIB-6: _PDCLIB_status_t: change members from size_t to unsigned or int as appropri... X-Git-Url: https://pd.if.org/git/?p=pdclib;a=commitdiff_plain;h=c3d04bb8ba4b67e327d2de9f7ffe47ee7c2c0d72 PDCLIB-6: _PDCLIB_status_t: change members from size_t to unsigned or int as appropriate. >int will overflow into error return anyway. Aligns types to better support negative precisions. --- diff --git a/functions/_PDCLIB/print.c b/functions/_PDCLIB/print.c index f06a532..439098d 100644 --- a/functions/_PDCLIB/print.c +++ b/functions/_PDCLIB/print.c @@ -112,7 +112,7 @@ static void int2base( uintmax_t value, struct _PDCLIB_status_t * status ) } // Pad field out to the precision specification - while( written < status->prec ) outend[-++written] = '0'; + while( (long) written < status->prec ) outend[-++written] = '0'; // If a field width specified, and zero padding was requested, then pad to // the field width @@ -178,7 +178,7 @@ const char * _PDCLIB_print( const char * spec, struct _PDCLIB_status_t * status status->base = 0; status->current = 0; status->width = 0; - status->prec = 0; + status->prec = EOF; /* First come 0..n flags */ do diff --git a/internals/_PDCLIB_int.h b/internals/_PDCLIB_int.h index af4c033..fee45ce 100644 --- a/internals/_PDCLIB_int.h +++ b/internals/_PDCLIB_int.h @@ -360,14 +360,14 @@ struct _PDCLIB_status_t { int base; /* base to which the value shall be converted */ _PDCLIB_int_fast32_t flags; /* flags and length modifiers */ - _PDCLIB_size_t n; /* print: maximum characters to be written */ + unsigned n; /* print: maximum characters to be written */ /* scan: number matched conversion specifiers */ - _PDCLIB_size_t i; /* number of characters read/written */ - _PDCLIB_size_t current;/* chars read/written in the CURRENT conversion */ + unsigned i; /* number of characters read/written */ + unsigned current;/* chars read/written in the CURRENT conversion */ char * s; /* *sprintf(): target buffer */ /* *sscanf(): source string */ - _PDCLIB_size_t width; /* specified field width */ - _PDCLIB_size_t prec; /* specified field precision */ + unsigned width; /* specified field width */ + int prec; /* specified field precision */ struct _PDCLIB_file_t * stream; /* *fprintf() / *fscanf() stream */ _PDCLIB_va_list arg; /* argument stack */ };