Date: Thu, 7 Aug 2003 17:32:34 +0200 (MET DST) X-Sybari-Space: 00000000 00000000 00000000 00000000 From: Martin Stromberg Message-Id: <200308071532.RAA17010@lws256.lu.erisoft.se> To: djgpp-workers AT delorie DOT com Subject: (fwd) Re: sscanf's return value Newsgroups: comp.std.c Content-Type: text Reply-To: djgpp-workers AT delorie DOT com Path: antares.lu.erisoft.se!atik.lu.erisoft.se!erinews.ericsson.se!newsfeed.sunet.se!news01.sunet.se!uninett.no!newsfeed1.enitel.no!newsfeed1.e.nsc.no!nsc.no!nextra.com!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!news-stu1.dfn.de!news.belwue.de!news-ge.switch.ch!switch.ch!cern.ch!news From: Dan DOT Pop AT cern DOT ch (Dan Pop) Newsgroups: comp.std.c Subject: Re: sscanf's return value Date: 4 Aug 2003 12:02:18 GMT Organization: DESY Zeuthen Lines: 46 Message-ID: References: <3f29164b DOT 214278 AT news DOT siemens DOT at> NNTP-Posting-Host: lxplus011.cern.ch X-Trace: sunnews.cern.ch 1059998538 27208 (None) 137.138.161.74 X-Complaints-To: news AT sunnews DOT cern DOT ch User-Agent: nn/6.6.2 Xref: antares.lu.erisoft.se comp.std.c:38916 In "Arthur J. O'Dwyer" writes: >On Thu, 31 Jul 2003, Stefan Farfeleder wrote: >> >> Arthur J. O'Dwyer wrote: >> > On Thu, 31 Jul 2003, Bruce Wheeler wrote: >> >> On 31 Jul 2003 11:17:13 GMT, Dan DOT Pop AT cern DOT ch (Dan Pop) wrote: >> >> > >> >> > #include >> >> > >> >> > int main() >> >> > { >> >> > int rc = sscanf("123", "%*[0123456789]%*c"); >> >> > printf("%d\n", rc); >> >> > return 0; >> >> > } >> >> > gcc, presumably the compiler Dan used too, reports -1 and 1. >> > I hadn't thought to try the second case when I posted in c.l.c, >> > so now I agree that gcc's implementation must be broken, although >> > I'm still not sure what the "right" answers should be. >> >> GCC alone is not a complete C implementation, it needs your system's C >> library which seems to be broken. >> >> $ uname -rs >> FreeBSD 5.1-CURRENT > > % uname -rs > Linux 2.4.21 > >Thanks for the correction. I must have been extra clueless today, >because I see DJGPP produces the right answers (0 and 1) - which >means I must've only tested the code on the Linux implementation. >... I wonder how one would go about rectifying such a thing... 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 :-) Dan -- Dan Pop DESY Zeuthen, RZ group Email: Dan DOT Pop AT ifh DOT de