From 92627d87c246591c540d0ae38296aa43e4c09b3c Mon Sep 17 00:00:00 2001 From: solar Date: Mon, 19 Jul 2010 07:40:52 +0000 Subject: [PATCH] Proper handling of end-of-string. git-svn-id: https://srv7.svn-repos.de/dev34/pdclib/trunk@445 546481bc-9713-0410-bf18-d3337bbf4a3e --- functions/stdio/vsscanf.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/functions/stdio/vsscanf.c b/functions/stdio/vsscanf.c index 8a23790..be9bf61 100644 --- a/functions/stdio/vsscanf.c +++ b/functions/stdio/vsscanf.c @@ -48,6 +48,11 @@ int vsscanf( const char * _PDCLIB_restrict s, const char * _PDCLIB_restrict form /* Non-whitespace char in format string: Match verbatim */ if ( *status.s != *format ) { + if ( *status.s == '\0' && status.n == 0 ) + { + /* Early input error */ + return EOF; + } /* Matching error */ return status.n; } @@ -61,9 +66,13 @@ int vsscanf( const char * _PDCLIB_restrict s, const char * _PDCLIB_restrict form } else { - /* NULL return code indicates input error */ + /* NULL return code indicates error */ if ( rc == NULL ) { + if ( ( *status.s == '\n' ) && ( status.n == 0 ) ) + { + status.n = EOF; + } break; } /* Continue parsing after conversion specifier */ -- 2.30.2