X-Sybari-Space: 00000000 00000000 00000000 00000000 From: Martin Stromberg Message-Id: <200308080854.KAA17657@lws256.lu.erisoft.se> Subject: Re: (fwd) Re: sscanf's return value To: djgpp-workers AT delorie DOT com Date: Fri, 8 Aug 2003 10:54:41 +0200 (MET DST) In-Reply-To: <1659-Fri08Aug2003103637+0300-eliz@elta.co.il> from "Eli Zaretskii" at Aug 08, 2003 10:36:37 AM X-Mailer: ELM [version 2.5 PL3] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk Eli said: > > From: Martin Stromberg > > Date: Fri, 8 Aug 2003 09:01:31 +0200 (MET DST) > > > > > > OTOH, DJGPP will output 0 even if the input string is "" in the code > > > quoted above. So, DJGPP's sscanf is broken, too, just in a different > > > way :-) > > > > The second return value they are talking about is when the code is > > changed to > > > > #include > > > > int main() > > { > > char buff[4]; > > int rc = sscanf("123", "%[0123456789]%*c", buff); > > printf("%d\n", rc); > > return 0; > > } > > Thanks for this, but I still don't understand why returning a 0 when > the string is "" is a bug. Can you explain? Because the standard says " The sscanf function returns the value of the macro EOF if an input failure occurs before any conversion. Otherwise, the sscanf function returns the number of input items assigned, which can be fewer than provided for, or even zero, in the event of an early matching failure." If the string is "" no conversion is done, hence EOF should be returned. The string "abc" should also make it return EOF, if I've understood correctly. Right, MartinS