X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2F_PDCLIB%2Fscan.c;h=f41079bd78ee98908e98642e14011ff3ac21718a;hb=cf87ec5a0d12a21d8651e980e5e8e037f55dac25;hp=b6012611b707b290158d4c3585de5a271149790b;hpb=52cca2123103a3ea5a914131eac4ca03b56f3b96;p=pdclib.old diff --git a/functions/_PDCLIB/scan.c b/functions/_PDCLIB/scan.c index b601261..f41079b 100644 --- a/functions/_PDCLIB/scan.c +++ b/functions/_PDCLIB/scan.c @@ -47,7 +47,7 @@ static int GET( struct _PDCLIB_status_t * status ) } else { - return *((status->s)++); + return ( *status->s == '\0' ) ? EOF : *((status->s)++); } } @@ -106,7 +106,12 @@ const char * _PDCLIB_scan( const char * spec, struct _PDCLIB_status_t * status ) strtol() will return zero. In both cases, endptr will point to the rest of the conversion specifier - just what we need. */ + char const * prev_spec = spec; status->width = (int)strtol( spec, (char**)&spec, 10 ); + if ( spec == prev_spec ) + { + status->width = SIZE_MAX; + } /* Optional length modifier We step one character ahead in any case, and step back only if we find @@ -216,6 +221,7 @@ const char * _PDCLIB_scan( const char * spec, struct _PDCLIB_status_t * status ) } else { + /* FIXME: Need two kinds of "no match" here: zero width, and input error */ return NULL; } }